From 1fd0f05d665c3db7593e1dd6a67081f64d0de7be Mon Sep 17 00:00:00 2001 From: awe Date: Tue, 9 Jun 2026 18:56:40 +0300 Subject: [PATCH] fix second graph --- rfg_vna_viewer.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/rfg_vna_viewer.py b/rfg_vna_viewer.py index ed2e796..1555bb3 100644 --- a/rfg_vna_viewer.py +++ b/rfg_vna_viewer.py @@ -134,13 +134,12 @@ 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 ch1/ch2 individually by ref amplitude + # Normalize by ref amplitude and subtract ref phase ref_amp_safe = np.where(ref_amplitude > 1e-12, ref_amplitude, 1e-12) - norm_ch1 = ch1_v / ref_amp_safe - norm_ch2 = ch2_v / ref_amp_safe + z_norm = (ch1_v / ref_amp_safe + 1j * ch2_v / ref_amp_safe) * np.exp(-1j * ref_phase_aligned) - # Build normalized complex signal and subtract ref phase - z_norm = (norm_ch1 + 1j * norm_ch2) * np.exp(-1j * ref_phase_aligned) + norm_ch1 = np.real(z_norm) + norm_ch2 = np.imag(z_norm) amp_norm = np.abs(z_norm) phase_norm = np.unwrap(np.angle(z_norm))