Mic-off Series-3 histograms (sub-minute interval) decode to nothing: 16-byte big-endian interval records #47

Closed
opened 2026-10-26 17:14:13 -04:00 by serversdown · 2 comments
Owner

Summary

A Series-3 histogram recorded with the microphone disabled at a sub-minute interval decodes to nothing. histogram_codec.decode_histogram_body returns None.

Consequence (from reading the code): SFM's download check, sfm/device_access/s3.py:verify_s3_download, would refuse such a download as "decodes as neither a waveform nor a histogram", although the downloaded bytes are exactly Blastware's. A Blastware import of such a file would presumably carry no histogram data either.

Measured (2026-10-26)

example-events/10-26-26/K441LTOK.QZ0: BE9441, Histogram, 2-second interval, mic disabled, 22 intervals (16:06:35–16:07:21), with Blastware's ASCII export.

  • Body layout:
    • a 5-byte block header 00 00 00 01 0a;
    • then 16-byte interval records of 8 × uint16 big-endian: [T_pk, T_hp, V_pk, V_hp, L_pk, L_hp, 0000, x];
    • the stream's final-block tail is 9c 06 00 42, as already documented.
  • Peak = count × 0.005 in/s. Frequency = 2048 / (2 × hp); the export says the histogram samples at 2048 sps.
  • Against the export: 66/66 peaks and 66/66 frequencies match. The tail word is 0000 on all 22 records.
  • The known mic-on variant is 20 bytes per record. With the mic off, the mic's peak/half-period pair is simply omitted.

Not yet measured

  • This file is one partial block (22 < 30 intervals), so the mic-off block stride (header plus 30 records plus trailer) is unseen. A mic-off 2-second histogram longer than a minute will show it.
  • How many archive histograms have this shape and currently decode to nothing.

Fix

  • Teach _walk_auto the mic-off record size, with the test pinned to the 66 values above.
  • Scan the DL2 archive for histograms that decode to nothing.
  • ⚠ This changes the decoder: bump TOOL_VERSION, then backfill_sidecars.py + backfill_event_shape.py (about 2 h on the NAS).
  • Related: #49 (byte order of the mic-on variant).

Found on feat/series4-sfm-parity (8acb951).

## Summary A Series-3 histogram recorded **with the microphone disabled** at a sub-minute interval **decodes to nothing**. `histogram_codec.decode_histogram_body` returns None. Consequence (from reading the code): SFM's download check, `sfm/device_access/s3.py:verify_s3_download`, would refuse such a download as "decodes as neither a waveform nor a histogram", although the downloaded bytes are exactly Blastware's. A Blastware import of such a file would presumably carry no histogram data either. ## Measured (2026-10-26) `example-events/10-26-26/K441LTOK.QZ0`: BE9441, Histogram, 2-second interval, mic disabled, 22 intervals (16:06:35–16:07:21), with Blastware's ASCII export. - **Body layout:** - a 5-byte block header `00 00 00 01 0a`; - then 16-byte interval records of **8 × uint16 big-endian**: `[T_pk, T_hp, V_pk, V_hp, L_pk, L_hp, 0000, x]`; - the stream's final-block tail is `9c 06 00 42`, as already documented. - **Peak** = count × 0.005 in/s. **Frequency** = 2048 / (2 × hp); the export says the histogram samples at 2048 sps. - **Against the export: 66/66 peaks and 66/66 frequencies match.** The tail word is `0000` on all 22 records. - The known mic-on variant is 20 bytes per record. With the mic off, the mic's peak/half-period pair is simply omitted. ## Not yet measured - This file is one partial block (22 < 30 intervals), so the mic-off **block stride** (header plus 30 records plus trailer) is unseen. A mic-off 2-second histogram longer than a minute will show it. - How many archive histograms have this shape and currently decode to nothing. ## Fix - Teach `_walk_auto` the mic-off record size, with the test pinned to the 66 values above. - Scan the DL2 archive for histograms that decode to nothing. - ⚠ This changes the decoder: bump `TOOL_VERSION`, then `backfill_sidecars.py` + `backfill_event_shape.py` (about 2 h on the NAS). - Related: #49 (byte order of the mic-on variant). Found on `feat/series4-sfm-parity` (`8acb951`).
serversdown added the Kind/Bug
Priority
Medium
3
labels 2026-10-26 17:14:13 -04:00
Author
Owner

Fixed on fix/47-mic-off-histograms (dfc5aef, branched from dev), together with #49. Not merged yet.

  • Mic-off records are 16 bytes: the mic's peak/half-period pair is left out. K441LTOK.QZ0 now decodes 22/22 intervals: 66/66 peaks and 66/66 frequencies match its export, and the mic channel comes back empty.
  • The last block is short, not padded. It holds only the intervals recorded and ends on 9c 06 00 42.
  • Archive regression (all 13,089 DL2 histograms with an ASCII export): the new reader is exact on 13,089, the old one on 13,087.

Separate bug found on the way, not fixed here: half_period_to_hz hard-codes 512/hp, which is right for 1024 sps only. This file was recorded at 2048 sps, and its frequencies are 1024/hp. Anything that shows histogram frequencies from that helper would be 2x low for 2048-sps histograms. Not checked further.

Inferred, not yet seen in a file: the mic-off 1-minute block (28 bytes) and the 15 s / 5 s mic-off strides.

Fixed on `fix/47-mic-off-histograms` (`dfc5aef`, branched from `dev`), together with #49. Not merged yet. - **Mic-off records** are 16 bytes: the mic's peak/half-period pair is left out. K441LTOK.QZ0 now decodes 22/22 intervals: 66/66 peaks and 66/66 frequencies match its export, and the mic channel comes back empty. - **The last block is short, not padded.** It holds only the intervals recorded and ends on `9c 06 00 42`. - **Archive regression** (all 13,089 DL2 histograms with an ASCII export): the new reader is exact on 13,089, the old one on 13,087. **Separate bug found on the way, not fixed here:** `half_period_to_hz` hard-codes 512/hp, which is right for 1024 sps only. This file was recorded at 2048 sps, and its frequencies are 1024/hp. Anything that shows histogram frequencies from that helper would be 2x low for 2048-sps histograms. Not checked further. Inferred, not yet seen in a file: the mic-off 1-minute block (28 bytes) and the 15 s / 5 s mic-off strides.
Author
Owner

Fixed on dev, merged in 6ed46dc (fix dfc5aef, changelog entry a0fd5fc).

Mic-off sub-minute histograms now decode. A multi-interval block is a 5-byte header, then one record per interval of big-endian peak/half-period pairs, 16 bytes with the mic off (20 with it on), then a 7-byte trailer; the last block ends on 9c 06 00 42. BE9441's K441LTOK.QZ0 matches its Blastware export on 66/66 peaks and 66/66 frequencies.

Verified: the full DL2 archive check (scratch/verify_against_ascii.py) is still 14,338 / 14,338 (13,089 histograms, 1,249 waveforms), the same bar as v0.27.0. On prod's 2026-09-30 store snapshot, 0 of 10,433 stored histograms change, so this fix moves no stored data; it matters for future imports.

Ships in v0.32.0. This issue stays open until that release reaches main. The dev → main PR will say Fixes #47, Fixes #49 so Gitea closes both on merge. The deploy's TOOL_VERSION bump and backfill_sidecars.py run (needed anyway for the release's other fixes) regenerate the stored histograms.

**Fixed on `dev`**, merged in `6ed46dc` (fix `dfc5aef`, changelog entry `a0fd5fc`). Mic-off sub-minute histograms now decode. A multi-interval block is a 5-byte header, then one record per interval of big-endian peak/half-period pairs, 16 bytes with the mic off (20 with it on), then a 7-byte trailer; the last block ends on `9c 06 00 42`. BE9441's `K441LTOK.QZ0` matches its Blastware export on 66/66 peaks and 66/66 frequencies. **Verified:** the full DL2 archive check (`scratch/verify_against_ascii.py`) is still **14,338 / 14,338** (13,089 histograms, 1,249 waveforms), the same bar as v0.27.0. On prod's 2026-09-30 store snapshot, **0 of 10,433** stored histograms change, so this fix moves no stored data; it matters for future imports. **Ships in v0.32.0.** This issue stays open until that release reaches `main`. The `dev` → `main` PR will say `Fixes #47, Fixes #49` so Gitea closes both on merge. The deploy's `TOOL_VERSION` bump and `backfill_sidecars.py` run (needed anyway for the release's other fixes) regenerate the stored histograms.
Sign in to join this conversation.