Rework radar system
This commit is contained in:
@@ -10,7 +10,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from python_app.models.run_config_model import RunConfigModel
|
||||
from python_app.models.run_config_schema import RunConfigModel
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
|
||||
import numpy as np
|
||||
from numpy.typing import NDArray
|
||||
|
||||
from python_app.models.run_config_schema import KamilAdcModel
|
||||
|
||||
@@ -189,7 +190,7 @@ class KamilAdcSweepProcessor:
|
||||
return phase + shift, anchor + shift
|
||||
return phase, anchor
|
||||
|
||||
def process(self, main: np.ndarray, reference: np.ndarray) -> np.ndarray | None:
|
||||
def process(self, main: np.ndarray, reference: np.ndarray) -> NDArray[np.complex64] | None:
|
||||
"""Return the S21 trace resampled onto the fixed grid, or ``None`` to reject.
|
||||
|
||||
``main`` and ``reference`` are equal-length complex arrays ordered by
|
||||
|
||||
@@ -24,6 +24,7 @@ from dataclasses import dataclass
|
||||
import struct
|
||||
|
||||
import numpy as np
|
||||
from numpy.typing import NDArray
|
||||
|
||||
# Wire-format constants.
|
||||
FRAME_BYTES = 8
|
||||
@@ -55,9 +56,9 @@ class RawSweep:
|
||||
samples at those steps. All three arrays share the same length.
|
||||
"""
|
||||
|
||||
steps: np.ndarray
|
||||
main: np.ndarray
|
||||
reference: np.ndarray
|
||||
steps: NDArray[np.int32]
|
||||
main: NDArray[np.complex64]
|
||||
reference: NDArray[np.complex64]
|
||||
combo: tuple[int, int] | None = None
|
||||
dirty: bool = False
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ from python_app.hardware_full.kamil_adc.tty_reader import (
|
||||
raise_if_process_exited,
|
||||
)
|
||||
from python_app.hardware_full.librevna_driver.models import SweepResult
|
||||
from python_app.models.run_config_model import RadarSweepModel, RunConfigModel
|
||||
from python_app.models.dataset_model import ComboKey
|
||||
from python_app.models.run_config_schema import RadarSweepModel, RunConfigModel
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -178,12 +179,15 @@ class KamilAdcService:
|
||||
return SweepResult(
|
||||
x=grid.copy(),
|
||||
traces={
|
||||
"s11": np.zeros(points, dtype=np.complex64),
|
||||
"s21": s21,
|
||||
},
|
||||
)
|
||||
self._log_rejected_sweep(raw)
|
||||
|
||||
def prepare_combo(self, combo: ComboKey) -> None:
|
||||
"""Discard buffered sweeps that predate or straddle the physical switch."""
|
||||
self.drain_after_switch()
|
||||
|
||||
def drain_after_switch(self, sweeps: int = _SWITCH_DRAIN_SWEEPS) -> None:
|
||||
"""Discard sweeps captured before / across a just-applied switch change.
|
||||
|
||||
@@ -362,9 +366,10 @@ class KamilAdcService:
|
||||
self._rejected_count += 1
|
||||
if self._rejected_count != 1 and self._rejected_count % _REJECT_LOG_EVERY != 0:
|
||||
return
|
||||
params = self._processor.params # type: ignore[union-attr]
|
||||
assert self._processor is not None
|
||||
params = self._processor.params
|
||||
try:
|
||||
freqs = self._processor.reference_frequency_axis(raw.reference) # type: ignore[union-attr]
|
||||
freqs = self._processor.reference_frequency_axis(raw.reference)
|
||||
covered = f"[{float(np.min(freqs)):.6g}, {float(np.max(freqs)):.6g}]"
|
||||
except Exception: # noqa: BLE001 — diagnostics must never raise
|
||||
covered = "<unavailable>"
|
||||
|
||||
Reference in New Issue
Block a user