diff --git a/rfg_adc_plotter/gui/pyqtgraph_backend.py b/rfg_adc_plotter/gui/pyqtgraph_backend.py index 3b01411..8c79789 100644 --- a/rfg_adc_plotter/gui/pyqtgraph_backend.py +++ b/rfg_adc_plotter/gui/pyqtgraph_backend.py @@ -3172,11 +3172,14 @@ def run_pyqtgraph(args) -> None: levels = compute_background_subtracted_bscan_levels(disp_fft_lin, disp_fft) if levels is None: try: - mean_spec = np.nanmean(disp_fft, axis=1) - vmin_v = float(np.nanmin(mean_spec)) - vmax_v = float(np.nanmax(mean_spec)) - if np.isfinite(vmin_v) and np.isfinite(vmax_v) and vmin_v != vmax_v: - levels = (vmin_v, vmax_v) + finite_rows = np.any(np.isfinite(disp_fft), axis=1) + if np.any(finite_rows): + mean_spec = np.nanmean(disp_fft[finite_rows], axis=1) + if mean_spec.size > 0: + vmin_v = float(np.nanmin(mean_spec)) + vmax_v = float(np.nanmax(mean_spec)) + if np.isfinite(vmin_v) and np.isfinite(vmax_v) and vmin_v != vmax_v: + levels = (vmin_v, vmax_v) except Exception: levels = None if levels is None and spec_clip is not None: