fix(decode): a Blastware file's footer is its last 26 bytes -- no more day-late histograms

Every DL2 file ends in a valid footer: 0e 08 and two valid times on
70,041 / 70,041.  The decoder took the first '0e 08 + plausible year'
instead, and 14 files also hold an earlier record, ~1.1 KB before the
end, with the stop time followed by zeros:
- a histogram started at its own stop -- a day late on BE9558's daily
  histograms (K558L9XP.FK0H: 2025-10-08 19:10:01 for Blastware's
  2025-10-07 19:14:08); T003LCYV.JD0H got no time at all;
- a waveform lost its stop, so the trigger was never computed and the
  stop was stamped instead (K440I4LG.JK0W: 11:14:12 for 11:14:08).

The last 26 bytes are now taken when they are a footer; otherwise the
old search stands unchanged.

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-03 12:10:44 -05:00
1 parent dd9f6dde7a
commit 8a40eb638a
6 files changed
+606 -16

No files matched your search

+30
View File
@@ -335,3 +335,33 @@ def test_a_loud_interval_does_not_hide_a_short_histogram(name, n):
# which the old "first word is 0000" test rejected.
ev = read_blastware_file(_FIX / _HD / name)
assert len(ev.raw_samples["Tran"]) == n
# ── The footer is the file's last 26 bytes ──────────────────────────────────
# Every DL2 file ends in a valid footer (70,041 / 70,041: 0e 08 and two valid
# times). A few also hold an earlier "0e 08 + date" record, ~1.1 KB before
# the end: the stop time followed by zeros. The first-match footer search took
# it, so a histogram started at its own stop -- a day late on BE9558's daily
# histograms -- and a waveform lost its stop and its trigger time.
_FT = "footer-11-03-26"
def test_a_histogram_starts_at_its_footer_not_at_an_earlier_stop_record():
ts = read_blastware_file(_FIX / _FT / "K558L9XP.FK0H").timestamp
# Blastware: 2025-10-07 19:14:08 (SFM read 2025-10-08 19:10:01)
assert (ts.year, ts.month, ts.day, ts.hour, ts.minute) == (2025, 10, 7, 19, 14)
def test_a_histogram_with_the_early_record_gets_its_time():
ts = read_blastware_file(_FIX / _FT / "T003LCYV.JD0H").timestamp
# Blastware: 2025-12-05 18:04:25 (SFM had no time at all)
assert ts is not None
assert (ts.year, ts.month, ts.day, ts.hour, ts.minute) == (2025, 12, 5, 18, 4)
def test_a_waveform_with_the_early_record_is_timed_from_its_trigger():
ev = read_blastware_file(_FIX / _FT / "K440I4LG.JK0W")
ts = ev.timestamp
# Blastware: 2019-09-26 11:14:08, record time 4 s (SFM read the stop, 11:14:12)
assert (ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second) == (2019, 9, 26, 11, 14, 8)
assert ev.timestamp_source in ("event_record", "estimate")