def evalDiode(): datalist = loadCSVToList('../data/part1/Kennlinie.txt') data = DataErrors() U0 = datalist[0][1] sU0 = 0.05 + 0.01 * U0 for I, u in datalist: U = u - U0 su = 5 + 0.01 * u sU = sqrt(su**2 + sU0**2) data.addPoint(I, U, 0.1, sU) xmin, xmax = 53, 71.5 c = TCanvas('c_diode', '', 1280, 720) g = data.makeGraph('g_diode', "Laserstrom I_{L} / mA", "Photodiodenspannung U_{ph} / mV") g.GetXaxis().SetRangeUser(-5, 90) g.SetMinimum(-50) g.SetMaximum(1400) g.Draw('APX') # y=0 line line = TLine(-5, 0, 90, 0) line.SetLineColor(OPData.CH2ECOLOR) line.Draw() data.filterX(xmin, xmax) g2 = data.makeGraph('g_diode_2', "Laserstrom I_{L} / mA", "Photodiodenspannung U_{ph} / mV") g2.SetMarkerColor(OPData.CH1COLOR) g2.SetLineColor(OPData.CH1COLOR) fit = Fitter('fit_diode', '[0] * (x-[1])') fit.function.SetNpx(1000) fit.setParam(0, 'a', 1) fit.setParam(1, 'I_{th}', 50) fit.fit(g2, 40, 77) fit.saveData('../fit/part1/kennlinie.txt') l = TLegend(0.15, 0.55, 0.4, 0.85) l.SetTextSize(0.03) l.AddEntry(g, 'Laserdiodenkennlinie', 'p') l.AddEntry(g2, 'Ausschnitt zum Fitten', 'p') l.AddEntry(fit.function, 'Fit mit U_{ph} = a (I_{ L} - I_{ th} )', 'l') fit.addParamsToLegend(l, (('%.1f', '%.1f'), ('%.2f', '%.2f')), chisquareformat='%.2f', units=['mV/mA', 'mA']) l.Draw() g.Draw('P') g2.Draw('P') c.Update() c.Print('../img/part1/diodenkennlinie.pdf', 'pdf')
def evalTaus(taus, filters): data = DataErrors() table = [] for key, (tau, stau) in taus.items(): invtau = 1 / tau sinvtau = stau / (tau**2) int, sint = filters[key] data.addPoint(int, invtau, sint, sinvtau) table.append([int * 100, sint * 100, tau * 1000, stau * 1000]) table.sort(key=lambda x: x[0], reverse=True) # make table with TxtFile('../src/tab_part5_taus.tex', 'w') as f: f.write2DArrayToLatexTable( table, [ r'$I_\text{mess}$ / \%', r'$s_{I_\text{mess}}$ / \%', r'$\tau$ / ms', r'$s_\tau$ / ms' ], ['%.2f', '%.2f', '%.3f', '%.3f'], r'Orientierungszeiten $\tau$ des Rubidiumensembles bei verschiedenen Pumpintensitäten $I_{\text{mess}}$.', 'tab:deh:fitres') # make fit c = TCanvas('c_taus', '', 1280, 720) g = data.makeGraph('g_taus', r'relative Intensitaet I_{mess}', 'inverse Orientierungszeit #tau^{ -1} / s^{-1}') g.Draw('APX') fit = Fitter('fit_taus', '[0]*x + 1/[1]') fit.setParam(0, '#alpha', 1) fit.setParam(1, 'T_{R}', 1) fit.fit(g, 0, 1.1) fit.saveData('../fit/part5/taufit.txt') l = TLegend(0.55, 0.15, 0.85, 0.5) l.SetTextSize(0.03) l.AddEntry(g, 'Inverse Orientierungszeit #tau^{ -1}', 'p') l.AddEntry(fit.function, 'Fit mit #tau^{ -1} (I) = #alpha I + #frac{1}{T_{R}}', 'l') fit.addParamsToLegend(l, [('%.0f', '%.0f'), ('%.5f', '%.5f')], chisquareformat='%.2f', units=['s^{-1}', 's']) l.Draw() g.Draw('P') c.Print('../img/part5/taufit.pdf', 'pdf')
def evalAngleDependency(): datalist = loadCSVToList(DIR + 'Winkelabh.txt') data = DataErrors() strel = 0.01 sI = 1 for t2, t1, n, phi in datalist: f, sf = calcPrecissionFreq(t2, t1, n) data.addPoint(phi, f, 0.5, sf) c = TCanvas('c_phi', '', 1280, 720) g = data.makeGraph('g_phi', 'Rotation des Strahlengangs #varphi / #circ', 'Praezessionsfrequenz f / kHz') g.GetXaxis().SetRangeUser(-15, 15) g.SetMinimum(0) g.Draw('APX') fit = Fitter('fit_phi', '[0] * abs(sin((x-[1])*pi/180))') fit.function.SetNpx(1000) fit.setParam(0, '#beta', 1) fit.setParam(1, '#phi_{0}', 0) fit.fit(g, -15, 15) fit.saveData('../fit/part4/winkel.txt') g.Draw('P') l = TLegend(0.7, 0.15, 0.95, 0.5) l.SetTextSize(0.03) l.AddEntry(g, 'Praezessionsfrequenz', 'p') l.AddEntry(fit.function, 'Fit mit f = #beta |sin(#varphi + #varphi_{0})|', 'l') fit.addParamsToLegend(l, (('%.1f', '%.1f'), ('%.2f', '%.2f')), chisquareformat='%.2f', units=['kHz/#muT', '#circ']) l.Draw() c.Update() c.Print('../img/part4/winkel.pdf', 'pdf')
def evalSpinPrecission(name): datalist = loadCSVToList(DIR + name + '.txt') data = DataErrors() sI = 1 for t2, t1, n, I in datalist: f, sf = calcPrecissionFreq(t2, t1, n) B, sB = inductorIToB(4, I * 1e-3, sI * 1e-3) data.addPoint(B * 1e6, f, sB * 1e6, sf) if len(name) == 4: xmin, xmax = 0, 50 else: xmin, xmax = 0, 80 c = TCanvas('c_%s' % name, '', 1280, 720) g = data.makeGraph('g_%s' % name, 'Zusaetzliches Vertikalfeld B_{S, v} / #muT', 'Praezessionsfrequenz f / kHz') g.GetXaxis().SetRangeUser(xmin, xmax) g.Draw('APX') fit1 = Fitter('fit1_%s' % name, '[0] * abs([1]-x)') fit1.function.SetNpx(1000) fit1.setParam(0, '#alpha', 1) fit1.setParam(1, 'B_{E, v}', 40) fit1.fit(g, xmin, xmax) fit1.saveData('../fit/part4/fit1_%s' % name) fit2 = Fitter('fit1_%s' % name, '[0] * (abs([1]-x) + [2])') fit2.function.SetNpx(1000) fit2.function.SetLineColor(3) fit2.setParam(0, '#alpha', 1) fit2.setParam(1, 'B_{E, v}', 40) fit2.setParam(2, 'B_{E,h,s}', 20) fit2.setParamLimits(2, 0, 100) fit2.fit(g, xmin, xmax, '+') fit2.saveData('../fit/part4/fit2_%s' % name) g.Draw('P') if len(name) == 4: l = TLegend(0.6, 0.4, 0.975, 0.95) else: l = TLegend(0.325, 0.475, 0.725, 0.99) l.SetTextSize(0.03) l.AddEntry(g, 'Praezessionsfrequenzen', 'p') l.AddEntry(fit1.function, 'Fit mit f_{1}(B_{S, v}) = #alpha |B_{E, v} - B_{S, v}|', 'l') fit1.addParamsToLegend(l, (('%.2f', '%.2f'), ('%.2f', '%.2f')), chisquareformat='%.2f', units=['kHz/#muT', '#muT']) l.AddEntry( fit2.function, 'Fit mit f_{2}(B_{S, v}) = #alpha (|B_{E, v} - B_{S, v}| + B_{E,h,s})', 'l') fit2.addParamsToLegend(l, (('%.2f', '%.2f'), ('%.2f', '%.2f'), ('%.2f', '%.2f')), chisquareformat='%.2f', units=['kHz/#muT', '#muT', '#muT']) l.Draw() c.Update() c.Print('../img/part4/%s.pdf' % name, 'pdf')