.h5 files record sample_rate 0 when there is no paired report: Blastware imports (BE9441) and SFM's Micromate downloads #44

Open
opened 2026-10-26 14:21:57 -04:00 by serversdown · 3 comments
Owner

Summary

Every .h5 written in tmi-seismo's Phase 2 session 1 (2026-10-25) has sample_rate = 0: 20 MiniMate events (BE9441) imported from Blastware files, and 20 Micromate events (UM12947) downloaded by SFM's own device path. Both units were set to 4096 S/s. The DB rows show sample_rate None for BE9441.

Re-checked on origin/feat/series4-sfm-parity at 465bc70, by decoding the same original files: still None from both decoders.

Where it comes from

  • MiniMate, Blastware import (save_imported_bw): read_blastware_file() returns sample_rate=None for BE9441's files, and the sidecar has event.sample_rate None.
  • Micromate, SFM download (phase 1b → save_imported_idf, no paired TXT): micromate.idf_file.read_idf_file() gives IdfBinaryMetadata(sample_rate=None, record_time_sec=None, event_datetime=None), and IdfEvent.timestamp comes out as 1970-01-01. The TXT report is the only source of these today, and the device download never has one.
  • sfm/event_hdf5.py writes int(event.sample_rate or 0) (~line 232), so None becomes 0.

Why it matters

  • plot_json_from_hdf5 reads it back as int(a.get("sample_rate", 1024) or 1024) (~line 475). These events would therefore plot on a 1024 S/s time base: four times too long for a 4096 event, and any frequency taken from it four times too low. This is from reading the code; I have not checked it in Terra-View.
  • tmi-seismo's reader refuses a rate of 0. Its comparison had to be given 4096 by hand (--ref-rate).

Evidence

  • The original files are in tmi-seismo at c0b6390:

    • bench/data/2026-10-25_phase2_garage/unit-originals/BE9441/: 20 Blastware event files plus BE9441.MLG;
    • unit-originals/UM12947/: 20 .IDFW.

    SHA-256 for every file is in that directory's manifest.txt.

  • The rate is 4096 from the record lengths:

    • MiniMate: 21,504 samples per channel = 5.25 s at 4096;
    • Micromate: 16,384 = 4.0 s.

    It also fits tmi-seismo's laptop-timed stream best of 2048, 4096 and 8192.

  • Write-up: tmi-seismo docs/phase-2-findings.md §6.

Suggested

Read the rate from the binary in both paths. Where a decoder can't find one, store "unknown" in a way a reader cannot mistake for a rate, rather than defaulting. For example, omit the attribute, or keep 0 and drop the 1024 fallback in plot_json_from_hdf5.

Context

Found with a standalone SFM at b1c87ec (sfm 0.31.0). Since then the same branch has:

  • fixed the MiniMate serial (a8cc516);
  • fixed the cold-boot wait (d73a27d);
  • made its MiniMate downloads byte-identical to Blastware's (465bc70).

So the MiniMate could now come through SFM directly. But the branch does not contain the #42 fix (e506bcf), so Micromate .h5 written from it are on the old +0.71% scale.

Pre-trigger, record time and the project fields are wrong or empty in the same files: see the companion issue.

## Summary Every `.h5` written in tmi-seismo's Phase 2 session 1 (2026-10-25) has **`sample_rate` = 0**: 20 MiniMate events (BE9441) imported from Blastware files, and 20 Micromate events (UM12947) downloaded by SFM's own device path. Both units were set to 4096 S/s. The DB rows show `sample_rate` None for BE9441. Re-checked on `origin/feat/series4-sfm-parity` at `465bc70`, by decoding the same original files: still None from both decoders. ## Where it comes from - **MiniMate, Blastware import** (`save_imported_bw`): `read_blastware_file()` returns `sample_rate=None` for BE9441's files, and the sidecar has `event.sample_rate` None. - **Micromate, SFM download** (phase 1b → `save_imported_idf`, no paired TXT): `micromate.idf_file.read_idf_file()` gives `IdfBinaryMetadata(sample_rate=None, record_time_sec=None, event_datetime=None)`, and `IdfEvent.timestamp` comes out as 1970-01-01. The TXT report is the only source of these today, and the device download never has one. - `sfm/event_hdf5.py` writes `int(event.sample_rate or 0)` (~line 232), so None becomes 0. ## Why it matters - `plot_json_from_hdf5` reads it back as `int(a.get("sample_rate", 1024) or 1024)` (~line 475). These events would therefore plot on a 1024 S/s time base: four times too long for a 4096 event, and any frequency taken from it four times too low. This is from reading the code; I have not checked it in Terra-View. - tmi-seismo's reader refuses a rate of 0. Its comparison had to be given 4096 by hand (`--ref-rate`). ## Evidence - The original files are in tmi-seismo at `c0b6390`: - `bench/data/2026-10-25_phase2_garage/unit-originals/BE9441/`: 20 Blastware event files plus `BE9441.MLG`; - `unit-originals/UM12947/`: 20 `.IDFW`. SHA-256 for every file is in that directory's `manifest.txt`. - The rate is 4096 from the record lengths: - MiniMate: 21,504 samples per channel = 5.25 s at 4096; - Micromate: 16,384 = 4.0 s. It also fits tmi-seismo's laptop-timed stream best of 2048, 4096 and 8192. - Write-up: tmi-seismo `docs/phase-2-findings.md` §6. ## Suggested Read the rate from the binary in both paths. Where a decoder can't find one, store "unknown" in a way a reader cannot mistake for a rate, rather than defaulting. For example, omit the attribute, or keep 0 and drop the 1024 fallback in `plot_json_from_hdf5`. ## Context Found with a standalone SFM at `b1c87ec` (sfm 0.31.0). Since then the same branch has: - fixed the MiniMate serial (`a8cc516`); - fixed the cold-boot wait (`d73a27d`); - made its MiniMate downloads byte-identical to Blastware's (`465bc70`). So the MiniMate could now come through SFM directly. But the branch does **not** contain the #42 fix (`e506bcf`), so Micromate `.h5` written from it are on the old +0.71% scale. Pre-trigger, record time and the project fields are wrong or empty in the same files: see the companion issue.
serversdown added the Kind/Bug
Priority
Medium
3
labels 2026-10-26 14:21:57 -04:00
Author
Owner

Series-3 half fixed on dev (merge 42fe35f, fix b4706a3). Ships in the next release. This issue stays open for the Micromate half.

Where the rate is (measured)

  • A Blastware event file's sample rate is a uint16 BE, 42 bytes before the recording setup's name.
  • That name is the NUL-terminated string right after the bytes 1c 08. That form matches exactly once in every one of DL2's 70,041 archive files.
  • The old lookup searched for the text "Standard Recording Setup", but that is just the setup's name. 37% of DL2's files use another name (BE18192.set, BE16352.set and so on), so it never found them.
  • BE9441's bench file K441LTOF.ZI0 now reads 4096 (tests/test_bw_file_fields.py).

Verified against Blastware's own reports (measured)

DL2's Sent/ folder holds Blastware's full event report for each event, <stem>_<ext>_XML.XML, with every report field and every sample. There are 70,042 of them, back to 2016. The ASCII reports only go back to 2025.

Checked against those reports, SFM's file-only sample rate matches on 70,042 / 70,042 (6,524 waveforms + 63,518 histograms). Harness: scratch/verify_bw_fields_against_xml.py.

Still open here

  • Micromate: read_idf_file() still returns no sample rate for SFM's own downloads. That path lives on feat/series4-sfm-parity.
  • The .h5 fallback: event_hdf5 still writes int(sample_rate or 0), and the plot still falls back to 1024. Series 3 now always has a rate, so this matters for Micromate downloads and undecodable files.

Prod

  • Codec change: TOOL_VERSION gets bumped at release.
  • Then run backfill_sidecars.py and backfill_event_shape.py (~2 h on the NAS). The existing upsert refreshes sample_rate and the notes on stored rows.
**Series-3 half fixed on `dev`** (merge `42fe35f`, fix `b4706a3`). Ships in the next release. This issue stays open for the Micromate half. ### Where the rate is (measured) - A Blastware event file's **sample rate is a uint16 BE, 42 bytes before the recording setup's name**. - That name is the NUL-terminated string right after the bytes `1c 08`. That form matches **exactly once in every one of DL2's 70,041 archive files**. - The old lookup searched for the text "Standard Recording Setup", but that is just the setup's name. **37% of DL2's files use another name** (`BE18192.set`, `BE16352.set` and so on), so it never found them. - BE9441's bench file `K441LTOF.ZI0` now reads **4096** (`tests/test_bw_file_fields.py`). ### Verified against Blastware's own reports (measured) DL2's `Sent/` folder holds Blastware's full event report for each event, `<stem>_<ext>_XML.XML`, with every report field and every sample. There are **70,042 of them, back to 2016**. The ASCII reports only go back to 2025. Checked against those reports, SFM's file-only sample rate matches on **70,042 / 70,042** (6,524 waveforms + 63,518 histograms). Harness: `scratch/verify_bw_fields_against_xml.py`. ### Still open here - **Micromate:** `read_idf_file()` still returns no sample rate for SFM's own downloads. That path lives on `feat/series4-sfm-parity`. - **The `.h5` fallback:** `event_hdf5` still writes `int(sample_rate or 0)`, and the plot still falls back to 1024. Series 3 now always has a rate, so this matters for Micromate downloads and undecodable files. ### Prod - Codec change: `TOOL_VERSION` gets bumped at release. - Then run `backfill_sidecars.py` and `backfill_event_shape.py` (~2 h on the NAS). The existing upsert refreshes `sample_rate` and the notes on stored rows.
Author
Owner

Series-3 half shipped in v0.33.0. It reached main with release PR #56 on 2026-11-01. It was deployed to prod the same day with its backfills (backfill_event_shape.py exit 0, 26,711 rows updated, 0 cleared).

This issue stays open for the Micromate half, which belongs to feat/series4-sfm-parity.

**Series-3 half shipped in v0.33.0.** It reached `main` with release PR #56 on 2026-11-01. It was deployed to prod the same day with its backfills (`backfill_event_shape.py` exit 0, 26,711 rows updated, 0 cleared). This issue stays open for the Micromate half, which belongs to `feat/series4-sfm-parity`.
Author
Owner

Fixed on dev (merge 0c228fa, 2026-11-20); ships in the next release, whose dev->main PR will close this.

  • MiniMate half: fixed in v0.33.0. Re-measured on the 20 BE9441 bench files: 4096 S/s, 1,024 pre-trigger samples (0.25 s), 5 s, notes "TestUnit-Minimate" / "Test unit 1".
  • Micromate half: a Thor file's own settings record, event time and notes are now read from the file. The old reader looked for bytes that only exist at a 0.25 s pre-trigger.
    • Measured against Thor's own reports on 2,027 corpus files: sample rate 2,027 / 2,027, event time 2,384 / 2,384.
    • The 20 UM12947 bench files now store 4096 S/s and the right time.
    • Details: CHANGELOG Unreleased, docs/idf_protocol_reference.md (Signature A).
Fixed on dev (merge 0c228fa, 2026-11-20); ships in the next release, whose dev->main PR will close this. - **MiniMate half:** fixed in v0.33.0. Re-measured on the 20 BE9441 bench files: 4096 S/s, 1,024 pre-trigger samples (0.25 s), 5 s, notes "TestUnit-Minimate" / "Test unit 1". - **Micromate half:** a Thor file's own settings record, event time and notes are now read from the file. The old reader looked for bytes that only exist at a 0.25 s pre-trigger. - Measured against Thor's own reports on 2,027 corpus files: sample rate 2,027 / 2,027, event time 2,384 / 2,384. - The 20 UM12947 bench files now store 4096 S/s and the right time. - Details: CHANGELOG Unreleased, docs/idf_protocol_reference.md (Signature A).
Sign in to join this conversation.