def transfer_plot(data, fig, error_plot=False): data.measurements = filter_measurements(data.measurements, ['pwm_value'], ['Ain']) title = 'Transfer error plot (%s)' if error_plot else 'Transfer plot (%s)' title = title % (data.model) fw = FigureWrapper( data, fig, x='voltage', y='error (V)' if error_plot else 'voltage', title=title, ) vcc = data.vcc fw.addcol( legend=data.config.pin_in, x=lambda e: pwm2v(e.pwm_value, vcc), y=lambda e: an2v(e.Ain, vcc) - (pwm2v(e.pwm_value, vcc) if error_plot else 0), ) ax = fw.subplot if error_plot: ax.axis([0, 5.1, -0.050, 0.050]) return fig
def extend(data): # data.measurements.to_csv('y.csv') config = data.config vcc = data.vcc # m=data.measurements ## data.measurements['Rload']=data.measurements['Rload'].fillna(NO_LOAD), # m['Rload']=m['Rload'].astype(str).fillna(NO_LOAD) # data.measurements=m m = filter_measurements( data.measurements.fillna(NO_LOAD), # ['Rload','phase'], ['phase', 'Rload', 'pwm_index_plus', 'pwm_index_minus'], ['Aminus', 'Aplus', 'Aout'] ) # m.to_csv('x.csv') # print set(data.measurements['phase']) # print m.to_string() # print set(m['phase']) # assert 0 A = config.R2 / config.R1 m['Vminus'] = an2v(m.Aminus, vcc) m['Vplus'] = an2v(m.Aplus, vcc) m['Vout'] = an2v(m.Aout, vcc) m['Vout_expected'] = Circuit(A, Vminus=m.Vminus, Vplus=m.Vplus).Vout m['Vout_diff'] = (m.Vout - m.Vout_expected) m['Vopamp_minus'] = Circuit(A, Vminus=m.Vminus, Vout=m.Vout).Vplus m['Vin_diff'] = (m.Vopamp_minus - m.Vplus) data.measurements = m
def analyse(data): config = data.config vcc = data.vcc m = filter_measurements(data.measurements, ['B', 'C', 'E', 'polarity'], ['Ab', 'Ac']) calculate_beta(m, vcc) movecol(m, 'beta', 0) m = m.sort_index(by='polarity') candidates = m[np.logical_and(m.Ube > 0.1, m.Ube < 1)] s = candidates.groupby(['polarity', 'B'], sort=False).size() ok = s[s == 2] if len(ok) == 1: polarity, B = ok.index[0] m = m[np.logical_and(m.polarity == polarity, m.B == B)] del m['Ue'] del m['Urc'] del m['Urb'] del m['Ub'] del m['Uc'] del m['Ab'] del m['Ac'] del m['t'] # del m['Ib'] del m['Ic'] del m['Ie'] del m['Rb'] del m['Rc'] return m
def analyse(data): config = data.config vcc = data.vcc m = filter_measurements( data.measurements, ['B', 'C', 'E', 'polarity'], ['Ab', 'Ac']) calculate_beta(m, vcc) movecol(m, 'beta', 0) m = m.sort_index(by='polarity') candidates = m[np.logical_and(m.Ube > 0.1, m.Ube < 1)] s = candidates.groupby(['polarity', 'B'], sort=False).size() ok = s[s==2] if len(ok)==1: polarity,B=ok.index[0] m=m[np.logical_and(m.polarity==polarity,m.B==B)] del m['Ue'] del m['Urc'] del m['Urb'] del m['Ub'] del m['Uc'] del m['Ab'] del m['Ac'] del m['t'] # del m['Ib'] del m['Ic'] del m['Ie'] del m['Rb'] del m['Rc'] return m
def transfer_plot(data, fig, error_plot=False): data.measurements = filter_measurements(data.measurements, ['value'], ['Ain']) title = 'Transfer error plot' if error_plot else 'Transfer plot' title = title fw = FigureWrapper( data, fig, x='voltage', y='error (V)' if error_plot else 'voltage', title=title, ) vcc = data.vcc if error_plot: fw.subplot.plot([0, vcc], [vcc / 99, vcc / 99], 'r-') fw.subplot.plot([0, vcc], [-vcc / 99, -vcc / 99], 'r-') else: fw.subplot.plot([0, 0], [vcc, vcc], 'r-') fw.addcol( legend=data.config.pin_in, x=lambda e: pot2v(e.value, vcc), y=lambda e: an2v(e.Ain, vcc) - (pot2v(e.value, vcc) if error_plot else 0), ) ax = fw.subplot if error_plot: ax.axis([0, 5.1, -0.1, 0.1]) return fig
def extend(data): # data.measurements.to_csv('y.csv') config = data.config vcc = data.vcc # m=data.measurements ## data.measurements['Rload']=data.measurements['Rload'].fillna(NO_LOAD), # m['Rload']=m['Rload'].astype(str).fillna(NO_LOAD) # data.measurements=m m = filter_measurements( data.measurements.fillna(NO_LOAD), # ['Rload','phase'], ['phase', 'Rload', 'pwm_index_plus', 'pwm_index_minus'], ['Aminus', 'Aplus', 'Aout']) # m.to_csv('x.csv') # print set(data.measurements['phase']) # print m.to_string() # print set(m['phase']) # assert 0 A = config.R2 / config.R1 m['Vminus'] = an2v(m.Aminus, vcc) m['Vplus'] = an2v(m.Aplus, vcc) m['Vout'] = an2v(m.Aout, vcc) m['Vout_expected'] = Circuit(A, Vminus=m.Vminus, Vplus=m.Vplus).Vout m['Vout_diff'] = (m.Vout - m.Vout_expected) m['Vopamp_minus'] = Circuit(A, Vminus=m.Vminus, Vout=m.Vout).Vplus m['Vin_diff'] = (m.Vopamp_minus - m.Vplus) data.measurements = m
def analyse(data): m = filter_measurements( data.measurements, ['R'], ) del m['t'] m.insert(0, 'Rx', calculate_ohm(m.R, m.Atop, m.Amiddle, m.Abottom)) m.insert(0, 'Rx_E12', map(format_ohmE12, nominal_values(m.Rx))) return m
def extend(data): # dw = DataWrapper(data) data.measurements = filter_measurements(data.measurements, ['pwm_value', 'rail'], ['Aout', 'Ain', 'Aamp']) # print 111,unbunchify(dw.data) # print 222,(dw.data) R = data.config.R vcc = data.vcc # def calc(x): # x.Vin = an2v(x.Ain, vcc) # x.Vout = an2v(x.Aout, vcc) # x.Vamp = an2v(x.Aamp, vcc) # x.Vx = x.Vout - x.Vin # x.I = (x.Vin - x.Vamp) / R data.Vmax = data.vcc data.Imax = data.vcc / R # ls=[] # pwm_current=0 # for x in dw.data.measurements: # # group by pwm_value # x.pwm_value==pwm_current: # ls.append(x) # else: # calc(x) # ls=[] # pwm_current=x.pwm_value d = groupped_measurements(data.measurements, ['pwm_value', 'rail']) for p in range(256): for r in [0, 1]: ls = d[p, r] # ls = [x for x in dw.data.measurements if x.pwm_value == p and x.rail == # r] if not len(ls): continue Ain = ls[0].Ain Aout = ls[0].Aout Aamp = ls[0].Aamp Vin = an2v(Ain, vcc) Vout = an2v(Aout, vcc) Vamp = an2v(Aamp, vcc) Vx = Vout - Vin I = (Vin - Vamp) / R for x in ls: x.I = I x.Vx = Vx x.Vin = Vin x.Vout = Vout x.Vamp = Vamp
def extend(data): m = filter_measurements(data.measurements, ['Dout', 'pwm_value'], ['Aout', 'Aamp']) R = data.config.R vcc = data.vcc m['Vout'] = an2v(m.Aout, vcc) m['Vamp'] = an2v(m.Aamp, vcc) m['I'] = (m.Vout - m.Vamp) / R m['Iabs'] = abs(m.I) data.measurements = m
def extend(data): # dw = DataWrapper(data) data.measurements = filter_measurements( data.measurements, ['pwm_value', 'rail'], ['Aout', 'Ain', 'Aamp']) # print 111,unbunchify(dw.data) # print 222,(dw.data) R = data.config.R vcc = data.vcc # def calc(x): # x.Vin = an2v(x.Ain, vcc) # x.Vout = an2v(x.Aout, vcc) # x.Vamp = an2v(x.Aamp, vcc) # x.Vx = x.Vout - x.Vin # x.I = (x.Vin - x.Vamp) / R data.Vmax = data.vcc data.Imax = data.vcc / R # ls=[] # pwm_current=0 # for x in dw.data.measurements: # # group by pwm_value # x.pwm_value==pwm_current: # ls.append(x) # else: # calc(x) # ls=[] # pwm_current=x.pwm_value d = groupped_measurements(data.measurements, ['pwm_value', 'rail']) for p in range(256): for r in [0, 1]: ls = d[p, r] # ls = [x for x in dw.data.measurements if x.pwm_value == p and x.rail == # r] if not len(ls): continue Ain = ls[0].Ain Aout = ls[0].Aout Aamp = ls[0].Aamp Vin = an2v(Ain, vcc) Vout = an2v(Aout, vcc) Vamp = an2v(Aamp, vcc) Vx = Vout - Vin I = (Vin - Vamp) / R for x in ls: x.I = I x.Vx = Vx x.Vin = Vin x.Vout = Vout x.Vamp = Vamp
def test_filt(): df = DataFrame( dict( a=['aa', 'aa', 'aa', 'aa', 'b', 'b'], b=[2, 2, 3, 3, 5, 5], c=[1, 2, 3, 4, 5, 6], d=[31, 32, 33, 44, 44, 66], )) m = filter_measurements( df, ['a', 'b'], # keys ['c', 'd']) print m.to_string() eq_(['aa', 'aa', 'b'], list(m.a)) eq_([2, 3, 5], list(m.b))
def extend(data): m = filter_measurements( data.measurements, ['Dout', 'pwm_value'], ['Aout', 'Aamp'] ) R = data.config.R vcc = data.vcc m['Vout'] = an2v(m.Aout, vcc) m['Vamp'] = an2v(m.Aamp, vcc) m['I'] = (m.Vout - m.Vamp) / R m['Iabs'] = abs(m.I) data.measurements = m
def test_filt(): df = DataFrame( dict( a=['aa', 'aa', 'aa', 'aa', 'b', 'b'], b=[2, 2, 3, 3, 5, 5], c=[1, 2, 3, 4, 5, 6], d=[31, 32, 33, 44, 44, 66], ) ) m = filter_measurements( df, ['a', 'b'], # keys ['c', 'd'] ) print m.to_string() eq_(['aa', 'aa', 'b'], list(m.a)) eq_([2, 3, 5], list(m.b))
def extend(data): m = filter_measurements( data.measurements, ['pwm_value', 'rail'], ['Aout', 'Ain', 'Aamp']) R = data.config.R vcc = data.vcc data.Vmax = data.vcc data.Imax = data.vcc / R col = ColsProxy(m) col.Vin = an2v(col.Ain, vcc) col.Vout = an2v(col.Aout, vcc) col.Vamp = an2v(col.Aamp, vcc) col.Vx = col.Vout - col.Vin col.I = (col.Vin - col.Vamp) / R m = m.sort_index(by='Vx') col.I = pandas.rolling_median(col.I, window=5) data.measurements = m
def transfer_plot(data, fig, error_plot=False): data.measurements = filter_measurements( data.measurements, ['pwm_value'], ['Ain']) title = 'Transfer error plot (%s)' if error_plot else 'Transfer plot (%s)' title = title % (data.model) fw = FigureWrapper( data, fig, x='voltage', y='error (V)' if error_plot else 'voltage', title=title, ) vcc = data.vcc fw.addcol(legend=data.config.pin_in, x=lambda e: pwm2v(e.pwm_value, vcc), y=lambda e: an2v( e.Ain, vcc) - (pwm2v(e.pwm_value, vcc) if error_plot else 0), ) ax = fw.subplot if error_plot: ax.axis([0, 5.1, -0.050, 0.050]) return fig
def transfer_plot(data, fig, error_plot=False): data.measurements = filter_measurements(data.measurements, ["value"], ["Ain"]) title = "Transfer error plot" if error_plot else "Transfer plot" title = title fw = FigureWrapper(data, fig, x="voltage", y="error (V)" if error_plot else "voltage", title=title) vcc = data.vcc if error_plot: fw.subplot.plot([0, vcc], [vcc / 99, vcc / 99], "r-") fw.subplot.plot([0, vcc], [-vcc / 99, -vcc / 99], "r-") else: fw.subplot.plot([0, 0], [vcc, vcc], "r-") fw.addcol( legend=data.config.pin_in, x=lambda e: pot2v(e.value, vcc), y=lambda e: an2v(e.Ain, vcc) - (pot2v(e.value, vcc) if error_plot else 0), ) ax = fw.subplot if error_plot: ax.axis([0, 5.1, -0.1, 0.1]) return fig