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
@@ -223,7 +223,8 @@ Read this first when picking the project back up.
|
|||||||
**Batch 1 fixed (2026-10-29):** #1 (`b320a53`, settings read after unescaping:
|
**Batch 1 fixed (2026-10-29):** #1 (`b320a53`, settings read after unescaping:
|
||||||
mode −7, rate −6, interval −4, record time +6), #9 (`ce441a0`, one reconnect for
|
mode −7, rate −6, interval −4, record time +6), #9 (`ce441a0`, one reconnect for
|
||||||
the read-back), #8 (`9492e49`, downloads stored through `save_imported_bw` with
|
the read-back), #8 (`9492e49`, downloads stored through `save_imported_bw` with
|
||||||
the unit's peaks/mic/vector sum overlaid and its range passed). #2 came with the
|
the unit's mic overlaid, its peaks/vector sum too unless Normal range is confirmed
|
||||||
|
-- since 2026-10-31, after the checker's histogram-PVS fix -- and its range passed). #2 came with the
|
||||||
`dev` merge. **#15 retracted** -- `sent` NULL is "unknown", by design.
|
`dev` merge. **#15 retracted** -- `sent` NULL is "unknown", by design.
|
||||||
Final review fixes: `dbd8a91` (wake before the reconnect's identity read),
|
Final review fixes: `dbd8a91` (wake before the reconnect's identity read),
|
||||||
`3a1d34a` ("already stored" by Blastware name too), `a72d3a9` (the 1A write
|
`3a1d34a` ("already stored" by Blastware name too), `a72d3a9` (the 1A write
|
||||||
|
|||||||
@@ -685,10 +685,12 @@ a short plan; #14 waits for the line-hold decision above.
|
|||||||
7. `/db/events` 500 "database is locked" on the first page load against a new DB.
|
7. `/db/events` 500 "database is locked" on the first page load against a new DB.
|
||||||
8. ✅ **Fixed `9492e49`**, plus `3a1d34a` ("already stored" also matches the Blastware
|
8. ✅ **Fixed `9492e49`**, plus `3a1d34a` ("already stored" also matches the Blastware
|
||||||
name: a histogram's row sits a second off its 0C time). The download carries the assembled Blastware file and is
|
name: a histogram's row sits a second off its 0C time). The download carries the assembled Blastware file and is
|
||||||
stored through `save_imported_bw` (`source.kind` "sfm-live"); the unit's 0C peaks,
|
stored through `save_imported_bw` (`source.kind` "sfm-live"), and its range scales
|
||||||
mic and vector sum are overlaid (the file path reads a histogram's vector sum as
|
the samples. The unit's 0C mic is overlaid (the file reads it as 0). Its channel
|
||||||
0.503 vs 0.385, the mic as 0, and no sensitive range yet), and its range scales
|
peaks and vector sum were overlaid too until 2026-10-31; since the checker's
|
||||||
the samples. The "Waveform" label waits for #41 from the checker branch.
|
histogram-PVS fix (625bc39, merged `6945009`) the file's are taken when the unit
|
||||||
|
confirms Normal range, and the unit's stand for Sensitive or an unread range (the
|
||||||
|
file reader assumes Normal: 8x off). The label came with #41 (`a1d2b61`).
|
||||||
**S3 downloads are stored from the live waveform decoder** (`store.save`), not
|
**S3 downloads are stored from the live waveform decoder** (`store.save`), not
|
||||||
the file reader that Series 4 uses (`save_imported_idf`): a histogram gets no
|
the file reader that Series 4 uses (`save_imported_idf`): a histogram gets no
|
||||||
samples and is labelled Waveform. Fix: store S3 downloads through the
|
samples and is labelled Waveform. Fix: store S3 downloads through the
|
||||||
|
|||||||
+26
-12
@@ -66,15 +66,23 @@ def _already_stored(dl: DownloadedEvent, row: dict) -> EventDownload:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _overlay_s3_record(ev: Any, unit_peaks: Any) -> None:
|
def _overlay_s3_record(ev: Any, unit_peaks: Any, geo_range: Any) -> None:
|
||||||
"""The unit's own 0C peaks, mic and vector sum over the file's.
|
"""The unit's own 0C values over the file's, where the file's are not yet right.
|
||||||
|
|
||||||
Measured 2026-10-29 on BE9441: the file path reads the channel peaks right but
|
* Mic: always the unit's -- the file reads it as 0 (its psi conversion is an
|
||||||
a histogram's vector sum as 0.503 where Blastware and the unit say 0.385 (the
|
open checker finding).
|
||||||
decode checker's open finding), the mic as 0, and it cannot scale a sensitive
|
* Channel peaks and vector sum: the file's when the unit's settings confirm
|
||||||
range. The unit's values are the accurate ones until the file decoder reads
|
Normal range (`geo_range` 0). The file reads them as the unit stored them
|
||||||
them. A vector sum below the largest channel peak is impossible -- BE9441's
|
-- K441LTON.900: 0.200 / 0.385 / 0.255 and 0.385, as Blastware's report,
|
||||||
0C read -0.0 for some events (bench finding #4) -- so it is not kept.
|
since the decode checker's fix (625bc39, 2026-10-31) -- while the 0C summary
|
||||||
|
is read at fixed offsets and can shift (BE9441 read 0 and -0.0 for vector
|
||||||
|
sums, bench #4). But the file reader computes every peak as if the range
|
||||||
|
were Normal, so a Sensitive unit's come out 8x off (the checker's 33
|
||||||
|
waveforms): for Sensitive, or a range not read (a monitoring unit's 1A
|
||||||
|
carries no settings), the unit's own peaks stand, as before -- a vector
|
||||||
|
sum below the largest channel peak is impossible and is not kept.
|
||||||
|
|
||||||
|
The 0C peaks remain the download *check* (verify_s3_download) either way.
|
||||||
"""
|
"""
|
||||||
from minimateplus.models import PeakValues
|
from minimateplus.models import PeakValues
|
||||||
|
|
||||||
@@ -83,7 +91,12 @@ def _overlay_s3_record(ev: Any, unit_peaks: Any) -> None:
|
|||||||
if ev.peak_values is None:
|
if ev.peak_values is None:
|
||||||
ev.peak_values = PeakValues()
|
ev.peak_values = PeakValues()
|
||||||
pv = ev.peak_values
|
pv = ev.peak_values
|
||||||
for name in ("tran", "vert", "long", "micl"):
|
micl = getattr(unit_peaks, "micl", None)
|
||||||
|
if micl is not None:
|
||||||
|
pv.micl = micl
|
||||||
|
if geo_range in (0, "normal"):
|
||||||
|
return
|
||||||
|
for name in ("tran", "vert", "long"):
|
||||||
value = getattr(unit_peaks, name, None)
|
value = getattr(unit_peaks, name, None)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
setattr(pv, name, value)
|
setattr(pv, name, value)
|
||||||
@@ -137,8 +150,9 @@ def persist_download(dl: DownloadedEvent, *, store: Any, db: Any) -> EventDownlo
|
|||||||
else:
|
else:
|
||||||
# The same path production's watcher uses for Blastware's own files: the
|
# The same path production's watcher uses for Blastware's own files: the
|
||||||
# event is decoded from the file (samples, histogram, setup-block sample
|
# event is decoded from the file (samples, histogram, setup-block sample
|
||||||
# rate and record time), not from the live 5A decode. The unit's own 0C
|
# rate and record time), not from the live 5A decode. The unit's 0C mic
|
||||||
# peaks, mic and vector sum then go over the file's (_overlay_s3_record).
|
# goes over the file's, and its peaks too unless Normal range is
|
||||||
|
# confirmed (_overlay_s3_record).
|
||||||
if not dl.bw_bytes:
|
if not dl.bw_bytes:
|
||||||
raise IngestError(f"{dl.filename}: the download carried no event file; nothing was stored")
|
raise IngestError(f"{dl.filename}: the download carried no event file; nothing was stored")
|
||||||
geo_range = getattr(dl.compliance, "geo_range", None) if dl.compliance else None
|
geo_range = getattr(dl.compliance, "geo_range", None) if dl.compliance else None
|
||||||
@@ -146,7 +160,7 @@ def persist_download(dl: DownloadedEvent, *, store: Any, db: Any) -> EventDownlo
|
|||||||
serial_hint=dl.serial, source_kind="sfm-live",
|
serial_hint=dl.serial, source_kind="sfm-live",
|
||||||
geo_range=geo_range if geo_range is not None else "normal")
|
geo_range=geo_range if geo_range is not None else "normal")
|
||||||
if ev is not None and dl.event is not None:
|
if ev is not None and dl.event is not None:
|
||||||
_overlay_s3_record(ev, getattr(dl.event, "peak_values", None))
|
_overlay_s3_record(ev, getattr(dl.event, "peak_values", None), geo_range)
|
||||||
family = "series3"
|
family = "series3"
|
||||||
if ev is None or ev._waveform_key is None:
|
if ev is None or ev._waveform_key is None:
|
||||||
raise IngestError(f"{dl.filename}: stored the file but could not build a database row")
|
raise IngestError(f"{dl.filename}: stored the file but could not build a database row")
|
||||||
|
|||||||
@@ -307,14 +307,26 @@ def _with_unit_peaks(dl, *, tran, vert, long, micl, pvs):
|
|||||||
return dl
|
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
|
store, db = sdm
|
||||||
dl = _with_unit_peaks(_hist_download("K441LTON.900", "0111f210", datetime.datetime(2026, 10, 26, 17, 0, 36)),
|
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)
|
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["peak_vector_sum"] == pytest.approx(0.3852, abs=1e-4) # Blastware: 0.385
|
||||||
assert row["mic_ppv"] == pytest.approx(0.00058, abs=1e-6)
|
|
||||||
assert (row["tran_ppv"], row["vert_ppv"], row["long_ppv"]) == pytest.approx((0.2, 0.385, 0.255), abs=1e-4)
|
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):
|
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
|
store, db = sdm
|
||||||
_stored_as(store, db, "K441LTOK.QZ0")
|
_stored_as(store, db, "K441LTOK.QZ0")
|
||||||
assert db.find_event_by_blastware_name("BE9441", "K441LTOK.QZ0H")["blastware_filename"] == "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