abibis
This commit is contained in:
@ -134,9 +134,13 @@ def process_main(main_ch1, main_ch2, ref_amplitude, ref_phase_aligned):
|
||||
z_main = ch1_v + 1j * ch2_v
|
||||
main_amp = np.abs(z_main)
|
||||
|
||||
# Normalize by ref amplitude and subtract ref phase of first point
|
||||
ref_amp_safe = np.where(ref_amplitude > 1e-12, ref_amplitude, 1e-12)
|
||||
z_norm = (ch1_v / ref_amp_safe + 1j * ch2_v / ref_amp_safe) * np.exp(-1j * ref_phase_aligned)
|
||||
# Normalize by ref amplitude and subtract ref phase; skip where ref < epsilon
|
||||
EPS = 1e-12
|
||||
mask = ref_amplitude > EPS
|
||||
ch1_norm = np.where(mask, ch1_v / ref_amplitude, ch1_v)
|
||||
ch2_norm = np.where(mask, ch2_v / ref_amplitude, ch2_v)
|
||||
phase_corr = np.where(mask, ref_phase_aligned, 0.0)
|
||||
z_norm = (ch1_norm + 1j * ch2_norm) * np.exp(-1j * phase_corr)
|
||||
|
||||
norm_ch1 = np.real(z_norm)
|
||||
norm_ch2 = np.imag(z_norm)
|
||||
@ -239,7 +243,7 @@ def build_gui():
|
||||
# ---------------------------------------------------------------------------
|
||||
def make_update(reader, parser, assembler, curves, plots):
|
||||
c_main_amp, c_ref_amp, c_norm_ch1, c_norm_ch2, c_norm_amp, c_ph, c_ph_line, c_ph_dev, c_fft = curves
|
||||
state = {"ref_phase_first": None, "axes_locked": False}
|
||||
state = {"ref_phase_first": None, "ref_phi0": None, "ref_phi1": None, "axes_locked": False}
|
||||
queue = deque(maxlen=64)
|
||||
|
||||
def update():
|
||||
@ -269,8 +273,13 @@ def make_update(reader, parser, assembler, curves, plots):
|
||||
sweep["ref_ch1"], sweep["ref_ch2"]
|
||||
)
|
||||
|
||||
# Capture phi0, phi1 from first sweep only
|
||||
if state["ref_phi0"] is None:
|
||||
state["ref_phi0"] = ref_phase[0]
|
||||
state["ref_phi1"] = ref_phase[-1]
|
||||
|
||||
# Compute frequency axis from reference signal phase (linear phase-freq model)
|
||||
phi0, phi1 = ref_phase[0], ref_phase[-1]
|
||||
phi0, phi1 = state["ref_phi0"], state["ref_phi1"]
|
||||
freqs_ghz = (F_START_HZ / 1e9) + (ref_phase - phi0) / (phi1 - phi0) * (BW_HZ / 1e9)
|
||||
freqs_hz = freqs_ghz * 1e9
|
||||
|
||||
|
||||
Reference in New Issue
Block a user