pydarm package

Submodules

pydarm.fir module

class pydarm.fir.FIRFilterFileGeneration(config, fir_config=None)

Bases: DARMModel

FIR filter file generation.

CALCS_corr(output_filename='CALCS_corr.h5', output_dir='.', plots_directory=None)

CALCS correction FIR filter generation

Parameters:
output_filenamestr

Output filename base

output_dirstr

Directory to which to save FIR filters file

plots_directorystr

Directory to which to save diagnostic plots

Returns:
output_filename, diagnostic plots of filters
DCS(output_filename='DCS.npz', output_dir='.', plots_directory=None)

DCS FIR filter generation

Parameters:
output_filenamestr

Output filename

output_directorystr

Directory to which to save FIR filters file

plots_directorystr

Directory to which to save diagnostic plots.

Returns:
output_filename, diagnostic plots of filters
GDS(output_filename='GDS.npz', output_dir='.', plots_directory=None)

GDS FIR filter generation

Parameters:
output_filenamestr

Output filename

output_dirstr

Directory to which to save FIR filters file

plots_directorystr

Directory to which to save diagnostic plots.

Returns:
output_filename, diagnostic plots of filters
class pydarm.fir.FIRfilter(fNyq=8192, desired_dur=1.0, highpass_fcut=None, lowpass_fcut=None, window_type='dpss', window=None, freq_res=3.0)

Bases: object

Model parameters for FIR filter creation

Parameters:
fNyqint, optional

Nyquist frequency of FIR filter

durfloat, optional

Duration in seconds of FIR filter

highpass_fcutfloat, optional

Cut off frequency for high-pass filter

lowpass_fcutfloat, optional

Cut off frequency for low-pass filter (relevant for inverse sensing filter)

window_typestr, optional

Type of window function to use. Options are ‘dpss’, ‘kaiser’, ‘dolph_chebyshev’, and ‘hann’.

windowArray, optional

A precomputed window function

freq_res: `float`, optional

Frequency resolution of the FIR filter, computed as half the width of

Returns:
FIRfilterlist

List of model parameters for FIR filter creation parameters

check_td_vs_fd(tdfilt, fdmodel, filename='td_vs_fd.png', plot_title='Frequency Response', legend=['FIR filter', 'DARM model'], samples_per_lobe=8, ymax_increase=1)

Checking time-domain vs frequency-domain filters

Parameters:
tdfilt

array of time domain filter

fdmodel

array of frequency domain model

filename

str for filename for plot output

plot_title

str for title of plot

legend

str, array-like for plot legend titles

samples_per_lobe

int for factor to upsample by for finer frequency resolution

ymax_increase

int for factor above max y array value to display in plot

Returns:
plot of filter and model comparison
freq_array:

frequency array for comparison

mag_ratio:

array of magnitude comparison

phase_diff:

array of phase differences

create_fir_filter(static_model, save_to_file=None, upsample_factor=16, model_already_upsampled=False)

Generate an FIR filter based on provided frequency-domain model

Parameters:
static_modelarray-like

Transfer function of frequency domain model

save_to_filestr, optional

Filename (NPZ) to save the data from this result

Returns:
model_FIRfloat64, array-like

A time domain FIR filter model

double_modelfloat, array-like

An array of real doubles FIR filter model

pydarm.fir.check_td_vs_fd_response(invsens_filt, invsens_highpass, TST_filt, PUM_filt, UIM_filt, act_highpass, D, R, invsens_fNyq=8192, invsens_highpass_fNyq=1024, act_fNyq=1024, D_fNyq=8192, R_fNyq=8192, invsens_delay=None, invsens_highpass_delay=None, act_delay=None, act_highpass_delay=None, time_delay=6.103515625e-05, filename='td_vs_fd_response.png', plot_title='Response Function', legend=['FIR filters', 'DARM model'])

Checking time-domain vs frequency-domain responses

Parameters:
invsens_filtarray
invsens_highpassarray
TST_filtarray-like
PUM_filtarray-like
UIM_filtarray-like
act_highpassarray
Darray
Rarray
invsens_fNyqfloat, int
invsens_highpass_fNyqfloat, int
act_fNyqfloat, int
D_fNyqfloat, int
R_fNyqfloat, int
invsens_delayfloat, int
invsens_highpass_delayfloat, int
act_delayfloat, int
act_highpass_delayfloat, int
time_delayfloat, int
filenamestr
plot_titlestr
legendstr, array-like
Returns:
plot figure
pydarm.fir.correctFIRfilter(FIRpars, tdfilt, fdmodel, window_correction_range, save_to_file=None)

Correct FIR filter production errors induced by windowing, and return a compensated version of the frequency-domain model.

pydarm.firtools module

pydarm.firtools.Blackman(N, return_double=False)

Blackman window

Parameters:
Nfloat, int
return_doubleTrue or False
Returns:
win / win[N // 2]array-like
pydarm.firtools.DPSS(N, alpha, return_double=False, max_time=10)

DPSS window

Compute a discrete prolate spheroidal sequence (DPSS) window, which maximizes the energy concentration in the central lobe.

Parameters:
Nfloat

length

alphafloat

parameter

return_doublebool, optional

double or longdouble

max_timeint, optional

maximum

Returns:
outputlongdouble, array-like

the filter

pydarm.firtools.DolphChebyshev(N, alpha, return_double=False)

Dolph-Chebyshev window

Parameters:
Nfloat, int
alphafloat, int
return_doubleTrue or False
Returns:
win / win[N // 2]array-like
pydarm.firtools.compute_Tn(x, n)

A function for Dolph-Chebyshev window

Parameters:
xfloat, int
nfloat, int
Returns:
+- np.cos or cosh(n * np. arccos or arcosh(+-x))float
pydarm.firtools.compute_W0_lagged(N, alpha)

A function for Dolph-Chebyshev window

Parameters:
Nfloat, int
alphafloat, int
Returns:
W0array-like
pydarm.firtools.dft(td_data, exp_array=None, return_double=False, inverse=False)

First, a discrete Fourier transform, evaluated according to the definition

Parameters:
td_dataarray
exp_array‘array-like’
return_doubleTrue or False
inverseTrue or False
Returns:
fd_dataarray
pydarm.firtools.fft(td_data, prime_factors=None, exp_array=None, return_double=False, inverse=False, M=None, M_prime_factors=None, M_exp_array2=None, M_exp_array=None)

A fast Fourier transform using the Cooley-Tukey algorithm, which factors the length N to break up the transform into smaller transforms.

Parameters:
td_dataarray
prime_factorsfloat, int
exp_array‘array-like’
return_doubleTrue or False
inverseTrue or False
M
M_prime_factors
M_exp_array2
M_exp_array
Returns:
fd_dataarray-like
pydarm.firtools.find_M(M_min)

For Bluestein’s algorithm. Find a good padded length.

Parameters:
M_minfloat
Returns:
tupleint of M and prime factors
pydarm.firtools.find_exp_array(N, inverse=False)

A function to compute the array of exponentials.

Parameters:
Nfloat
inverseTrue or False
Returns:
exp_arrayarray-like
pydarm.firtools.find_exp_array2(N, inverse=False)

A function to compute the array of exponentials for Bluestein’s algorithm.

Parameters:
Nfloat
inverseTrue or False
Returns:
exp_arrayarray-like
pydarm.firtools.find_prime_factors(N)

A function to find prime factors of N, the size of the input data.

Parameters:
Nfloat, ‘array-like’
Returns:
prime_factorsarray-like
pydarm.firtools.freqresp(filt, delay_samples=0, samples_per_lobe=8, return_double=False)

A function to get the frequency-responce of an FIR filter, showing the lobes.

Parameters:
filtarray
delay_samplesfloat, int
samples_per_lobefloat, int
return_doubleTrue or False
Returns:
rfft(filt_prime, return_double=return_double)array-like
pydarm.firtools.ifft(fd_data, prime_factors=None, exp_array=None, return_double=False, normalize=True)

An inverse fast Fourier transform that factors the length N to break up the transform into smaller transforms

Parameters:
fd_dataarray
prime_factorsfloat, int
exp_array‘array-like’
return_doubleTrue or False
normalizeTrue or False
Returns:
td_dataarray-like
pydarm.firtools.irdft(fd_data, exp_array=None, return_double=False, N=None, normalize=True)

Inverse of the above real-input DFT. So the output of this is real and the input is assumed to be shortened to N // 2 + 1 samples to avoid redundancy.

Parameters:
fd_dataarray
exp_arrayfloat, array-like, optional
return_doublebool, optional
Nint, optional
normalizebool, optional
Returns:
td_datafloat, array-like
pydarm.firtools.irfft(fd_data, prime_factors=None, exp_array=None, return_double=False, normalize=True, M_fft=None, M_fft_prime_factors=None, M_fft_exp_array2=None, M_fft_exp_array=None, M_irfft=None, M_irfft_prime_factors=None, M_irfft_exp_array2=None, M_irfft_exp_array=None)

Inverse of the above real-input FFT. So the output of this is real and the input is assumed to be shortened to N // 2 + 1 samples to avoid redundancy.

Parameters:
fd_dataarray
prime_factorsfloat, int
exp_array‘array-like’
return_doubleTrue or False
M_fftfloat
M_fft_prime_factorsfloat, int
M_fft_exp_array2‘array-like’
M_fft_exp_array‘array-like’
M_irfft :float, int
M_irfft_prime_factorsfloat, int
M_irfft_exp_array2‘array-like’
M_irfft_exp_array‘array-like’
Returns:
fd_dataarray-like
pydarm.firtools.mat_times_vec(mat, vec)

A function to multiply a symmetric Toeplitz matrix times a vector and normalize. Assume that only the first row of the matrix is stored, to save memory. Assume that only half of the vector is stored, due to symmetry.

Parameters:
matarray-like
vecarray-like
Returns:
outputarray-like
pydarm.firtools.prime_fft(td_data, return_double=False, inverse=False, exp_array2=None, M=None, prime_factors=None, exp_array=None)

Bluestein’s algorithm for FFTs of prime length, for which the Cooley-Tukey algorithm is ineffective. Make the replacement nk -> -(k - n)^2 / 2 + n^2 / 2 + k^2 / 2. Then X_k = sum_(n=0)^(N-1) x_n * exp(-2*pi*i*n*k/N) = exp(-pi*i*k^2/N) * sum_(n=0)^(N-1) x_n * exp(-pi*i*n^2/N) * exp(pi*i*(k-n)^2/N) This can be done as a cyclic convolution between the sequences a_n = x_n * exp(-pi*i*n^2/N) and b_n = exp(pi*i*n^2/N), with the output multiplied by conj(b_k). a_n and b_n can be padded with zeros to make their lengths a power of 2. The zero-padding for a_n is done simply by adding zeros at the end, but since the index k - n can be negative and b_{-n} = b_n, the padding has to be done differently. Since k - n can take on 2N - 1 values, it is necessary to make the new arrays a length N’ >= 2N - 1. The new arrays are

|– | a_n, 0 <= n < N

A_n = -|
0, N <= n < N’

|

|– | b_n, 0 <= n < N

B_n = -| 0, N <= n <= N’ - N
b_{N’-n}, N’ - N <= n < N’

|

The convolution of A_n and B_n can be evaluated using the convolution theorem and the Cooley-Tukey FFT algorithm: X_k = conj(b_k) * ifft(fft(A_n) * fft(B_n))[:N]

Parameters:
td_dataarray
return_doublebool, optional
inversebool, optional
exp_array2float, array-like, optional
Mfloat, optional
prime_factorsfloat, int
exp_arrayfloat, array-like, optional
Returns:
fd_datacomplex, array-like
pydarm.firtools.prime_irfft(fd_data, return_double=False, N=None, normalize=True, exp_array2=None, M=None, prime_factors=None, exp_array=None)

Inverse of the above real-input FFT. So the output of this is real and the input is assumed to be shortened to N // 2 + 1 samples to avoid redundancy.

Parameters:
fd_dataarray
prime_factorsfloat, int
exp_array‘array-like’
return_doubleTrue or False
normalizeTrue or False
Nfloat
Mfloat
exp_array2array-like
Returns:
td_dataarray-like
pydarm.firtools.prime_rfft(td_data, return_double=False, return_full=False, exp_array2=None, M=None, prime_factors=None, exp_array=None)

If the input is real, the output is conjugate-symmetric: fd_data[n] = conj(fd_data[N - n]) We can reduce the number of operations by a factor of ~2. Also, we have the option to only output half of the result, since the second half is redundant.

Parameters:
td_dataarray
prime_factorsfloat, int
exp_array‘array-like’
return_doubleTrue or False
return_fullTrue or False
Mfloat
exp_array2array-like
Returns:
fd_dataarray-like
pydarm.firtools.rdft(td_data, exp_array=None, return_double=False, return_full=False)

If the input is real, the output is conjugate-symmetric: fd_data[n] = conj(fd_data[N - n]). We can reduce the number of operations by a factor of ~2. Also, we have the option to only output half of the result, since the second half is redundant.

Parameters:
td_dataarray
exp_arrayfloat, array-like, optional
return_doublebool, optional
return_fullbool, optional
Returns:
fd_dataarray
pydarm.firtools.resample(data, N_out, return_double=False)

A resampler

Parameters:
dataarray
N_outfloat, int
return_doubleTrue or False
Returns:
resampledfloat, array-like
pydarm.firtools.rfft(td_data, prime_factors=None, exp_array=None, return_double=False, return_full=False, M=None, M_prime_factors=None, M_exp_array2=None, M_exp_array=None)

If the input is real, the output is conjugate-symmetric: fd_data[n] = conj(fd_data[N - n]) We can reduce the number of operations by a factor of ~2. Also, we have the option to only output half of the result, since the second half is redundant.

Parameters:
td_dataarray
prime_factorsfloat, int
exp_array‘array-like’
return_doubleTrue or False
return_fullTrue or False
Mfloat, int
M_exp_array2array-like
M_prime_factorsarray-like
Returns:
fd_dataarray-like
pydarm.firtools.two_tap_zero_filter_response(zeros, sr, freq)

Generating two-tap zero filter

Parameters:
zerosfloat, int
srfloat, int
freqarray
Returns:
two_taparray
class pydarm.firtools.window_info(window, info)

Bases: tuple

info

Alias for field number 1

window

Alias for field number 0

pydarm.actuation module

class pydarm.actuation.ActuationModel(config, measurement)

Bases: Model

An arm actuation model object

This is a class to set up the model for the actuation function from a configuration file with all the information about where the data is stored

actuation_stage_residual(frequencies, stage='TST')

This is the actuation residual for a given stage on a given arm (this object), meaning it contains everything in the actuation except for the output matrix, the digital distribution filters, the actuator gain, and suspension dynamics.

See T1900169

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

stagestr, optional

UIM, PUM or TST (default = ‘TST’)

Returns:
A_mn_rescomplex128, array-like

transfer function response of the residual actuation function

analog_driver_response(frequencies)

The transfer function of the analog driver electronics. By default, the output will be a dictionary for UIM, PUM, and TST with dictionaries for each containing the quadrants UL, LL, UR, LR. Transfer functions are unity with zero phase unless the params file/string contains a <uim|pum|tst>_driver_meas_<z|p>_<ul|ll|ur|lr> for the particular quadrant and values

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
outdict, complex128, array-like

transfer function response of the uncompensated driver electronics

combine_sus_quadrants(frequencies)

Combine the digital and analog paths for the SUS quadrants on a per-stage and per-path basis. Meaning (0.25 x UIM UL digital x UIM UL analog + 0.25 x UIM LL digital x UIM LL analog + …) and so on for each stage

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
uimdict, complex128, array-like

transfer function response of the digital compensation filters in each path and quadrant for the UIM

pumdict, complex128, array-like

transfer function response of the digital compensation filters in each path and quadrant for the PUM

tstdict, complex128, array-like

transfer function response of the digital compensation filters in each path and quadrant for the TST

compute_actuation_single_stage(frequencies, stage='TST')

Compute the actuation function transfer function for a single stage (see G1501518). This transfer function is from the DARM control input at the SUS user model, or the input to the ISCINF bank, to DARM displacement.

This does not include the OMC to SUS model jump delay

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

stagestr, optional

UIM, PUM or TST (default = ‘TST’)

Returns:
tfcomplex128, array-like

transfer function response of the actuation function

digital_out_to_displacement(frequencies)

This computes the transfer function from the output of the DRIVEALIGN filter bank of each stage to displacement of the test mass

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
uim_responsecomplex128, array-like

transfer function response of the UIM stage

pum_responsecomplex128, array-like

transfer function response of the PUM stage

tst_responsecomplex128, array-like

transfer function response of the TST stage

drivealign_to_darm_displacement(frequencies)

This computes the transfer function from the input of the DRIVEALIGN filter bank of each action stage to DARM by accounting for how positive longitudinal drive for each actuation stage pushes the given test mass to creates DARM.

DARM displacement is defined by

\[+ DARM = + Delta L \ = (Delta L_X - Delta L_Y) \ = - (Delta L_EX + Delta L_IX) + (Delta L_EY + Delta L_IY)\]

This is particularly useful for computing EPICS records

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
uim_responsecomplex128, array-like

transfer function response of the UIM stage

pum_responsecomplex128, array-like

transfer function response of the PUM stage

tst_responsecomplex128, array-like

transfer function response of the TST stage

drivealign_to_longitudinal_displacement(frequencies)

This computes the transfer function from the input of the DRIVEALIGN filter bank of each stage to displacement of the test mass where “longitudinal” is defined as in the traditional SUS Euler Basis: positive longitudinal displacement is along a vector perpendicular to the plane of the HR surface (positive ETMX displacement is in the -X global IFO direction, positive ITMY displacement is in the +Y global IFO direction).

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
uim_responsecomplex128, array-like

transfer function response of the UIM stage

pum_responsecomplex128, array-like

transfer function response of the PUM stage

tst_responsecomplex128, array-like

transfer function response of the TST stage

known_actuation_terms_for_measurement(frequencies)

This method computes all known terms which are divided out of the DARM_ERR / SUS_EXC full IFO actuation measurement for each stage such that the remaining dimensional actuation strength, H_Ai, can be fit by MCMC.

This computes the transfer function from the input of the DRIVEALIGN filter bank (same as the SUS_EXC point) of each stage to DARM displacement from any test mass, including everything except the N/(drive unit); either amps or volts**2, for which the MCMC will fit. The DARM feedback sign of the arm the measurement is taken on since we read out the measurement with DARM_ERR.

This method is essentially computing drivealign_to_darm_displacement / dc_gain_Npct * dc_gain_?pct where ? is A or V2, but we write all of this out explicitly because we want to be able to compute the transfer function without knowing in advance anything about NpA or NpV2

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
uim_responsecomplex128, array-like

transfer function response of the UIM stage, everything but N/ct

pum_responsecomplex128, array-like

transfer function response of the PUM stage, everything but N/ct

tst_responsecomplex128, array-like

transfer function response of the TST stage, everything but N/ct

static matlab_force2length_response(suspension_file, frequencies)

Load the ZPK output from the matlab exported values and output a frequency response. This function expects variables in a .mat file to be UIMz, UIMp, UIMk, PUMz, PUMp, PUMk, TSTz, TSTp, and TSTk

Parameters:
suspension_file: `str`

path and filename to .mat file that has the ZPK arrays

frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
UIM_F2L_freqrespcomplex128, array-like

transfer function response of the UIM stage

PUM_F2L_freqrespcomplex128, array-like

transfer function response of the PUM stage

TST_F2L_freqrespcomplex128, array-like

transfer function response of the TST stage

pum_dc_gain_Apct()

This computes the PUM DC gain in units of amps / count

pum_dc_gain_Npct()

This computes the PUM DC gain in units of Newtons / count

sus_digital_compensation_response(frequencies)

The transfer function of the SUS compensation filters for driver electronics. By default, the output will be a dictionary for UIM, PUM, and TST with dictionaries for each containing the quadrants UL, LL, UR, LR. Transfer functions are unity with zero phase unless the params file/string contains: <uim|pum|tst>_compensation_filter_bank_<ul|ll|ur|lr> with a name; <uim|pum|tst>_compensation_filter_modules_in_use_<ul|ll|ur|lr> with list of modules turned on; and <uim|pum|tst>_compensation_filter_gain_<ul|ll|ur|lr>

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
outdict, complex128, array-like

transfer function response of the digital compensation filters in each path and quadrant

sus_digital_filters(frequencies)

The transfer function of the SUS digital filters

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
tst_isc_inf_filter_responsecomplex128, array-like

transfer function response of the ISC_INF digital filters in the TST path

tst_lock_filter_responsecomplex128, array-like

transfer function response of the LOCK digital filters in the TST path

tst_drive_align_filter_responsecomplex128, array-like

transfer function response of the DRIVEALIGN digital filters in the TST path

pum_lock_filter_responsecomplex128, array-like

transfer function response of the LOCK digital filters in the PUM path

pum_drive_align_filter_responsecomplex128, array-like
transfer function response of the DRIVEALIGN digital filters in the

PUM path

uim_lock_filter_responsecomplex128, array-like

transfer function response of the LOCK digital filters in the UIM path

uim_drive_align_filter_responsecomplex128, array-like

transfer function response of the DRIVEALIGN digital filters in the UIM path

sus_digital_filters_response(frequencies)

The transfer function of the SUS digital filters

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
uim_digital_filter_responsecomplex128, array-like

transfer function response of the digital filters in the UIM path

pum_digital_filter_responsecomplex128, array-like

transfer function response of the digital filters in the PUM path

tst_digital_filter_responsecomplex128, array-like

transfer function response of the digital filters in the TST path

tst_dc_gain_Npct()

This computes the TST DC gain in units of Newtons / count

tst_dc_gain_V2pct()

This computes the TST DC gain in units of volts**2 / count

uim_dc_gain_Apct()

This computes the UIM DC gain in units of amps / count

uim_dc_gain_Npct()

This computes the UIM DC gain in units of Newtons / count

class pydarm.actuation.DARMActuationModel(config)

Bases: Model

An DARM actuation model object

This is a class to set up the model for the DARM loop from a configuration file with all the information about where the data is stored

arm_super_actuator(frequencies, arm='x', syserr_dict=None)

Compute the super actuator transfer function for a specific arm. In this case, the “arm super actuator” is created by choosing a specific arm and then for each QUAD, the arm transfer function to DARM is summed together.

This transfer function is from DARM_CTRL to meters sensed by the IFO. Note that the sign of the DARM_ERR signal is dependent upon which arm is under control.

The OMC to SUS delay is included in this transfer function.

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

armstr

arm for the calculation, ‘x’ or ‘y’

syserr_dictdict, optional

dict of multiplicative values, ex.: {‘xarm’: {‘UIM’: complex, array-like}}

Returns:
super_actuationcomplex128, array-like

transfer function response of the actuation function

compute_actuation(frequencies, syserr_dict=None)

Compute the entire actuation function transfer function (see G1501518). This transfer function is from DARM_CTRL to meters sensed by the IFO. Note that the sign of the DARM_ERR signal is dependent upon which arm is under control.

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

syserr_dictdict, optional

dict of multiplicative values, ex.: {‘xarm’: {‘UIM’: complex, array-like}}

Returns:
tfcomplex128, array-like

transfer function response of the actuation function

darm_output_matrix_values()

Turns the output matrix values into an array for the QUAD SUS

stage_super_actuator(frequencies, stage='TST', syserr_dict=None)

Compute the super actuator transfer function for a specific stage. In this case, the “stage super actuator” is created by choosing a specific stage and then for each QUAD, the stage transfer function to DARM is summed together.

This transfer function is from DARM_CTRL to meters sensed by the IFO. Note that the sign of the DARM_ERR signal is dependent upon which arm is under control.

The OMC to SUS delay is included in this transfer function.

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

stagestr, optional

SUS stage for the calculation, ‘UIM’, ‘PUM’, or ‘TST’

syserr_dictdict, optional

dict of multiplicative values, ex.: {‘xarm’: {‘UIM’: complex, array-like}}

Returns:
super_actuationcomplex128, array-like

transfer function response of the actuation function

stage_super_actuator_drivealign(frequencies, stage='TST', syserr_dict=None)

Compute the super actuator transfer function for a specific stage. In this case, the “stage super actuator” is created by choosing a specific stage and then for each QUAD, the stage transfer function to DARM is summed together.

This transfer function is from the input of the DRIVEALIGN filter bank to meters sensed by the IFO. This method assumes that the signal feedback to a single stage would be positive, but if the signal is sent to both arms (like a DARM signal) then X and Y are 180 degrees out of phase.

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

stagestr

SUS stage for the calculation, ‘UIM’, ‘PUM’, or ‘TST’

syserr_dictdict, optional

dict of multiplicative values, ex.: {‘xarm’: {‘UIM’: complex, array-like}}

Returns:
super_actuationcomplex128, array-like

transfer function response of the actuation function

pydarm.analog module

pydarm.analog.analog_aa_or_ai_filter_response(mat_file, frequencies)

This comes from an export of a Matlab LTI object which was a fit of measurements made at LHO and LLO by JeffK, JoeB, et al. The object has zeros, poles, gain, and a delay, so the exported mat-file has the arrays of zeros and poles, gain, and delay in the file. Measurements were made around ER7. TODO: find alog entries?

Parameters:
mat_filestr

path and filename of the Matlab mat-file export

frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
tfcomplex128, array-like

transfer function response of the analog AA or AI filter

pydarm.calcs module

class pydarm.calcs.CALCSModel(config, calcs=None)

Bases: DARMModel

A_corr(frequencies, daqdownsample=True)

Compute total DARM actuator A_corr = A / A_foton (aka delta A), see T1900169.

This is more complicated than computing C_corr, since the GDS actuation correction is applied to each stage separately, so we cannot just sum the corrections and multiply by a common factor. Instead, we compute the modeled (true) DARM actuation, and divide by the CALCS (approximate) DARM actuation. We also account for the OMC to CALCS delay and the possibility for DAQ downsampling.

DAQ downsample is an option here because if you want to create delta L_ctrl from ${IFO}:CAL-DELTAL_CTRL_DBL_DQ, then we need to use daqdownsampling = True because the channel that is read has been downsampled. When computing the delay between CAL-DELTAL_CTRL and CAL-DELTAL_RESIDUAL to improve CAL-DELTAL_EXTERNAL, however, one does not need daqdownsampling (see discussion in sec III of T1900169).

Both products are using the CALCS copy of DARM_CTRL and therefore need the delay (OMC to CALCS)

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the GDS sensing correction

daqdownsamplebool, optional

When True (default), the 16k-4k daqdownsample is applied in A_corr

Returns:
A_corrcomplex128, array-like

transfer function response of the correction

C_corr(frequencies)

Compute delta C = delay*(opt resp)/(opt resp)_foton*C_r

The inverse of this transfer function is multiplied by DELTAL_RESIDUAL as the GDS correction.

We need to divide out the normalized optical response FOTON filter only and be sure to include 1 16k clock cycle delay from the model jump OMC to CAL-CS. There is an optical gain factor in the front end model, but it is fine to leave this in place. The output is basically C_pydarm / C_foton, and GDS will need to either divide the DELTAL_RESIDUAL data by this function or invert the output of this function and multiply by the DELTAL_RESIDUAL data.

This is delay*(opt resp)/(opt resp)_foton*C_r (see T1900169-v5 eq 33)

This is also known as C_corr or delta C in T1900169

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the GDS sensing correction

Returns:
tfcomplex128, array-like

transfer function response of the correction

arm_super_actuator(frequencies, arm='x')

Compute the super actuator transfer function for a specific arm. In this case, the “arm super actuator” is created by choosing a specific arm and then for each QUAD, the arm transfer function to DARM is summed together.

This transfer function is from DARM_CTRL to meters sensed by the IFO. Note that the sign of the DARM_ERR signal is dependent upon which arm is under control.

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

armstr, optional

SUS stage for the calculation, ‘UIM’, ‘PUM’, or ‘TST’

Returns:
super_actuationcomplex128, array-like

transfer function response of the actuation function

calcs_darm_actuation(frequencies)

Compute the CALCS approximated DARM actuation. This method implicitly assumes that the CALCS DARM output matrix and actuation digital filtering matches the installed in-loop DARM ouput matrix and actuation digital filtering.

See T1900169, definition of A_CALCS

Parameters:
frequenciesfloat, array-like

array of frequencies for the CALCS approximated DARM actuation

Returns:
calcs_actuationcomplex128, array-like

Residual phase after removing the simulated delay

calcs_dtt_calibration(frequencies, include_whitening=True, strain_calib=False, save_to_file=None, fmt=None)

Compute the calibration transfer function, dL_pyDARM / dL_CALCS for the main control room calibrated sensitivity curve. One can save this data to a file with the needed frequency, dB magnitude, and degrees phase columns, and apply it to a DTT template.

See T1900169 section IV

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the CAL_DELTAL_EXTERNAL DTT calibration

include_whiteningbool, optional

if the whitening filter is on (default), then we’d like to remove its effect so by default this divides out the whitening filter

strain_calibbool, optional

the output defaults to dL_pyDARM/dL_CALCS, so that we can recalibrate CAL-DELTAL_EXTERNAL. If this option is True, then the output is h_pyDARM/dL_CALCS

save_to_filestr, optional

Filename (ASCII) to save the data from this result. Note: the default file columns are <frequency> <magnitude (dB)> <phase (deg)>

fmtstr, optional

if save_to_file is used, then this is the output format. Options are ‘dB,deg’ (default), ‘mag,deg’, ‘dB,rad’, ‘mag,rad’, or ‘re,im’. If none is given, then the default is used

Returns:
tfcomplex128, array-like

transfer function response of the calibration

compute_actuation_single_stage(frequencies, arm, stage)

A_n,calcs

CALCS approximation of a specific arm, stage from input to SUS ISCINF to DARM (and therefore does not include the OMC to CALCS delay) displacement. See T1900169

Parameters:
frequenciesfloat, array-like

array of frequencies for the CALCS approximated DARM actuation

armstr

arm for the calculation, ‘x’ or ‘y’

stagestr

SUS stage for the calculation, ‘UIM’, ‘PUM’, or ‘TST’

Returns:
calcs_stage_actuationcomplex128, array-like

CALCS approximation of SUS model ISCINF input to DARM displacement transfer function

compute_epics_records(gds_pcal_endstation=False, gds_sus_endstation=False, gds_darm_omc=False, exact=False)

Generate EPICS values for CALCS front-end model time dependent correction factors

This is a LIGO specific function for generating front end calibration EPICS records. The GDS pipeline reads these EPICS records and together with channels read from frames computes TDCFs. If GDS reads channels from the end station or OMC models rather than CALCS, then the CALCS model will need to get phase values assigned to DEMODs in order to have the proper synchronization. The default assumes that GDS reads all channels from CALCS

See T1700106-v10 and G1601472 for additional details

Parameters:
gds_pcal_endstationbool, optional

When false (default), the correction is computed for CAL-CS PCAL channel, which includes 1 16k clock cycle delay that we must compensate (undo). Otherwise, when true, the correction is computed at the end station, which does not include 1 16k clock cycle delay

gds_sus_endstationbool, optional

When false (default), the correction is computed for CAL-CS SUS channel, which includes 1 16k clock cycle delay that we must compensate (undo). Otherwise, when true, the correction is computed at the end station, which does not include 1 16k clock cycle delay

gds_darm_omcbool, optional

When false (default), the correction is computed for CAL-CS DARM ERR channel, which includes 1 16k clock cycle delay that we must compensate (undo). Otherwise, when true, the correction is computed at the OMC, which does not include 1 16k clock cycle delay

exactbool, optional

When True, the exact TDCF transfer function calculations are updated in the output dictionary. This will append new values to the output dictionary

Returns:
outdict

Dictionary of EPICS records

deltal_ext_pcal_correction(frequencies, **kwargs)

Compute the calibration transfer function, dL_pyDARM / dL_Pcal for determining the response function systematic error

See T1900169 section V

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the CAL_DELTAL_EXTERNAL DTT calibration

kwargsoptional

values are passed to calcs.calcs_dtt_calibration() and pcal.compute_pcal_correction()

Returns:
tfcomplex128, array-like

transfer function resposne of the correction factor

deltal_ext_whitening(frequencies)

Compute the interpolated transfer function of the DELTAL_EXTERNAL export from FOTON

If no export file is provided in the configuration, this method will return an array of ones

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the interpolation

Returns:
whitening_interpcomplex128, array-like

transfer function response of the calibration

drivealign_out_to_darm_displacement(frequencies, arm, stage)

CALCS representation of the SUS_EXC DRIVEALIGN point to DARM displacement transfer function.

Units are m/ct = (N/ct) * (m/N)

The gain (N/ct) of the CALCS model is assumed to be exactly the same as what is in the reference model, so that is used.

If there is anything in the “coiloutf” key-value pair, then this transfer function is also used, but this would be used only in special circumstances.

Parameters:
frequenciesfloat, array-like

array of frequencies

armstr

arm for the calculation, ‘x’ or ‘y’

stagestr

SUS stage for the calculation, ‘UIM’, ‘PUM’, or ‘TST’

Returns:
tfcomplex128, array-like

CALCS approximation of the DRIVEALIGN output to DARM displacement

drivealign_out_to_longitudinal_displacement(frequencies, arm, stage)

CALCS representation of the transfer function from the DRIVEALIGN bank to longitudinal displacement of the test mass. Units are m/ct = (N/ct) * (m/N)

The gain (N/ct) of the CALCS model is assumed to be exactly the same as what is in the reference model, so that is used. If any digital gain is present as <arm>_<stage>_analog_gain, then it will be applied here.

If there is anything in the “coiloutf” key-value pair, then this transfer function is also used, but this would be used only in special circumstances.

Parameters:
frequenciesfloat, array-like

array of frequencies for the CALCS approximated longitudinal actuation of the test mass from the given stage

armstr

arm for the calculation, ‘x’ or ‘y’

stagestr

SUS stage for the calculation, ‘UIM’, ‘PUM’, or ‘TST’

Returns:
out_tfcomplex128, array-like

CALCS approximation of the DRIVEALIGN output to displacement

gds_actuation_correction(frequencies, stage, daqdownsample=True)

Compute the correction to the CAL-CS output for GDS. Note that this implicitly assumes that the front end digital filters in CALCS is the same as that in the SUS path!

This is also more complicated than sensing because there is a single channel for a given stage that accounts for BOTH arms; e.g., ${IFO}:CAL-DELTAL_CTRL_${STAGE}_DBL_DQ takes input from both x and y arms using an output matrix.

This is (A_{xn}+A_{yn})/(A_{xn,calcs}+A_{yn,calcs})/(F*delay) where n is the stage, calcs denotes FOTON implementation of an actuator F is the DAQ downsampling filter (on by default), and delay of the 1 16384 clock cycle delay going from OMC to CALCS

See T1900169, definition of delta A_n

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the GDS sensing correction

stagestr

SUS stage for the calculation, ‘UIM’, ‘PUM’, or ‘TST’

daqdownsamplebool, optional

When True (default), the 16k-4k daqdownsample is applied in GDS actuation correction

Returns:
correctioncomplex128, array-like

transfer function response of the correction

gds_sensing_correction(frequencies)

Compute 1 / C_corr = C_foton / C see T1900169.

For the sensing path, GDS sensing correction = 1 / C_corr. This is to be multiplied into DELTAL_RESIDUAL

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the GDS sensing correction

Returns:
tfcomplex128, array-like

transfer function response of the correction

optical_response_ratio(frequencies)

This computes (opt resp) / (opt resp)_foton

It is a bit confusing because the FOTON filter is the inverse sensing function, so we’ll be multiplying the true optical response from the model by the FOTON transfer function.

In T1900169, in the definition of C/C_CALCS, the last three terms are .. math :: (opt resp)/(opt resp)_foton * (LP_foton/LP) * LP and this method returns this combination since the export from FOTON gives the full combination of .. math :: LP_foton / (opt resp)_foton

Note that (LP_foton/LP) is the “IIR warping”

Parameters:
frequenciesfloat, array-like

array of frequencies for the optical response ratio

Returns:
foton_inv_sensing_interpcomplex128, array-like

ratio of interpolated values

sensing_actuation_delay(frequencies, clock=False)

Compute the delay based on the GDS sensing and actuation correction in units of seconds delay or (if clock=True) in units of 16384 samples/sec, i.e., 1 16384 Hz clock delay = 6.1035e-5 s. Positive indicates a delay, negative indicates an advance

See T1900169, sec III “method 1”

Parameters:
frequenciesfloat, array-like

array of frequencies to model the phase delay

clockboolean, optional

if clock is True, then the output delay_fit and residual will be computed and rounded to the nearest number of integer clock cycles (16384)

Returns:
delayfloat

Units of seconds or 16384 Hz clock cycles (if clock=True)

stage_super_actuator(frequencies, stage='TST')

Compute the super actuator transfer function for a specific stage as estimated by the CALCS model. In this case, the “stage super actuator” is created by choosing a specific stage and then for each QUAD, the stage transfer function to DARM is summed together.

This transfer function is from DARM_CTRL to meters sensed by the IFO. Note that the sign of the DARM_ERR signal is dependent upon which arm is under control.

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

stagestr, optional

SUS stage for the calculation, ‘UIM’, ‘PUM’, or ‘TST’

Returns:
tfcomplex128, array-like

transfer function response of the actuation function

sus_response_ratio(frequencies, arm, stage)

This computes (sus resp) / (sus resp)_foton

See T1900169 definition of delta A_mn

Parameters:
frequenciesfloat, array-like

array of frequencies for the optical response ratio

armstr, x or y
stagestr UIM, PUM, or TST
Returns:
response_ratiocomplex128, array-like

ratio of interpolated values

pydarm.darm module

class pydarm.darm.DARMModel(config, sensing=None, actuation=None, digital=None, pcal=None)

Bases: Model

DARM model object

This is a class to set up the model for the DARM loop from a configuration file with all the information about where the data is stored

compute_darm_olg(frequencies)

Compute the entire DARM open loop transfer function (see G1501518)

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
tfcomplex128, array-like

transfer function response of the sensing function

compute_etas(frequencies, sensing_syserr=None, actuation_syserr_dict=None)

Compute multiplicative scaling factor to the response function. This returns “eta_R_C”, applying sensing systematic error only; “eta_R_A”, applying actuation systematic error only; and “eta_R”, applying both sensing and systematic errors.

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

sensing_syserrcomplex, array-like, optional

multiplicative factor to include relative sensing systematic error

actuation_syserr_dictdict, optional

dict of multiplicative values, ex.: {‘xarm’: {‘UIM’: complex, array-like}, ‘yarm’: {‘PUM’: complex, array-like}}

Returns:
eta_R_ccomplex128, array-like

multiplicative scaling factor for the response function, applying the sensing systematic errors only

eta_R_acomplex128, array-like

multiplicative scaling factor for the response function, applying the actuation systematic errors only

eta_Rcomplex128, array-like

multiplicative scaling factor for the response function, applying both sensing and actuation systematic errors

compute_response_function(frequencies, sensing_syserr=None, actuation_syserr_dict=None)

Compute the entire DARM response transfer function (see G1501518)

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

sensing_syserrcomplex, array-like, optional

multiplicative factor to include relative sensing systematic error

actuation_syserr_dictdict, optional

dict of multiplicative values, ex.: {‘xarm’: {‘UIM’: complex, array-like}}

Returns:
tfcomplex128, array-like

transfer function of the DARM closed-loop response

plot(plot_selection='all', freq_min=0.1, freq_max=5000, filename=None, ifo='', label=None, style=None, ugf_start=10, ugf_end=1000, show=None, **kwargs)

Make DARM critique plots

This method produces critique models for 1 or 2 models.

Parameters:
plot_selectionstr, optional

Select plot type, one of: ‘all’ (default), ‘optical’, ‘actuation’, ‘clg’, ‘olg’, or ‘digital’

freq_minfloat, optional

start frequency

freq_maxfloat, optional

end frequency

filenamestr, optional

if given, ALL generated graphs will be saved in one pdf

ifostr, optional

if given with a model to plot, it will appear in the graph titles

labelstr list, optional

FIXME: what should this be?

stylestr, optional

one of the styles matplotlib has or a user filename with style

ugf_startfloat, optional

start frequency used for the search

ugf_endfloat, optional

end frequency used for the search

showbool, optional

if true the plot(s) will show

**kwargsoptional

Matplotlib values passed to plots

class pydarm.darm.DigitalModel(config)

Bases: Model

DARM digital filter model object

compute_response(frequencies)

Compute DARM digital controller frequency response

Uses filter ZPK transfer function response from Foton file.

Parameters:
frequencies
Returns:
tfcomplex128, array-like

transfer function response of the digital SUS filter

pydarm.digital module

pydarm.digital.daqdownsamplingfilters(from_freq, to_freq, filter_method, rcg_ver)

Compute the transfer function for the DAQ downsampling filters

Parameters:
from_freqint

Number of samples per second input

to_freqint

Number of samples per second output

filter_methodstr

Filtering method. Choose between ‘biquad’ and ‘df2’

rcg_verstr

RCG version. Choose between ‘v3’ and ‘v2’

Returns:
daq_filterscipy.signal.StateSpace

State space object

pydarm.digital.iopdownsamplingfilters(sample_freq_str, filter_calc_method, rcg_ver='v3', model_sample_rate=65536)

Compute the transfer function for the DAQ downsampling filters

Parameters:
sample_freq_strstr

Number of samples per second input

filter_calc_methodstr

Filtering method. Choose between ‘biquad’ and ‘df2’

rcg_verstr, optional

RCG version. Choose between ‘v3’ (default) and ‘v2’ (only needed when also specifying ‘16k’ and ‘biquad’)

model_sample_rateint, optional

Model sampling rate. Default value is 2**16 = 65536

Returns:
iopfilterscipy.signal.StateSpace

State space object

pydarm.measurement module

pydarm.model module

class pydarm.model.Model(config, measurement=None)

Bases: object

pyDARM Model class

Represents a transfer function.

analog_aa_or_ai_filter_response(frequencies, idx=0)

Compute the analog anti-aliasing or anti-imaging filter response

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

idxint, optional

if multiple files provided, use an index like 0, 1, or 2 to access the appropriate file (default = 0)

Returns:
tfcomplex128, array-like

transfer function response of the analog AA or AI filter

config_to_dict()

Return a nested dict of the model configuration. Sections are dict in of themselves

Returns:
outdict

dictionary of the model parameters

digital_aa_or_ai_filter_response(frequencies)

Compute the digital anti-aliasing or -imaging filter response

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
tfcomplex128, array-like

transfer function response of the digital filter

dpath(*args)

Return path to data file

Path should be relative to the directory specified in the cal_data_root configuration variable, which may be overridden with the CAL_DATA_ROOT environment variable. If not specified, paths will be assumed to be relative to the current working directory.

if os.path.join(*args) is a full path then return that.

pydarm.model.isfloat(value)

pydarm.pcal module

class pydarm.pcal.PcalModel(config)

Bases: Model

A photon calibrator (pcal) model object

The class serves to return transfer functions that are important to the pcal system, be it corrections to the response when pulling the PCAL channels from the frames, or establishing force coefficients.

compute_pcal_correction(frequencies, endstation=False, include_dewhitening=True, arm='REF')

Compute the Pcal correction for the offline analysis See G1501518 NOTE: This also includes the Pcal arm sign, so be aware!

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

endstationbool, optional

When false (default), the correction is computed for CAL-CS PCAL channel, which includes 1 16k clock cycle delay that we must compensate (undo). Otherwise, when true, the correction is computed at the end station, which does not include 1 16k clock cycle delay

include_dewhiteningbool, optional

if the dewhitening filter is on (default), then the correction will include the two 1 Hz poles

armstr, optional

string to indicate which arm is used for this correction, ‘REF’ (default), ‘X’, or ‘Y’

Returns:
tfcomplex128, array-like

transfer function response of the correction

digital_filter_response(frequencies)
Importing suspension filter from FOTON file which normalized by whitening

filter 2 1Hz poles (susnorm) and mpN_DC gain.

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
tfcomplex128, array-like

transfer function response of the correction

hwinj_calibration_newtons_per_ct(frequencies, arm='X')

Calibration of the hardware injection path, consisting of the photon calibrator components: N/ct, corner station to end station analog delay (2 16k clock cycles and 4 65k clock cycles), Pcal analog AI, and Pcal digital AI.

Note: this does not include the PCAL to DARM sign

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

armstr, optional

string to indicate which arm is used for this correction, ‘REF’ ‘X’ (default), or ‘Y’

Returns:
tfcomplex128, array-like

transfer function response of the correction

newtons_per_ct(arm='X')

Newtons per count for the photon calibrator

newtons_per_watt()

Newtons per watt for the photon calibrator 2*cos(theta)/c

pcal_dewhiten_response(frequencies)

Compute the dewhitening response

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
tfcomplex128, array-like

transfer function response of the Pcal dewhitening filter

pydarm.plot module

class pydarm.plot.BodePlot(fig=None, title=None, figsize=(12, 8), only='', spspec=[211, 212])

Bases: object

bode plotting object

static autoscale_axis(ax, xlim=None, log=False)

This function rescales a figure’s y-axis.

Scaling takes place based on the data that is visible given the current xlim of the axis, by default. If provided, the data within the provided xlim list is used instead.

Parameters:
xlimlist

data boundary to consider in stead of the entire visible range

logbool

use logarithmic (base 10) scale. Default is False.

autoscale_mag_y(**kwargs)

Rescale the mag plot’s y-axis.

See BodePlot.autoscale_axis() for keyword arguments.

autoscale_phase_y(**kwargs)

Rescale the mag plot.

See BodePlot.autoscale_axis() for keyword arguments.

error(freq, tf, tf_error, **kwargs)
add frequency response to plot with error

Note: Error should be relative.

Parameters:
freqarray, list

frequency array

tfarray, list

frequency response

tf_errorarray, list

relative error of frequency response

**kwargsText properties

Other miscellaneous text parameters for matplotlib

static get_ax_index_from_spspec(spec: int) int

Get index of axes object from the spec.

Assumes a three-digit spec (e.g. 212).

greed(more_minor=True)

add a finer grid than the default

Parameters:
more_minorbool

Determine the finer tick location for log axes

legend(labels=None, **kwargs)

add legend

Parameters:
labelsstring, Optional

add string legend for the plot

**kwargsText properties

Other miscellaneous text parameters for matplotlib

plot(freq, tf, **kwargs)

add frequency response to plot

Parameters:
freqarray, list

frequency array

tfarray, list

frequency response

**kwargsText properties

Other miscellaneous text parameters for matplotlib

save(path)

save bode plot to file

Parameters:
pathstr, path-like or binary file-like

path directory for saving the figure

show()

show interactive plot

text(x, y, plot_text)

add text in plot

Parameters:
xfloat

x-position to place the text

yfloat

y-position to place the text

plot_textstr

The text

vlines(vfreq, color='red', lw=1.0, linestyle='--', label='_nolegend_')

add vertical line at specific frequency in both mag and phase plot

Parameters:
vfreqfloat

frequency point for vertical line

colorcolor, Optional

color for vertical line, default = ‘red’

lwfloat

line width, default = 1.0

linestyle{‘-’, ‘–’, ‘-.’, ‘:’, ‘’, …}, Optional

style for vertical line, default = ‘–’

labelstr

legend string for the vertical line

xlim(freq_min, freq_max)

set min max for frequency axis

Parameters:
freq_minfloat

start frequency

freq_maxfloat

end frequency

ylim(mag_min, mag_max, phase_min=-185, phase_max=185)

set min max for the magnitude (and phase) axis

Parameters:
mag_minfloat

minimum magnitude scale

mag_maxfloat

maximum magnitude scale

phase_minfloat, Optional

minimum phase scale, default = -185

phase_maxfloat, Optional

maximum phase scale, default = 185

class pydarm.plot.QuadPlot(fig=None, title=None, figsize=(12, 8))

Bases: object

quad bode plotting object This is essentially a copy of the BodePlot class but plots two bode plots side by side

greed(more_minor=True, quadrant=['tl', 'bl', 'tr', 'br'])

add a finer grid than the default

Parameters:
more_minorbool, Optional

set a finer grid on the plot, default=True

quadrant[‘tl’, ‘bl’, ‘tr’, or ‘br’]

select specific plot to set finer grid alternatively you can use a list of numbers quadrant : [1, 3, 2, or 4]

legend(label=None, quadrant=['tl', 'bl', 'tr', 'br'])

add legend

Parameters:
labelstr

add text label for legend

quadrant[‘tl’, ‘bl’, ‘tr’, or ‘br’]

select position for legend on specific quadrant ‘tl’ : top-left (magnitude left) ‘bl’ : bottom-left (phase left) ‘tr’ : top-right (magnitude right) ‘br’ : bottom-right (phase right) alternatively you can use a list of numbers quadrant : [1, 3, 2, or 4] select position for legend on specific quadrant 1 : top-left (magnitude left) 3 : bottom-left (phase left) 2 : top-right (magnitude right) 4 : bottom-right (phase right)

plot(tuple_left, tuple_right, **kwargs)
Add frequency response to plot with or without error

Note: Error should be relative.

Parameters:
tuple_lefttuple, array-like

add frequency response for the left-side frequencies area

tuple_righttuple, array-like

add frequency response for the right-side frequencies area

**kwargsText properties

Other miscellaneous text parameters for matplotlib

save(path)

save bode plot to file

Parameters:
pathstr, path-like

path directory for saving the figure

show()

show interactive plot

text(x, y, plot_text, quadrant=['tl', 'bl', 'tr', 'br'])

add text in plot

Parameters:
xfloat

x-position to place the text

yfloat

y-position to place the text

plot_textstr

The text

quadrant[‘tl’, ‘bl’, ‘tr’, or ‘br’]

select specific plot to add the text alternatively you can use a list of numbers quadrant : [1, 3, 2, or 4]

vlines(vfreq, quadrant=['tl', 'bl', 'tr', 'br'])

add vertical line at specific frequency in both mag and phase plot

Parameters:
vfreqfloat

frequency position for vertical line

quadrant[‘tl’, ‘bl’, ‘tr’, or ‘br’]

select specific plot to add vertical line alternatively you can use a list of numbers quadrant : [1, 3, 2, or 4]

xlim(freq_min, freq_max, quadrant=['tl', 'bl', 'tr', 'br'])

set min max for frequency axis

Parameters:
freq_minfloat, Optional

start frequency

freq_maxfloat, Optional

final frequency

quadrant[‘tl’, ‘bl’, ‘tr’, or ‘br’]

select specific plot to setup xlim alternatively you can use a list of numbers quadrant : [1, 3, 2, or 4]

xscale(scale='linear', quadrant=['tl', 'bl', 'tr', 'br'])

change the y scale of plot at given quadrant, linear or log

Parameters:
scalestr, Optional

scale for x axis, default=’linear’

quadrant[‘tl’, ‘bl’, ‘tr’, or ‘br’]

select specific plot to set the xscale alternatively you can use a list of numbers quadrant : [1, 3, 2, or 4]

ylim(y_min, y_max, quadrant=['tl', 'bl', 'tr', 'br'])

set min max for the magnitude (and phase) axis

Parameters:
freq_minfloat, Optional

start frequency

freq_maxfloat, Optional

final frequency

quadrant[‘tl’, ‘bl’, ‘tr’, or ‘br’]

select specific plot to setup ylim alternatively you can use a list of numbers quadrant : [1, 3, 2, or 4]

yscale(scale='linear', quadrant=['tl', 'bl', 'tr', 'br'])

change the y scale of plot at given quadrant, linear or log

Parameters:
scalestr, Optional

scale for y axis, default=’linear’

quadrant[‘tl’, ‘bl’, ‘tr’, or ‘br’]

select specific plot to set the yscale alternatively you can use a list of numbers quadrant : [1, 3, 2, or 4]

pydarm.plot.critique(*args, filename=None, plot_selection='all', ifo='', show=None, label=None, freq_min=0.1, freq_max=5000, freq_points=1001, ugf_start=10, ugf_end=1000, greed=True, figsize=(12, 8), **kwargs)

This method produces critique models for 1 or 2 models.

Parameters:
argspydarm.darm.DARMModel object

1 or 2 darm models objects, if more than 1, this should be a list

filenamestr, optional

if given, ALL generated graphs will be saved in one pdf

plot_selectionstr, optional

Select plot type, one of: ‘all’ (default), ‘optical’, ‘actuation’, ‘clg’, ‘olg’, or ‘digital’

ifostr, optional

if given with a model to plot, it will appear in the graph titles

showbool, optional

if true the plot(s) will show

labelstr list, optional

a list of labels for legend

freq_minfloat, optional

start frequency

freq_maxfloat, optional

final frequency

freq_pointsint, optional

Number of frequency points

ugf_startfloat, optional

start frequency used for the search

ugf_endfloat, optional

end frequency used for the search

greedbool, optional
figsizefloat, tuple
**kwargsoptional

Matplotlib values passed to plots

pydarm.plot.get_ugf(freq, tf, search_start=5.0, search_end=1000.0, n_points=10000)

Very non-fancy function for easily finding UGF in the simplest of cases.

Parameters:
freqfloat, array

frequencie arrays corresponding to the given tf

tfcomplex, array

transfer function you want the ugf of

search_start: `float`

frequency to start UGF search

search_end: `float`

frequency to end UGF search

n_points: `int`

N point number for increased accuracy of UGF frequency

Returns:
floats: ugf frequency, ugf phase, ugf gain, ugf index of original array
pydarm.plot.plot(*args, freq_min=0.1, freq_max=5000, freq_points=1001, filename=None, mag_min=None, mag_max=None, phase_min=-185, phase_max=185, label=None, title=None, style=None, show=None, greed=False, figsize=(12, 8), **kwargs)

This method provides a simple way to plot quickly anything you want.

Parameters:
argstuple, lists

Here you can input any kind of transfer function related data. It accepts multiple sets in multiple formats. FORMATS: - 2-tuple (freq,transfer function) - 3-tuple (freq,transfer function, rel unc) - 4-tuple (freq,transfer function, coherence, rel unc) - freq, transfer function (two lists or 1d arrays separated by comma) - method that returns a transfer function e.g. D.compute_darm_olg (assuming D is a darm model object)

freq_minfloat, optional

start frequency

freq_maxfloat, optional

end frequency

freq_pointsint, optional

number of points to calculate

filenamestr, optional

if given, ALL generated graphs will be saved in one pdf.

mag_minfloat, optional

minimum magnitude scale

mag_maxfloat, optional

maximum magnitude scale

phase_minfloat, optional

minimum phase scale

phase_maxfloat, optional

maximum phase scale

labelstr list, optional

legend string for the data sets given e.g. [‘first data’, ‘second’]

titlestr, optional

title of the graph

stylestr, optional

one of the styles matplotlib has or a user filename with style

showbool, optional

if true the plot will show

greedbool, optional

if true a finer grid is drawn for all figs

figsizefloat tuple, optional

figure size

**kwargs

matplotlib arguments passed to all plots

Returns:
bppydarm.plot.BodePlot object
pydarm.plot.residuals(freq_model, tf_model, freq_data, tf_data, unc_data, mag_min=0.8, mag_max=1.2, phase_min=-5, phase_max=5, mag_major_tick=0.05, mag_minor_tick=0.01, phase_major_tick=2, phase_minor_tick=0.5, filename=None, show=None, title='')

This method provides a simple way to plot quickly anything you want.

Parameters:
freq_modelfloat, array-like

frequencies that the model transfer function is computed

tf_modelcomplex, array-like

transfer function response values at the freq_model points

freq_datafloat, array-like

frequencies that the measured transfer function data values are computed at

tf_datacomplex, array-like

measured transfer function response values at the freq_daata points

unc_datafloat, array-like

relative uncertainty values, determined from the measurement coherence

mag_minfloat, optional

minimum magnitude scale

mag_maxfloat, optional

maximum magnitude scale

phase_minfloat, optional

minimum phase scale

phase_maxfloat, optional

maximum phase scale

mag_major_tickfloat, optional

major tick placement for the residual magnitude plot

mag_minor_tickfloat, optional

minor tick placement for the residual magnitude plot

phase_major_tickfloat, optional

major tick placement for the residual phase plot

phase_minor_tickfloat, optional

minor tick placement for the residual phase plot

filenamestr, optional

save the plot to this file

showbool, optional

if true the plot will show

Notes

Example usage: >>> residuals(freq_model, tf_model, … freq_data, tf_data, unc_data, title=’Measurement vs Model’)

pydarm.plot.save_multifig(filename, figs=None)

method to save all existing (or list of given) figures in one pdf file

Parameters:
filenamestr

pdf file name for the figures

figslist, dict

list of given figures to save

pydarm.sensing module

class pydarm.sensing.SensingModel(config)

Bases: Model

A sensing function model object This is a class to set up the model for the sensing function from a configuration file with all the information about where the data is stored

adc_delay_response(name, frequencies)

Compute the ADC delay response

Parameters:
namestr

a string (e.g., ‘A’ or ‘A_A’) indicating the OMC path name to be evaluated. This string should be listed in SensingModel.omc_path_names variable

frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
delaycomplex, array-like

frequency response of the ADC delay

compute_sensing(frequencies)

Compute the entire sensing function transfer function (see G1501518)

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
tfcomplex128, array-like

transfer function response of the sensing function

light_travel_time_delay_response(frequencies)

Compute the frequency response from the light travel time delay

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
tfcomplex128, array-like

transfer function response

mean_arm_length()

Compute the mean arm length of the x and y arms

Returns:
mean_lengthfloat

mean arm length in units of meters

omc_analog_dcpd_readout_response(name, frequencies)

The transfer function of the analog OMC DCPD readout electronics

Parameters:
namestr

a string (e.g., ‘A’ or ‘A_A’) indicating the OMC path name to be evaluated. This string should be listed in SensingModel.omc_path_names variable

frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
responsecomplex128, array-like

transfer function response of the analog electronics in path name

omc_combine_path_responses(frequencies)

Compute the frequency response from the OMC DCPD electronics as shown in G1501518-v21 (the bracketed term directly below “O4 Calibration”)

Note however, that this is the WEIGHTED MEAN! Meaning that for N paths, we would sum the paths and divide by N if they were perfectly balanced

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
combined_pathscomplex128, array-like

transfer function response

omc_dcpd_transimpedence_amplifier_response(name, frequencies)

The transfer function of the analog OMC DCPD transimpedence amplifier electronics

Parameters:
namestr

a string (e.g., ‘A’ or ‘A_A’) indicating the OMC path name to be evaluated. This string should be listed in SensingModel.omc_path_names variable

frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
responsecomplex128, array-like

transfer function response of the analog transimpedence amplifier in path name

omc_dcpd_whitening_response(name, frequencies)

The transfer function of the analog OMC DCPD whitening electronics

Parameters:
namestr

a string (e.g., ‘A’ or ‘A_A’) indicating the OMC path name to be evaluated. This string should be listed in SensingModel.omc_path_names variable

frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
responsecomplex128, array-like

transfer function response of the analog whitening electronics in path name

omc_digital_filters_response(name, frequencies)

The transfer function of the OMC digital compensation filters

Parameters:
namestr

a string (e.g., ‘A’ or ‘A_A’) indicating the OMC path name to be evaluated. This string should be listed in SensingModel.omc_path_names variable

frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
filter_responsecomplex128, array-like

transfer function response of the digital filters in the path labeled by name

omc_path_response(name, frequencies)

Compute the frequency response for a single OMC DCPD readout as shown in G1501518-v21 (the bracketed term directly below “O4 Calibration”). This includes the gain ratio (= path idx / ref path, usually path A) and the balance matrix coefficient for path idx.

The reference path (usually path A) should have gain ratio = 1.

Parameters:
namestr

a string (e.g., ‘A’ or ‘A_A’) indicating the OMC path name to be evaluated. This string should be listed in SensingModel.omc_path_names variable

frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
path_responsecomplex128, array-like

transfer function response of the path labeled by idx

static optical_response(pole_frequency, detune_spring_frequency, detune_spring_Q, pro_spring=False)

Compute the coupled cavity response approximated by a single cavity pole and a detuned spring frequency and Q

Parameters:
pole_frequencyfloat

Coupled cavity pole frequency in Hz

detune_spring_frequencyfloat

Detuning spring frequency in Hz

detune_spring_Qfloat

Unitless Q

pro_springboolean, optional

logic flag to indicate pro-spring

Returns:
optical_responseLTI object

coupled cavity optical response

sensing_residual(frequencies)

Compute the residual sensing function

This is everything in the sensing function except the optical gain and the optical response

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the residual sensing function

Returns:
C_rescomplex128, array-like

transfer function response

single_pole_approximation_delay_correction_response(frequencies)

Compute the frequency response from the time delay correction to the single pole approximation

Parameters:
frequenciesfloat, array-like

array of frequencies to compute the response

Returns:
tfcomplex128, array-like

transfer function response

pydarm.uncertainty module

pydarm.utils module

class pydarm.utils.cds_filter(name, soscoef, fs, design)

Bases: tuple

design

Alias for field number 3

fs

Alias for field number 2

name

Alias for field number 0

soscoef

Alias for field number 1

class pydarm.utils.cds_filter_bank(name, filters, headerAndBody)

Bases: tuple

filters

Alias for field number 1

headerAndBody

Alias for field number 2

name

Alias for field number 0

pydarm.utils.clear_filter_module(foton_file, filterbank, mod_idx, verbose=False)

Clear foton filterbank module

Parameters:
foton_filefoton.FilterFile

foton file object for file that will be modified.

filterbankstr

the filterbank that is being written to (e.g. CS_DARM_ERR). Each filterbank contains 10 filter module “slots”

mod_idxint

filter module slot. based at zero. i.e. a bank in slot 5 as seen on MEDM should have mod_idx=4.

pydarm.utils.compute_digital_filter_response(filter_filename, filter_bank_name, filter_bank_modules, filter_bank_gain, frequencies, pfilt=None)

Compute a digital filter ZPK transfer function response from a Foton file

Parameters:
filter_filenamestr

Path to file and filename of Foton filter file

filter_bank_namestr

Name of the filter bank

filter_bank_modulesint, array-like

filter modules requested from the bank, from 1 .. 10

filter_bank_gainfloat

Digital gain of the filter bank

frequenciesfloat, array-like

Array of frequencies (in Hz) for the transfer function

pfiltarray-like (optional)

Use this as input when reading from the same Foton filter file multiple times. pfilt can be passed back in because it has all the file stored in the namedtuple

Returns:
tfcomplex128, array-like

transfer function response of the digital SUS filter

pfiltarray-like

The Foton file is stored in this array for later re-use

pydarm.utils.dfreqrespZPK(sys, w)

Compute the frequency response of a discrete ZPK filter

Note that control room computers don’t have the latest scipy so this is brought from scipy>=0.19.0. It basically does the same as freqz_zpk():

Parameters:
sysscipy.signal.ZerosPolesGain

Filter object

wfloat, array-like

Angular frequencies at which to compute the filter response

Returns:
wfloat, array-like

Angular frequencies at which to compute the filter response

hcomplex128, array-like

Filter response

Examples

>>> filt = signal.ZerosPolesGain(-2.0*np.pi*np.asarray([1.]),
               -2.0*np.pi*np.asarray([20.]), 20.0/1.0, 1.0/16384)
>>> out = dfreqrespZPK(filt, 2.0*np.pi*np.logspace(0, 3, 100))
pydarm.utils.digital_delay_filter(clock_cycles, sample_frequency)

Compute a digital delay filter

Parameters:
clock_cyclesint

Number of cycles delay with sample_frequency

sample_frequencyint

Sampling frequency

Returns:
filterscipy.signal.ZerosPolesGain

Zeros poles gain object

pydarm.utils.freqrespZPK(sys, w)

Compute the frequency response of a continuous ZPK filter

Parameters:
sysscipy.signal.ZerosPolesGain

Filter object

wfloat, array-like

Angular frequencies at which to compute the filter response

Returns:
gcomplex128, array-like

Filter response

Examples

>>> filt = signal.ZerosPolesGain(-2.0*np.pi*np.asarray([1.]),
               -2.0*np.pi*np.asarray([20.]), 20.0/1.0)
>>> out = freqrespZPK(filt, 2.0*np.pi*np.logspace(0, 3, 100))
pydarm.utils.freqresp_to_mag_db_phase_str(f, fr, include_header=False)

Convert frequency response to magnitude (dB) and phase string.

Parameters:
f: np.ndarray

Frequency array in Hertz.

fr: np.ndarray, complex

Complex frequency response.

include_header: bool, optional

If True, include a header line at the beginning of the string that indicates the purpose and unit of each column. This line will be preceded by a ‘#’ character to mark it as a comment.

Returns:
out: str

String containing three columns: frequency (Hz), magnitude (dB), and phase (degrees). Each row is separated by a newline character. Columns are delimited by a single space.

pydarm.utils.load_foton_export_tf(filename)

This function is designed to take a filename and load the data. The filename must be an ASCII file with three columns: frequency, real term, imaginary term (I think this is the default export behavior of FOTON)

Parameters:
filenamestr

full path and filename to the ASCII export of FOTON data

Returns:
file_data_freqfloat, array-like

frequency array of the data in the file in units of Hz

file_data_responsecomplex128, array-like

transfer function data of the FOTON filter

pydarm.utils.normalize(b, a)
pydarm.utils.parallelZPK(sys1, sys2)

Add two ZPK filters together as though they were in parallel paths and summed

Parameters:
sys1scipy.signal.ZerosPolesGain

First filter object

sys2scipy.signal.ZerosPolesGain

Second filter object

Returns:
sysscipy.signal.ZerosPolesGain

Combined filter object

Examples

>>> out = parallelZPK(in1, in2)
pydarm.utils.read_chain_from_hdf5(filename)

Read the MCMC chain from an HDF5 file

Parameters:
filenamestr

HDF5 filename

Returns:
meas_modelstr

Configuration string for the model

fminfloat

Minimum frequency used in the MCMC fit

fmaxfloat

Maximum frequency used in the MCMC fit

measurementstr

Either ‘sensing’ or ‘actuation’

chainfloat, array-like

The MCMC chain

pydarm.utils.read_eta_or_syserr_from_hdf5(filename, measurement=None, sensing=False, actuation=False)

Read eta results(See aLOG:62621) or sensing and actuation systematic error defined by user from an HDF5 file

Parameters:
filenamestr

Output filename

measurementstr

Either ‘sensing’ or ‘actuation’ or ‘filename’

sensingboolen
actuationboolen
Returns:
frequenciesfloat, array-like

Array of frequencies the eta result is valid for

syserrdict

dictionary of systematic error for this arm and stage

pydarm.utils.read_filter_file(filename)

Read a filter file and return all the SOS coefficients info for the filters

Parameters:
filenamestr

Path and filename of FOTON filter file

Returns:
outarray-like

Data from the FOTON filter file

pydarm.utils.read_filter_sys(filename, bank, module, **kwargs)

Read a filter system from a file and return a ZPK filter and pfilt (a structure containing the filter info from the file)

Parameters:
filenamestr

Path and filename of FOTON filter file

bankstr

Name of the filter bank

moduleint, array-like

Module numers ranging from 1 to 10

dataarray-like, optional

Array containing [filename, filter .. filter]. This is passed as an optional argument in case the file has already been read once and you don’t want to spend more I/O time re-reading this again

Returns:
sysdscipy.signal.ZerosPolesGain

ZPK object of the requested FOTON filters

pfiltarray-like

Data from the FOTON filter file. Passing this back to the same function speeds up searching more filters in the file

pydarm.utils.read_gpr_from_hdf5(filename, measurement)

Read GPR results from an HDF5 file

Parameters:
filenamestr

Output filename

measurementstr

Either ‘sensing’ or ‘actuation’

Returns:
meas_modelstr

Configuration string for the model

y_predcomplex128, array-like

Best fit curve using the GPR and covariance kernel

covfloat, array-like

Covariance matrix for the GPR

frequenciesfloat, array-like

Array of frequencies the GPR is valid for

pydarm.utils.read_response_curves_from_hdf5(filename)

Read the residual response curves from the response curve uncertainty envelope calculation

Parameters:
filenamestr

Response curve file

Returns:
frequencies`float’, array-like

Array of frequencies for the response curves

response_curves`complex’, array-like

Array of individual residual response function curves

pydarm.utils.save_chain_to_hdf5(filename, meas_model, fmin, fmax, measurement, chain)

Save the MCMC chain to an HDF5 file

Parameters:
filenamestr

Output filename

meas_modelstr or dict

Configuration string or dictionary for the model

fminfloat

Minimum frequency used in the MCMC fit

fmaxfloat

Maximum frequency used in the MCMC fit

measurementstr

Either ‘sensing’ or ‘actuation’

chainfloat, array-like

The MCMC chain

pydarm.utils.save_gpr_to_hdf5(filename, meas_model, measurement, y_pred, cov, frequencies)

Save GPR results to an HDF5 file

Parameters:
filenamestr

Output filename

meas_modelstr

Configuration string for the model

measurementstr

Either ‘sensing’ or ‘actuation’

y_predcomplex128, array-like

Best fit curve using the GPR and covariance kernel

covfloat, array-like

Covariance matrix for the GPR

frequenciesfloat, array-like

Array of frequencies the GPR is valid for

pydarm.utils.save_samples_to_txt(filename, frequencies, response_mag_quant, response_pha_quant)

This method saves frequencies and response uncertainty quantiles into a txt file, given a specified filename.

Parameters:
filenamestr

Chosen output filename, needs to end in .txt

frequenciesfloat, array-like

frequencies corresponding to the values of the response uncertainty

response_mag_quanttuple of arrays

response magnitude quantiles (float array-like for the 16th percentile,

float array-like for the 50th percentile, float array-like for the 84th percentile)

response_pha_quanttuple of arrays

response phase quantiles (float array-like for the 16th percentile,

float array-like for the 50th percentile, float array-like for the 84th percentile)

pydarm.utils.serielZPK(sys1, sys2)

Multiply two ZPK filters together as though they were in a seriel path

Parameters:
sys1scipy.signal.ZerosPolesGain

First filter object

sys2scipy.signal.ZerosPolesGain

Second filter object

Returns:
sysscipy.signal.ZerosPolesGain

Combined filter object

Examples

>>> out = serielZPK(in1, in2)
pydarm.utils.sos2zp(sos)

Replicate the MATLAB version of sos2zp because the scipy version is not like the MATLAB version

Parameters:
sosfloat, array-like

Second order sections

Returns:
zfloat

Zeros of the ZPK filter

pfloat, array-like
pydarm.utils.tf2zp(b, a)
pydarm.utils.tf_from_foton_zpk(zpk_params, fstart, fstop, n_points, rate=16384)

Use Foton Python bindings to compute a transfer function from ZPK params.

Parameters:
zpk_paramstuple

Tuple containing a transfer function’s zeros, poles, and gain. The tuple is expected to be of the form ([zeros], [poles], k).

fstartfloat

Start frequency

fstopfloat

Stop frequency

n_pointsint

Number of points to generate.

ratefloat, optional

Sampling rate to passed to Foton.

Returns:
freqsnp.array, float

Frequency array returned by the Foton binding

tfnp.array, complex

Complex transfer function generated by Foton

pydarm.utils.thiran_delay_filter(tau, Ts)

Create a frequency response Thiran Delay Filter

Parameters:
taufloat

time delay(secod)

Tsfloat

sample time(second)

Returns:
sysscipy.signal.TransferFunction
pydarm.utils.tuple_from_foton_zp_format(s)

Takes a list of zeros or poles in foton format and returns tuple.

Foton design strings contain lists of zeros and poles in the following format: ‘[6.2699;-6.4297]’. This function converts that string into a tuple of floats.

Parameters:
sstr

Foton formatted list of zeros or poles.

Returns:
tuple of zeros or poles as floats
pydarm.utils.write_dict_epics(dictionary, dry_run=True, IFO=None, save_file=None, as_float=True)

Write dictionary of key/value pairs to EPICS records (keys are channel names)

Parameters:
dictionarydict

the dictionary of values to write

dry_runboolean

actually write to EPICS if value is False

IFOstr

optional IFO string for IFO channel prefix if needed

save_file: path

optional file to save written record values

as_float: boolean, optional

convert all values to float before caput

pydarm.utils.write_filter_module(foton_file, filterbank, mod_idx, filter_name, zpk_params, verbose=False)

Write zpk string to foton module.

TODO: write pure gains using the gain() foton string rather than zpk()

Parameters:
foton_filefoton.FilterFile

foton file that the new values will be written to.

filterbankstr

the filterbank that is being written to (e.g. CS_DARM_ERR). Each filterbank contains 10 filter module “slots”

mod_idxint

filter module slot. based at zero. i.e. a bank in slot 5 as seen on MEDM should have mod_idx=4.

filter_namestr

the name given to the filter being installed. This is the name that appears above the toggle switch in MEDM.

zpk_paramsiterable

zpk parameters to be fed directly into foton. Format is (zs, ps, gain). the value written to the foton file will be ‘zpk({zs}, {ps}, {gain})’.

pydarm.utils.write_hwinj_data(frequencies, transfer_function, filename, name='', info='')

Write an ASCII file for the hardware injection transfer function

Parameters:
frequenciesfloat, array-like

array of frequencies for the transfer function

transfer_functioncomplex128, array-like

array of transfer function response values

filenamestr

Output filename

namestr, optional

Optional extra name string printed to the header

infostr, optional

Optional additional information string printed to the header

Module contents