fix(decode): a histogram's start and stop come from its own event record (#51)
The footer's start runs a second early on 97% of histograms. Each
histogram carries an event record like a waveform's -- lead 00 28 05 00,
source 04 00, marker fe f5, then start and stop -- and it holds
Blastware's Histogram Start and Stop on 63,490 / 63,490 DL2 histograms.
On all 63,500 there is exactly one, its start 0 or 1 s after the
footer's and its stop 0 or 1 s before; that is the validation rule.
Without a validated record the footer's start stands, as a decode
problem.
Ships with the unit + time + type key (ea2dfc2), without which a
waveform and its histogram at the same second would collide. Three
tests that pinned the old footer start (one said 'for now', pointing at
#51) now pin the record's, which equals the file's Blastware name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
This commit is contained in:
1 parent
e24e77bfd0
commit
a9bb9f08c0
5 files changed
+98
-18
No files matched your search
@@ -471,3 +471,27 @@ def test_the_h5_carries_the_interval_detail(tmp_path):
|
||||
assert int(f.attrs["histogram_interval_sec"]) == 60
|
||||
assert list(f["intervals/half_period/Vert"][:]) == ev.interval_half_periods["Vert"]
|
||||
assert abs(float(f["intervals/pvs_ips"][0]) - 2.644) <= 0.0005 + 1e-9
|
||||
|
||||
|
||||
# ── #51: a histogram's start and stop from its own event record ─────────────
|
||||
# The footer's start runs a second early on 97%. The histogram's event record
|
||||
# (lead 00 28 05 00, source 04 00, marker fe f5) holds Blastware's start and
|
||||
# stop: 63,490 / 63,490 DL2 histograms each (2026-11-03).
|
||||
|
||||
def test_a_histogram_starts_at_its_event_records_start():
|
||||
ev = read_blastware_file(_FIX / "decode-checker-10-29-26/T004JTRF.ME0H")
|
||||
t, s = ev.timestamp, ev.stop_time
|
||||
# Blastware: start 2022-12-28 12:49:26, stop 12:49:33
|
||||
assert (t.year, t.month, t.day, t.hour, t.minute, t.second) == (2022, 12, 28, 12, 49, 26)
|
||||
assert (s.hour, s.minute, s.second) == (12, 49, 33)
|
||||
assert ev.timestamp_source == "event_record"
|
||||
|
||||
|
||||
def test_a_histogram_without_its_record_falls_back_to_the_footer_and_says_so():
|
||||
raw = bytearray((_FIX / "decode-checker-10-29-26/T004JTRF.ME0H").read_bytes())
|
||||
i = raw.find(b"\xfe\xf5")
|
||||
raw[i] = 0x00 # break the record's marker
|
||||
ev = decode_blastware_bytes(bytes(raw), name=None)
|
||||
assert ev.timestamp_source == "footer"
|
||||
assert ev.timestamp.second == 25 # the footer's start, a second early
|
||||
assert any("histogram event record" in p for p in ev.decode_problems)
|
||||
Reference in new issue
Block a user