diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bb5bd8..21a5034 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,41 @@ All notable changes to seismo-relay are documented here. --- -## Unreleased +## v0.33.0 — 2026-11-01 + +**SFM reads Series-3 events from the file alone, and proves it against +Blastware.** + +**What was broken.** A Blastware event that reached SFM without its ASCII +report used to come in half-decoded: +- no sample rate +- a "70 s" record time, which was really the record-type byte +- blank notes +- every histogram typed as a waveform +- a histogram vector sum built from channel peaks taken at different moments +- a mic reading about 95× low in psi + +That matters more now: every DL2 event from before 2025 arrives with no report, +and SFM's own download and call-in paths never have one. + +**What this release does.** It reads all of those from the event file itself, +and adds the decode checker that proves it. The checker compares SFM's +file-only decode, field by field and sample by sample, with Blastware's own +`_XML.XML` event reports for the 70,042 DL2 events that have one (2016–2026). + +**Where that stands now:** +- sample rate, record time, pre-trigger, notes and event type match on every + event +- geophone samples are exact on 6,491 / 6,524 waveforms (the 33 others are on + the 1.250 in/s range, which SFM cannot read from the file yet) +- the histogram vector sum matches on 69,919 +- the mic matches on all but a few dozen + +Events imported with an ASCII report are unchanged on prod; the report still +overlays. + +⚠ **This release owes prod a backfill.** It does not move stored event times; +see *Migration* below. ### Fixed - **The mic in psi was ~95× low: one MicL count is 0.25 Pa.** @@ -163,6 +197,9 @@ All notable changes to seismo-relay are documented here. - job number, ZC frequency, acceleration, displacement, time of peak, sensor check, battery, calibration, range, units and monitor log are not read yet + - Later in this release, the record type (#41), the histogram vector sum + and the mic conversion were fixed. See their entries above; each was + proven by a full checker run with 0 regressions. - It replaces `scratch/verify_bw_fields_against_xml.py`, added and removed within this release. - **Operational consequence: none.** Nothing on the ingest path changes. @@ -191,6 +228,45 @@ All notable changes to seismo-relay are documented here. The old section stays below the banner as history. Docs only: no code or schema change, no migration, `TOOL_VERSION` unchanged. +### Migration + +⚠ **This release owes prod a backfill.** It does not move stored event times. + +**Before you start:** +- `TOOL_VERSION` is bumped to **0.33.0**, which gates the regeneration, so no + `--force` is needed. +- No parser change, so no `--reparse-txt` is needed. +- No schema change. +- **Back up `seismo_relay.db` first.** + +**Then, in the `sfm` container, in this order** (the scripts default to +`bridges/captures/seismo_relay.db` and its `waveforms/`): + +1. `python scripts/backfill_sidecars.py` re-decodes every Series-3 event file + whose sidecar predates 0.33.0. Sidecars and `.h5` files regenerate, and each + DB row refreshes in place (id and review kept). ⚠ **~2 h on the NAS.** + - **Report-less events** pick up the new values: sample rate, record time, + pre-trigger, notes, record type, histogram vector sum, mic. + - **Report-paired events** keep the report's values. + - **The record type** stays the same for every ACH file (`…W` / `…H`). Only a + histogram stored under a 3-character manual-download name flips from + Waveform to Histogram. +2. `python scripts/backfill_event_shape.py --db-path bridges/captures/seismo_relay.db + --store-root bridges/captures/waveforms` recomputes the shape and offset + metrics from the regenerated files. + +Series-4 (Thor) events are untouched; nothing in their decode changed. + +**Not rehearsed on a prod snapshot** (v0.32.0 was). The risk is lower: +- Event times do not move, so every row is matched in place. +- No row is created or removed. +- The full decode checker ran clean against all 70,112 DL2 event files before + release. + +**Afterwards**, the DL2 watcher can be widened for the 2016–2024 backfill: +`MAX_EVENT_AGE_DAYS = 2130` reaches 2021. Set it back to 365 when done, +because the same setting widens the heartbeat's scan. + --- ## v0.32.0 — 2026-10-27 diff --git a/CLAUDE.md b/CLAUDE.md index 38347da..8ceb078 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,7 +2,7 @@ Ground-up Python replacement for **Blastware**, Instantel's Windows-only software for managing MiniMate Plus seismographs. Connects over direct RS-232 or cellular modem -(Sierra Wireless RV50 / RV55). Current version: **v0.32.0**. +(Sierra Wireless RV50 / RV55). Current version: **v0.33.0**. Stack-level context — which repo owns what, and how the three project versions pair — lives in `../terra-view/docs/tmi-stack.md`, which is also loaded as @@ -10,36 +10,42 @@ pair — lives in `../terra-view/docs/tmi-stack.md`, which is also loaded as --- -## Where things stand (updated 2026-10-19) +## Where things stand (updated 2026-11-01) Read this first when picking the project back up. -- **🔑 The Series-3 decode checker (2026-10-29).** Goal: SFM produces everything - Blastware reports, from the event file alone (spec/plan in `docs/superpowers/`). - Run it with `scratch/check_s3_decode.py ~/dl2-archive/files ~/dl2-archive/xml`. - It decodes each event from its bytes only (no filename, no report) and - compares every field, sample and interval with Blastware's `_XML.XML`: 70,042 - events, 2016–2026, ~22 min at `--jobs 4`. Run output (`summary.md`, - `details.json`, `changes.md`) goes to `~/dl2-archive/checker-runs/` and is - never committed. The rule: every mismatch is SFM's bug unless a carve-out - with evidence covers it. - **First full run:** - - ✅ Sample rate, record time, pre-trigger and notes match everywhere. - - ✅ Geophone samples are exact on 6,491 / 6,524 waveforms in every year. The - 33 others are the 1.250 in/s range, 8× under SFM's Normal-range assumption. - - ❌ Every histogram reads as a waveform without its filename (#41), and - their start times are 1 s early (#51). - - ❌ Open findings: - - histogram PVS: SFM takes the vector magnitude of each channel's interval - peak (peaks that may come from different moments); Blastware takes the - per-interval vector sum - - mic psi conversion - - mic dB off by 0.05–0.1 on ~1,000 events +- **🔑 The Series-3 decode checker (2026-10-29; v0.33.0).** + - **Goal:** SFM produces everything Blastware reports, from the event file + alone (spec and plan in `docs/superpowers/`). + - **Running it:** `scratch/check_s3_decode.py ~/dl2-archive/files + ~/dl2-archive/xml` decodes each event from its bytes only (no filename, no + report). It compares every field, sample and interval with Blastware's + `_XML.XML`: 70,042 events, 2016–2026, ~22 min at `--jobs 4`. + - **Output** (`summary.md`, `details.json`, `changes.md`) goes to + `~/dl2-archive/checker-runs/` and is never committed. + - **The rule:** every mismatch is SFM's bug unless a carve-out with evidence + covers it. + + **As of v0.33.0:** + - ✅ **Match on every event:** sample rate, record time, pre-trigger, notes, + and event type (#41, from STRT[18]). + - ✅ **Geophone samples** are exact on 6,491 / 6,524 waveforms in every year. + The 33 others are the 1.250 in/s range, 8× under SFM's Normal-range + assumption. + - ✅ **Histogram PVS** = the stored per-interval PVS²: 69,919 / 70,042. + - ✅ **Mic: one count = 0.25 Pa,** with Blastware's dB offset at 81.9384. It + fails on only a few dozen events. + - ❌ **Open:** + - histogram start times are 1 s early (#51) - 35 sub-minute (5 s / 2 s) histograms decode wrongly, plus 2 one-minute no-mic histograms (`R352HFZ7`-shaped, likely a separate cause) - 26 histogram start dates are a day off - - ⬜ Not read yet: job number, ZC frequency, acceleration, displacement, time - of peak, sensor check, battery, calibration, range, units, monitor log. + - the per-interval PVS is not stored + - Blastware prints `OORANGE` when the vector sum alone exceeds the range + (a carve-out to prove) + - ⬜ **Not read yet:** job number, ZC frequency, acceleration, displacement, + time of peak, sensor check, battery, calibration, range, units, monitor + log. - **The Series-4 LIVE wire protocol is reverse-engineered end to end (2026-09-25).** `docs/micromate_protocol_reference.md` is the Series-4 Rosetta Stone, sibling to `instantel_protocol_reference.md`. **A Micromate diff --git a/README.md b/README.md index f22397a..2b12e08 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# seismo-relay `v0.32.0` +# seismo-relay `v0.33.0` A ground-up replacement for **Blastware** — Instantel's aging Windows-only software for managing seismographs. Supports both the **MiniMate Plus @@ -74,6 +74,27 @@ over direct RS-232 or cellular modem (Sierra Wireless RV50 / RV55). > > ⚠ The deploy owes a backfill and moves stored waveform times; see the > changelog's *Migration*. +> +> **v0.33.0 (2026-11-01)** reads Series-III events from the file alone, and +> proves it. +> - **Fields now read from the event file** when no Blastware report comes with +> the event: +> - sample rate, record time, pre-trigger and the four notes (#44/#45) +> - the event type (#41) +> - a histogram's peak vector sum, which the unit stores per interval +> - the mic, at one count = 0.25 Pa (it read ~95× low in psi) +> +> This matters for every DL2 event from before 2025, and for SFM's own +> download and call-in paths, none of which have a report. +> - **The decode checker** (`scratch/check_s3_decode.py`) compares SFM's +> file-only decode with Blastware's `_XML.XML` event reports, field by field +> and sample by sample, for 70,042 DL2 events back to 2016: +> - every setup field, the notes and the event type match on every event +> - geophone samples are exact on 6,491 / 6,524 waveforms +> - the histogram vector sum matches on 69,919 +> +> ⚠ The deploy owes a backfill; it does not move event times. See the +> changelog's *Migration*. > See [CHANGELOG.md](CHANGELOG.md) for full version history. --- @@ -600,7 +621,16 @@ Implementation steps (concrete): ### High-impact (unblocks product features) -- [ ] **Series III waveform body codec reverse-engineering.** The 5A bulk-stream body is some kind of compressed/encoded format (not raw int16 LE as previously assumed — see §7.6.1 retraction in `docs/instantel_protocol_reference.md`). Structural framing is ~50% decoded on branch `claude/codec-re-cBGNe` (tagged-block walker, segment counters); per-byte sample mapping is still open. Until this lands, the in-app waveform viewer renders garbage and BW-import peak values fall back to `_peaks_from_samples()` saturation noise. Workaround: pair every BW-imported event with its `_ASCII.TXT` so the device-authoritative peaks land in the DB regardless of codec. +- [x] **Series III waveform body codec reverse-engineering.** ✅ The body codec is fully decoded (`minimateplus/waveform_codec.py`, `histogram_codec.py`), and verified per-sample against Blastware's own exports. As of v0.33.0, geophone samples are exact on 6,491 / 6,524 DL2 waveforms against their `_XML.XML` reports, across 2016–2026. +- [ ] **SFM produces everything Blastware reports, from the event file alone.** The four-piece plan: + 1. the decode checker ✅ v0.33.0 + 2. complete the file-only decode, one field group at a time, each proven by the checker + 3. flip ingest so reports are kept only for checking + 4. stop the watchers forwarding reports + + **Done so far:** setup fields, notes, event type, histogram PVS, mic. + + **Next:** histogram start times (#51), the 37 histograms that decode wrongly, the job number, the geophone range (Sensitive-range events read 8×), and the values Blastware computes itself (ZC frequency, acceleration, displacement, time of peak), plus the sensor check, battery, calibration and monitor log. Design: `docs/superpowers/specs/2026-10-29-s3-decode-checker-design.md`. - [x] **Series IV (Thor IDF) binary codec reverse-engineering.** ✅ v0.21.0 — `micromate/idf_file.read_idf_file()` decodes both IDFW (waveform body at offset `0x0f1f`, reusing `decode_waveform_v2()`; 87–99% sample fidelity on quiet events) and IDFH (dedicated segment-based decoder: all 859 corpus files decode, 181,071 intervals, peaks within ~1.8% of sidecar values). `WaveformStore.save_imported_idf` now also projects parsed Thor data into a `bw_report` block via `micromate/idf_to_bw_report.py` so Thor events render in the existing Event Report PDF pipeline without a separate renderer. - [ ] **In-app waveform viewer accuracy.** Depends on Series III codec decode. Plot.v1 JSON pipeline + viewer skeleton already exist; will start showing real waveforms automatically once `_decode_a5_waveform` produces correct samples. Series IV waveforms come online when the IDF codec lands. - [ ] **Series IV live-device support.** Once the IDF binary is decoded, extend `micromate/` with `transport.py` / `framing.py` / `protocol.py` / `client.py` mirroring the `minimateplus/` package layout — depends on capturing Thor's wire protocol (TCP / RS-232 captures TBD). diff --git a/minimateplus/event_file_io.py b/minimateplus/event_file_io.py index 6bb4a3f..61eacbc 100644 --- a/minimateplus/event_file_io.py +++ b/minimateplus/event_file_io.py @@ -51,7 +51,7 @@ SIDECAR_KIND = "sfm.event" # bumped without a `pip install` re-run — leading to confusing stale # version stamps in sidecars. Bump this constant and CHANGELOG.md # together at release time. -TOOL_VERSION = "0.32.0" # waveform times from the event record, report dates, histogram reader; gates the backfill regen +TOOL_VERSION = "0.33.0" # setup + notes, record type, histogram PVS and mic from the file; gates the backfill regen try: # Best-effort: prefer the installed metadata when it's NEWER than the diff --git a/pyproject.toml b/pyproject.toml index 0f3a8c0..e03f473 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "seismo-relay" -version = "0.32.0" +version = "0.33.0" description = "Python client and REST server for MiniMate Plus seismographs" requires-python = ">=3.10" dependencies = [