def auswerten(name, d, n, t, z, V_mol, eps, raw): d *= 1e-3 N = unp.uarray(n/t, np.sqrt(n)/t) - N_u if name=="Cu": tools.table((raw[0], raw[1], N), ("D/mm", "n", "(N-N_U)/\per\second"), "build/{}.tex".format(name), "Messdaten von {}.".format(name), "tab:daten{}".format(name), split=2, footer=r"$\Delta t = \SI{60}{s}$")#"(N-N_U)/\per\second" else: tools.table((raw[0], raw[1], raw[2], N), ("D/mm", "n", "\Delta t/s", "(N-N_U)/\per\second"), "build/{}.tex".format(name), "Messdaten von {}.".format(name), "tab:daten{}".format(name), split=2) mu = z * const.N_A / V_mol * 2 * np.pi * (const.e**2 / (4 * np.pi * const.epsilon_0 * const.m_e * const.c**2))**2 * ((1+eps)/eps**2 * ((2 * (1+eps))/(1+2*eps) - 1/eps * np.log(1+2*eps)) + 1/(2*eps) * np.log(1+ 2*eps) - (1+ 3*eps)/(1+2*eps)**2) params, pcov = curve_fit(fit, d, unp.nominal_values(N), sigma=unp.std_devs(N)) params_ = unc.correlated_values(params, pcov) print("{}: N(0) = {}, µ = {}, µ_com = {}".format(name, params_[0], -params_[1], mu)) sd = np.linspace(0, .07, 1000) valuesp = (fit(sd, *(unp.nominal_values(params_) + 10*unp.std_devs(params_)))).astype(float) valuesm = (fit(sd, *(unp.nominal_values(params_) - 10*unp.std_devs(params_)))).astype(float) #plt.xlim(0,7) plt.xlabel(r"$D/\si{mm}$") plt.ylabel(r"$(N-N_U)/\si{\per\second}$") plt.plot(1e3*sd, fit(sd, *params), 'b-', label="Fit") plt.fill_between(1e3*sd, valuesm, valuesp, facecolor='blue', alpha=0.125, edgecolor='none', label=r'$1\sigma$-Umgebung ($\times 10$)') plt.errorbar(1e3*d, unp.nominal_values(N), yerr=unp.std_devs(N), fmt='rx', label="Messdaten") plt.legend(loc='best') plt.yscale('linear') plt.tight_layout(pad=0) plt.savefig("build/{}.pdf".format(name)) plt.yscale('log') plt.savefig("build/{}_log.pdf".format(name)) plt.clf()
def decode(classification, boxes, kernel=3, nms_params=detection_table.nms_defaults): h, w, num_classes = classification.shape maxima, mask = local_maxima(classification, kernel=kernel, threshold=nms_params.threshold) confidence, inds = maxima.view(-1).topk(k = min(nms_params.detections, mask.sum()), dim=0) labels = inds // (h * w) box_inds = inds % (h * w) return table(label = labels, bbox = boxes.view(-1, 4)[box_inds], confidence=confidence)
def decode_detections(detections, class_mapping): objs = filter_map(decode_detection, detections) boxes = pluck('box', objs) labels = list(map(lookup(class_mapping), pluck('label', objs))) return table(bbox=torch.FloatTensor(boxes) if len(boxes) else torch.FloatTensor(0, 4), label=torch.LongTensor(labels), confidence=torch.FloatTensor(pluck('confidence', objs)))
def decode(self, input_size, prediction, nms_params=detection_table.nms_defaults): classification, location = prediction location.dim() == 2 and classification.dim() == 2 anchor_boxes = self.anchors(input_size) bbox = anchor.decode(location, anchor_boxes) confidence, label = classification.max(1) if self.params.crop_boxes: box.clamp(bbox, (0, 0), inputs) decoded = table(bbox=bbox, confidence=confidence, label=label) return detection_table.nms(decoded, nms_params)
def decode_object_map(annotations, config): mapping = class_mapping(config) objs = {k: decode_obj(a) for k, a in annotations.items()} objs = [ ann._extend(id=int(k)) for k, ann in objs.items() if ann is not None ] boxes = pluck('box', objs) labels = list(map(lookup(mapping), pluck('label', objs))) ids = pluck('id', objs) return table(bbox=torch.FloatTensor(boxes) if len(boxes) else torch.FloatTensor(0, 4), label=torch.LongTensor(labels), id=torch.LongTensor(ids))
import torch import torchvision.ops as torchvision from tools import table, struct nms_defaults = struct(nms=0.5, threshold=0.05, detections=500) def nms(prediction, params): inds = (prediction.confidence >= params.threshold).nonzero( as_tuple=False).squeeze(1) prediction = prediction._index_select(inds)._extend(index=inds) inds = torchvision.nms(prediction.bbox, prediction.confidence, params.nms) return prediction._index_select(inds)._take(params.detections) empty_detections = table(bbox=torch.FloatTensor(0, 4), label=torch.LongTensor(0), confidence=torch.FloatTensor(0))
sigma_y = np.sqrt(np.sum((y - A * x - B)**2) / (N - 2)) A_error = sigma_y * np.sqrt(N / Delta) B_error = sigma_y * np.sqrt(np.sum(x**2) / Delta) return A, A_error, B, B_error Al = np.genfromtxt('daten/{}.txt'.format('Al'), unpack=True, dtype=object) d, delta_d, t, n = Al.astype(float) N_u = unc.ufloat(324/900, np.sqrt(324)/900) d = unp.uarray(d, delta_d) * 1e-6 N = unp.uarray(n/t, np.sqrt(n)/t) - N_u tools.table((Al[0], Al[2], Al[3], N), ("D/µm", "n", "\Delta t/s", "(N-N_U)/\per\second"), "build/Al.tex", "Messdaten von Aluminium.", "tab:datenAl", split=2, round_figures=(0,0,0,3)) N = unp.log(N) slope1, std_a1, intercept1, std_b1 = linregress(unp.nominal_values(d[:5]), unp.nominal_values(N[:5])) slope2, std_a2, intercept2, std_b2 = linregress(unp.nominal_values(d[5:]), unp.nominal_values(N[5:])) D_max = (unc.ufloat(intercept2, std_b2)-unc.ufloat(intercept1, std_b1))/(unc.ufloat(slope1, std_a1) - unc.ufloat(slope2, std_a2)) print(D_max) R_max = D_max * 2700 / 10 E_max = 1.92*unp.sqrt(R_max**2 + 0.22*R_max) print("D_max = {}µm, R_max = {}g/cm², E_max = {} MeV".format(D_max*1e6, R_max, E_max)) #print(unp.nominal_values(d), N) sd = np.linspace(0, 0.5e-3)
d = 48.4-16.2 d *= 0.5e-6 d *= c V = np.pi / 3 * d**2 * (3 * R - d) print(d, V*1e6, 1e6*V * f) c = 1480 d = 44-unc.ufloat(zeit.mean(), scipy.stats.sem(zeit)) d *= 0.5e-6 d *= c V = np.pi / 3 * d**2 * (3 * R - d) tools.table((t, zeit), ('t/s', 'd/µs'), 'build/tm.tex', 'Messergebnisse des Herzmodells.', 'tab:tm', split=2) print(unc.ufloat(zeit.mean(), scipy.stats.sem(zeit)), d*1e2, V*1e6, 1e6*V * f) d = np.genfromtxt('daten/tm/scan.dat', unpack=True) #plt.figure(figsize=(5.78, 2.7)) plt.imshow(d, cmap=cm.inferno_r, extent=(0,25, 100, 0), aspect='auto') plt.ylim(100, -0.5) plt.xlabel(r"$t/s$") plt.ylabel(r"$d/\si{\micro\second}$") for siegmannistdoof in zip(t, zeit): plt.plot((siegmannistdoof[0], siegmannistdoof[0]), (0, siegmannistdoof[1]), 'r_') plt.plot((siegmannistdoof[0], siegmannistdoof[0]), (0, siegmannistdoof[1]), 'r-') plt.plot((),(), 'r-', label='Gemessene Längen')
plt.savefig('build/'+name+'_kurzgeschlossen.pdf') plt.close() print(name) t = (zeiten[1]-zeiten[0]) print('{}ns'.format(t*1e9)) print('{}m'.format(c * t / 2)) '''if fit: #Schmissscharts plt.figure(figsize=(5,5)) ax = plt.subplot(1, 1, 1, projection='smith') #plt.plot([10, 100], markevery=1) omega = 2* np.pi * np.linspace(2*1e3, 100*1e3, 20) X = omega * L - 1 / (omega * C) plt.plot((0+X*1j)/50, datatype=SmithAxes.Z_PARAMETER, label='Muh') plt.plot((1e100+X*1j)/50, datatype=SmithAxes.Z_PARAMETER, label='Muh') plt.legend(loc='best') plt.tight_layout(pad=0) plt.savefig('build/'+name+'_smith.pdf') plt.close()''' ausw('langes_kabel', (-9e-7, -4e-8, -2e-8, 8.5e-7, 1, 1), 8.7e-7, True, 0) ausw('mittleres_50ohm', (-1.7e-7, -0.7e-7, -0.0e-7, 0.2e-7, 0.6e-7, 0.5e-7), 0, True, 1) ausw('mittleres_75ohm', (-1.4e-7, -0.4e-7, 0.3e-7, 0.1e-7, 0.6e-7, 0.6e-7), 0, True, 2) K ={0:'Langes Kabel', 1:'Mittleres 50 Ohm', 2:'Mittleres 75 Ohm'} tools.table([*pa1.T, *pa2.T], ('a_1/V', 'b_1/\per\second', 'c_1', 'd_1/V', 'a_2/V', 'b_2/\per\second', 'c_2', 'd_2/V'), 'build/laufzeit.tex', 'Fitparameter.', 'tab:laufzeit', interrows=K) tools.table((La*1e6, Ca*1e9), ('L/µH', 'C/nF'), 'build/laufzeit2.tex', 'Ergebnisse der Leitungsparameter.', 'tab:laufzeit2', interrows = K)
import numpy as np import matplotlib.pyplot as plt import tools import uncertainties.unumpy as unp d = np.genfromtxt('daten/a.txt', dtype=object, unpack=True) d_ = np.concatenate((d[1:4].T, d[4:7].T, d[7:10].T), axis=0).T tools.table((np.tile(d[0], 3), *d_), ("\dot V / \percent", r"\Delta f_{\SI{30}{\degree}}/Hz", r"\Delta f_{\SI{15}{\degree}}/Hz", r"\Delta f_{\SI{60}{\degree}}/Hz"), "build/datena.tex", "Messdaten zum ersten Aufgabenteil.", "datena", interrows={0:r"$d=\SI{16}{mm}$", 5:r"$d=\SI{10}{mm}$", 10:r"$d=\SI{7}{mm}$"}) d_ = d.astype(float) V = d_[0] f = np.absolute(np.array([d_[1:4], d_[4:7], d_[7:10]])) V /= 10 theta = np.radians(np.array((30, 15, 60))) alpha = np.pi/2 - np.arcsin(np.sin(theta) * 18/27) c_l = 1800 nu_0 = 2e6 v = f * c_l / nu_0 / 2 / np.cos(alpha)[np.newaxis, :, np.newaxis] v_ = np.concatenate((v[0].T, v[1].T, v[2].T), axis=0).T tools.table((np.tile(V, 3), *v_, unp.uarray(v_.mean(axis=0), v_.std(axis=0))), (r"\dot V/ \liter\per\minute", r"v_{\SI{30}{\degree}}/\meter\per\second", r"v_{\SI{15}{\degree}}/\meter\per\second", r"v_{\SI{60}{\degree}}/\meter\per\second", r"\bar v / \meter\per\second"), "build/a.tex", "Ergebnisse.", "tab:erg", round_figures=(1,3,3,3,3), interrows={0:r"$d=\SI{16}{mm}$", 5:r"$d=\SI{10}{mm}$", 10:r"$d=\SI{7}{mm}$"}) print((v_.std(axis=0) / v_.mean(axis=0)).mean() * 100) for i in range(0, 3): plt.plot(v[:,i,:], f[:,i,:]/np.cos(alpha)[i], 'rx') plt.xlabel(r'$v/\si{\meter\per\second}$') plt.ylabel(r'$\Delta \nu / \cos \alpha / \si{\per\second}$') plt.tight_layout()
plt.plot(I1, U1, 'x', label='Daten 1') plt.plot(I2, U2, 'x', label='Daten 2') plt.legend(loc='best') plt.tight_layout(pad=0) plt.savefig('build/' + name + '.pdf') plt.close() param1 = unc.correlated_values(popt1, pcov1) param2 = unc.correlated_values(popt2, pcov2) return param1[2], param2[2] I = np.array(list(map(auswerten, zip(liste, p0liste)))).T / 1e3 tools.table((f[:-1] / 1e6, I[0] * 1e3, I[1] * 1e3), ('f/MHz', 'I_1/mA', 'I_2/mA'), 'build/ergfit.tex', 'Ermittelte Extremstellen, entsprechen der Resonanzfeldstärke.', 'tab:ergfit') data_kal = np.genfromtxt('daten/kal.txt', dtype=object).T tools.table(data_kal, ('l/mm', 'I/mA'), 'build/kal.tex', 'Daten der XY-Schreiber-Kalibrierung.', 'tab:kal') kal_l, kal_i = data_kal.astype(float) #m, n, r, p, std = scipy.stats.linregress(kal_l, kal_i) z, cov = np.polyfit(kal_l, kal_i, 1, cov=True) m = unc.ufloat(z[0], np.sqrt(cov[0][0])) n = unc.ufloat(z[1], np.sqrt(cov[1][1])) x = np.linspace(0, 210) plt.plot(kal_l, kal_i, 'x', label='Kalibrierung XY-Schreiber')
import matplotlib.pyplot as plt import numpy as np from scipy import stats import scipy.constants as const import tools import uncertainties as unc import uncertainties.unumpy as unp data1 = np.genfromtxt('daten/dicke_ohne.txt', unpack=True, dtype=object) data2 = np.genfromtxt('daten/dicke_mit.txt', unpack=True, dtype=object) tools.table([data1[0], data1[1], data2[0], data2[1]], ["U_1/V", "p_1/hPa", "U_2/V", "p_2/hPa"], "build/table_energieverlust.tex", "Messdaten der Energieverlustmessung", "tab:daten1", split=1, footer=None, round_figures=None, interrows=None) U1, p1 = data1.astype(float) U2, p2 = data2.astype(float) slope1, intercept1, r_value, p_value, std_err1 = stats.linregress(p1, U1) slope2, intercept2, r_value, p_value, std_err2 = stats.linregress(p2, U2) mx = p1.mean() sx2 = ((p1 - mx)**2).sum() intercept_err1 = std_err1 * np.sqrt(1. / len(p1) + mx * mx / sx2)
import numpy as np import matplotlib.pyplot as plt import tools d = np.genfromtxt("daten/b.txt", unpack=True, dtype=object) tools.table(d, (r"d/µs", r"\Delta f_1/Hz", r"I_1", r"\Delta f_2/Hz", r"I_2"), "build/datenb.tex", "Messdaten zum zweiten Versuchsteil.", "label", split=2) t, delta_f1, I1, delta_f2, I2 = d.astype(float) t/=1e6 alpha = np.pi/2 - np.arcsin(np.sin(15) * 18/27) c_l = 1800 c_p = 2700 prism_time = 30.7e-3 / c_p print(prism_time) depth = np.zeros(len(t)) depth[t < prism_time] = t[t < prism_time] * c_p depth[t >= prism_time] = prism_time * c_p + (t[t >= prism_time] - prism_time) * c_l nu_0 = 2e6 v1 = -delta_f1 * c_l / nu_0 / 2 / np.cos(alpha) v2 = -delta_f2 * c_l / nu_0 / 2 / np.cos(alpha) plt.plot(depth*1e3, v1, 'x', label="70% Pumpenleistung") plt.plot(depth*1e3, v2, 'x', label="45% Pumpenleistung")
innenwiderstand = 1e6 I /= 1e9 U = Ur - I * innenwiderstand print(U) def anlaufstrom(U, C, T): j = C * np.exp((const.elementary_charge * U) / (const.k * T)) return j * 0.35e-4 params, cov = curve_fit(anlaufstrom, U, I, maxfev=1000000, p0=[1, 1000]) print(params) u = np.linspace(-1, 0.05, 1e6) plt.plot(u, 1e9 * anlaufstrom(u, *params), 'b-', label='Fit') plt.plot(U, 1e9 * I, 'rx', label='Daten') plt.xlim(-1, 0.05) plt.xlabel(r"$U_G/\si{V}$") plt.ylabel(r"$I/\si{nA}$") plt.tight_layout() plt.legend(loc='best') plt.savefig('build/c.pdf') tools.table((d[0], U, d[1]), ("U_G/V", r"U_\text{korr}/V", "I/nA"), "build/fqfepoijfewoij.tex", "Daten der Messreihe für das Anlaufstromgebiet.", "tab:anlauf", round_figures=(2, 2, 3), split=2)
p2 = peak.peakdetect(u2, f2, 3) plt.plot(f1 / 1e6, u1, '-', label='FFT des Signals auf Leitung 1') plt.plot(f2 / 1e6, u2, '-', label='FFT des Signals auf Leitung 2') p1 = np.array(p1[0]).T p2 = np.array(p2[0]).T p1 = p1.T[np.ma.mask_or(p1[1] > -15, np.logical_and(p1[0] > 1.1050e7, p1[0] < 1.1075e7))].T p2 = p2.T[p2[1] > -15].T plt.plot(p1[0] / 1e6, p1[1], 'C0x', label='Peaks Leitung 1') plt.plot(p2[0] / 1e6, p2[1], 'C1x', label='Peaks Leitung 2') alpha = p2[1] - p1[1] tools.table((p1[0] / 1e6, alpha), (r'f/MHz', r'\alpha/\deci\bel'), 'build/alpha.tex', 'Ergebnisse der Dämpfungsmessung.', 'tab:alpha', round_figures=(4, 2), split=2) print(alpha.mean(), alpha.std()) plt.ylabel(r'$L_P/\mathrm{dB}$') plt.xlabel(r'$f/\mathrm{MHz}$') plt.legend(loc='best') plt.tight_layout(pad=0) plt.savefig('build/alpha.pdf')
def auswerten(name, d, n, t, z, V_mol, eps, raw): d *= 1e-3 N = unp.uarray(n / t, np.sqrt(n) / t) - N_u if name == "Cu": tools.table((raw[0], raw[1], N), ("D/mm", "n", "(N-N_U)/\per\second"), "build/{}.tex".format(name), "Messdaten von {}.".format(name), "tab:daten{}".format(name), split=2, footer=r"$\Delta t = \SI{60}{s}$") #"(N-N_U)/\per\second" else: tools.table((raw[0], raw[1], raw[2], N), ("D/mm", "n", "\Delta t/s", "(N-N_U)/\per\second"), "build/{}.tex".format(name), "Messdaten von {}.".format(name), "tab:daten{}".format(name), split=2) mu = z * const.N_A / V_mol * 2 * np.pi * ( const.e**2 / (4 * np.pi * const.epsilon_0 * const.m_e * const.c**2))**2 * ( (1 + eps) / eps**2 * ((2 * (1 + eps)) / (1 + 2 * eps) - 1 / eps * np.log(1 + 2 * eps)) + 1 / (2 * eps) * np.log(1 + 2 * eps) - (1 + 3 * eps) / (1 + 2 * eps)**2) params, pcov = curve_fit(fit, d, unp.nominal_values(N), sigma=unp.std_devs(N)) params_ = unc.correlated_values(params, pcov) print("{}: N(0) = {}, µ = {}, µ_com = {}".format(name, params_[0], -params_[1], mu)) sd = np.linspace(0, .07, 1000) valuesp = (fit(sd, *(unp.nominal_values(params_) + 10 * unp.std_devs(params_)))).astype(float) valuesm = (fit(sd, *(unp.nominal_values(params_) - 10 * unp.std_devs(params_)))).astype(float) #plt.xlim(0,7) plt.xlabel(r"$D/\si{mm}$") plt.ylabel(r"$(N-N_U)/\si{\per\second}$") plt.plot(1e3 * sd, fit(sd, *params), 'b-', label="Fit") plt.fill_between(1e3 * sd, valuesm, valuesp, facecolor='blue', alpha=0.125, edgecolor='none', label=r'$1\sigma$-Umgebung ($\times 10$)') plt.errorbar(1e3 * d, unp.nominal_values(N), yerr=unp.std_devs(N), fmt='rx', label="Messdaten") plt.legend(loc='best') plt.yscale('linear') plt.tight_layout(pad=0) plt.savefig("build/{}.pdf".format(name)) plt.yscale('log') plt.savefig("build/{}_log.pdf".format(name)) plt.clf()
import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit import scipy.constants as const import scipy.stats as stats import tools U_h_, I_h_ = np.genfromtxt("daten/a_heiz.txt", unpack=True, dtype=object) U_h = U_h_.astype(float) I_h = I_h_.astype(float) I_s_ = np.genfromtxt("daten/i_s.txt", dtype=object) I_s = I_s_.astype(float) / 1e3 f = 0.35e-4 eta = 0.28 T = np.power((U_h*I_h-0.95)/(f*eta*const.sigma), 0.25) #print(T) #Tr = T[2:] #print(Tr) f = 0.35e-4 phi = - const.Boltzmann * T / const.e * np.log(I_s * const.h**3 / (4*np.pi * f * const.e * const.m_e * const.Boltzmann**2 * T**2)) print(phi.mean(), phi.std()) tools.table([U_h_[::-1], I_h_[::-1], T[::-1], I_s_[::-1], phi[::-1]], ["U_H/V", "I_H/A","T/K", "I_S/mA", "\phi/\electronvolt"], "build/d.tex", "Abgeschätzte Kathodentemperaturen.", "tab:temp")
data = np.genfromtxt('daten/kontrast.txt', dtype=object, unpack=True) phi, Umin, Umax = data.astype(float) phi = np.deg2rad(phi) def f(x, A, phi, omega): return A * np.abs(np.sin(omega * x + phi)) K = (Umax - Umin) / (Umax + Umin) tools.table((*data, K), (r'\phi/\degree', r'U_\mathrm{min}/\milli\volt', r'U_\mathrm{max}/\milli\volt', 'K'), 'build/kontrast.tex', 'Messdaten und Ergebnisse der Kontrastmessung.', 'tab:kontrast', round_figures=(None, None, None, 3)) params, pcov = scipy.optimize.curve_fit(f, phi, K, p0=[0.5, 0, 2]) A, phi_, omega = params print(A) print(np.rad2deg((np.pi * 0.5 - phi_) / omega)) x = np.linspace(-0.4, 3.5, 2000) plt.xlim(-0.4, 3.5) plt.plot(x, f(x, *params), label='Fit') plt.plot(phi, K, 'x', label='Messdaten') plt.xlabel(r'$\phi/\mathrm{rad}$') plt.ylabel(r'$K$') plt.legend(loc='upper right')
R = unp.uarray((U[:,1:]/I__[1:]).mean(axis=1), (U[:,1:]/I__[1:]).std(axis=1)) sl = np.array((auswerten(I_, Cu, 'b2'), auswerten(I_[:-4], Zn[:-4], 'b'))) #d = np.array((18e-6, 1/(sl[1] / (6.4e-11 * B)) )) d = rho * L / (R * b) print(R, d) R_H = sl / B * d n = 1 / (sl * d / B * const.e) V = (2.8e-2*2.5e-2, 4.4e-2*2.6e-2)*d z = n * Vm / const.N_A #print(R_H, d, n, z) tau = 1/(R / 2 * const.e**2 / const.m_e * n / (2.8e-2, 4.4e-2) * d * (2.5e-2, 2.6e-2)) v_d = 1e9 / n / const.e µ = const.e * tau / const.m_e E_F = const.h**2 / (2* const.m_e) * ((3/8/np.pi * n)**2)**(1/3) v = unp.sqrt(2*E_F/const.m_e) l = tau * unp.sqrt(2*E_F/const.m_e) tools.table((sl, R_H*1e11, d*1e6, n/1e27), (r"m/\ohm", r"R_H/(10^{-11} \cubic\meter\per\coulomb)", r"d/µm", r"n/\per\cubic\nano\meter"), "build/erg.tex", "Ergebnisse der Auswertung, erster Teil.", "tab:erg", round_figures=(3,3,3,3), interrows={0:"Kupfer", 1:"Zink"}) tools.table((z, R*1e3, tau*1e15), ("z", "R/\milli\ohm", r"\bar\tau/fs"), "build/erg3.tex", "Ergebnisse der Auswertung, dritter Teil.", "tab:erg3", round_figures=(3,3,3), interrows={0:"Kupfer", 1:"Zink"}) tools.table((v_d*1e3, 1e4* µ, v/1e6, l*1e9), (r"\bar v_d/(\milli\meter\per\second)", r"\mu/(\centi\meter\squared\per\volt\per\second)", "v/(\mega\meter\per\second)", r"\bar l/nm"), "build/erg2.tex", "Ergebnisse der Auswertung, zweiter Teil.", "tab:erg2", round_figures=(3,3,3,3), interrows={0:"Kupfer", 1:"Zink"}) tools.table(data, ('I/A', r'U_\text{Zn}/mV', r'U_\text{Cu}/mV'), 'build/datena.tex', 'Messdaten, Widerstandsmessreihe.', 'datena', split=2)
import matplotlib.pyplot as plt import numpy as np import scipy.optimize import uncertainties.unumpy as unp import uncertainties as unc import scipy.stats from scipy.optimize import curve_fit import tools data = np.genfromtxt('daten/glas.txt', dtype=object, unpack=True) theta = np.deg2rad(data[0].astype(float)) M = data[1:4].astype(float) M = unp.uarray(M.mean(axis=0), M.std(axis=0)).cumsum() tools.table((data[0], *data[1:4], M), (r'\phi/\degree', 'M_1', 'M_2', 'M_3', 'M'), 'build/glas.tex', 'Messdaten und Ergebnisse der Glasmessung.', 'tab:glas', round_figures=(0, 0, 0, 0, 3)) T = 1e-3 lambda_ = 623.990e-9 alpha = np.deg2rad(10) def func(theta, n): return T/lambda_ * (n-1)/(2*n) * ((alpha+theta)**2 - (alpha-theta)**2) params, pcov = curve_fit(func, theta, unp.nominal_values(M)) print(unc.correlated_values(params, pcov)) theta_s = np.linspace(-1, 1, 1000) plt.plot(1e3*theta_s, func(theta_s, *params), label='Fit') plt.xlim(0, 0.2*1e3)
d1 *= c d2 *= c h = 80.04e-3 dia = h - d1 - d2 d_1, d_2 = np.genfromtxt('daten/mech.txt', unpack=True) dia_ = h * 1e3 - d_1 - d_2 la = np.array( (b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'10', b'11'), dtype=object) np.savez('build/a.npz', d2, d1, dia) tools.table( (la, 1e3 * d2, 1e3 * d1, 1e3 * dia, d_1, d_2, dia_), (r"\text{Störstelle}", "d_1/mm", "d_2/mm", "2r/mm", r"d_1^\text{mech}/mm", r"d_2^\text{mech}/mm", r"2r^\text{mech}/mm"), 'build/a.tex', r'Messergebnisse aus dem A-Scan. Neben den abgelesenen und berechneten Daten $d_n$ sind auch die zuvor mittels Messschieber bestimmten Abmessungen $d_n^\text{mech}$ eingetragen.', 'tab:a') tools.table((la, t1, t2), (r"\text{Störstelle}", "t_1/\micro\second", "t_2/\micro\second"), "build/a_d.tex", "Messdaten zum A-Scan.", "tab:mess_a") def abw(a, b): return 100 * np.abs(a - b) / b #tools.table((la, abw(d2 , d_1/1e3), abw(d1, d_2/1e3), abw(dia, dia_/1e3)), (r"\text{Störstelle}", r"\Delta d_1/\percent", r"\Delta d_2/\percent", r"\Delta 2r/\percent"), 'build/diska.tex', 'Abweichungen beim A-Scan.', 'tab:diska', round_figures=(0,2,2,2))
data = np.genfromtxt('daten/rlc.txt', unpack=True, dtype=object) f, C1, R1, L1, C2, R2, L2 = data.astype(float) C1 /= 1e12 C2 /= 1e12 L1 /= 1e6 L2 /= 1e6 f *= 1e3 ω = 2 * np.pi * f c = const.c / np.sqrt(2.25) G1 = R1 * C1 / L1 G2 = R2 * C2 / L2 tools.table((data[0], data[2], data[5], data[3], data[6], data[1], data[4], G1*1e3, 1e3*G2), ('f/kHz', 'R_1/\ohm', 'R_2/\ohm', 'L_1/\micro\henry', 'L_2/\micro\henry', 'C_1/pF', 'C_2/pF', 'G_1/mS', 'G_2/mS'), 'build/rlcg.tex', 'Messdaten der ersten Messreihe.', 'tab:rlcg') def smith(R, L, C, G, name): #Schmissscharts plt.figure(figsize=(5,5)) ax = plt.subplot(1, 1, 1, projection='smith', axes_impedance=name) #plt.plot([10, 100], markevery=1) #omega = 2* np.pi * np.linspace(2*1e3, 100*1e3, 20) Z = np.sqrt((R + 1j*ω*L)/(G + 1j*ω*C)) beta = 2 * np.pi / (c/f) phi = 2 * beta * 10 #print(np.rad2deg(phi)) plt.plot(Z, datatype=SmithAxes.Z_PARAMETER, label=r'$Z_\mathrm{Leitung}', markersize=3) plt.legend(loc='best') plt.tight_layout(pad=0)
N0 = 5360 / 180 N = N / t N = unp.uarray(N, np.sqrt(N)) F = 2e-3 * 10e-3 N_T = 2e-6 * F * 97986 * const.N_A sigma = N / N0 * F / N_T omega = (F / 101e-3**2) print(omega) difsigma = sigma / omega tools.table( [data[0], data[1], data[2], N, difsigma], [ r'\theta/\degree', r'N_\text{mess}', 't/s', r'N/\per\second', r'\frac{\mathrm{d}\sigma}{\mathrm{d}\Omega}(\theta)/\mathrm{m}^2' ], 'build/daten2.tex', 'Messwerte und daraus abgeleitete Größen bei der Messung des Streuquerschnitts.', 'tab:daten2', split=1) plt.errorbar(theta, unp.nominal_values(difsigma), yerr=unp.std_devs(difsigma), fmt='x', label='Messwerte') plt.xlabel(r'$\theta/^\circ$') plt.ylabel(r'$\frac{\mathrm{d}\sigma}{\mathrm{d}\Omega}(\theta)/\mathrm{m}^2$') plt.ylim(-0.1e-21, 2.6e-21) plt.xlim(-5, 25)
import numpy as np import matplotlib.pyplot as plt import tools d = np.genfromtxt('daten/e.txt', unpack=True, dtype=object) Ihy, Bhy = d.astype(float) plt.figure(figsize=(5.78, 3.4)) plt.plot(Ihy, Bhy, 'rx-', markersize=3, linewidth=0.5, label='Hysteresekurve') plt.xlabel(r'$I/\si{A}$') plt.ylabel(r'$B/\si{mT}$') plt.legend(loc='best') plt.tight_layout(pad=0) plt.savefig('build/hysterese.pdf') tools.table(d, ('I/A', 'B/mT'), 'build/e.tex', 'Messdaten, Hysteresekurve.', 'de', split=3)
return A, A_error, B, B_error Al = np.genfromtxt('daten/{}.txt'.format('Al'), unpack=True, dtype=object) d, delta_d, t, n = Al.astype(float) N_u = unc.ufloat(324 / 900, np.sqrt(324) / 900) d = unp.uarray(d, delta_d) * 1e-6 N = unp.uarray(n / t, np.sqrt(n) / t) - N_u tools.table((Al[0], Al[2], Al[3], N), ("D/µm", "n", "\Delta t/s", "(N-N_U)/\per\second"), "build/Al.tex", "Messdaten von Aluminium.", "tab:datenAl", split=2, round_figures=(0, 0, 0, 3)) N = unp.log(N) slope1, std_a1, intercept1, std_b1 = linregress(unp.nominal_values(d[:5]), unp.nominal_values(N[:5])) slope2, std_a2, intercept2, std_b2 = linregress(unp.nominal_values(d[5:]), unp.nominal_values(N[5:])) D_max = (unc.ufloat(intercept2, std_b2) - unc.ufloat(intercept1, std_b1)) / ( unc.ufloat(slope1, std_a1) - unc.ufloat(slope2, std_a2)) print(D_max) R_max = D_max * 2700 / 10
l4 *= 1e-2 l5 *= 1e-2 l6 *= 1e-2 s2 *= 1e-2 x1 = 129.9e-2 x2 = 130.1e-2 lc = np.concatenate((l3, l5)) lb = np.concatenate((l4, l6)) e = np.concatenate((x1 - s, np.tile(x2 - s2, 2))) b1 = np.concatenate((l1 - x1, lb - x2)) + e b2 = np.concatenate((l2 - x1, lc - x2)) + e g1 = e - b1 g2 = e - b2 f2 = auswerten(130.1e-2, l3, l4, s2, '100mm rot') f3 = auswerten(130.1e-2, l5, l6, s2, '100mm blau') tools.table( (1e2 * e, 1e2 * b1, 1e2 * g1, 1e2 * b2, 1e2 * g2, 1e3 * np.concatenate( (f1, f2, f3))), ("e/cm", "b_1/cm", "g_1/cm", "b_2/cm", "g_2/cm", "f/mm"), "build/b.tex", "Messreihe zur Bessel-Methode", "tab:b", interrows={ 0: "Ohne Filter", 10: "Roter Filter", 15: "Blauer Filter" })
import numpy as np import matplotlib.pyplot as plt import tools d = np.genfromtxt("daten/a.txt", unpack=True, dtype=object) f, U_A = d.astype(float) plt.plot(f, U_A, "rx", label="Messwerte") plt.xlabel(r"f/kHz") plt.ylabel(r"$U_\mathrm{A}/mV$") plt.savefig("build/a.pdf") plt.legend(loc="best") plt.clf() tools.table(d, ("f/kHz", "U_A/mV"), "build/daten_a.tex", "Messdaten a.", "tab:mess_a")
y *= 1e-2 z *= 1e-2 x = 129.4e-2 G = 2.8e-2 g_ = x - z b_ = x - y - g_ V = B / G tools.table( (1e2 * B, V, 1e2 * g_, 1e2 * b_), ("B/cm", "V", "g'/cm", "b'/cm"), "build/c.tex", "Messreihe zur Abbe-Methode.", "tab:c", split=2, round_figures=(3, 4, 4, 4), ) m1, m1_, n1, n1_ = linregress((1 + 1 / V), g_) m2, m2_, n2, n2_ = linregress((1 + V), b_) x = np.linspace(1.0, 2.6) print("f1 = {}+-{}mm, f2 = {}+-{}mm".format(m1 * 1e3, m1_ * 1e3, m2 * 1e3, m2_ * 1e3)) print("h = {}+-{}cm, h' = {}+-{}cm".format(n1 * 1e2, n1_ * 1e2, n2 * 1e2, n2_ * 1e2)) f1 = unc.ufloat(m1, m1_) f2 = unc.ufloat(m2, m2_) f = (f1 + f2) / 2 ft = 1 / (1 / 100e-3 + 1 / -100e-3 - 6e-2 / (100e-3 * -100e-3))
d = 48.4 - 16.2 d *= 0.5e-6 d *= c V = np.pi / 3 * d**2 * (3 * R - d) print(d, V * 1e6, 1e6 * V * f) c = 1480 d = 44 - unc.ufloat(zeit.mean(), scipy.stats.sem(zeit)) d *= 0.5e-6 d *= c V = np.pi / 3 * d**2 * (3 * R - d) tools.table((t, zeit), ('t/s', 'd/µs'), 'build/tm.tex', 'Messergebnisse des Herzmodells.', 'tab:tm', split=2) print(unc.ufloat(zeit.mean(), scipy.stats.sem(zeit)), d * 1e2, V * 1e6, 1e6 * V * f) d = np.genfromtxt('daten/tm/scan.dat', unpack=True) #plt.figure(figsize=(5.78, 2.7)) plt.imshow(d, cmap=cm.inferno_r, extent=(0, 25, 100, 0), aspect='auto') plt.ylim(100, -0.5) plt.xlabel(r"$t/s$") plt.ylabel(r"$d/\si{\micro\second}$") for siegmannistdoof in zip(t, zeit): plt.plot((siegmannistdoof[0], siegmannistdoof[0]), (0, siegmannistdoof[1]), 'r_')
print(U) def anlaufstrom(U, C, T): j = C * np.exp((const.elementary_charge * U) / (const.k * T)) return j * 0.35e-4 params, cov = curve_fit(anlaufstrom, U, I, maxfev=1000000, p0=[1, 1000]) print(params) u = np.linspace(-1, 0.05, 1e6) plt.plot(u, 1e9 * anlaufstrom(u, *params), "b-", label="Fit") plt.plot(U, 1e9 * I, "rx", label="Daten") plt.xlim(-1, 0.05) plt.xlabel(r"$U_G/\si{V}$") plt.ylabel(r"$I/\si{nA}$") plt.tight_layout() plt.legend(loc="best") plt.savefig("build/c.pdf") tools.table( (d[0], U, d[1]), ("U_G/V", r"U_\text{korr}/V", "I/nA"), "build/fqfepoijfewoij.tex", "Daten der Messreihe für das Anlaufstromgebiet.", "tab:anlauf", round_figures=(2, 2, 3), split=2, )
plt.xlim(0, 1.2) plt.ylim(0, 0.6 if name=='2' else 0.33) plt.plot((f_-epsilon, f_+epsilon, f_+epsilon, f_-epsilon, f_-epsilon), (f_-epsilon, f_-epsilon, f_+epsilon, f_+epsilon, f_-epsilon), 'k-', linewidth=0.5, label="Vergrößerter Ausschnitt") plt.legend() plt.tight_layout(pad=0) plt.savefig('build/a{}.pdf'.format(name)) plt.clf() return f g1, b1, B1, g2, b2 = np.genfromtxt('daten/a.txt', unpack=True) g1 *= 1e-2 b1 *= 1e-2 B1 *= 1e-2 g2 *= 1e-2 b2 *= 1e-2 f1 = auswerten(g1, b1, '1', [3]) f2 = auswerten(g2, b2, '2', []) V = b1/g1 print("V_1 = {}+-{}".format(V.mean(), scipy.stats.sem(V))) V2 = B1/0.028 print("V_2 = {}+-{}".format(V2.mean(), scipy.stats.sem(V2))) tools.table((1e2*B1, 1e2*g1, 1e2*b1, f1*1e3, V, V2), ("B/cm", "g/cm", "b/cm", "f/mm", "\sfrac{b_1}{g_1}","\sfrac{B}{G}"), "build/a.tex", "Messreihe zur Linse mit $f=\SI{150}{mm}$.", "tab:a1", split=1, round_figures=(3,4,4,4,4,4)) tools.table((1e2*g2, 1e2*b2, f2*1e3), ("g/cm", "b/cm", "f/mm"), "build/a2.tex", "Messreihe zur Linse mit $f=\SI{100}{mm}$.", "tab:a2", split=2)
import scipy.constants as const from scipy.stats import linregress import tools d = np.genfromtxt("daten/a.txt", unpack=True, dtype=object) lambd, gamma = d.astype(float) lambd /= 1e9 gamma = np.deg2rad(400-gamma) alpha = np.deg2rad(400-337.8) beta = np.pi/2 - alpha/2 phi = gamma - alpha/2 - np.pi/2 g = lambd / (np.sin(beta) + np.sin(phi)) tools.table((*d, phi, g*1e9), ("\lambda/nm", "\gamma/\degree", "\phi/rad", "g/nm"), "build/a.tex", "Messdaten und Ergebnisse aus dem ersten Aufgabenteil.", "tab:a") print (np.rad2deg(phi)) g = unc.ufloat(g.mean(), g.std()) print(g*1e9) slope, intercept, r_value, p_value, std_err = linregress(lambd, np.sin(phi)) lambda_synth = np.linspace(400/1e9, 750/1e9) print(1/unc.ufloat(slope, std_err)*1e9) print(-intercept, beta) #g = unc.ufloat(1/slope, 1/std_err) plt.plot(lambda_synth*1e9, slope*lambda_synth + intercept, label="Lineare Regression") plt.plot(lambd*1e9, np.sin(phi), 'rx', label="Messdaten") plt.legend(loc='best') plt.xlabel(r"$\lambda/\si{nm}$")
else: return default_collate(batch) raise TypeError( "batch must contain Table, numbers, dicts or lists; found {}".format( elem_type)) # Use this to get around pickling problems using multi-processing def callable(name, f): return type(name, (object, ), {'__call__': lambda self, batch: f(batch)}) # collate_batch = callable('collate_batch', _collate_batch)() empty_target = table(bbox=torch.FloatTensor(0, 4), label=torch.LongTensor(0)) def load_image(image): img = cv.imread_color(image.file) return image._extend(image=img, image_size=torch.LongTensor( [img.size(1), img.size(0)])) def random_mean(mean, magnitude): return mean + random.uniform(-magnitude, magnitude) def scale(scale): def apply(d):
g = -1 / (slope / const.h * const.value('Bohr magneton')) print('g-Faktor Rb-{}: {}'.format(Z, g)) print('Kernspin Rb-{}: {}'.format( Z, 0.5 * (const.value('electron g factor') / g - 1))) return g, slope, intercept, B g1, slope1, emf1, B1 = auswerten(I11, I12, 0, '87') g2, slope2, emf2, B2 = auswerten(I21, I22, 1, '85') print((I11, I12, B1 * 1e6, I21, I22, B2 * 1e6)) tools.table( (*data[:3], B1 * 1e6, *data[3:], B2 * 1e6), ('f/MHz', 'I_1^\mathrm{sweep}/A', 'I_1^\mathrm{hor}/A', r'B_1/\micro\tesla', 'I_2^\mathrm{sweep}/A', 'I_2^\mathrm{hor}/A', r'B_2/\micro\tesla'), 'build/feld.tex', 'Bestimmte Stromstärken der jeweiligen Resonanzstellen und daraus berechnete magnetische Flussdichten.', 'tab:feld') emf = unc.ufloat(np.mean((emf1.n, emf2.n)), np.std((emf1.n, emf2.n))) print('Gemitteltes Horizontalkomponente des Erdmagnetfelds: {}µT'.format(1e6 * emf)) print('Kompensiertes Vertikalfeld: {}µT'.format( helmholtz(0.23, 20, 11.735e-2) * 1e6)) plt.xlabel(r'$f/\mathrm{MHz}$') plt.ylabel(r'$B/\mathrm{µT}$') plt.xlim(0, 1.1) t = list(plt.yticks()[0])
import numpy as np import matplotlib.pyplot as plt import tools import uncertainties.unumpy as unp d = np.genfromtxt('daten/a.txt', dtype=object, unpack=True) d_ = np.concatenate((d[1:4].T, d[4:7].T, d[7:10].T), axis=0).T tools.table( (np.tile(d[0], 3), *d_), ("\dot V / \percent", r"\Delta f_{\SI{30}{\degree}}/Hz", r"\Delta f_{\SI{15}{\degree}}/Hz", r"\Delta f_{\SI{60}{\degree}}/Hz"), "build/datena.tex", "Messdaten zum ersten Aufgabenteil.", "datena", interrows={ 0: r"$d=\SI{16}{mm}$", 5: r"$d=\SI{10}{mm}$", 10: r"$d=\SI{7}{mm}$" }) d_ = d.astype(float) V = d_[0] f = np.absolute(np.array([d_[1:4], d_[4:7], d_[7:10]])) V /= 10 theta = np.radians(np.array((30, 15, 60))) alpha = np.pi / 2 - np.arcsin(np.sin(theta) * 18 / 27) c_l = 1800 nu_0 = 2e6 v = f * c_l / nu_0 / 2 / np.cos(alpha)[np.newaxis, :, np.newaxis]
import numpy as np import matplotlib.pyplot as plt import tools d = np.genfromtxt('daten/e.txt', unpack=True, dtype=object) Ihy, Bhy = d.astype(float) plt.figure(figsize=(5.78,3.4)) plt.plot(Ihy, Bhy, 'rx-', markersize=3, linewidth=0.5, label='Hysteresekurve') plt.xlabel(r'$I/\si{A}$') plt.ylabel(r'$B/\si{mT}$') plt.legend(loc='best') plt.tight_layout(pad=0) plt.savefig('build/hysterese.pdf') tools.table(d, ('I/A', 'B/mT'), 'build/e.tex', 'Messdaten, Hysteresekurve.', 'de', split=3)
plt.plot(t*1e6, U, 'x', alpha=0.2, markersize=4, label='Messdaten') plt.ylim(U.min()-1, U.max()+10) plt.xlim(t.min()*1e6, t.max()*1e6) if start_fit_at != None: t_ = t[t>start_fit_at] U_ = U[t>start_fit_at] plt.plot(np.ones(2)*start_fit_at*1e6, (U.min()-1, U.max()+10), 'k-', label="Beginn der Fit-Daten") params, pcov = curve_fit(expo, t_, U_, maxfev=100000000, p0=[5.75540096e-03, -5.50832242e+05, -1.02684351e+01, 4.81875157e+00]) pa[num] = params plt.plot(t*1e6, expo(t, *params), 'C1', label='Exponentieller Fit') #plt.xlim(t.min(), t.max()) plt.xlabel(r'$t/\mathrm{µs}$') plt.ylabel(r'$U/\mathrm{V}$') plt.legend(loc='best') plt.tight_layout(pad=0) plt.savefig('build/bauteil'+name+'.pdf') plt.close() if start_fit_at != None: return params[1] print("L = {}µH".format(-50/plot('3.5', 1.2e-6, 0)*1e6,)) print("L = {}µH".format(-50/plot('3.7', 0.87e-6, 1)*1e6)) print("C = {}nF".format(-1/(50*plot('3.10', 1.5e-6, 2))*1e9)) K ={0:'Induktivität', 1:'50 Ohm-Abschlusswiderstand', 2:'Kondensator'} tools.table([*pa.T, *pa.T], ('a_1/V', 'b_1/\per\second', 'c_1', 'd_1/V', 'a_2/V', 'b_2/\per\second', 'c_2', 'd_2/V'), 'build/bauteile.tex', 'Fitparameter der Bauteile.', 'tab:bauteile', interrows=K)
s2, l3, l4, l5, l6 = np.genfromtxt("daten/b2.txt", unpack=True) l3 *= 1e-2 l4 *= 1e-2 l5 *= 1e-2 l6 *= 1e-2 s2 *= 1e-2 x1 = 129.9e-2 x2 = 130.1e-2 lc = np.concatenate((l3, l5)) lb = np.concatenate((l4, l6)) e = np.concatenate((x1 - s, np.tile(x2 - s2, 2))) b1 = np.concatenate((l1 - x1, lb - x2)) + e b2 = np.concatenate((l2 - x1, lc - x2)) + e g1 = e - b1 g2 = e - b2 f2 = auswerten(130.1e-2, l3, l4, s2, "100mm rot") f3 = auswerten(130.1e-2, l5, l6, s2, "100mm blau") tools.table( (1e2 * e, 1e2 * b1, 1e2 * g1, 1e2 * b2, 1e2 * g2, 1e3 * np.concatenate((f1, f2, f3))), ("e/cm", "b_1/cm", "g_1/cm", "b_2/cm", "g_2/cm", "f/mm"), "build/b.tex", "Messreihe zur Bessel-Methode", "tab:b", interrows={0: "Ohne Filter", 10: "Roter Filter", 15: "Blauer Filter"}, )
#print(R_H, d, n, z) tau = 1 / (R / 2 * const.e**2 / const.m_e * n / (2.8e-2, 4.4e-2) * d * (2.5e-2, 2.6e-2)) v_d = 1e9 / n / const.e µ = const.e * tau / const.m_e E_F = const.h**2 / (2 * const.m_e) * ((3 / 8 / np.pi * n)**2)**(1 / 3) v = unp.sqrt(2 * E_F / const.m_e) l = tau * unp.sqrt(2 * E_F / const.m_e) tools.table((sl, R_H * 1e11, d * 1e6, n / 1e27), (r"m/\ohm", r"R_H/(10^{-11} \cubic\meter\per\coulomb)", r"d/µm", r"n/\per\cubic\nano\meter"), "build/erg.tex", "Ergebnisse der Auswertung, erster Teil.", "tab:erg", round_figures=(3, 3, 3, 3), interrows={ 0: "Kupfer", 1: "Zink" }) tools.table((z, R * 1e3, tau * 1e15), ("z", "R/\milli\ohm", r"\bar\tau/fs"), "build/erg3.tex", "Ergebnisse der Auswertung, dritter Teil.", "tab:erg3", round_figures=(3, 3, 3), interrows={ 0: "Kupfer", 1: "Zink" }) tools.table((v_d * 1e3, 1e4 * µ, v / 1e6, l * 1e9),
plt.plot(d, a, 'b-') plt.ylabel(r'echo intensity/arb.\,unit') plt.xlabel(r'd/\si{\micro\second}') plt.tight_layout(pad=0) plt.savefig('build/a.pdf') bla, t1, t2 = np.genfromtxt('daten/a/a.txt', unpack=True) d1 = (t1-delta)*1e-6/2 d2 = (t2-delta)*1e-6/2 c = 2730 d1 *= c d2 *= c h = 80.04e-3 dia = h - d1 - d2 d_1, d_2 = np.genfromtxt('daten/mech.txt', unpack=True) dia_ = h*1e3 - d_1 - d_2 la = np.array((b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'10', b'11'), dtype=object) np.savez('build/a.npz', d2, d1, dia) tools.table((la, 1e3*d2, 1e3*d1, 1e3*dia, d_1, d_2, dia_), (r"\text{Störstelle}", "d_1/mm", "d_2/mm", "2r/mm", r"d_1^\text{mech}/mm", r"d_2^\text{mech}/mm", r"2r^\text{mech}/mm"), 'build/a.tex', r'Messergebnisse aus dem A-Scan. Neben den abgelesenen und berechneten Daten $d_n$ sind auch die zuvor mittels Messschieber bestimmten Abmessungen $d_n^\text{mech}$ eingetragen.', 'tab:a') tools.table((la, t1, t2), (r"\text{Störstelle}", "t_1/\micro\second", "t_2/\micro\second"), "build/a_d.tex", "Messdaten zum A-Scan.", "tab:mess_a") def abw(a, b): return 100* np.abs(a-b)/b #tools.table((la, abw(d2 , d_1/1e3), abw(d1, d_2/1e3), abw(dia, dia_/1e3)), (r"\text{Störstelle}", r"\Delta d_1/\percent", r"\Delta d_2/\percent", r"\Delta 2r/\percent"), 'build/diska.tex', 'Abweichungen beim A-Scan.', 'tab:diska', round_figures=(0,2,2,2))
g1, b1, B1, g2, b2 = np.genfromtxt('daten/a.txt', unpack=True) g1 *= 1e-2 b1 *= 1e-2 B1 *= 1e-2 g2 *= 1e-2 b2 *= 1e-2 f1 = auswerten(g1, b1, '1', [3]) f2 = auswerten(g2, b2, '2', []) V = b1 / g1 print("V_1 = {}+-{}".format(V.mean(), scipy.stats.sem(V))) V2 = B1 / 0.028 print("V_2 = {}+-{}".format(V2.mean(), scipy.stats.sem(V2))) tools.table( (1e2 * B1, 1e2 * g1, 1e2 * b1, f1 * 1e3, V, V2), ("B/cm", "g/cm", "b/cm", "f/mm", "\sfrac{b_1}{g_1}", "\sfrac{B}{G}"), "build/a.tex", "Messreihe zur Linse mit $f=\SI{150}{mm}$.", "tab:a1", split=1, round_figures=(3, 4, 4, 4, 4, 4)) tools.table((1e2 * g2, 1e2 * b2, f2 * 1e3), ("g/cm", "b/cm", "f/mm"), "build/a2.tex", "Messreihe zur Linse mit $f=\SI{100}{mm}$.", "tab:a2", split=2)
B, y, z = np.genfromtxt('daten/c.txt', unpack=True) B *= 1e-2 y *= 1e-2 z *= 1e-2 x = 129.4e-2 G = 2.8e-2 g_ = x - z b_ = x - y - g_ V = B / G tools.table((1e2 * B, V, 1e2 * g_, 1e2 * b_), ("B/cm", "V", "g'/cm", "b'/cm"), "build/c.tex", "Messreihe zur Abbe-Methode.", "tab:c", split=2, round_figures=(3, 4, 4, 4)) m1, m1_, n1, n1_ = linregress((1 + 1 / V), g_) m2, m2_, n2, n2_ = linregress((1 + V), b_) x = np.linspace(1.0, 2.6) print("f1 = {}+-{}mm, f2 = {}+-{}mm".format(m1 * 1e3, m1_ * 1e3, m2 * 1e3, m2_ * 1e3)) print("h = {}+-{}cm, h' = {}+-{}cm".format(n1 * 1e2, n1_ * 1e2, n2 * 1e2, n2_ * 1e2)) f1 = unc.ufloat(m1, m1_) f2 = unc.ufloat(m2, m2_) f = (f1 + f2) / 2 ft = 1 / (1 / 100e-3 + 1 / -100e-3 - 6e-2 / (100e-3 * -100e-3))
d2 *= c h = 80.04e-3 dia = h - d1 - d2 la = np.array((b"1", b"2", b"3", b"4", b"5", b"6", b"7", b"8", b"9", b"10", b"11"), dtype=object) d_1, d_2 = np.genfromtxt("daten/mech.txt", unpack=True) dia_ = h * 1e3 - d_1 - d_2 tools.table( (la, 1e3 * d1, 1e3 * d2, 1e3 * dia, d_1, d_2, dia_), ( r"\text{Störstelle}", "d_1/mm", "d_2/mm", "2r/mm", r"d_1^\text{mech}/mm", r"d_2^\text{mech}/mm", r"2r^\text{mech}/mm", ), "build/b.tex", r"Messergebnisse aus dem B-Scan.", "tab:b", ) a = np.load("build/a.npz") d1 = np.array((d1, a["arr_0"])) d2 = np.array((d2, a["arr_1"])) dia = np.array((dia, a["arr_2"])) d1 = unp.uarray(d1.mean(axis=0), scipy.stats.sem(d1, axis=0))