def eval(): data1 = PockData.fromPath('../data/%s.tab' % 'pock_licht_01', 1) data2 = PockData.fromPath('../data/%s.tab' % 'pock_licht_02', 1) data3 = PockData.fromPath('../data/%s.tab' % 'pock_licht_03', 1) data4 = PockData.fromPath('../data/%s.tab' % 'pock_licht_04', 1) L0 = [0]*data1.getLength() Ly1 = [0]*data1.getLength() Ly2 = [0.03]*data1.getLength() Ly3 = [0.08]*data1.getLength() Ly4 = [0.17]*data1.getLength() Offset1 = DataErrors.fromLists(L0, Ly1, L0, L0) Offset2 = DataErrors.fromLists(L0, Ly2, L0, L0) Offset3 = DataErrors.fromLists(L0, Ly3, L0, L0) Offset4 = DataErrors.fromLists(L0, Ly4, L0, L0) data1 += Offset1 data2 += Offset2 data3 += Offset3 data4 += Offset4 c = TCanvas('c', '', 1280, 720) g1 = data1.makeGraph('g1', 'Zeit t / s', 'Spannung U / V') g1.SetMarkerStyle(8) g1.SetMarkerSize(0.5) g1.SetMarkerColor(1) g1.GetXaxis().SetRangeUser(0, 0.1) g1.SetMinimum(-0.02) g1.SetMaximum(0.25) g1.Draw('AP') g2 = data2.makeGraph('g2', 'Zeit t / s', 'Spannung U / V') g2.SetMarkerStyle(8) g2.SetMarkerSize(0.5) g2.SetMarkerColor(100) g2.Draw('P') g3 = data3.makeGraph('g3', 'Zeit t / s', 'Spannung U / V') g3.SetMarkerStyle(8) g3.SetMarkerSize(0.5) g3.SetMarkerColor(95) g3.Draw('P') g4 = data4.makeGraph('g4', 'Zeit t / s', 'Spannung U / V') g4.SetMarkerStyle(8) g4.SetMarkerSize(0.5) g4.SetMarkerColor(89) g4.Draw('P') l = TLegend(0.63, 0.51, 0.87, 0.87) l.SetTextSize(0.027) l.AddEntry('g4', 'Licht an,', 'p') l.AddEntry('', 'ohne Abschirmung', '') l.AddEntry('g3', 'Licht an,', 'p') l.AddEntry('', 'mit Papier als Abschirmung', '') l.AddEntry('g2', 'Licht an,', 'p') l.AddEntry('', 'mit Tuch als Abschirmung', '') l.AddEntry('g1', 'Licht aus,', 'p') l.AddEntry('', 'mit Tuch als Abschirmung', '') l.SetFillColor(0) l.Draw() c.Update() c.Print('../img/%s.pdf' % 'licht', 'pdf')
def eval(): data1 = PockData.fromPath('../data/%s.tab' % 'pock_gleich_01', 2) data2 = PockData.fromPath('../data/%s.tab' % 'pock_gleich_02', 2) data3 = PockData.fromPath('../data/%s.tab' % 'pock_gleich_03', 2) data4 = PockData.fromPath('../data/%s.tab' % 'pock_gleich_01', 1) L0 = [0]*data1.getLength() Ly1 = [0.41]*data1.getLength() Ly2 = [0.31]*data1.getLength() Ly3 = [0.14]*data1.getLength() Ly4 = [0]*data1.getLength() Offset1 = DataErrors.fromLists(L0, Ly1, L0, L0) Offset2 = DataErrors.fromLists(L0, Ly2, L0, L0) Offset3 = DataErrors.fromLists(L0, Ly3, L0, L0) Offset4 = DataErrors.fromLists(L0, Ly4, L0, L0) data1 += Offset1 data2 += Offset2 data3 += Offset3 data4 += Offset4 c = TCanvas('c', '', 1280, 720) g1 = data1.makeGraph('g1', 'Zeit t / s', 'Spannung U / V') g1.SetMarkerStyle(8) g1.SetMarkerSize(0.5) g1.SetMarkerColor(65) g1.GetXaxis().SetRangeUser(0, 0.005) g1.SetMinimum(-0.08) g1.SetMaximum(0.45) g1.Draw('AP') g2 = data2.makeGraph('g2', 'Zeit t / s', 'Spannung U / V') g2.SetMarkerStyle(8) g2.SetMarkerSize(0.5) g2.SetMarkerColor(60) g2.Draw('P') g3 = data3.makeGraph('g3', 'Zeit t / s', 'Spannung U / V') g3.SetMarkerStyle(8) g3.SetMarkerSize(0.5) g3.SetMarkerColor(53) g3.Draw('P') g4 = data4.makeGraph('g4', 'Zeit t / s', 'Spannung U / V') g4.SetMarkerStyle(8) g4.SetMarkerSize(0.5) g4.SetMarkerColor(2) g4.Draw('P') l = TLegend(0.63, 0.51, 0.87, 0.87) l.SetTextSize(0.027) l.AddEntry('g1', 'Photodiodensignal,', 'p') l.AddEntry('', 'U_{G} = 120 V', '') l.AddEntry('g2', 'Photodiodensignal,', 'p') l.AddEntry('', 'U_{G} = 122 V', '') l.AddEntry('g3', 'Photodiodensignal,', 'p') l.AddEntry('', 'U_{G} = 128 V', '') l.AddEntry('g4', 'Wechselsignal vom', 'p') l.AddEntry('', 'Sinusgenerator mit', '') l.AddEntry('', 'Frequenz #omega', '') l.SetFillColor(0) l.Draw() c.Update() c.Print('../img/%s.pdf' % 'pockdurchf', 'pdf')
def eval(name,f): """description Arguments: name -- f -- """ dataCH1 = PockData.fromPath('../data/%s.tab' % name, 1) dataCH2 = PockData.fromPath('../data/%s.tab' % name, 2) c = TCanvas('c', '', 1280, 720) g1 = dataCH1.makeGraph('g1', 'Zeit t / s', 'Spannung U / V') g1.SetMarkerStyle(8) g1.SetMarkerSize(0.5) g1.SetMarkerColor(2) g1.GetXaxis().SetRangeUser(0.01, 0.04) g1.SetMinimum(-3.2) g1.SetMaximum(5) g1.Draw('AP') g2 = dataCH2.makeGraph('g2', 'Zeit t / s', 'Spannung U / V') g2.SetMarkerStyle(8) g2.SetMarkerSize(0.5) g2.SetMarkerColor(4) g2.Draw('P') paramlist = [] if f: #fit1 = Fitter('f1', '[0]+[1]*x') #fit1.function.SetLineWidth(2) #fit1.function.SetLineColor(1) #fit1.setParam(0, 'a', -5) #fit1.setParam(1, 'b', 300) #fit1.fit(g1, 0.015, 0.029) #fit1.saveData('../calc/fit1.txt', 'w') fit2 = Fitter('f2', '[0]*(x-[1])**2+[2]') fit2.function.SetLineWidth(2) fit2.function.SetLineColor(1) fit2.setParam(0, 'a', 400000) fit2.setParam(1, 's', 0.017) fit2.setParam(2, 'c', -2) fit2.fit(g2, 0.015, 0.0202, '+') #fit2.saveData('../calc/fit2.txt', 'w') fit3 = Fitter('f2', '[0]*(x-[1])**2+[2]') fit3.function.SetLineWidth(2) fit3.function.SetLineColor(1) fit3.function.SetLineStyle(2) fit3.setParam(0, 'a', -200000) fit3.setParam(1, 's', 0.023) fit3.setParam(2, 'c', 2) fit3.fit(g2, 0.0202, 0.0275, '+') #fit3.saveData('../calc/fit3.txt', 'w') l = TLegend(0.63, 0.48, 0.87, 0.87) l.SetTextSize(0.027) l.AddEntry('g1', 'Saegezahnspannung', 'p') #l.AddEntry(fit1.function, 'Fit mit y = a + b*x', 'l') #l.AddEntry(0, 'a = %.3f #pm %.3f' % (fit1.params[0]['value'], fit1.params[0]['error']), '') #l.AddEntry(0, 'b = %.1f #pm %.1f' % (fit1.params[1]['value'], fit1.params[1]['error']), '') l.AddEntry('g2', 'Signal der Photodiode', 'p') l.AddEntry(fit2.function, 'Fit mit U = a_{1} * (t-b_{min})^{2} + c_{1}', 'l') l.AddEntry(0, 'b_{min} = %.6f #pm %.6f' % (fit2.params[1]['value'], fit2.params[1]['error']), '') l.AddEntry(fit3.function, 'Fit mit U = a_{2} * (t-b_{max})^{2} + c_{2}', 'l') l.AddEntry(0, 'b_{max} = %.6f #pm %.6f' % (fit3.params[1]['value'], fit3.params[1]['error']), '') l.SetFillColor(0) l.Draw() paramlist = [(fit2.params[1]['value'], fit2.params[1]['error']), (fit3.params[1]['value'], fit3.params[1]['error'])] else: l = TLegend(0.635, 0.72, 0.85, 0.87) l.SetTextSize(0.027) l.AddEntry('g1', 'Saegezahnspannung', 'p') l.AddEntry('g2', 'Signal der Photodiode', 'p') l.SetFillColor(0) l.Draw() c.Update() c.Print('../img/%s.pdf' % name, 'pdf') return paramlist