rf_det_act#
Measure RF amplitude and phase from ADC samples.
Functions
|
A/P to I/Q waveforms. |
|
Asynchronous demodulation (need reference). |
|
I/Q to A/P waveforms. |
|
Non-I/Q demodulation. |
|
normalize phase to +-180 degree or between 0 to 360 degree. |
|
get information of a pulse. |
|
Self demodulation with Hilbert transform (later may implement padding to mitigate the edge effects). |
|
Demodulation with two points. |
- ap2iq_wf(A, P)[source]#
A/P to I/Q waveforms.
- Parameters:
A – numpy array, amplitude/phase waveforms, P in degree
P – numpy array, amplitude/phase waveforms, P in degree
- Returns:
I, Q – numpy array, I/Q waveforms
- asyn_demod(raw_wf, ref_wf)[source]#
Asynchronous demodulation (need reference).
- Parameters:
raw_wf – numpy array, signal waveform to be demodulated
ref_wf – numpy array, samples of the RF reference signal
- Returns:
status – boolean, success (True) or faile (False)
I, Q – numpy array, I/Q waveforms of final demodulation
Isig, Qsig – numpy array, I/Q waveforms of raw_wf (with inaccurate phase)
Iref, Qsig – numpy array, I/Q waveforms of ref_wf (with inaccurate phase)
- iq2ap_wf(I, Q)[source]#
I/Q to A/P waveforms.
- Parameters:
I – numpy array, I/Q waveforms
Q – numpy array, I/Q waveforms
- Returns:
A, P – numpy array, amplitude/phase waveforms, P in degree
- noniq_demod(raw_wf, n, m=1)[source]#
Non-I/Q demodulation.
Refer to LLRF Book section 5.2.2.
- Parameters:
raw_wf – numpy array, 1-D array of the raw waveform
m – integer, non-I/Q parameters (n samples cover m IF cycles)
n – integer, non-I/Q parameters (n samples cover m IF cycles)
- Returns:
status – boolean, success (True) or faile (False)
I, Q – numpy array, I/Q waveforms
- norm_phase(P, cmd='+-180')[source]#
normalize phase to +-180 degree or between 0 to 360 degree.
- Parameters:
P – float, phase in degree
cmd – string ‘+-180’ or ‘0to360’
- Returns:
Pnorm – float, normalized phase, degree
- pulse_info(pulse, threshold=0.1)[source]#
get information of a pulse.
- Parameters:
pulse – numpy array, the pulse data
threshold – float, threshold for edge detection
- Returns:
offs – int, offset id of the pulse
pulw – int, pulse width as number of samples
peak – float, peak magnitude of the pulse
- To be done:
detect the rise time and falling time
detect the flattop region and average
calculate the energy in the pulse
- self_demod_ap(raw_wf, n=1)[source]#
Self demodulation with Hilbert transform (later may implement padding to mitigate the edge effects).
- Parameters:
raw_wf – numpy array, signal waveform to be demodulated
n – int, number of points covering full cycles (for coherent sampling)
- Returns:
status – boolean, success (True) or faile (False)
A, P – numpy array, amplitude and phase waveforms, P in degree
- twop_demod(raw_wf, f_if, fs)[source]#
Demodulation with two points.
Refer to LLRF Book section 5.2.2.
- Parameters:
raw_wf – numpy array, raw waveform to be demodulated
f_if – float, IF frequency, Hz
fs – float, sampling frequency, Hz
- Returns:
status – boolean, success (True) or faile (False)
I, Q – numpy array, I/Q waveforms