Ejemplo n.º 1
0
def analyse(data):
    config = data.config
    vcc = data.vcc
    m = data.measurements
    grouped = segmented_measurements(m, ["charge", "R"], as_index=1)

    def voltage(measurement):
        return u_an2v(measurement.Amiddle, vcc)

    def first(ls):
        return ls.values[0]

    def last(ls):
        return ls.values[-1]

    t = grouped["t"].agg(dict(t1=first, t2=last))
    A = grouped["Amiddle"].agg(dict(A1=first, A2=last))
    mreg = DataFrame([(charge, R, regc(g, R)) for (charge, R), g in grouped], columns=["charge", "R", "Creg"])

    df = A.join(t)
    df = df.reset_index()

    df = df[df["charge"] == 0]
    del df["charge"]

    col = ColsProxy(df)

    col.Creg = mreg["Creg"]
    col.dt = col.t2 - col.t1
    col.C = calculate_c(col.A1, col.A2, col.R, col.t1, col.t2)

    movecol(df, "Creg", 0)
    movecol(df, "C", 0)

    return df
Ejemplo n.º 2
0
def analyse1(data, calibration=0.94):
    vcc = data.vcc

    grouped = segmented_measurements(
        data.measurements[['frequency', 'dc', 'Ain']], ['frequency', 'dc'])
    #    print (0.0, 0) in dict(grouped).keys()
    for (f, dc), group in grouped:
        if f == 0:
            #            print dc
            #            print group
            if dc == 0:
                _, V0 = Ain, Vin = avgAV(group, vcc)
            else:
                _, V255 = Ain, Vin = avgAV(group, vcc)

    Vnull = average([V0, V255])

    #    d = SortedDict(d)[2:]
    #    dRx = SortedDict()
    #    for (f, dc), ls in d.items():
    #        if not f:
    #            continue
    #        R, calibration_open = calculate_ohm(data, Vnull, ls)
    #        dRx[f] = dict(frequency=f,
    #                      R=R,
    #                      )

    def maxi(ls):
        # drop 1% on top
        #        ls = list(df)
        #        ls.sort()
        #        drop = int(len(ls) * 0.05)
        #        i = len(ls) - drop - 1
        #        a = ls[i]
        a = ls.quantile(q=0.99)
        #    a = averaged_median()
        Ain = ufloat((a, 1))
        #    Vin = an2v(Ain, vcc)
        return Ain

    filtered = grouped.agg(maxi)
    del filtered['dc']
    filtered = filtered.drop([0, 1])  # rows
    #    print 44,filtered
    dRx, calibration_open = calculate_ohm(data, Vnull, filtered['Ain'])
    #    dRx=
    #    print 44,filtered
    filtered['Rx'] = dRx
    #    print 44,filtered
    #    filtered['calibration_open']=calibration_open
    #    print 55,filtered
    #    print filtered
    #    print dict(x=filtered)
    #        print dict(row)
    return filtered
Ejemplo n.º 3
0
def analyse1(data, calibration=0.94):
    vcc = data.vcc

    grouped = segmented_measurements(
        data.measurements[['frequency', 'dc', 'Ain']], ['frequency', 'dc'])
#    print (0.0, 0) in dict(grouped).keys()
    for (f, dc), group in grouped:
        if f == 0:
#            print dc
#            print group
            if dc == 0:
                _, V0 = Ain, Vin = avgAV(group, vcc)
            else:
                _, V255 = Ain, Vin = avgAV(group, vcc)

    Vnull = average([V0, V255])
#    d = SortedDict(d)[2:]
#    dRx = SortedDict()
#    for (f, dc), ls in d.items():
#        if not f:
#            continue
#        R, calibration_open = calculate_ohm(data, Vnull, ls)
#        dRx[f] = dict(frequency=f,
#                      R=R,
#                      )

    def maxi(ls):
        # drop 1% on top
#        ls = list(df)
#        ls.sort()
#        drop = int(len(ls) * 0.05)
#        i = len(ls) - drop - 1
#        a = ls[i]
        a = ls.quantile(q=0.99)
    #    a = averaged_median()
        Ain = ufloat((a, 1))
    #    Vin = an2v(Ain, vcc)
        return Ain
    filtered = grouped.agg(maxi)
    del filtered['dc']
    filtered = filtered.drop([0, 1])  # rows
#    print 44,filtered
    dRx, calibration_open = calculate_ohm(data, Vnull, filtered['Ain'])
#    dRx=
#    print 44,filtered
    filtered['Rx'] = dRx
#    print 44,filtered
#    filtered['calibration_open']=calibration_open
#    print 55,filtered
#    print filtered
#    print dict(x=filtered)
#        print dict(row)
    return filtered
Ejemplo n.º 4
0
def analyse(data):
    config = data.config
    vcc = data.vcc
    m = data.measurements
    grouped = segmented_measurements(m, ['charge', 'R'], as_index=1)

    def voltage(measurement):
        return u_an2v(measurement.Amiddle, vcc)

    def first(ls):
        return ls.values[0]

    def last(ls):
        return ls.values[-1]

    t = grouped['t'].agg(dict(t1=first, t2=last))
    A = grouped['Amiddle'].agg(dict(A1=first, A2=last))
    mreg = DataFrame([(charge, R, regc(g, R)) for (charge, R), g in grouped],
                     columns=['charge', 'R', 'Creg'])

    df = A.join(t)
    df = df.reset_index()

    df = df[df['charge'] == 0]
    del df['charge']

    col = ColsProxy(df)

    col.Creg = mreg['Creg']
    col.dt = col.t2 - col.t1
    col.C = calculate_c(col.A1, col.A2, col.R, col.t1, col.t2)

    movecol(df, 'Creg', 0)
    movecol(df, 'C', 0)

    return df