import menzalib as l3 import numpy as np Vout, f = np.loadtxt("2a.txt", unpack=True) Vin = 1.14 dVin = l3.dVosc(Vin) dVout = l3.dVosc(Vout) Av = Vout / Vin dAv = l3.drapp(Vout, dVout, Vin, dVin) out = open("output.txt", "w") for i in range(len(Vout)): s = "$%0.1f \pm %0.1f$& $ %0.2f \pm %0.3f$& $%0.3f\pm %0.4f$ \\\ \n" % ( f[i], f[i] * 0.01, Vout[i], dVout[i], Av[i], dAv[i]) out.write(s) out.close()
for i in range(0, len(v1)): for j in range(0, len(v1)): if (s1[i] == v1[j]): s2[i] = v2[j] break return s1, s2 Vt, dVt = [0.260, mz.dVosc(0.260)] #voltaggio in ingresso f, df, deltaf, ddeltaf, V = np.genfromtxt( 'dati/1.txt', unpack='True') #aggiusta l'errore sullo sfasamento ddeltaf = np.sqrt((0.02 * deltaf)**2 + ddeltaf**2) #calcolo la fase fase = 360 * f / deltaf dfase = 360 * mz.drapp(f, df, deltaf, ddeltaf) #metto i dati alla frequenza di taglio f = np.append(f, 1598.34) #frequenza di tagli df = np.append(df, 0.01) V = np.append(V, 182) #ampiezza di taglio fase = np.append(fase, 0) dfase = np.append(dfase, 0.08) #aggiusta l'errore sullo sfasamento #ordino in i dati f_temp = f f, fase = ordina_2_vett(f, fase) f, df = ordina_2_vett(f_temp, df) f, V = ordina_2_vett(f_temp, V) f, dfase = ordina_2_vett(f_temp, dfase)
def lineare(x, a, b): return a * x + b def costante(x, a, b): return a #Punto 1.a R1 = 1.187e3 dR1 = mz.dRdig(R1) R2 = 12.16e3 dR2 = mz.dRdig(R2) Aexp = R2 / R1 dAexp = mz.drapp(R2, dR2, R1, dR1) #punto 1.c Vin, Vout = np.genfromtxt('dati/1c.txt', unpack='True') dVin = mz.dVosc(Vin) dVout = mz.dVosc(Vout) A = Vout / Vin dA = mz.drapp(Vout, dVout, Vin, dVin) tab1 = [mz.ne_tex(Vin, dVin), mz.ne_tex(Vout, dVout), mz.ne_tex(A, dA)] mz.stampa_matrice_latex(tab1) popt, pcov = mz.curve_fitdx(lineare, Vin, Vout, dx=dVin, dy=dVout) chi2, pval = mz.chi2_pval(lineare, Vin, Vout,
R1 = 178500 R2 = 17650 Rc = 9820 Re = 1014 dR1, dR2, dRc, dRe = mz.dRdig([R1, R2, Rc, Re]) Cout = 110.7e-9 Cin = 221e-9 Vcc = 19.97 Vbe = 0.7 # ddp base emettitore al punto di lavoro Vrc = 9.92 dVcc, dVbe, dVrc = mz.dVdig([Vcc, Vbe, Vrc]) Vbb = Vcc / (1 + R1 / R2) dVbb = mz.drapp(Vcc, dVcc, 1 + R1 / R2, mz.drapp(R1, dR1, R2, dR2)) Ic_q = (Vbb - Vbe) / Re dIc_q = mz.drapp(Vbb - Vbe, dVbb + dVbe, Re, dRe) Vce_q = Vcc - Ic_q * (Rc + Re) dVce_q = dVcc + mz.dprod(Vbb - Vbe, dVbb + dVbe, 1 + (Rc / Re), mz.drapp(Rc, dRc, Re, dRe)) print(Vbb, dVbb) print("Ic_q %f+-%f\nVce_q %f+-%f" % (Ic_q, dIc_q, Vce_q, dVce_q)) #print(18.24/R1, 1.644/R2, Ic_q/100) print(Vrc / Rc, mz.drapp(Vrc, dVrc, Rc, dRc)) Vin = 1 #Vout, f = np.genfromtxt("dati/dati.txt", unpack=True) plt.figure()