added s11!

This commit is contained in:
Ayzen
2026-03-26 18:29:42 +03:00
parent 9ddbde22bd
commit 077542cbd0
43 changed files with 713 additions and 347 deletions
+2 -1
View File
@@ -32,10 +32,11 @@ class ComboKey:
@dataclass(slots=True)
class TraceData:
"""One frequency-domain S21 trace for a specific switch combination."""
"""One frequency-domain trace set for a specific switch combination."""
combo: ComboKey
frequency_hz: np.ndarray
s11: np.ndarray
s21: np.ndarray
+59 -44
View File
@@ -8,6 +8,7 @@ from python_app.models.run_config_schema import (
ComboModel,
GprRxGeometryModel,
GprTxGeometryModel,
PreprocessAssetModel,
RunConfigModel,
)
from python_app.models.run_config_validation import load_ring_payload, load_switch_payload, validate_gpr_model
@@ -22,6 +23,12 @@ def _as_dict(value: Any, context: str) -> dict[str, Any]:
return value
def _load_preprocess_asset(payload: dict[str, Any], target: PreprocessAssetModel) -> None:
"""Load preprocess asset fields into target model."""
target.set_name = str(payload.get("set_name", target.set_name))
target.bundle_path = str(payload.get("bundle_path", target.bundle_path))
def run_config_from_dict(payload: dict[str, Any]) -> RunConfigModel:
"""Decode JSON-like payload into :class:`RunConfigModel`."""
# Schema carries only minimal-safe fallbacks; operational defaults live in run_config.json.
@@ -65,47 +72,33 @@ def run_config_from_dict(payload: dict[str, Any]) -> RunConfigModel:
run_payload.get("processing_live_config_path", model.runtime.processing_live_config_path)
)
model.preprocess.s21_calibration_set = str(
preprocess_payload.get("s21_calibration_set", model.preprocess.s21_calibration_set)
s21_preprocess_payload = _as_dict(preprocess_payload.get("s21"), "preprocess.s21")
_load_preprocess_asset(
_as_dict(s21_preprocess_payload.get("calibration"), "preprocess.s21.calibration"),
model.preprocess.s21.calibration,
)
model.preprocess.s21_reference_set = str(
preprocess_payload.get("s21_reference_set", model.preprocess.s21_reference_set)
_load_preprocess_asset(
_as_dict(s21_preprocess_payload.get("reference"), "preprocess.s21.reference"),
model.preprocess.s21.reference,
)
model.preprocess.s21_calibration_bundle_path = str(
preprocess_payload.get(
"s21_calibration_bundle_path",
model.preprocess.s21_calibration_bundle_path,
)
s11_preprocess_payload = _as_dict(preprocess_payload.get("s11"), "preprocess.s11")
s11_calibration_payload = _as_dict(s11_preprocess_payload.get("calibration"), "preprocess.s11.calibration")
_load_preprocess_asset(
_as_dict(s11_calibration_payload.get("open"), "preprocess.s11.calibration.open"),
model.preprocess.s11.calibration.open,
)
model.preprocess.s21_reference_bundle_path = str(
preprocess_payload.get(
"s21_reference_bundle_path",
model.preprocess.s21_reference_bundle_path,
)
_load_preprocess_asset(
_as_dict(s11_calibration_payload.get("short"), "preprocess.s11.calibration.short"),
model.preprocess.s11.calibration.short,
)
model.preprocess.s11_open_calibration_bundle_path = str(
preprocess_payload.get(
"s11_open_calibration_bundle_path",
model.preprocess.s11_open_calibration_bundle_path,
)
_load_preprocess_asset(
_as_dict(s11_calibration_payload.get("load"), "preprocess.s11.calibration.load"),
model.preprocess.s11.calibration.load,
)
model.preprocess.s11_short_calibration_bundle_path = str(
preprocess_payload.get(
"s11_short_calibration_bundle_path",
model.preprocess.s11_short_calibration_bundle_path,
)
)
model.preprocess.s11_load_calibration_bundle_path = str(
preprocess_payload.get(
"s11_load_calibration_bundle_path",
model.preprocess.s11_load_calibration_bundle_path,
)
)
model.preprocess.s11_reference_bundle_path = str(
preprocess_payload.get(
"s11_reference_bundle_path",
model.preprocess.s11_reference_bundle_path,
)
_load_preprocess_asset(
_as_dict(s11_preprocess_payload.get("reference"), "preprocess.s11.reference"),
model.preprocess.s11.reference,
)
model.gpr.mode = str(gpr_payload.get("mode", model.gpr.mode))
@@ -213,14 +206,36 @@ def run_config_to_dict(model: RunConfigModel) -> dict[str, Any]:
"combos": [{"input": combo.input, "output": combo.output} for combo in model.combos],
},
"preprocess": {
"s21_calibration_set": model.preprocess.s21_calibration_set,
"s21_reference_set": model.preprocess.s21_reference_set,
"s21_calibration_bundle_path": model.preprocess.s21_calibration_bundle_path,
"s21_reference_bundle_path": model.preprocess.s21_reference_bundle_path,
"s11_open_calibration_bundle_path": model.preprocess.s11_open_calibration_bundle_path,
"s11_short_calibration_bundle_path": model.preprocess.s11_short_calibration_bundle_path,
"s11_load_calibration_bundle_path": model.preprocess.s11_load_calibration_bundle_path,
"s11_reference_bundle_path": model.preprocess.s11_reference_bundle_path,
"s21": {
"calibration": {
"set_name": model.preprocess.s21.calibration.set_name,
"bundle_path": model.preprocess.s21.calibration.bundle_path,
},
"reference": {
"set_name": model.preprocess.s21.reference.set_name,
"bundle_path": model.preprocess.s21.reference.bundle_path,
},
},
"s11": {
"calibration": {
"open": {
"set_name": model.preprocess.s11.calibration.open.set_name,
"bundle_path": model.preprocess.s11.calibration.open.bundle_path,
},
"short": {
"set_name": model.preprocess.s11.calibration.short.set_name,
"bundle_path": model.preprocess.s11.calibration.short.bundle_path,
},
"load": {
"set_name": model.preprocess.s11.calibration.load.set_name,
"bundle_path": model.preprocess.s11.calibration.load.bundle_path,
},
},
"reference": {
"set_name": model.preprocess.s11.reference.set_name,
"bundle_path": model.preprocess.s11.reference.bundle_path,
},
},
},
"gpr": {
"mode": model.gpr.mode,
+8
View File
@@ -6,6 +6,7 @@ from python_app.models.run_config_schema import (
GprModel,
GprRxGeometryModel,
GprTxGeometryModel,
PreprocessAssetModel,
PreprocessModel,
RadarModel,
RadarSweepModel,
@@ -13,6 +14,9 @@ from python_app.models.run_config_schema import (
RingsModel,
RunConfigModel,
RuntimeModel,
S11CalibrationModel,
S11PreprocessModel,
S21PreprocessModel,
SwitchModel,
)
from python_app.models.run_config_validation import (
@@ -26,6 +30,7 @@ __all__ = [
"GprModel",
"GprRxGeometryModel",
"GprTxGeometryModel",
"PreprocessAssetModel",
"PreprocessModel",
"RadarModel",
"RadarSweepModel",
@@ -33,6 +38,9 @@ __all__ = [
"RingsModel",
"RunConfigModel",
"RuntimeModel",
"S11CalibrationModel",
"S11PreprocessModel",
"S21PreprocessModel",
"SwitchModel",
"load_ring_payload",
"load_switch_payload",
+35 -8
View File
@@ -85,18 +85,45 @@ class RuntimeModel:
processing_live_config_path: str = ""
@dataclass(slots=True)
class PreprocessAssetModel:
"""One preprocessing asset selected for live acquisition."""
set_name: str = ""
bundle_path: str = ""
@dataclass(slots=True)
class S21PreprocessModel:
"""Two-port S21 preprocessing assets."""
calibration: PreprocessAssetModel = field(default_factory=PreprocessAssetModel)
reference: PreprocessAssetModel = field(default_factory=PreprocessAssetModel)
@dataclass(slots=True)
class S11CalibrationModel:
"""One-port S11 OSL calibration assets."""
open: PreprocessAssetModel = field(default_factory=PreprocessAssetModel)
short: PreprocessAssetModel = field(default_factory=PreprocessAssetModel)
load: PreprocessAssetModel = field(default_factory=PreprocessAssetModel)
@dataclass(slots=True)
class S11PreprocessModel:
"""One-port S11 preprocessing assets."""
calibration: S11CalibrationModel = field(default_factory=S11CalibrationModel)
reference: PreprocessAssetModel = field(default_factory=PreprocessAssetModel)
@dataclass(slots=True)
class PreprocessModel:
"""Selected preprocessing artifacts for live acquisition."""
s21_calibration_set: str = ""
s21_reference_set: str = ""
s21_calibration_bundle_path: str = ""
s21_reference_bundle_path: str = ""
s11_open_calibration_bundle_path: str = ""
s11_short_calibration_bundle_path: str = ""
s11_load_calibration_bundle_path: str = ""
s11_reference_bundle_path: str = ""
s21: S21PreprocessModel = field(default_factory=S21PreprocessModel)
s11: S11PreprocessModel = field(default_factory=S11PreprocessModel)
@dataclass(slots=True)