rf_sysid#

Identify the RF system transfer function and characteristic parameters.

Functions

beta_powers(pf, pr[, weak])

Identify the cavity input coupling factor using the steady-state forward/reflected powers.

cav_beam_pulse_obs(vc, vf, wh_pul, dw_pul, ...)

Calculate the beam drive waveform of a standing-wave cavity given the intra-pulse half-bandwidth and detuning.

cav_drv_est(vc, half_bw, Ts[, detuning, beta])

Calculate the theoritical drive waveform for the cavity probe waveform.

cav_observer(vc, vf, half_bw, Ts[, beta, ...])

Estimate the cavity voltage (denoised) and the general disturbance with the ADRC observer.

cav_par_pulse(vc, vf, half_bw, Ts[, beta])

Calculate the half-bandwidth and detuning of a standing-wave cavity within an RF pulse with beam off (directly solve the cavity equation).

cav_par_pulse_obs(vc, vf, half_bw, Ts[, vb, ...])

Calculate the half-bandwidth and detuning of a standing-wave cavity within an RF pulse with beam on/off (use ADRC observer).

detuning_decay(pha_wf_deg, decay_ids, ...)

Calculate the detuning of a standing-wave cavity from RF pulse decay.

etfe(u, y[, r, exclude_transient, ...])

Implement the Empirical Transfer Function Estimation (ETFE).

half_bw_decay(amp_wf, decay_ids, decay_ide, Ts)

Calculate the half-bandwidth of a standing-wave cavity from RF pulse decay.

iden_impulse(U, Y[, order])

Identify the impulse response using the input-output data.

prbs(n[, lower_b, upper_b])

Generate prbs signal (PRBS monic polynomials)

beta_powers(pf, pr, weak=False)[source]#

Identify the cavity input coupling factor using the steady-state forward/reflected powers.

Refer to LLRF Book section 9.4.1.

Parameters:
  • pf – float, forward power in steady-state

  • pr – float, reflected power in steady-state (with the same unit as pf)

  • weak – boolean, True for weak coupling (beta < 1), False for strong coupling (beta > 1)

Returns:
  • status – boolean, True for success

  • beta – float, cavity input coupling factor

cav_beam_pulse_obs(vc, vf, wh_pul, dw_pul, half_bw, Ts, beta=10000.0, pole_scale=20)[source]#

Calculate the beam drive waveform of a standing-wave cavity given the intra-pulse half-bandwidth and detuning.

Refer to the paper “Geng Z (2017a) Superconducting cavity control and model identification based on active disturbance rejection control. IEEE Trans Nucl Sci 64(3):951-958”.

Parameters:
  • vc – numpy array (complex), cavity probe waveform (reference plane)

  • vf – numpy array (complex), cavity forward waveform (calibrated to the same reference plane as the cavity probe signal)

  • wh_pul – numpy array, half-bandwidth in the pulse, rad/s

  • dw_pul – numpy array, detuning in the pulse, rad/s

  • half_bw – float, half bandwidth of the cavity (derived from early part of decay), rad/s

  • Ts – float, sampling time, s

  • beta – float, input coupling factor (needed for NC cavities; for SC cavities, can use the default value, or you can specify it if more accurate calibration is needed)

  • pole_scale – float, scale of the cavity half-bandwidth for the observer pole, it should be tens of times of the closed-loop bandwidth of the cavity

Returns:
  • status – boolean, success (True) or fail (False)

  • vb_est – numpy array (complex), beam drive waveform (estimated by observer)

  • vc_est – numpy array (complex), cavity probe waveform (estimated by observer)

  • f_est – numpy array (complex), general disturbance WF (estimated by observer)

cav_drv_est(vc, half_bw, Ts, detuning=0.0, beta=10000.0)[source]#

Calculate the theoritical drive waveform for the cavity probe waveform.

Parameters:
  • vc – numpy array (complex), cavity probe waveform

  • half_bw – float, half bandwidth of the cavity, rad/s

  • Ts – float, sampling time, s

  • detuning – float, detuning of the cavity, rad/s

  • beta – float, input coupling factor (needed for NC cavities; for SC cavities, can use the default value, or you can specify it if more accurate calibration is needed)

Returns:
  • status – boolean, success (True) or fail (False)

  • vf – numpy array (complex), estimated cavity drive waveform

  • vr – numpy array (complex), estimated cavity reflected waveform

Note

  1. If the cavity probe signal contains pass-band modes, better notch filter them.

  2. The estimate is useful to determine how to move the measured forward and reflected signals to align with the timing of the cavity probe signal.

cav_observer(vc, vf, half_bw, Ts, beta=10000.0, pole_scale=50)[source]#

Estimate the cavity voltage (denoised) and the general disturbance with the ADRC observer.

Refer to the paper “Geng Z (2017a) Superconducting cavity control and model identification based on active disturbance rejection control. IEEE Trans Nucl Sci 64(3):951-958”.

Parameters:
  • vc – numpy array (complex), cavity probe waveform (reference plane)

  • vf – numpy array (complex), cavity forward waveform (calibrated to the same reference plane as the cavity probe signal)

  • half_bw – float, half bandwidth of the cavity (derived from early part of decay), rad/s

  • Ts – float, sampling time, s

  • beta – float, input coupling factor (needed for NC cavities; for SC cavities, can use the default value, or you can specify it if more accurate calibration is needed)

  • pole_scale – float, scale of the cavity half-bandwidth for the observer pole, it should be tens of times of the closed-loop bandwidth of the cavity

Returns:
  • status – boolean, success (True) or fail (False)

  • vc_est – numpy array (complex), cavity probe waveform (estimated by observer)

  • f_est – numpy array (complex), general disturbance WF (estimated by observer)

cav_par_pulse(vc, vf, half_bw, Ts, beta=10000.0)[source]#

Calculate the half-bandwidth and detuning of a standing-wave cavity within an RF pulse with beam off (directly solve the cavity equation).

Refer to LLRF Book section 9.4.3.

Parameters:
  • vc – numpy array (complex), cavity probe waveform (reference plane)

  • vf – numpy array (complex), cavity forward waveform (calibrated to the same reference plan as the cavity probe signal)

  • half_bw – float, half bandwidth of the cavity (derived from early part of decay), rad/s

  • Ts – float, sampling time, s

  • beta – float, input coupling factor (needed for NC cavities; for SC cavities, can use the default value, or you can specify it if more accurate calibration is needed)

Returns:
  • status – boolean, success (True) or fail (False)

  • wh_pul – numpy array, half-bandwidth in the pulse, rad/s

  • dw_pul – numpy array, detuning in the pulse, rad/s

cav_par_pulse_obs(vc, vf, half_bw, Ts, vb=None, beta=10000.0, pole_scale=50)[source]#

Calculate the half-bandwidth and detuning of a standing-wave cavity within an RF pulse with beam on/off (use ADRC observer).

Refer to the paper “Geng Z (2017a) Superconducting cavity control and model identification based on active disturbance rejection control. IEEE Trans Nucl Sci 64(3):951-958”.

Parameters:
  • vc – numpy array (complex), cavity probe waveform (reference plane)

  • vf – numpy array (complex), cavity forward waveform (calibrated to the same reference plan as the cavity probe signal)

  • half_bw – float, half bandwidth of the cavity (derived from early part of decay), rad/s

  • Ts – float, sampling time, s

  • vb – numpy array (complex), beam drive waveform (calibrated to the same reference plan as the cavity probe signal)

  • beta – float, input coupling factor (needed for NC cavities; for SC cavities, can use the default value, or you can specify it if more accurate calibration is needed)

  • pole_scale – float, scale of the cavity half-bandwidth for the observer pole, it should be tens of times of the closed-loop bandwidth of the cavity

Returns:
  • status – boolean, success (True) or fail (False)

  • wh_pul – numpy array, half-bandwidth in the pulse, rad/s

  • dw_pul – numpy array, detuning in the pulse, rad/s

  • vc_est – numpy array (complex), cavity probe waveform (estimated by observer)

  • f_est – numpy array (complex), general disturbance WF (estimated by observer)

detuning_decay(pha_wf_deg, decay_ids, decay_ide, Ts)[source]#

Calculate the detuning of a standing-wave cavity from RF pulse decay.

Refer to LLRF Book section 9.4.3.

Parameters:
  • pha_wf_deg – numpy array, phase waveform, deg

  • decay_ids – int, starting index of calc window

  • decay_ide – int, ending index of calc window

  • Ts – float, sampling time, s

Returns:
  • status – boolean, ‘True’ for successful calculation

  • detuning – float, detuning, rad/s

etfe(u, y, r=1, exclude_transient=True, transient_batch_num=1, fs=1.0)[source]#

Implement the Empirical Transfer Function Estimation (ETFE).

Parameters:
  • u – numpy array, system input waveform

  • y – numpy array, system output waveform

  • r – int, periods (number of batches) in the waveform

  • exclude_transient – boolean, True to exclude the transient (the first transient_batch_num batches will be excluded from calculation)

  • transient_batch_num – int, number of transient batches

  • fs – float, sampling frequency, Hz

Returns:
  • status – boolean, True for success

  • freq – numpy array, frequency vector

  • G – numpy array (complex), frequency response of the system

  • u_fft – numpy array (complex), spectrum of the input waveform

  • y_fft – numpy array (complex), spectrum of the output waveform

half_bw_decay(amp_wf, decay_ids, decay_ide, Ts)[source]#

Calculate the half-bandwidth of a standing-wave cavity from RF pulse decay.

Refer to LLRF Book section 9.4.3.

Parameters:
  • amp_wf – numpy array, amplitude waveform

  • decay_ids – int, starting index of calc window

  • decay_ide – int, ending index of calc window

  • Ts – float, sampling time, s

Returns:
  • status – boolean, ‘True’ for successful calculation

  • half_bw – float, half bandwidth, rad/s

iden_impulse(U, Y, order=20)[source]#

Identify the impulse response using the input-output data.

Parameters:
  • U – numpy array (complex), input waveforms

  • Y – numpy array (complex), output waveforms

  • order – int, order of the impulse response

Returns:
  • status – boolean, success (True) or fail (False)

  • h – numpy array (complex), impulse response

prbs(n, lower_b=-1.0, upper_b=1.0)[source]#
Generate prbs signal (PRBS monic polynomials)
  • PRBS3   = x^3 + x^2 + 1

  • PRBS4   = x^4 + x^3 + 1

  • PRBS5   = x^5 + x^3 + 1

  • PRBS6   = x^6 + x^5 + 1

  • PRBS7   = x^7 + x^6 + 1

  • PRBS8   = x^8 + x^6 + x^5 + x^4 + 1

  • PRBS9   = x^9 + x^5 + 1

  • PRBS10  = x^10 + x^7 + 1

  • PRBS11  = x^11 + x^9 + 1

  • PRBS12  = x^12 + x^11 + x^10 + x^4 + 1

  • PRBS13  = x^13 + x^12 + x^11 + x^8 + 1

  • PRBS14  = x^14 + x^13 + x^12 + x^2 + 1

  • PRBS15  = x^15 + x^14 + 1

  • PRBS16  = x^16 + x^14 + x^13 + x^11 + 1

  • PRBS17  = x^17 + x^14 + 1

  • PRBS18  = x^18 + x^11 + 1

  • PRBS19  = x^19 + x^18 + x^17 + x^14 + 1

  • PRBS20  = x^20 + x^3 + 1

  • PRBS23  = x^23 + x^18 + 1

  • PRBS31  = x^31 + x^28 + 1

Parameters:
  • n – int, number of point

  • lower_b – float, lower boundary

  • upper_b – float, upper boundary

Returns:
  • status – good or not

  • data – numpy array, 1-D array of PRBS signal