feat(parse): carry per-channel ZC freq onto PeakValues (report + dict paths)

This commit is contained in:
2026-07-29 17:20:17 +00:00
parent 248276d141
commit 9a71d5b914
3 changed files with 74 additions and 0 deletions
+42
View File
@@ -43,3 +43,45 @@ def test_migration_adds_zc_freq_columns_to_legacy_db(tmp_path: Path):
for c in ZC_COLS:
assert c in rows[0] # present
assert rows[0][c] is None # NULL for the legacy row
from minimateplus.models import PeakValues, Event
from minimateplus import event_file_io
from minimateplus.bw_ascii_report import BwAsciiReport, ChannelStats, MicStats
def _report_with_freqs():
r = BwAsciiReport()
r.channels["Tran"] = ChannelStats(ppv_ips=0.075, zc_freq_hz=100.0, zc_freq_above_range=True)
r.channels["Vert"] = ChannelStats(ppv_ips=0.220, zc_freq_hz=85.0)
r.channels["Long"] = ChannelStats(ppv_ips=0.045, zc_freq_hz=73.0)
r.mic = MicStats(zc_freq_hz=51.0)
return r
def test_apply_report_copies_zc_freq_onto_peakvalues():
ev = Event(index=0)
event_file_io.apply_report_to_event(ev, _report_with_freqs())
pv = ev.peak_values
assert pv.vert_zc_freq == 85.0
assert pv.tran_zc_freq == 100.0
assert pv.tran_zc_above_range is True
assert pv.vert_zc_above_range is False
assert pv.mic_zc_freq == 51.0
def test_apply_bw_report_dict_copies_zc_freq():
ev = Event(index=0)
bw = {
"peaks": {
"tran": {"ppv_ips": 0.075, "zc_freq_hz": 100.0, "zc_freq_above_range": True},
"vert": {"ppv_ips": 0.220, "zc_freq_hz": 85.0},
"long": {"ppv_ips": 0.045, "zc_freq_hz": 73.0},
},
"mic": {"zc_freq_hz": 51.0, "zc_freq_above_range": False},
}
event_file_io.apply_bw_report_dict_to_event(ev, bw)
pv = ev.peak_values
assert pv.vert_zc_freq == 85.0
assert pv.tran_zc_above_range is True
assert pv.mic_zc_freq == 51.0