text
stringlengths
0
828
Request corresponding oscilloscope RMS voltage reading.
'''
r = x['resistor index'].values[0]
f = x['frequency'].values[0]
control_board.set_waveform_frequency(f)
actuation_index, data = find_good(control_board, actuation_steps, r, 0,
len(actuation_steps) - 1)
board_measured_rms = data.loc[data['divider resistor index'] >= 0,
'board measured V'].mean()
oscope_rms = oscope_reading_func()
print 'R=%s, f=%s' % (r, f)
return pd.DataFrame([[r, f, actuation_index, board_measured_rms,
oscope_rms]],
columns=['resistor index', 'frequency',
'actuation index', 'board measured V',
'oscope measured V'])
# Return board-measured RMS voltage and oscilloscope-measured RMS voltage
# for each frequency/feedback resistor pair.
return (conditions.groupby(['resistor index', 'frequency'])
.apply(max_actuation_reading).reset_index(drop=True))"
591,"def fit_feedback_params(calibration, max_resistor_readings):
'''
Fit model of control board high-voltage feedback resistor and
parasitic capacitance values based on measured voltage readings.
'''
R1 = 10e6
# Get transfer function to compute the amplitude of the high-voltage input
# to the control board _(i.e., the output of the amplifier)_ based on the
# attenuated voltage measured by the analog-to-digital converter on the
# control board.
#
# The signature of the transfer function is:
#
# H(V1, R1, C1, R2, C2, f)
#
# See the `z_transfer_functions` function docstring for definitions of the
# parameters based on the control board major version.
def fit_resistor_params(x):
resistor_index = x['resistor index'].values[0]
p0 = [calibration.R_hv[resistor_index],
calibration.C_hv[resistor_index]]
def error(p, df, R1):
v1 = compute_from_transfer_function(calibration.hw_version.major,
'V1',
V2=df['board measured V'],
R1=R1, R2=p[0], C2=p[1],
f=df['frequency'].values)
e = df['oscope measured V'] - v1
return e
p1, success = optimize.leastsq(error, p0, args=(x, R1))
# take the absolute value of the fitted values, since is possible
# for the fit to produce negative resistor and capacitor values
p1 = np.abs(p1)
return pd.DataFrame([p0 + p1.tolist()],
columns=['original R', 'original C',
'fitted R', 'fitted C']).T
results = (max_resistor_readings
[max_resistor_readings['resistor index'] >= 0]
.groupby(['resistor index']).apply(fit_resistor_params))
data = results.unstack()
data.columns = data.columns.droplevel()
return data"
592,"def plot_feedback_params(hw_major_version, max_resistor_readings,
feedback_params, axis=None):
'''
Plot the effective attenuation _(i.e., gain less than 1)_ of the control
board measurements of high-voltage AC input according to:
- AC signal frequency.
- feedback resistor used _(varies based on amplitude of AC signal)_.
Each high-voltage feedback resistor (unintentionally) forms a low-pass
filter, resulting in attenuation of the voltage measured on the control
board. The plot generated by this function plots each of the following
trends for each feedback resistor:
- Oscilloscope measurements.
- Previous model of attenuation.
- Newly fitted model of attenuation, based on oscilloscope readings.
'''
R1 = 10e6
# Since the feedback circuit changed in version 2 of the control board, we
# use the transfer function that corresponds to the current control board
# version that the fitted attenuation model is based on.
if axis is None:
fig = plt.figure()
axis = fig.add_subplot(111)
markers = MarkerStyle.filled_markers
def plot_resistor_params(args):
resistor_index, x = args