LLRFLibsPy Contents#
Architecture#
The LLRFLibsPy library consists of several Python modules as shown in the diagram below. The associations between these modules are also shown in the diagram. Each module is a Python source file implementing routines that can be directly called in the user codes. The list of routines and the example codes to test the routines are summarized in tables below.
rf_sysid
Functions#
Function |
Example |
Comments |
---|---|---|
|
|
produce the PRBS signal for system identification |
|
|
Empirical Transfer Function Estimation (ETFE) |
|
|
calculate the cavity half-bandwidth from the RF pulse decay stage |
|
|
calculate the cavity detuning from the RF pulse decay stage |
|
|
estimate the required cavity drive and reflected signals from probe signal |
|
|
calculate the cavity parameters (half-bandwidth and detuning) within the pulse by directly solving the cavity equation |
|
|
calculate the cavity parameters (half-bandwidth and detuning) within the pulse using the ADRC observer |
|
|
calculate the beam drive voltage within the pulse using the ADRC observer |
|
construct the ADRC observer and estimate the denoised cavity voltage and the general disturbances |
|
|
|
identify the impulse response of a real/complex SISO system from data |
|
identify the cavity input coupling factor using steady-state forw/refl powers |
rf_calib
Functions#
Function |
Example |
Comments |
---|---|---|
|
|
calib. cavity virtual probe with forward/reflected signals |
|
|
calib. DAC offset with I/Q modulator direct upconversion |
|
|
calib. I/Q modulator imbalance with direct upconversion |
|
|
calib. cavity forward signal using forward and probe |
|
|
calib. cavity forward/reflected signals with constant QL and detuning |
|
|
calib. cavity forward/reflected signals with time-varying QL and detuning |
|
|
calib. forward/reflected power from forward/reflected voltage |
|
|
calib. energy gain and beam phase with phase scan and energy meas. |
|
|
est. steady-state standing-wave cavity voltage from drive power |
|
|
est. const gradient traveling-wave structure ACC voltage from drive power |
|
calib. vector sum by rotating and scaling referring to one channel |
|
|
|
calib. system gain and system phase |
rf_control
Functions#
Function |
Example |
Comments |
---|---|---|
|
|
discretize a continous state-space system and compare freq responses |
|
|
cascade two state-space systems (either continous or discrete - C/D) |
|
|
calculate and plot freq response of a state-space system (C/D) |
|
|
derive a basic continous RF I/Q controller: P + I + frequency notches |
|
|
perform one time-step execution of the discretized controller |
|
|
analyze the sensitivity/complementary sensitivity of an RF control loop (C/D) |
|
|
derive the setpoint and feedforward waveforms for desired cavity voltage and beam loading |
|
|
derive a basic ADRC controller (the observer and gain) |
|
|
perform one time-step execution of the discretized controller including the ADRC observer |
|
|
time-reversed low pass filter-based adaptive feedforward |
|
|
derive the ILC gain matrix from the impulse response and weighting |
|
|
apply the ILC algorithm to calculate the feedforward correction signal |
|
|
response matrix inversion with SVD (with singular value filtering) |
|
|
response matrix inversion with lease-square method (with regularization) |
rf_det_act
Functions#
Function |
Example |
Comments |
---|---|---|
|
|
perform non-I/Q demodulation of a given raw sampling waveform |
|
|
demodulate raw with every two samples |
|
|
demodulate raw sampled by asyn. clock, reference WF needed |
|
|
demodulate raw with Hilbert transform, return amplitude and phase |
|
|
convert I/Q waveforms to amplitude/phase waveforms |
|
convert amplitude/phase waveforms to I/Q waveforms |
|
|
normalize phase (scalar or WF) to a specific range (default ±180 deg) |
|
|
derive the pulse info like pulse width, pulse offset, etc. |
rf_fit
Functions#
Function |
Example |
Comments |
---|---|---|
|
|
fit the sine or cosine function |
|
|
fit the 2D points to a circle function |
|
|
fit the 2D points to an ellipse function |
|
|
fit a 1D Guassian function |
rf_noise
Functions#
Function |
Example |
Comments |
---|---|---|
|
|
calculate the power spectral density (PSD) of a coherent sampled data series |
|
|
calculate the PSD of a general data series |
|
generate uniform distributed random numbers |
|
|
|
generate noise series from a given PSD spectrum |
|
|
calculate the RMS jitter from a given PSD spectrum |
|
|
apply notch filter to a data series |
|
|
design a notch filter in state-space format |
|
|
apply a single time step of state-space filter |
|
moving average without compensating the group delay |
rf_sim
Functions#
Function |
Example |
Comments |
---|---|---|
|
|
derive a continous state-space equation of a cavity |
|
cavity state-space equation with mechanical modes (to be implemented) |
|
|
|
derive the cavity impulse response from the cavity parameters |
|
|
simulate cavity (with constant QL and detuning) response to a pulsed input |
|
|
simulate cavity (with constant QL and detuning) response for a time step |
|
|
simulate cavity (with constant QL and detuning) response for a time step (simplified cavity equation only with the fundamental passband mode) |
|
|
calculate the required RF power for diesired cavity voltage and beam |
|
|
calcualte the optimal QL and detuning for minimizing the reflection power |
rf_misc
Functions#
Function |
Example |
Comments |
---|---|---|
|
save a dictionary into a Matlab .mat file |
|
|
load a Matlab .mat file into a dictionary |
|
|
get a string of the current date/time |
|
|
get a bit of an integer |
|
|
adding two transfer function in num/den format |
|
|
|
plot an ellipse using its characteristics |
|
|
plot a 1D Guassian distribution |
rf_plot
Functions#
Function |
Example |
Comments |
---|---|---|
|
make plot for function |
|
|
make plot for function |
|
|
make plot for function |
|
|
make plot for function |
|
|
make plot for function |
|
|
make plot for function |
|
|
make plot for function |
|
|
make plot for function |
|
|
make plot for function |