WIP on normaliser: 2e6ad24 ad to gitignore

This commit is contained in:
2026-02-20 20:32:02 +03:00
7 changed files with 116 additions and 23 deletions

View File

@ -9,7 +9,7 @@ from typing import Optional
import numpy as np
from rfg_adc_plotter.constants import DATA_INVERSION_THRESHOLD
from rfg_adc_plotter.constants import DATA_INVERSION_THRESHOLD, LOG_EXP
from rfg_adc_plotter.io.serial_source import SerialChunkReader, SerialLineSource
from rfg_adc_plotter.types import SweepInfo, SweepPacket
@ -25,6 +25,7 @@ class SweepReader(threading.Thread):
stop_event: threading.Event,
fancy: bool = False,
bin_mode: bool = False,
logscale: bool = False,
):
super().__init__(daemon=True)
self._port_path = port_path
@ -34,6 +35,7 @@ class SweepReader(threading.Thread):
self._src: Optional[SerialLineSource] = None
self._fancy = bool(fancy)
self._bin_mode = bool(bin_mode)
self._logscale = bool(logscale)
self._max_width: int = 0
self._sweep_idx: int = 0
self._last_sweep_ts: Optional[float] = None
@ -92,6 +94,16 @@ class SweepReader(threading.Thread):
except Exception:
pass
pre_exp_sweep = None
if self._logscale:
try:
pre_exp_sweep = sweep.copy()
with np.errstate(over="ignore", invalid="ignore"):
sweep = np.power(LOG_EXP, np.asarray(sweep, dtype=np.float64)).astype(np.float32)
sweep[~np.isfinite(sweep)] = np.nan
except Exception:
pass
self._sweep_idx += 1
if len(ch_list) > 1:
sys.stderr.write(
@ -129,6 +141,8 @@ class SweepReader(threading.Thread):
"std": std,
"dt_ms": dt_ms,
}
if pre_exp_sweep is not None:
info["pre_exp_sweep"] = pre_exp_sweep
try:
self._q.put_nowait((sweep, info))