new method

This commit is contained in:
awe
2026-06-09 18:54:24 +03:00
parent fe775f8ff1
commit 8104ba6581

View File

@ -110,10 +110,10 @@ def extract_sweep(packet):
# ---------------------------------------------------------------------------
# Signal processing
# ---------------------------------------------------------------------------
def process_reference(ref_ch1, ref_ch2, freqs_hz):
"""Process reference channel: amplitude, phase aligned to first point.
def process_reference(ref_ch1, ref_ch2):
"""Process reference channel: amplitude and phase.
Returns (amplitude, aligned_phase).
Returns (amplitude, phase).
"""
ch1_v = ref_ch1 * TTY_SCALE
ch2_v = ref_ch2 * TTY_SCALE
@ -121,11 +121,7 @@ def process_reference(ref_ch1, ref_ch2, freqs_hz):
amplitude = np.sqrt(ch1_v ** 2 + ch2_v ** 2)
phase = np.unwrap(np.arctan2(ch2_v, ch1_v))
# Align phase to first point of this sweep, scaled by frequency
correction = phase[0] * (freqs_hz / freqs_hz[0])
aligned = phase - correction
return amplitude, aligned
return amplitude, phase
def process_main(main_ch1, main_ch2, ref_amplitude, ref_phase_aligned):
@ -274,7 +270,7 @@ def make_update(reader, parser, assembler, curves, plots):
freqs_hz = freqs_ghz * 1e9
ref_amp, ref_phase = process_reference(
sweep["ref_ch1"], sweep["ref_ch2"], freqs_hz
sweep["ref_ch1"], sweep["ref_ch2"]
)
main_amp, ref_amplitude, norm_ch1, norm_ch2, norm_amp, phase, fft_mag, fft_dist = process_main(