merge: dev into feat/series4-sfm-parity -- #41, a Blastware event's record type from its bytes
Bringsede6292(fix46daea1, changelogb6fc71b) from the decode checker's branch. Completes #8's live S3 download path: a live histogram, whose direct download name (K441LTON.900) carries no type letter, is now labelled from STRT[18] instead of defaulting to Waveform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
commit
a1d2b61f22
4 files changed
+73
-10
No files matched your search
@@ -111,3 +111,38 @@ def test_import_without_a_report_stores_the_file_fields(tmp_path: Path):
|
||||
assert sc["event"]["pretrig_samples"] == 253
|
||||
assert sc["project_info"]["project"] == "JV 241 - 1425 Spanlers Mill Rad"
|
||||
assert sc["project_info"]["sensor_location"] == "Loc #1 - 1425 Spanlers Mill Rd"
|
||||
|
||||
|
||||
# ── #41: the record type comes from the bytes ───────────────────────────────
|
||||
# STRT[18] is the record-type byte: 0x46 on every one of DL2's 6,577 waveform
|
||||
# files, 0x0A on every one of its 63,535 histograms (measured 2026-10-29).
|
||||
|
||||
from minimateplus import blastware_file as _bw # noqa: E402
|
||||
from minimateplus.event_file_io import decode_blastware_bytes # noqa: E402
|
||||
|
||||
_TYPES = [
|
||||
("bw-import-fields-10-29-26/R352HIUI.F40W", "Waveform"),
|
||||
("bw-import-fields-10-29-26/M529L4XQ.R30H", "Histogram"),
|
||||
("5-11-26/M529LL1A.SP0", "Waveform"), # name carries no type
|
||||
("histogram-mic-off-10-26-26/K441LTOK.QZ0", "Histogram"), # name carries no type
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("rel,want", _TYPES)
|
||||
def test_record_type_comes_from_the_bytes_without_a_name(rel, want):
|
||||
assert decode_blastware_bytes((_FIX / rel).read_bytes(), name=None).record_type == want
|
||||
|
||||
|
||||
def test_the_bytes_win_over_a_filename_that_disagrees(caplog):
|
||||
raw = (_FIX / "bw-import-fields-10-29-26/M529L4XQ.R30H").read_bytes()
|
||||
ev = decode_blastware_bytes(raw, name="M529L4XQ.R30W")
|
||||
assert ev.record_type == "Histogram"
|
||||
assert "record type" in caplog.text
|
||||
|
||||
|
||||
def test_an_unknown_type_byte_is_unknown_not_a_guess():
|
||||
raw = bytearray((_FIX / "bw-import-fields-10-29-26/R352HIUI.F40W").read_bytes())
|
||||
raw[_bw._WAVEFORM_HEADER_SIZE + 18] = 0x99
|
||||
ev = decode_blastware_bytes(bytes(raw), name=None)
|
||||
assert ev.record_type is None
|
||||
assert any("record type" in p for p in ev.decode_problems)
|
||||
@@ -31,11 +31,10 @@ def test_histogram_interval_peak_in_counts():
|
||||
assert s.counts["Tran"] == [7776] and s.values["NumberofIntervals"] == 1
|
||||
|
||||
|
||||
def test_no_filename_reaches_the_decoder():
|
||||
# The type must come from the bytes; today they can't tell it (#41), so this
|
||||
# histogram reads as a waveform. Update to "Full Histogram" when #41 lands.
|
||||
def test_event_type_comes_from_the_bytes():
|
||||
# No filename reaches the decoder; the type is the STRT record-type byte (#41).
|
||||
s = sfm_side((FIX / "M529L4XQ.R30H").read_bytes())
|
||||
assert s.values["EventType"] == "Full Waveform"
|
||||
assert s.values["EventType"] == "Full Histogram"
|
||||
|
||||
|
||||
def test_report_fields_stay_blank():
|
||||
|
||||
Reference in new issue
Block a user