1 sweep per plot

This commit is contained in:
awe
2026-06-09 17:53:04 +03:00
parent 83c83262d4
commit 712bc16571

View File

@ -9,6 +9,7 @@ normalization and plots amplitude, phase, and FFT in real time.
import os import os
import signal import signal
import sys import sys
from collections import deque
import numpy as np import numpy as np
import pyqtgraph as pg import pyqtgraph as pg
@ -154,7 +155,8 @@ class SweepAccumulator:
# Keep only points present in both channels # Keep only points present in both channels
valid = np.isfinite(main_ch1) & np.isfinite(ref_ch1) valid = np.isfinite(main_ch1) & np.isfinite(ref_ch1)
if valid.sum() < 2: nvalid = int(valid.sum())
if nvalid < MIN_SWEEP_POINTS:
return None return None
return { return {
@ -162,7 +164,7 @@ class SweepAccumulator:
"main_ch2": main_ch2[valid], "main_ch2": main_ch2[valid],
"ref_ch1": ref_ch1[valid], "ref_ch1": ref_ch1[valid],
"ref_ch2": ref_ch2[valid], "ref_ch2": ref_ch2[valid],
"num_points": int(valid.sum()), "num_points": nvalid,
} }
@ -285,21 +287,23 @@ def build_gui():
def make_update(reader, accumulator, curves): def make_update(reader, accumulator, curves):
c_main_amp, c_ref_amp, c_norm_ch1, c_norm_ch2, c_norm_amp, c_ph, c_fft = curves c_main_amp, c_ref_amp, c_norm_ch1, c_norm_ch2, c_norm_amp, c_ph, c_fft = curves
state = {"ref_phase_first": None} state = {"ref_phase_first": None}
queue = deque(maxlen=64)
def update(): def update():
# Read and parse — push completed sweeps into queue
data = reader.read_available() data = reader.read_available()
if not data: if data:
return for sw in accumulator.feed(data):
queue.append(sw)
sweeps = accumulator.feed(data) # Draw exactly one sweep per tick
if not sweeps: if not queue:
return return
sweep = queue.popleft()
sweep = sweeps[-1] # latest complete sweep
n = sweep["num_points"] n = sweep["num_points"]
print(f"[VNA] sweeps_in_batch={len(sweeps)} points={n} " print(f"[VNA] queue={len(queue)} points={n} "
f"main_ch1_range=[{sweep['main_ch1'].min():.0f}..{sweep['main_ch1'].max():.0f}] " f"main=[{sweep['main_ch1'].min():.0f}..{sweep['main_ch1'].max():.0f}] "
f"ref_ch1_range=[{sweep['ref_ch1'].min():.0f}..{sweep['ref_ch1'].max():.0f}]") f"ref=[{sweep['ref_ch1'].min():.0f}..{sweep['ref_ch1'].max():.0f}]")
if n < 2: if n < 2:
return return