示例#1
0
def evalDistance(n, params):
    xmin, xmax = params[1:]
    deltax = abs(xmax - xmin) * 0.1

    data = P2SemiCon.fromPath('../data/part2/length/ALL%04.d/F%04dCH1.CSV' % (n, n))
    g = data.makeGraph('g%d' % n, 'Zeit t / s', 'Spannung U / V')
    c = TCanvas('c%d' % n, '', 1280, 720)
    g.SetMarkerStyle(1)
    g.GetXaxis().SetRangeUser(xmin - deltax, xmax + deltax)
    closex = min(getByCloseX(data, xmin)[1], getByCloseX(data, xmax)[1])
    if closex > 0:
        ymin = closex * 0.95
    else:
        ymin = closex * 1.1
    g.SetMinimum(ymin)
    g.GetYaxis().SetTitleOffset(1.2)
    g.Draw('APX')

    fit = Fitter('f', 'pol1(0) + 1/(sqrt(2*pi*[4]^2))*gaus(2)')
    fit.function.SetNpx(1000)
    paramname = ['a', 'b', 'A', 't_{c}', '#sigma']
    for i, param in enumerate(params[0]):
        fit.setParam(i, paramname[i], param)
    fit.fit(g, xmin, xmax)
    fit.saveData('../calc/part2/dist%02d.txt' % n, 'w')

    l = TLegend(0.625, 0.6, 0.99, 0.99)
    l.SetTextSize(0.03)
    l.AddEntry(g, 'Messung', 'p')
    l.AddEntry(fit.function, 'Fit mit U(t) = a + b*t + #frac{A}{#sqrt{2#pi*#sigma^{2}}} e^{- #frac{1}{2} (#frac{t - t_{c}}{#sigma})^{2}}', 'l')
    l.AddEntry(0, '', '')
    fit.addParamsToLegend(l, [('%.2e', '%.2e')] * len(params[0]), chisquareformat='%.2f')
    l.Draw()

    if PRINTGRAPHS:
        c.Update()
        c.Print('../img/part2/dist%02d.pdf' % n, 'pdf')

    return data, fit.params, fit.getCorrMatrix(), params[1], params[2]
示例#2
0
def getVoltages():
    volts = []
    for i in range(11):
        data = P2SemiCon.fromPath('../data/part2/voltage/ALL%04.d/F%04dCH2.CSV' % (i, i))
        volts.append((abs(data.points[0][1]), P2SemiCon.UERROR))
    return volts