fix(histogram_codec): read multi-interval blocks big-endian from byte 5, mic on and off (#47, #49)

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:
serversdownandClaude Opus 5.5 committed 2026-10-26 18:30:09 -04:00
1 parent 6690434ecf
commit dfc5aefef7
5 files changed
+410 -140

No files matched your search

Binary file not shown.
@@ -0,0 +1,72 @@
"Event Type : Full Histogram"
"Serial Number : BE9441"
"Version : V 10.72-8.17 MiniMate Plus"
"File Name : K441LTOK.QZ0"
"Histogram Start Time : 16:06:35"
"Histogram Start Date : October 26, 2026"
"Histogram Stop Time : 16:07:21"
"Histogram Stop Date : October 26, 2026"
"Number of Intervals : 22.00"
"Interval Size : 2 seconds "
"Sample Rate : 2048 sps"
"Battery Level : 6.8 Volts"
"Calibration : October 6, 2026 by Instantel"
"Units : in/s and "
"Project: : TestUnit-Minimate"
"Client: : Terra-Mechanics"
"User Name: : Terra-Mechanics Inc. - Harrison"
"Seis. Loc: : Test unit 1"
"Geo Range : 10.000 in/s"
"Tran PPV : 0.250 in/s"
"Vert PPV : 1.080 in/s"
"Long PPV : 0.195 in/s"
"Tran ZC Freq : 16.8 Hz"
"Vert ZC Freq : 22 Hz"
"Long ZC Freq : 19.3 Hz"
"Tran Peak Time : 16:06:45"
"Tran Peak Date : October 26, 2026"
"Vert Peak Time : 16:06:49"
"Vert Peak Date : October 26, 2026"
"Long Peak Time : 16:06:43"
"Long Peak Date : October 26, 2026"
"Peak Vector Sum : 1.083 in/s"
"Peak Vector Sum Time : 16:06:49"
"Peak Vector Sum Date : October 26, 2026"
"Tran Test Freq : 7.3 Hz"
"Tran Test Ratio : 4.5"
"Tran Test Results : Passed"
"Vert Test Freq : 7.4 Hz"
"Vert Test Ratio : 3.5"
"Vert Test Results : Passed"
"Long Test Freq : 7.3 Hz"
"Long Test Ratio : 4.2"
"Long Test Results : Passed"
"Monitor Log(s)"
"Oct 26 /26 16:06:34 Oct 26 /26 16:07:21 Event recorded. (Keyboard Exit)"
"PC SW Version : V 10.74"
Tran Tran Vert Vert Long Long Geo
PPV Freq PPV Freq PPV Freq PVS
Time in/s Hz in/s Hz in/s Hz in/s
October 26, 2026
16:06:37 0.040 21 0.060 21 0.025 21 0.065
16:06:39 0.030 12.8 0.030 16.5 0.015 73 0.034
16:06:41 0.010 >200 0.010 >200 0.010 >200 0.015
16:06:43 0.230 26 0.400 17.4 0.195 19.3 0.461
16:06:45 0.250 16.8 0.120 24 0.135 20 0.255
16:06:47 0.015 20 0.020 10.7 0.015 39 0.022
16:06:49 0.235 33 1.080 22 0.165 20 1.083
16:06:51 0.015 19.7 0.040 19.0 0.020 25 0.043
16:06:53 0.085 4.3 0.140 3.0 0.115 3.4 0.185
16:06:55 0.045 2.9 0.140 2.9 0.120 2.8 0.181
16:06:57 0.015 31 0.010 >200 0.010 >200 0.015
16:06:59 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:01 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:03 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:05 0.015 114 0.010 >200 0.010 >200 0.016
16:07:07 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:09 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:11 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:13 0.045 4.0 0.055 3.4 0.055 5.7 0.066
16:07:15 0.055 5.0 0.070 3.0 0.075 2.2 0.111
16:07:17 0.010 >200 0.010 >200 0.010 >200 0.015
16:07:19 0.010 >200 0.010 >200 0.010 >200 0.015