Rework radar system
This commit is contained in:
@@ -2,38 +2,14 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from python_app.models.run_config_schema import PreprocessAssetModel, RunConfigModel
|
||||
|
||||
from python_app.models.run_config_model import PreprocessAssetModel, RunConfigModel
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class PreprocessAssetSpec:
|
||||
"""Stable description of one preprocess asset."""
|
||||
|
||||
display_name: str
|
||||
set_kind: str
|
||||
runtime_filename: str
|
||||
channel: str
|
||||
|
||||
|
||||
PREPROCESS_ASSET_SPECS = {
|
||||
"s21_calibration": PreprocessAssetSpec("S21 Calibration", "s21_calibration", "s21_calibration_bundle.bin", "s21"),
|
||||
"s21_reference": PreprocessAssetSpec("S21 Reference", "s21_reference", "s21_reference_bundle.bin", "s21"),
|
||||
"s21_object_calibration": PreprocessAssetSpec("Object Calibration", "s21_object_calibration", "s21_object_calibration_bundle.bin", "s21"),
|
||||
"s11_open": PreprocessAssetSpec("S11 Open", "s11_open", "s11_open_calibration_bundle.bin", "s11"),
|
||||
"s11_short": PreprocessAssetSpec("S11 Short", "s11_short", "s11_short_calibration_bundle.bin", "s11"),
|
||||
"s11_load": PreprocessAssetSpec("S11 Load", "s11_load", "s11_load_calibration_bundle.bin", "s11"),
|
||||
"s11_reference": PreprocessAssetSpec("S11 Reference", "s11_reference", "s11_reference_bundle.bin", "s11"),
|
||||
PREPROCESS_ASSET_NAMES = {
|
||||
"s21_calibration": "S21 Calibration",
|
||||
"s21_reference": "S21 Reference",
|
||||
"s21_object_calibration": "Object Calibration",
|
||||
}
|
||||
|
||||
PREPROCESS_ASSET_KEYS = tuple(PREPROCESS_ASSET_SPECS.keys())
|
||||
S21_PREPROCESS_ASSET_KEYS = ("s21_calibration", "s21_reference")
|
||||
S11_PREPROCESS_ASSET_KEYS = ("s11_open", "s11_short", "s11_load", "s11_reference")
|
||||
S11_PREPROCESS_CALIBRATION_KEYS = ("s11_open", "s11_short", "s11_load")
|
||||
VISIBLE_PREPROCESS_ASSET_KEYS = (*S21_PREPROCESS_ASSET_KEYS, "s21_object_calibration")
|
||||
CAPTURABLE_PREPROCESS_ASSET_KEYS = S21_PREPROCESS_ASSET_KEYS
|
||||
REQUIRED_PREPROCESS_ASSET_KEYS = S21_PREPROCESS_ASSET_KEYS
|
||||
REQUIRED_PREPROCESS_ASSET_KEYS = ("s21_calibration", "s21_reference")
|
||||
|
||||
|
||||
def preprocess_asset_model(config: RunConfigModel, key: str) -> PreprocessAssetModel:
|
||||
@@ -44,46 +20,16 @@ def preprocess_asset_model(config: RunConfigModel, key: str) -> PreprocessAssetM
|
||||
return config.preprocess.s21.reference
|
||||
if key == "s21_object_calibration":
|
||||
return config.preprocess.s21.object_calibration
|
||||
if key == "s11_open":
|
||||
return config.preprocess.s11.calibration.open
|
||||
if key == "s11_short":
|
||||
return config.preprocess.s11.calibration.short
|
||||
if key == "s11_load":
|
||||
return config.preprocess.s11.calibration.load
|
||||
if key == "s11_reference":
|
||||
return config.preprocess.s11.reference
|
||||
raise KeyError(f"Unknown preprocess asset key: {key}")
|
||||
|
||||
|
||||
def preprocess_asset_display_name(key: str) -> str:
|
||||
"""Return human-readable label for preprocess asset."""
|
||||
return PREPROCESS_ASSET_SPECS[key].display_name
|
||||
|
||||
|
||||
def preprocess_asset_channel(key: str) -> str:
|
||||
"""Return associated trace channel for preprocess asset."""
|
||||
return PREPROCESS_ASSET_SPECS[key].channel
|
||||
|
||||
|
||||
def preprocess_asset_set_name(config: RunConfigModel, key: str) -> str:
|
||||
"""Return normalized selected set name for one preprocess asset."""
|
||||
return str(preprocess_asset_model(config, key).set_name).strip()
|
||||
return PREPROCESS_ASSET_NAMES[key]
|
||||
|
||||
|
||||
def runtime_preprocess_asset_keys(config: RunConfigModel) -> tuple[str, ...]:
|
||||
"""Return preprocess assets that should be exported and validated for runtime."""
|
||||
enabled_keys: list[str] = list(REQUIRED_PREPROCESS_ASSET_KEYS)
|
||||
if preprocess_asset_set_name(config, "s21_object_calibration"):
|
||||
enabled_keys.append("s21_object_calibration")
|
||||
|
||||
has_full_s11_calibration = all(
|
||||
preprocess_asset_set_name(config, key)
|
||||
for key in S11_PREPROCESS_CALIBRATION_KEYS
|
||||
)
|
||||
if not has_full_s11_calibration:
|
||||
return tuple(enabled_keys)
|
||||
|
||||
enabled_keys.extend(S11_PREPROCESS_CALIBRATION_KEYS)
|
||||
if preprocess_asset_set_name(config, "s11_reference"):
|
||||
enabled_keys.append("s11_reference")
|
||||
return tuple(enabled_keys)
|
||||
"""The through/reference pair plus the selected optional object correction."""
|
||||
return (*REQUIRED_PREPROCESS_ASSET_KEYS, "s21_object_calibration") if (
|
||||
config.preprocess.s21.object_calibration.set_name.strip()
|
||||
) else REQUIRED_PREPROCESS_ASSET_KEYS
|
||||
|
||||
Reference in New Issue
Block a user