From 44a89b8da37717b559d314b0243bbb18740f2e7b Mon Sep 17 00:00:00 2001 From: awe Date: Fri, 10 Apr 2026 21:02:14 +0300 Subject: [PATCH] ch1 / ch2 add to pic --- rfg_adc_plotter/constants.py | 2 +- rfg_adc_plotter/gui/pyqtgraph_backend.py | 73 +++++++++++++++++++++--- 2 files changed, 65 insertions(+), 10 deletions(-) diff --git a/rfg_adc_plotter/constants.py b/rfg_adc_plotter/constants.py index cf4daa1..e3f937c 100644 --- a/rfg_adc_plotter/constants.py +++ b/rfg_adc_plotter/constants.py @@ -1,7 +1,7 @@ """Shared constants for sweep parsing and visualization.""" WF_WIDTH = 1000 -FFT_LEN = 1024 +FFT_LEN = 2048 BACKGROUND_MEDIAN_SWEEPS = 64 SWEEP_FREQ_MIN_GHZ = 3.3 diff --git a/rfg_adc_plotter/gui/pyqtgraph_backend.py b/rfg_adc_plotter/gui/pyqtgraph_backend.py index d68a8a2..1ba6042 100644 --- a/rfg_adc_plotter/gui/pyqtgraph_backend.py +++ b/rfg_adc_plotter/gui/pyqtgraph_backend.py @@ -613,16 +613,57 @@ def run_pyqtgraph(args) -> None: p_line = win.addPlot(row=0, col=0, title="Сырые данные") p_line.showGrid(x=True, y=True, alpha=0.3) curve = p_line.plot(pen=pg.mkPen((80, 120, 255), width=1)) - curve_aux_1 = p_line.plot(pen=pg.mkPen((255, 170, 40), width=1)) - curve_aux_2 = p_line.plot(pen=pg.mkPen((170, 70, 255), width=1)) + p_line_aux_vb = None + if bin_iq_power_mode: + p_line_aux_vb = pg.ViewBox() + try: + p_line.showAxis("right") + p_line.getAxis("right").setLabel("CH1/CH2") + p_line.scene().addItem(p_line_aux_vb) + p_line.getAxis("right").linkToView(p_line_aux_vb) + p_line_aux_vb.setXLink(p_line) + except Exception: + p_line_aux_vb = None + curve_aux_1 = pg.PlotDataItem(pen=pg.mkPen((255, 170, 40), width=1)) + curve_aux_2 = pg.PlotDataItem(pen=pg.mkPen((170, 70, 255), width=1)) + if p_line_aux_vb is not None: + p_line_aux_vb.addItem(curve_aux_1) + p_line_aux_vb.addItem(curve_aux_2) + else: + p_line.addItem(curve_aux_1) + p_line.addItem(curve_aux_2) + else: + curve_aux_1 = p_line.plot(pen=pg.mkPen((255, 170, 40), width=1)) + curve_aux_2 = p_line.plot(pen=pg.mkPen((170, 70, 255), width=1)) curve_calib = p_line.plot(pen=pg.mkPen((220, 60, 60), width=1)) curve_norm = p_line.plot(pen=pg.mkPen((60, 180, 90), width=1)) p_line.setLabel("bottom", "ГГц") p_line.setLabel("left", "Y") + if bin_iq_power_mode: + try: + p_line.setLabel("left", "CH1^2 + CH2^2") + except Exception: + pass ch_text = pg.TextItem("", anchor=(1, 1)) ch_text.setZValue(10) p_line.addItem(ch_text) + def sync_line_aux_view() -> None: + if p_line_aux_vb is None: + return + try: + p_line_aux_vb.setGeometry(p_line.vb.sceneBoundingRect()) + p_line_aux_vb.linkedViewChanged(p_line.vb, p_line_aux_vb.XAxis) + except Exception: + pass + + if p_line_aux_vb is not None: + try: + p_line.vb.sigResized.connect(sync_line_aux_view) + sync_line_aux_view() + except Exception: + pass + p_img = win.addPlot(row=0, col=1, title="Сырые данные водопад") p_img.invertY(False) p_img.showGrid(x=False, y=False) @@ -1717,16 +1758,30 @@ def run_pyqtgraph(args) -> None: curve_norm.setData([], []) if fixed_ylim is None: - y_series = [ - runtime.current_sweep_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, - (runtime.current_sweep_norm * norm_display_scale) if runtime.current_sweep_norm is not None else None, - ] + if bin_iq_power_mode: + y_series = [ + runtime.current_sweep_raw, + displayed_calib, + (runtime.current_sweep_norm * norm_display_scale) if runtime.current_sweep_norm is not None else None, + ] + else: + y_series = [ + runtime.current_sweep_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, + (runtime.current_sweep_norm * norm_display_scale) if runtime.current_sweep_norm is not None else None, + ] y_limits = compute_auto_ylim(*y_series) if y_limits is not None: p_line.setYRange(y_limits[0], y_limits[1], padding=0) + if p_line_aux_vb is not None: + aux_limits = compute_auto_ylim( + displayed_aux[0] if displayed_aux is not None else None, + displayed_aux[1] if displayed_aux is not None else None, + ) + if aux_limits is not None: + p_line_aux_vb.setYRange(aux_limits[0], aux_limits[1], padding=0) line_x_bounds = resolve_axis_bounds(xs) if line_x_bounds is not None: