Measured 2026-10-26. A sub-minute histogram block is [00][segment][ctr LE][0a] (5 bytes), then one record per interval of BIG-endian peak / half-period pairs per channel, then 0000 and one more word, then a 7-byte trailer. A record is 20 bytes with the mic and 16 without (4 x channels + 4); the standard 32-byte block is the same thing holding one record. The last block is short, not padded: it holds only the intervals recorded and ends on 9c 06 00 42. #47: a mic-off histogram (16-byte records) decoded to nothing, so a Blastware import carried no histogram data and SFM's download check would refuse it. BE9441's K441LTOK.QZ0 (2 s, 22 intervals; fixture) now matches its Blastware export on 66/66 peaks and 66/66 frequencies. #49: the old reader took the mic-on records as little-endian from byte 6 -- the same bytes shifted by one, identical while every high byte is zero. It also required byte 5 to be 0 (the first record's Tran peak high byte) and read the last block at full stride, trimming what it overran. Regression over every DL2 histogram with a Blastware ASCII export (13,089 files, interval counts + every geo peak, frequency and mic dB): old reader 13,087 exact, new 13,089. The two the old one got wrong were one interval each: K440KZP4.560H #4764 (Long half-period 1 read as 257, mic peak 389 as 133) and M462KZUD.6R0H #145 (mic peak 6 read as 262). Walk: blocks follow by block_ctr + 1, or the next segment every 256 blocks; the last block is bounded by its terminal tail; with no terminal tail the old trimming rule remains as the fallback. Mic-off records give m_peak None and an empty MicL channel, as a mic-off waveform does. Inferred, not yet seen in a file: mic-off 1-minute (28-byte) and 15 s / 5 s mic-off strides. Not fixed here, noted on #47: half_period_to_hz assumes 1024 sps (512/hp); the 2048-sps histogram's frequencies are 1024/hp. Operational: a decoder change -- needs a TOOL_VERSION bump at release, then backfill_sidecars.py + backfill_event_shape.py (~2 h on the NAS) to regenerate stored histograms. No schema change. 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
6690434ecf
commit
dfc5aefef7
5 files changed
+410
-140
No files matched your search
@@ -509,8 +509,10 @@ def test_marker_is_single_byte_not_uint16():
|
||||
# followed by 2 words (first is 0x0000)
|
||||
# [-6:] 6-byte block trailer
|
||||
#
|
||||
# NOTE the endianness flip: the standard 32-byte block is big-endian, this
|
||||
# variant is little-endian.
|
||||
# ⚠ RETRACTED 2026-10-26 (#49): "the standard block is big-endian, this variant
|
||||
# little-endian" -- both are big-endian from byte 5 (histogram_codec.py). The
|
||||
# builder below writes little-endian from byte 6, which reads identically while
|
||||
# every value is under 256.
|
||||
#
|
||||
# Ground truth: BE9440/K440L3AQ.T70H (15 s intervals, 5,710 of them) decodes
|
||||
# with 17,130/17,130 geo peak counts, 22,840/22,840 frequencies and
|
||||
@@ -556,14 +558,19 @@ def test_multi_interval_block_decodes_all_four_channels():
|
||||
assert recs[1]["t_peak"] == 5 and recs[1]["m_halfp"] == 12
|
||||
|
||||
|
||||
def test_multi_interval_values_are_little_endian():
|
||||
"""The standard 32-byte block is big-endian; this variant is not.
|
||||
def test_multi_interval_values_are_not_little_endian_from_byte_6():
|
||||
"""RETRACTED 2026-10-26 (#49): the records are BIG-endian from byte 5.
|
||||
|
||||
A peak of 0x0100 must decode as 256, not 1.
|
||||
This test once pinned "a peak of 0x0100 written little-endian from byte 6
|
||||
decodes as 256". Those bytes (``00 | 00 01``) read big-endian from byte 5
|
||||
are a Tran peak of 0 and a half-period of 1 -- the right reading, per
|
||||
Blastware. The two models agree whenever the high bytes are zero, which
|
||||
is why this builder's other tests pass under both; see
|
||||
tests/test_histogram_multi_interval.py for the measured cases.
|
||||
"""
|
||||
ivs = [(0x0100, 1, 1, 1, 1, 1, 1, 1), (1, 1, 1, 1, 1, 1, 1, 1)]
|
||||
body = _mk_multi_block(ivs) + _mk_multi_block(ivs, ctr=257)
|
||||
assert walk_multi_interval_blocks(body)[0]["t_peak"] == 0x0100
|
||||
assert walk_multi_interval_blocks(body)[0]["t_peak"] != 0x0100
|
||||
|
||||
|
||||
def test_decode_histogram_body_falls_back_to_the_variant():
|
||||
|
||||
Reference in new issue
Block a user