fix(sfm): a MiniMate download's peaks come from its file when the unit confirms Normal range
Since the decode checker's histogram-PVS fix (625bc39, merged6945009) the file reads a histogram's vector sum as the unit stored it: K441LTON.900 stores 0.200 / 0.385 / 0.255 and a vector sum of 0.3852, as Blastware's report (was 0.503). The 0C summary, read at fixed offsets, can shift (BE9441 read 0 and -0.0, bench #4) -- and a shifted value can look plausible and pass the impossible-value guard. So the row now takes the file's channel peaks and vector sum. Only when the unit's settings confirm Normal range: the file reader computes every peak as if the range were Normal (_GEO_SENSITIVE_FS_INS is defined but unused), so a Sensitive unit's file peaks are 8x off (the checker's 33 waveforms). For Sensitive, or a range not read (a monitoring unit's 1A has no settings), the unit's own peaks stand, as before. The mic is always the unit's: the file still reads it as 0. The 0C peaks remain the download check. Store consequence: new live downloads only; no backfill, no migration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
69450093f6
commit
0a87d85202
4 files changed
+68
-21
No files matched your search
@@ -307,14 +307,26 @@ def _with_unit_peaks(dl, *, tran, vert, long, micl, pvs):
|
||||
return dl
|
||||
|
||||
|
||||
def test_a_series3_download_keeps_the_units_peaks_mic_and_vector_sum(sdm):
|
||||
def _range(geo_range):
|
||||
cc = FakeMiniMateClient().compliance
|
||||
cc.geo_range = geo_range
|
||||
return cc
|
||||
|
||||
|
||||
def test_a_series3_download_takes_its_peaks_from_the_file_and_its_mic_from_the_unit(sdm):
|
||||
# 2026-10-31: the file now reads a histogram's vector sum as the unit stored it
|
||||
# (0.385 here, as Blastware's report), so the row takes the file's peaks and
|
||||
# vector sum. The unit's 0C summary is read at fixed offsets and can shift
|
||||
# (bench #4 read 0 / -0.0); these believable-but-wrong values must not win.
|
||||
# The mic still comes from the unit: the file reads it as 0.
|
||||
store, db = sdm
|
||||
dl = _with_unit_peaks(_hist_download("K441LTON.900", "0111f210", datetime.datetime(2026, 10, 26, 17, 0, 36)),
|
||||
tran=0.2, vert=0.385, long=0.255, micl=0.00058, pvs=0.38516)
|
||||
tran=0.21, vert=0.36, long=0.27, micl=0.00058, pvs=0.40) # clears the old guard
|
||||
dl.compliance = _range(0) # Normal, confirmed by the unit
|
||||
row = db.get_event(persist_download(dl, store=store, db=db).db_event_id)
|
||||
assert row["peak_vector_sum"] == pytest.approx(0.38516, abs=1e-5) # Blastware: 0.385; the file path says 0.503
|
||||
assert row["mic_ppv"] == pytest.approx(0.00058, abs=1e-6)
|
||||
assert row["peak_vector_sum"] == pytest.approx(0.3852, abs=1e-4) # Blastware: 0.385
|
||||
assert (row["tran_ppv"], row["vert_ppv"], row["long_ppv"]) == pytest.approx((0.2, 0.385, 0.255), abs=1e-4)
|
||||
assert row["mic_ppv"] == pytest.approx(0.00058, abs=1e-6)
|
||||
|
||||
|
||||
def test_an_impossible_unit_vector_sum_is_not_kept(sdm):
|
||||
@@ -409,3 +421,21 @@ def test_a_letterless_stored_name_still_matches_a_lettered_download(sdm):
|
||||
store, db = sdm
|
||||
_stored_as(store, db, "K441LTOK.QZ0")
|
||||
assert db.find_event_by_blastware_name("BE9441", "K441LTOK.QZ0H")["blastware_filename"] == "K441LTOK.QZ0"
|
||||
|
||||
|
||||
|
||||
# The file reader computes every peak as if the unit were in Normal range (10 in/s);
|
||||
# a Sensitive (1.25 in/s) unit's file peaks come out 8x off (the checker's 33
|
||||
# waveforms). So the file's peaks are taken only when the unit's settings confirm
|
||||
# Normal -- the download check's rule; Sensitive or unread keeps the unit's own.
|
||||
|
||||
@pytest.mark.parametrize("compliance", [_range(1), None], ids=["sensitive", "range-unread"])
|
||||
def test_without_a_confirmed_normal_range_the_units_peaks_stand(sdm, compliance):
|
||||
store, db = sdm
|
||||
dl = _with_unit_peaks(_hist_download("K441LTON.900", "0111f210", datetime.datetime(2026, 10, 26, 17, 0, 36)),
|
||||
tran=0.025, vert=0.048, long=0.032, micl=0.00058, pvs=0.0481)
|
||||
dl.compliance = compliance
|
||||
row = db.get_event(persist_download(dl, store=store, db=db).db_event_id)
|
||||
assert (row["tran_ppv"], row["vert_ppv"], row["long_ppv"]) == pytest.approx((0.025, 0.048, 0.032), abs=1e-6)
|
||||
assert row["peak_vector_sum"] == pytest.approx(0.0481, abs=1e-6)
|
||||
assert row["mic_ppv"] == pytest.approx(0.00058, abs=1e-6)
|
||||
Reference in new issue
Block a user