added s11!
This commit is contained in:
@@ -24,7 +24,7 @@ from python_app.storage.store_api import StoreApi
|
||||
|
||||
|
||||
class NpzStore(StoreApi):
|
||||
"""Persist calibration/reference sets and runtime snapshots using NumPy files."""
|
||||
"""Persist preprocess sets and runtime snapshots using NumPy files."""
|
||||
|
||||
def __init__(self, root_dir: Path) -> None:
|
||||
"""Create store rooted at `root_dir`."""
|
||||
@@ -32,7 +32,7 @@ class NpzStore(StoreApi):
|
||||
self._root_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def save_set(self, kind: str, radar_key: str, set_name: str, collection: SweepCollection) -> None:
|
||||
"""Persist named calibration/reference set as NPZ and metadata JSON."""
|
||||
"""Persist named preprocess set as NPZ and metadata JSON."""
|
||||
set_dir = self._set_dir(kind, radar_key)
|
||||
set_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -45,14 +45,17 @@ class NpzStore(StoreApi):
|
||||
for trace in collection.traces:
|
||||
suffix = f"i{trace.combo.input_pos}_o{trace.combo.output_pos}"
|
||||
freq_key = f"freq_{suffix}"
|
||||
s11_key = f"s11_{suffix}"
|
||||
s21_key = f"s21_{suffix}"
|
||||
payload[freq_key] = np.asarray(trace.frequency_hz, dtype=np.float32)
|
||||
payload[s11_key] = np.asarray(trace.s11, dtype=np.complex64)
|
||||
payload[s21_key] = np.asarray(trace.s21, dtype=np.complex64)
|
||||
combo_records.append(
|
||||
{
|
||||
"input": trace.combo.input_pos,
|
||||
"output": trace.combo.output_pos,
|
||||
"freq_key": freq_key,
|
||||
"s11_key": s11_key,
|
||||
"s21_key": s21_key,
|
||||
}
|
||||
)
|
||||
@@ -66,7 +69,7 @@ class NpzStore(StoreApi):
|
||||
meta_path.write_text(json.dumps(meta, indent=2), encoding="utf-8")
|
||||
|
||||
def load_set(self, kind: str, radar_key: str, set_name: str) -> SweepCollection:
|
||||
"""Load named calibration/reference set from NPZ representation."""
|
||||
"""Load named preprocess set from NPZ representation."""
|
||||
set_dir = self._set_dir(kind, radar_key)
|
||||
npz_path = set_dir / f"{set_name}.npz"
|
||||
meta_path = set_dir / f"{set_name}.json"
|
||||
@@ -80,11 +83,13 @@ class NpzStore(StoreApi):
|
||||
traces: list[TraceData] = []
|
||||
for combo in meta["combos"]:
|
||||
freq = np.asarray(arrays[combo["freq_key"]], dtype=np.float32)
|
||||
s11 = np.asarray(arrays[combo["s11_key"]], dtype=np.complex64)
|
||||
s21 = np.asarray(arrays[combo["s21_key"]], dtype=np.complex64)
|
||||
traces.append(
|
||||
TraceData(
|
||||
combo=ComboKey(input_pos=int(combo["input"]), output_pos=int(combo["output"])),
|
||||
frequency_hz=freq,
|
||||
s11=s11,
|
||||
s21=s21,
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user