Audit Series III binary metadata and eliminate unknown decoder regions #53

Open
opened 2026-10-26 23:52:44 -04:00 by serversdown · 3 comments
Owner

While looking at various binaries in the seismo_lab.py inspector tab i see some "unknown" areas. I think aprox 5% are unknown in this particular file. (K441LTMK.YZ0... its a manually downloaded waveform event, hence no W in the extension). So we need to do an audit of the protocol/parser/decoder. and make sure we are really understanding everything the events are reading.

image.png image.png
While looking at various binaries in the seismo_lab.py inspector tab i see some "unknown" areas. I think aprox 5% are unknown in this particular file. (K441LTMK.YZ0... its a manually downloaded waveform event, hence no W in the extension). So we need to do an audit of the protocol/parser/decoder. and make sure we are really understanding everything the events are reading. <img width="1019" alt="image.png" src="attachments/4ce32ba3-d86d-4292-bebf-d00895afe845"> <img width="1043" alt="image.png" src="attachments/e73bfafd-bc08-43b3-a3db-99ca1041c5c0">
115 KiB
165 KiB
serversdown added the Kind/Bug
Priority
Medium
3
labels 2026-10-26 23:53:11 -04:00
Author
Owner

Two items for this audit, found while fixing waveform event times for v0.32.0 (branch fix/waveform-time-from-record: f91949b, 6cfcd04). Each is graded measured or inferred.

0. Part of the "unknown" region is now identified (measured)

The trailing region the Inspector labels "unknown" holds the instrument's embedded event record, documented in Series-III reference §7.8.9:

00 28 05 00 ?? ?? | fe 80 | trigger (dd mm yyyy-BE 00 hh mm ss) | stop

  • Its trigger is exact on 7,935 waveforms. It's instrument data: it's present in the unit's own A5 stream and in SFM-only downloads.
  • The bytes around it ([M−2:M], [M+18:M+40], including a constant 16 32) are still undecoded.
  • Histograms carry the same record with marker fe f5 (see #51).
  • The surrounding device-info, notes and channel blocks in that region are what this issue is about.

1. Three archive waveforms the waveform codec does not recognise (measured)

These DL2 files are named as waveforms (…W) and carry a valid embedded event record, but decode_waveform_v2 returns nothing for their body. So read_blastware_file treats them as histograms: decode_histogram_body yields 4,352 / 13,280 "samples" per channel, almost certainly not real samples. Their time comes from the footer start, which is 4 s after the trigger in the record and the filename.

file size record / filename trigger footer start (what we store)
K440I4LG.JK0W 10,250 B 2019-09-26 11:14:08 11:14:12
K888HW07.7K0W 10,246 B 2019-04-12 11:14:08 11:14:12
R349KPNU.FK0W 33,206 B 2024-09-08 16:14:08 16:14:11
  • dev behaves the same, and prod's store has none of these (all 1,394 prod waveforms decode normally).
  • 🔶 Inferred: two units at the same 11:14:08 hints at a scheduled daily event, perhaps a self-check, with a body layout the codec doesn't know. Worth one Blastware ASCII export of either 2019 file.
  • To do: identify the body format. The record type should also come from instrument data rather than the filename (#41).

2. The documented 0C (SUB F3) timestamp layouts look like escape misreads (inferred)

In the 2026-10-26 recording, every 0C record's timestamp is the plain 8-byte form, the same as the embedded record and the footer: F3 data [11:19] = dd mm yyyy(BE) 00 hh mm ss. For example 1a 0a 07 ea 00 0e 17 2a = 26/10/2026 14:23:42 (8/8 events).

The two layouts our notes document (CLAUDE.md "SUB 0C", reference §7.5) look like that same form read with the unit's escape bytes left in:

  • the 9-byte "sub_code 0x10" form (day 10 month …): a 10 before a month of 2/3/4, the values a unit escapes. The early captures were all taken in April (month 04, sent as 10 04).
  • the 10-byte "continuous mode" form: its own documented example 10 03 10 04 07 ea 00 0f 14 11 reads as day 3 and month 4, each escaped, at 15:20:17. That's exactly the time documented next to it.

This is the same "escape rule seen half" pattern retracted for the 5A requests and the config writes on 2026-10-26. To do: decode the 0C timestamp with the escapes removed, and check it against a capture from a month outside 2–4 and a day outside 2–4 or 16. Nothing has been changed.

**Two items for this audit, found while fixing waveform event times for v0.32.0** (branch `fix/waveform-time-from-record`: `f91949b`, `6cfcd04`). Each is graded measured or inferred. ### 0. Part of the "unknown" region is now identified (measured) The trailing region the Inspector labels "unknown" holds the instrument's **embedded event record**, documented in Series-III reference **§7.8.9**: `00 28 05 00 ?? ?? | fe 80 | trigger (dd mm yyyy-BE 00 hh mm ss) | stop` - Its trigger is exact on 7,935 waveforms. It's instrument data: it's present in the unit's own A5 stream and in SFM-only downloads. - The bytes around it (`[M−2:M]`, `[M+18:M+40]`, including a constant `16 32`) are still undecoded. - Histograms carry the same record with marker `fe f5` (see #51). - The surrounding device-info, notes and channel blocks in that region are what this issue is about. ### 1. Three archive waveforms the waveform codec does not recognise (measured) These DL2 files are named as waveforms (`…W`) and carry a **valid** embedded event record, but `decode_waveform_v2` returns nothing for their body. So `read_blastware_file` treats them as histograms: `decode_histogram_body` yields 4,352 / 13,280 "samples" per channel, almost certainly not real samples. Their time comes from the footer start, which is **4 s** after the trigger in the record and the filename. | file | size | record / filename trigger | footer start (what we store) | |---|---|---|---| | `K440I4LG.JK0W` | 10,250 B | 2019-09-26 11:14:08 | 11:14:12 | | `K888HW07.7K0W` | 10,246 B | 2019-04-12 11:14:08 | 11:14:12 | | `R349KPNU.FK0W` | 33,206 B | 2024-09-08 16:14:08 | 16:14:11 | - `dev` behaves the same, and prod's store has **none** of these (all 1,394 prod waveforms decode normally). - 🔶 Inferred: two units at the same 11:14:08 hints at a scheduled daily event, perhaps a self-check, with a body layout the codec doesn't know. Worth one Blastware ASCII export of either 2019 file. - To do: identify the body format. The record type should also come from instrument data rather than the filename (#41). ### 2. The documented `0C` (SUB F3) timestamp layouts look like escape misreads (inferred) In the 2026-10-26 recording, every `0C` record's timestamp is the plain 8-byte form, the same as the embedded record and the footer: F3 data `[11:19]` = `dd mm yyyy(BE) 00 hh mm ss`. For example `1a 0a 07 ea 00 0e 17 2a` = 26/10/2026 14:23:42 (8/8 events). The two layouts our notes document (CLAUDE.md "SUB 0C", reference §7.5) look like that same form read with the unit's escape bytes left in: - the **9-byte "sub_code 0x10" form** (`day 10 month …`): a `10` before a month of 2/3/4, the values a unit escapes. The early captures were all taken in **April** (month `04`, sent as `10 04`). - the **10-byte "continuous mode" form**: its own documented example `10 03 10 04 07 ea 00 0f 14 11` reads as day 3 and month 4, each escaped, at 15:20:17. That's exactly the time documented next to it. This is the same "escape rule seen half" pattern retracted for the 5A requests and the config writes on 2026-10-26. To do: decode the `0C` timestamp with the escapes removed, and check it against a capture from a month outside 2–4 and a day outside 2–4 or 16. **Nothing has been changed.**
Author
Owner

Cross-check from the parity branch (measured 2026-10-26, BE9441 through a recording bridge, 748/748 reply frames): the unit DLE-escapes 02, 03, 04 and 10 in every reply. S3FrameParser collapses 10 10, but it keeps the 10 of 10 02/03/04 as data.

That explains the two 0C timestamp "layouts" exactly. CLAUDE.md's "sub_code=0x03, 10-byte" example 10 03 10 04 07 ea 00 0f 14 11 is the ordinary 9-byte layout for day 3, month 4, 2026, 15:20:17. Day and month each arrive escaped, and the parser keeps both escape bytes. A day or month of 2, 3 or 4 gives the "10-byte" form; any other gives the "9-byte" form. The monitor-log partial records' "raw_data[11] == 0x10 → 10-byte format" rule is the same artifact.

The fix on the parity branch for the 0x1C status (d990466) adds framing.unescape_reply(), which removes the kept escape bytes. Decoding the 0C record after it should collapse both layouts into one. Not tested on 0C.

Cross-check from the parity branch (measured 2026-10-26, BE9441 through a recording bridge, 748/748 reply frames): **the unit DLE-escapes 02, 03, 04 and 10 in every reply.** `S3FrameParser` collapses `10 10`, but it keeps the `10` of `10 02/03/04` as data. That explains the two 0C timestamp "layouts" exactly. CLAUDE.md's "sub_code=0x03, 10-byte" example `10 03 10 04 07 ea 00 0f 14 11` is the ordinary 9-byte layout for day **3**, month **4**, 2026, 15:20:17. Day and month each arrive escaped, and the parser keeps both escape bytes. A day or month of 2, 3 or 4 gives the "10-byte" form; any other gives the "9-byte" form. The monitor-log partial records' "`raw_data[11] == 0x10` → 10-byte format" rule is the same artifact. The fix on the parity branch for the 0x1C status (`d990466`) adds `framing.unescape_reply()`, which removes the kept escape bytes. Decoding the 0C record after it should collapse both layouts into one. Not tested on 0C.
Author
Owner

One more field identified: the geophone range (measured 2026-11-01).

  • Where it is: in the recording setup's channel blocks, the byte 29 after each geophone label (00 00 01 + Tran / Vert / Long). 0x00 is Normal (10.000 in/s full scale), 0x01 is Sensitive (1.250 in/s). The blocks follow the setup name (1c 08 + name).
  • Measured against Blastware: it matches the _XML.XML report's GeoRange on 70,042 / 70,042 DL2 events, 2016–2026. All three channels agree on every event; 35 are Sensitive.
  • Related: SFM's live 1A read has the same byte at label+33.

Fixed on dev: merge 057df47, fix 4844135.

  • Before this, SFM assumed Normal, so a Sensitive event's peaks, vector sum and .h5 samples read 8× high.
  • Decode checker over all DL2 events: geophone samples now exact on 6,524 / 6,524 waveforms (was 6,491), 70,287 comparisons fixed, 0 regressions.
  • Ships in the next release. That release needs backfill_sidecars.py + backfill_event_shape.py.
**One more field identified: the geophone range (measured 2026-11-01).** - **Where it is:** in the recording setup's channel blocks, the byte 29 after each geophone label (`00 00 01` + `Tran` / `Vert` / `Long`). `0x00` is Normal (10.000 in/s full scale), `0x01` is Sensitive (1.250 in/s). The blocks follow the setup name (`1c 08` + name). - **Measured against Blastware:** it matches the `_XML.XML` report's `GeoRange` on **70,042 / 70,042** DL2 events, 2016–2026. All three channels agree on every event; 35 are Sensitive. - **Related:** SFM's live 1A read has the same byte at label+33. **Fixed on `dev`:** merge `057df47`, fix `4844135`. - Before this, SFM assumed Normal, so a Sensitive event's peaks, vector sum and `.h5` samples read 8× high. - Decode checker over all DL2 events: geophone samples now exact on **6,524 / 6,524** waveforms (was 6,491), 70,287 comparisons fixed, 0 regressions. - Ships in the next release. That release needs `backfill_sidecars.py` + `backfill_event_shape.py`.
Sign in to join this conversation.