new channel mode

This commit is contained in:
awe
2026-04-10 19:18:38 +03:00
parent 3cd29c60d6
commit 709976c527
2 changed files with 112 additions and 4 deletions

View File

@ -412,6 +412,30 @@ def resolve_visible_aux_curves(aux_curves: SweepAuxCurves, enabled: bool) -> Swe
return aux_1_arr, aux_2_arr
def resolve_visible_raw_plot_curves(
raw_sweep: Optional[np.ndarray],
aux_curves: SweepAuxCurves,
*,
channel_pair_raw_mode: bool,
parsed_data_enabled: bool,
) -> Tuple[Optional[np.ndarray], SweepAuxCurves]:
"""Resolve visible series for the raw plot depending on current input mode."""
raw_arr = None
if raw_sweep is not None:
candidate = np.asarray(raw_sweep, dtype=np.float32).reshape(-1)
if candidate.size > 0:
raw_arr = candidate
if channel_pair_raw_mode:
visible_aux = resolve_visible_aux_curves(aux_curves, enabled=True)
if visible_aux is not None:
return None, visible_aux
return raw_arr, None
visible_aux = resolve_visible_aux_curves(aux_curves, enabled=parsed_data_enabled)
return raw_arr, visible_aux
def decimate_curve_for_display(
xs: Optional[np.ndarray],
ys: Optional[np.ndarray],
@ -534,6 +558,7 @@ def run_pyqtgraph(args) -> None:
or getattr(args, "parser_16_bit_x2", False)
or getattr(args, "parser_test", False)
)
channel_pair_raw_mode = bool(getattr(args, "bin_mode", False) and (not complex_sweep_mode))
if not sys.platform.startswith("win"):
display_name = os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY")
if not display_name:
@ -762,6 +787,12 @@ def run_pyqtgraph(args) -> None:
parsed_data_cb.setText("Сырые Re/Im")
except Exception:
pass
if channel_pair_raw_mode:
try:
parsed_data_cb.setEnabled(False)
parsed_data_cb.setToolTip("В режиме CH1/CH2 каналы отображаются всегда.")
except Exception:
pass
fft_curve_group = QtWidgets.QGroupBox("FFT кривые")
fft_curve_layout = QtWidgets.QVBoxLayout(fft_curve_group)
fft_curve_layout.setContentsMargins(6, 6, 6, 6)
@ -1656,10 +1687,15 @@ def run_pyqtgraph(args) -> None:
else (runtime.calib_envelope.size if runtime.calib_envelope is not None else 0)
)
displayed_calib = None
displayed_aux = resolve_visible_aux_curves(runtime.current_aux_curves, parsed_data_enabled)
displayed_raw, displayed_aux = resolve_visible_raw_plot_curves(
runtime.current_sweep_raw,
runtime.current_aux_curves,
channel_pair_raw_mode=channel_pair_raw_mode,
parsed_data_enabled=parsed_data_enabled,
)
if runtime.current_sweep_raw is not None:
raw_x, raw_y = decimate_curve_for_display(xs, runtime.current_sweep_raw)
if displayed_raw is not None:
raw_x, raw_y = decimate_curve_for_display(xs, displayed_raw)
raw_x, raw_y = sanitize_curve_data_for_display(raw_x, raw_y)
curve.setData(raw_x, raw_y, autoDownsample=False)
else:
@ -1701,7 +1737,7 @@ def run_pyqtgraph(args) -> None:
if fixed_ylim is None:
y_series = [
runtime.current_sweep_raw,
displayed_raw,
displayed_aux[0] if displayed_aux is not None else None,
displayed_aux[1] if displayed_aux is not None else None,
displayed_calib,

View File

@ -19,6 +19,7 @@ from rfg_adc_plotter.gui.pyqtgraph_backend import (
sanitize_curve_data_for_display,
sanitize_image_for_display,
set_image_rect_if_ready,
resolve_visible_raw_plot_curves,
resolve_visible_fft_curves,
resolve_visible_aux_curves,
)
@ -214,6 +215,77 @@ class ProcessingTests(unittest.TestCase):
self.assertTrue(np.allclose(visible[0], aux[0]))
self.assertTrue(np.allclose(visible[1], aux[1]))
def test_resolve_visible_raw_plot_curves_channel_pair_mode_prefers_aux(self):
raw = np.asarray([10.0, 11.0], dtype=np.float32)
aux = (
np.asarray([1.0, 2.0], dtype=np.float32),
np.asarray([3.0, 4.0], dtype=np.float32),
)
visible_raw, visible_aux = resolve_visible_raw_plot_curves(
raw,
aux,
channel_pair_raw_mode=True,
parsed_data_enabled=False,
)
self.assertIsNone(visible_raw)
self.assertIsNotNone(visible_aux)
self.assertTrue(np.allclose(visible_aux[0], aux[0]))
self.assertTrue(np.allclose(visible_aux[1], aux[1]))
def test_resolve_visible_raw_plot_curves_channel_pair_mode_falls_back_to_raw(self):
raw = np.asarray([10.0, 11.0], dtype=np.float32)
visible_raw, visible_aux = resolve_visible_raw_plot_curves(
raw,
None,
channel_pair_raw_mode=True,
parsed_data_enabled=False,
)
self.assertIsNotNone(visible_raw)
self.assertTrue(np.allclose(visible_raw, raw))
self.assertIsNone(visible_aux)
def test_resolve_visible_raw_plot_curves_non_channel_pair_hides_aux_when_checkbox_off(self):
raw = np.asarray([10.0, 11.0], dtype=np.float32)
aux = (
np.asarray([1.0, 2.0], dtype=np.float32),
np.asarray([3.0, 4.0], dtype=np.float32),
)
visible_raw, visible_aux = resolve_visible_raw_plot_curves(
raw,
aux,
channel_pair_raw_mode=False,
parsed_data_enabled=False,
)
self.assertIsNotNone(visible_raw)
self.assertTrue(np.allclose(visible_raw, raw))
self.assertIsNone(visible_aux)
def test_resolve_visible_raw_plot_curves_non_channel_pair_shows_aux_when_checkbox_on(self):
raw = np.asarray([10.0, 11.0], dtype=np.float32)
aux = (
np.asarray([1.0, 2.0], dtype=np.float32),
np.asarray([3.0, 4.0], dtype=np.float32),
)
visible_raw, visible_aux = resolve_visible_raw_plot_curves(
raw,
aux,
channel_pair_raw_mode=False,
parsed_data_enabled=True,
)
self.assertIsNotNone(visible_raw)
self.assertTrue(np.allclose(visible_raw, raw))
self.assertIsNotNone(visible_aux)
self.assertTrue(np.allclose(visible_aux[0], aux[0]))
self.assertTrue(np.allclose(visible_aux[1], aux[1]))
def test_decimate_curve_for_display_preserves_small_series(self):
xs = np.linspace(3.3, 14.3, 64, dtype=np.float64)
ys = np.linspace(-1.0, 1.0, 64, dtype=np.float32)