def f3(korr=False): i = len(data)-3 x = np.arange(0, (len(data[i]))*10, 10) y = np.array(data[i]) ey = np.ones(len(x))*e_s ex = np.ones(len(x))*e_m ax1, ax2, a,ea,b,eb,chiq,corr = bib.pltmitres(x,y,ey, ex=ex,yeinheit="mm", xl="m", yl="s", regData=True, title="kalib3") #Korrektur? if korr: deltas = [] for j in range(len(x)-1): deltas.append((y[j+1]-y[j])) deltas = np.array(deltas) #1. Fall: Nehme +0.07 als 10 an ax1, ax2, a,ea,b,eb,chiq,corr = bib.pltmitres(x[:-1],deltas,ey[:-1],yeinheit="mm", xl="m", yl="δ", regData=True) korrektur = np.round((deltas-0.07)/0.01) korrektur = np.append(np.zeros(1), korrektur) x2=np.array(x) for j in range(len(korrektur)): for k in range(j,len(x2)): x2[k] = x2[k]+korrektur[j] ax1, ax2, a,ea,b,eb,chiq,corr=bib.pltmitres(x2,y,ey,yeinheit="mm", xl="m", yl="s", regData=True) print("a=", a) k=l/(2*a) k*=10**-9 * 10**3 ek = l*0.5*ea/a**2 * 10**-9 * 10**3 print("k=", k) print("ek=", ek) print("ek/k", ek/k) return k, ek
def f12(korr=False): i = len(data) - 1 #N=20 N = 0 x = np.arange(10 * N, (N + len(data[i][N:])) * 10, 10) #12 y1 = np.array(data[i][N:]) #12 i = len(data) - 2 y2 = np.array(data[i][N:]) #12 y = 0.5 * (y1 + y2) ey = np.ones(len(y)) * e_s ex = np.ones(len(y)) * e_m ax1, ax2, a, ea, b, eb, chiq, corr = bib.pltmitres(x, y, ey, ex=ex, yeinheit="mm", xl="m", yl="s", regData=True, title="kalib12") print("a=", a) k = l / (2 * a) k *= 10**-9 * 10**3 ek = l * 0.5 * ea / a**2 * 10**-9 * 10**3 print("k=", k) print("ek=", ek) print("ek/k", ek / k) return k, ek
def kalib_2(): i = len(data) - 2 intervalle = [0, 60, 100, 200, 300] K = [] eK = [] for I in range(len(intervalle) - 1): j = int(intervalle[I] / 10) k = int(intervalle[I + 1] / 10) x = np.arange(intervalle[I], (j + len(data[i][j:k])) * 10, 10) #12 y = np.array(data[i][j:k]) #12 ey = np.ones(len(x)) * e_s ex = np.ones(len(x)) * e_m ax1, ax2, a, ea, b, eb, chiq, corr = bib.pltmitres(x, y, ey, ex=ex, yeinheit="mm", xl="m", yl="s", regData=True, title="kalib2") print("a=", a) k = l / (2 * a) k *= 10**-9 * 10**3 ek = l * 0.5 * ea / a**2 * 10**-9 * 10**3 print("k=", k) print("ek=", ek) print("ek/k", ek / k) K.append(k) eK.append(ek) return np.array(K), np.array(eK)
def f2(korr=False): i = len(data) - 2 x = np.arange(0, (0 + len(data[i][0:])) * 10, 10) #12 y = np.array(data[i][0:]) #12 ey = np.ones(len(x)) * e_s ex = np.ones(len(x)) * e_m ax1, ax2, a, ea, b, eb, chiq, corr = bib.pltmitres(x, y, ey, ex=ex, yeinheit="mm", xl="m", yl="s", regData=True, title="kalib2") print("a=", a) k = l / (2 * a) k *= 10**-9 * 10**3 ek = l * 0.5 * ea / a**2 * 10**-9 * 10**3 print("k=", k) print("ek=", ek) print("ek/k", ek / k) return k, ek
for line in file: d = np.array(line.split(" ")) data.append(d.astype(np.float)) data = np.array(data) for i in range(1, len(data)): if i != 2: s = data[i][:] #13: m = np.arange(0, len(s) * 10, 10) #13 delta, edelta_sys, edelta = stodelta(s, np.ones(len(s)) * e_s) em = np.ones(len(delta)) * e_m ax1, ax2, a, ea, b, eb, chiq, corr = bib.pltmitres(m, delta, edelta, ex=em, xl="m", yl="mm", regData=True, title="grun" + str(i)) print("lambda", i, "=", 2 * a * 10**6) print("e_lambda", i, "=", 2 * ea * 10**6) #Verschiebemethode ap, eap, bp, ebp, chiq, corr = anal.lineare_regression_xy( m + e_m, delta + edelta_sys, em, edelta) am, eam, bm, ebm, chiq, corr = anal.lineare_regression_xy( m - e_m, delta - edelta_sys, em, edelta) e_l_sys = np.max((np.abs(a - ap), np.abs(a - am))) * 2 * 10**6 print("e_lambda_sys", i, "=", e_l_sys) else:
sigma_winkel1 = np.array(sigma_winkel1) sigma_winkel2 = np.array(sigma_winkel2) sigma_winkel = np.array(np.sqrt(sigma_winkel1**2 + sigma_winkel2**2)) dmin = np.array(dmin) e_dmin = sigma_winkel / 2 n = np.sin(bib.DegToRad(dmin + e) * 0.5) / np.sin(bib.DegToRad(e / 2)) e_n = (np.cos(bib.DegToRad(dmin + e) * 0.5) / np.sin(bib.DegToRad(e / 2))) * 0.5 * bib.DegToRad(e_dmin) ax1, ax2, c, ec, d, ed, chiq, corr = bib.pltmitres(lambdas**-2, n, e_n, yl="n", xl="$\lambda$", xeinheit="$nm^{-2}$", ratios=[4, 1], regData=True, markersize=10) ax1.set_ylim(top=1.9) p, cov = curve_fit(lton, lambdas**-2, n, sigma=e_n) a = np.arange( min(lambdas**-2) * 0.95, max(lambdas**-2) * 1.05, max(lambdas**-2) * 0.01) b = lton(a, *p) #ax1.plot(a,b, color="b", label="fit") #ax2.plot(a,b-c*a-d, color="b") plt.show() plt.close()
(R * C))**2) * eC**2 / 4) return eQ_1 x = R_1 #R**-1 ex = eR_1 y = np.array([R_L * np.sqrt(C / L)]) #Q**-1 y = np.append(y, Q_p(R_1[1:]**-1)**-1) ey = np.array([ y[0] * np.sqrt((eR_L / R_L)**2 + 0.25 * (eC / C)**2 + 0.25 * (eL / L)**2) ]) ey = np.append(ey, eQ_p_1(R_o, eR_o)) ax1, ax2, a, ea, b, eb, chiq, corr = bib.pltmitres(x, y, ey, ex, regData=True, xl="$R^{-1} [\Omega^{-1}]$", yl="$Q^{-1}$") ax1.legend( title= "Lineare Regression\n{} = ({:.6f} ± {:.6f}){} $\cdot$ {}+({:.6f}±{:.6f}){}" .format("$Q^{-1}$", a, ea, "/$\Omega^{-1}$", "$R^{-1}$", b, eb, "", loc=1)) ax1.set_ylim(top=1.5) plt.show() plt.close() print("Aus den Messgrößen erhält man:") for i in range(len(x)): print("Q=", y[i]**-1, "+-", ey[i] * y[i]**-2, "für R^-1=", R_1[i]) #Plot der LSG:
import numpy as np import praktikum_addons.bib as bib import matplotlib.pyplot as plt x, y = bib.c_open("../WegaufKal3.lab", ["R_B1", "s"]) ex = np.ones(len(x)) * 0.005 ey = np.ones(len(y)) * 0.1 / np.sqrt(12) ax1, ax2 = bib.pltmitres(x, y, ex, ey, yl="s", xl="R", yeinheit="cm", xeinheit="$k\Omega$", ratios=[5, 1]) ax1.set_ylim(top=120) plt.show()