feat(decode): sensor check results from the unit's own records (group E)

The record chain that starts with the embedded event record runs to the
file's end on all 70,041 DL2 files: the event record 0x05, the unit's
summary 0x32-0x35, its sensor checks 0x3c-0x3f, then the footer 0x0e
(no 0x35 / 0x3f on a unit without a mic, 8 files).  _record_chain walks
it and refuses a chain that does not end exactly at the file's end; the
unit's summary is now read from it too.

Each sensor-check record's header holds the results (DL2, 2026-11-06):
[2] channel type (1 geophone, 2 mic, 0 disabled), [4] status (0 =
passed), [5:7] frequency x 10, [7:9] ratio x 10, [9:11] amplitude mV.
Blastware prints them as they are: 209,943 / 209,943 geophone
frequencies and ratios, 69,975 / 69,975 mic frequencies and amplitudes;
"Passed" on status 0, "Check" on every other (its bits not decoded:
a Check can sit inside every passing range), "Disabled" on type 0.

Event.sensor_check_results: channel -> SensorCheckResult (result,
status, freq_hz, ratio, amplitude_mv).  The checker compares them.
Behaviour change: an unknown id inside an intact chain now leaves only
that record unread (was: everything after it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-11-06 12:58:31 -05:00
1 parent d2fe675650
commit f7b310b130
7 files changed
+4158 -30

No files matched your search

Binary file not shown.
File diff suppressed because it is too large. Load diff
+59 -3
View File
@@ -595,10 +595,66 @@ def test_time_of_peak_is_the_units_own_peak_sample():
assert pv.pvs_time == 0.0
def test_without_the_units_summary_nothing_is_guessed():
def test_an_unreadable_channel_record_leaves_only_that_channel_unread():
raw = bytearray((_FIX / f"{_US}/I145L6UJ.3Y0W").read_bytes())
i = raw.find(b"\x00\x16\x32")
raw[i + 2] = 0x00 # break the Tran record's id
raw[i + 2] = 0x00 # break the Tran record's id; the chain holds
pv = decode_blastware_bytes(bytes(raw), name=None).peak_values
assert (pv.tran_zc_freq, pv.mic_zc_freq, pv.tran_peak_disp_in) == (None, None, None)
assert (pv.tran_zc_freq, pv.tran_peak_disp_in) == (None, None)
assert abs(pv.tran_time_of_peak - 2.281) <= 0.0005 # the samples' peak, as before
assert _prints_as(pv.mic_zc_freq, "43") # the others are read
def test_without_a_whole_record_chain_nothing_is_guessed():
# The chain from the event record ends exactly at the file's end on all
# 70,041 DL2 files; one that does not is not read at all.
raw = bytearray((_FIX / f"{_US}/I145L6UJ.3Y0W").read_bytes())
i = raw.find(b"\x00\xd4\x3c") # the Tran sensor-check record, length 212
raw[i + 1] = 0xd3 # one byte short
ev = decode_blastware_bytes(bytes(raw), name=None)
assert ev.sensor_check_results is None
pv = ev.peak_values
assert (pv.tran_zc_freq, pv.mic_zc_freq, pv.tran_peak_disp_in) == (None, None, None)
# ── Group E: the sensor check results ───────────────────────────────────────
# Records 0x3c Tran .. 0x3f MicL, after the unit's summary, carry the sensor
# check the unit ran: its trace (minimateplus.sensor_check) and, in the record's
# header, its results (measured on DL2, 2026-11-06):
# [2] channel type (1 geophone, 2 mic, 0 check disabled) [4] status, 0 = passed
# [5:7] frequency x 10 [7:9] ratio x 10 [9:11] amplitude, mV
# Blastware prints them as they are: 209,943 / 209,943 geophone frequencies and
# ratios, 69,975 / 69,975 mic frequencies and amplitudes; "Passed" on status 0,
# "Check" on every other status, "Disabled" on type 0.
@pytest.mark.parametrize("rel,want", [
# channel: (result, frequency Hz, ratio, amplitude mV), Blastware's _XML.XML
(f"{_US}/I145L6UJ.3Y0W", {"Tran": ("Passed", 7.3, 3.7, None), "Vert": ("Passed", 7.2, 3.9, None),
"Long": ("Passed", 7.2, 3.9, None), "MicL": ("Passed", 19.7, None, 592)}),
(f"{_US}/K440HJCN.AS0W", {"Tran": ("Check", 9.6, 13.8, None), "Vert": ("Check", 8.5, 7.2, None),
"Long": ("Passed", 7.3, 1.9, None), "MicL": ("Passed", 19.7, None, 519)}),
(f"{_US}/R349KMF7.9O0W", {"Tran": ("Passed", 7.4, 3.8, None), "Vert": ("Passed", 7.5, 3.5, None),
"Long": ("Passed", 7.8, 3.6, None), "MicL": ("Check", 0.0, None, 0)}),
(f"{_US}/R352HFZ7.5D0W", {"Tran": ("Disabled", None, None, None), # no mic; check disabled
"Vert": ("Disabled", None, None, None),
"Long": ("Disabled", None, None, None)}),
(f"{_US}/T193HLJ3.X80H", {"Tran": ("Passed", 7.4, 3.9, None), "Vert": ("Passed", 7.2, 3.9, None),
"Long": ("Passed", 7.5, 4.1, None), "MicL": ("Passed", 20.1, None, 556)}),
])
def test_sensor_check_results_are_the_units_own(rel, want):
got = read_blastware_file(_FIX / rel).sensor_check_results
assert set(got) == set(want)
for ch, (result, freq, ratio, amp) in want.items():
r = got[ch]
assert r.result == result, ch
assert r.freq_hz == (pytest.approx(freq) if freq is not None else None), ch
assert r.ratio == (pytest.approx(ratio) if ratio is not None else None), ch
assert r.amplitude_mv == amp, ch
def test_a_check_keeps_the_units_status_code():
# Blastware prints only "Check"; the code's bits are not decoded (K559L6N1's
# Tran is a Check at 8.1 Hz and 3.3, inside every passing range).
got = read_blastware_file(_FIX / f"{_US}/K440HJCN.AS0W").sensor_check_results
assert [got[ch].status for ch in ("Tran", "Vert", "Long", "MicL")] == [11, 2, 0, 0]
+24 -1
View File
@@ -43,7 +43,7 @@ def test_report_fields_stay_blank():
# since 2026-11-04, ZC frequency and displacement since 2026-11-05:
# test_the_setup_fields_match_blastware, test_waveform_peak_detail_*,
# test_zc_frequency_and_displacement_match_blastware. Its Tran ZC is N/A.)
for tag in ("TranZCFreq", "TranTestResults"):
for tag in ("TranZCFreq",): # (sensor check results since 2026-11-06)
assert s.values.get(tag) is None
@@ -393,3 +393,26 @@ def test_a_clipped_events_peak_times_match_blastware():
for f in ("TranTimeofPeak", "VertTimeofPeak", "LongTimeofPeak", "MicLTimeofPeak",
"PeakVectorSumTimeSum"):
assert res[f].verdict == "match", (f, res[f])
# ── Group E: the sensor check results (2026-11-06) ──────────────────────────
_SENSOR_CHECK = [f"{ch}Test{f}" for ch in ("Tran", "Vert", "Long", "MicL")
for f in ("Results", "Freq", "Ratio", "Amplitude")]
@pytest.mark.parametrize("path", [
FIX / "R352HIUI.F40W", FIX / "T1905KDW.5F0W", FIX / "T004JTRF.ME0H", FIX / "M529L4XQ.R30H",
_US / "K440HJCN.AS0W", # two Checks
_US / "K558IKSJ.P20W", _US / "O117I1NK.R70W",
])
def test_sensor_check_results_match_blastware(path):
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
checked = 0
for f in _SENSOR_CHECK:
if ref.scalars.get(f) is None:
continue
assert res[f].verdict == "match", (f, res[f])
checked += 1
assert checked >= 4