17 Commits
Author SHA1 Message Date
serversdown fb14a8f7bb Merge pull request 'Release v0.33.0 — SFM reads Series-3 events from the file alone' (#56) from dev into main
Reviewed-on: #56
2026-11-01 14:33:00 -05:00
serversdownandClaude Opus 5.5 6c7c6b0a15 chore(release): v0.33.0 — SFM reads Series-3 events from the file alone, and proves it
A Blastware event that reaches SFM without its ASCII report -- every DL2
event before 2025, and every event SFM downloads itself -- now carries
its sample rate, record time, pre-trigger, notes and event type, the
histogram vector sum the unit stores, and a mic reading at one count =
0.25 Pa.  The new decode checker proves each against Blastware's own
_XML.XML reports for 70,042 DL2 events.

- CHANGELOG: Unreleased -> v0.33.0 with theme and Migration.
- TOOL_VERSION 0.33.0 (gates the backfill regeneration).
- pyproject, CLAUDE.md and README versions; README status entry and
  roadmap (the Series-III codec item was long done; the file-only goal
  added); CLAUDE.md 'Where things stand' brought up to v0.33.0.

Deploy: back up seismo_relay.db, then backfill_sidecars.py and
backfill_event_shape.py (~2 h on the NAS).  No schema change, no
migration, event times do not move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-01 14:20:15 -05:00
serversdownandClaude Opus 5.5 287ef2a653 docs(changelog): Unreleased -- one MicL count is 0.25 Pa
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-10-31 02:19:49 -04:00
serversdownandClaude Opus 5.5 30a249ef57 merge: one MicL count is 0.25 Pa; Blastware's dB offset 81.9384
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-10-31 02:19:17 -04:00
serversdownandClaude Opus 5.5 18951505f0 fix(decode): Blastware's mic dB offset is 81.9384, a hair above exact 0.25 Pa
The checker caught 280 regressions in the first mic fix: every one a dB
value at count 129, where 20 log10(129 x 0.25 Pa / 20 uPa) = 124.149997
rounds to 124.1 and Blastware prints 124.2.  Blastware's dB offset sits in
[81.9383, 81.9385] -- any value there matches its dB(L) on 1,729,252 /
1,729,253 DL2 intervals (the last printed '0.000'); exact 81.93820 rounds
count 129 down, and the old 81.94 misses counts 119 and 132.  Single
precision does not explain it.  psi keeps 0.25 Pa per count, which
matches every interval.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-10-31 01:55:45 -04:00
serversdownandClaude Opus 5.5 5644dbd5ad fix(decode): one MicL count is 0.25 Pa -- the mic psi was ~95x low
SFM converted mic counts to psi with a '~0.5 psi full-scale' guess
(0.0125 / 32768 psi per count).  Measured against 1,729,253 DL2
histogram intervals' 'MicL Peak' columns: one count is exactly 0.25 Pa.
count x 0.25 Pa matches Blastware's psi(L) on every interval, and
20 log10(count x 0.25 Pa / 20 uPa) its dB(L) on all but 17 exact
half-way cases.

- event_file_io: _MIC_FS_PSI -> _MIC_PSI_PER_COUNT = 0.25 / 6894.757
  (3.626e-5 psi per count, was 3.81e-7).  The event's mic peak in psi,
  and with it the .h5 mic trace (event_hdf5 back-solves its scale from
  that peak), come right on events with no report.
- waveform_codec.mic_count_to_db: the offset is 20 log10(0.25 / 20e-6)
  = 81.938, not 81.94 -- the old value missed 49 of those intervals at a
  rounding edge (count 119 printed 123.4, 81.94 gave 123.451).

The decoded count was always right: count 16 on K441LTON.900 is
Blastware's 106.0 dB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-10-31 01:28:23 -04:00
serversdown e9c01ce8d4 Merge pull request 'Release v0.32.0 — event times you can trust, and Series 4 mapped' (#54) from dev into main
Reviewed-on: #54
2026-10-27 11:00:59 -04:00
serversdown d2258dad4e Merge pull request 'Release v0.31.0 — report parity + the inverted rescue (0.29.0 → 0.31.0)' (#40) from dev into main
Reviewed-on: #40
2026-09-18 16:46:41 -04:00
serversdown e050e602c2 Merge pull request 'Release v0.29.0 — offset detector + false_trigger_reason + BlastMate serials (0.27.0→0.29.0)' (#36) from dev into main
Reviewed-on: #36
2026-09-07 15:57:37 -04:00
serversdown fc1c7c7936 Merge pull request 'Docs/claude.md corrections' (#35) from dev into main
Reviewed-on: #35
2026-08-29 15:48:33 -04:00
serversdown 7d0d12079b Merge pull request 'v0.27.0 Decoder fixes, offset exploration and testing.' (#34) from dev into main
Reviewed-on: #34
2026-08-28 22:40:34 -04:00
serversdown 5203aab849 Merge pull request 'update to 0.26.0. Big chonking update including 0.23, 0.24, and 0.25 as well.' (#33) from dev into main
Reviewed-on: #33
2026-08-27 13:43:00 -04:00
serversdown 5b65718b72 Merge pull request 'v0.23.0 - ZC freq in events store' (#31) from dev into main
Reviewed-on: #31
2026-08-06 12:12:19 -04:00
serversdown 483762607e Merge pull request 'Update to v0.22.0' (#30) from dev into main
Reviewed-on: #30
2026-07-03 15:35:20 -04:00
serversdown d0b66368d5 Merge pull request 'update to v0.21.1, thor data import successful' (#29) from dev into main
Reviewed-on: #29
2026-06-01 16:54:23 -04:00
serversdown 2eb1d25028 Merge pull request 'v0.20.0 -- Full s3 event parse and PDF creation.' (#28) from dev into main
Reviewed-on: #28
2026-05-28 17:54:31 -04:00
claude cc821f9ee3 hotfix: fix dockerfile on main to fix import bug on prod 2026-05-21 20:42:15 +00:00
9 changed files with 236 additions and 48 deletions

No files matched your search

+108 -1
View File
@@ -4,9 +4,74 @@ 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.**
- SFM converted mic counts with a "~0.5 psi full-scale" guess (0.0125 /
32768 psi per count). The decoded count was always right: count 16 on
`K441LTON.900` is Blastware's 106.0 dB.
- Measured against 1,729,253 DL2 histogram intervals' "MicL Peak"
columns: count × 0.25 Pa matches Blastware's psi(L) on every one.
- `event_file_io._MIC_FS_PSI` is now `_MIC_PSI_PER_COUNT` = 0.25 / 6894.757
(3.626e-5 psi per count).
- The event's mic peak comes right on events with no report, and so does
the `.h5` mic trace (`event_hdf5` derives its scale from that peak).
- **dB offset:** `waveform_codec.mic_count_to_db` now uses 81.9384, not
81.94. Blastware's dB sits in a measured window, [81.9383, 81.9385], a
hair above the exact 81.93820. Any value in the window matches on
1,729,252 / 1,729,253 intervals.
- The checker's first run of this fix flagged 280 regressions, every one
count 129, which exact 0.25 Pa rounds to 124.1 against Blastware's
124.2.
- The old 81.94 misses counts 119 and 132.
- Decode checker, against the pre-fix baseline: 45,035 fixed, 0
regressions.
| Field | Mismatches before | After |
|---|---|---|
| interval psi | 42,783 | 26 |
| interval dB | 974 | 20 |
| mic peak | 345 | 40 |
| waveform mic samples | 1,056 | 37 |
- ⚠ **Codec change, covered by the same release bump.** The backfill
rewrites stored mic values on report-less events; report-paired events
keep the report's. No schema change.
- **A histogram's peak vector sum is now the one the unit stores.** SFM
computed it from each channel's interval peak, and those can come from
different moments. So on 86% of DL2's histograms with no report it read
@@ -132,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.
@@ -160,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
+31 -25
View File
@@ -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
+32 -2
View File
@@ -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).
+3 -3
View File
@@ -18,7 +18,7 @@ from dataclasses import dataclass
from typing import Callable, Optional, Sequence
from .bw_xml_report import XmlReport
from .event_file_io import _GEO_INT16_FS, _GEO_NORMAL_FS_INS, _MIC_FS_PSI, decode_blastware_bytes
from .event_file_io import _GEO_INT16_FS, _GEO_NORMAL_FS_INS, _MIC_PSI_PER_COUNT, decode_blastware_bytes
from .models import Event
from .waveform_codec import mic_count_to_db
@@ -133,7 +133,7 @@ def _mic_converter(ref: XmlReport) -> Optional[Callable[[int], float]]:
if "dB(L)" in units:
return mic_count_to_db
if "psi(L)" in units:
return lambda c: c * _MIC_FS_PSI
return lambda c: c * _MIC_PSI_PER_COUNT
return None
@@ -200,7 +200,7 @@ def _interval_converter(title: str) -> Optional[Callable[[int], float]]:
if ch == "MicL" and rest == "Peak dB(L)":
return mic_count_to_db
if ch == "MicL" and rest == "Peak psi(L)":
return lambda c: c * _MIC_FS_PSI
return lambda c: c * _MIC_PSI_PER_COUNT
return None
+9 -7
View File
@@ -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
@@ -708,10 +708,12 @@ _GEO_INT16_FS = 32000.0
# the Normal range (the same assumption as the samples above).
_HIST_GEO_UNIT_INS = 16 * _GEO_NORMAL_FS_INS / _GEO_INT16_FS
# Microphone scale factor, psi per ADC count. Approximate — exact factor
# depends on the geophone-vs-mic ADC scaling and the firmware reference.
# We mark mic_psi as "computed approximate" in the sidecar.
_MIC_FS_PSI = 0.0125 / _INT16_FS # ~0.5 psi full-scale assumption
# Microphone scale factor, psi per MicL count: one count is 0.25 Pa
# (waveform_codec.MIC_PA_PER_COUNT, measured against Blastware's psi(L) on
# 1,729,253 DL2 intervals). It replaces a "~0.5 psi full-scale" guess,
# 0.0125 / 32768, that read every mic peak ~95x low (2026-10-31).
_PA_PER_PSI = 6894.757
_MIC_PSI_PER_COUNT = _wc.MIC_PA_PER_COUNT / _PA_PER_PSI
def _decode_strt(strt: bytes) -> dict:
@@ -763,9 +765,9 @@ def _peaks_from_samples(samples: dict[str, list[int]]) -> PeakValues:
vert = _peak_ins(samples.get("Vert", []))
long_ = _peak_ins(samples.get("Long", []))
# Mic in psi (approximate)
# Mic in psi: one count = 0.25 Pa
mic_ch = samples.get("MicL", []) or []
mic = max((abs(int(v)) for v in mic_ch), default=0) * _MIC_FS_PSI
mic = max((abs(int(v)) for v in mic_ch), default=0) * _MIC_PSI_PER_COUNT
# Peak vector sum: max over time of sqrt(T^2 + V^2 + L^2)
pvs = 0.0
+20 -9
View File
@@ -628,23 +628,34 @@ def decoded_to_adc_counts(decoded: dict) -> dict:
}
# One MicL count is 0.25 Pa (measured 2026-10-31): count x 0.25 Pa matches
# Blastware's "MicL Peak psi(L)" on all 1,729,253 DL2 histogram intervals
# checked.
MIC_PA_PER_COUNT = 0.25
# Blastware's dB(L) offset sits a hair above the exact 20 log10(0.25 Pa /
# 20 uPa) = 81.93820: any value in [81.9383, 81.9385] matches its dB on
# 1,729,252 / 1,729,253 intervals (the one left printed "0.000"), while
# 81.93820 rounds count 129 (162 intervals) to 124.1 against Blastware's
# 124.2, and the 81.94 first fitted to a handful of values misses counts 119
# and 132. Its display chain presumably carries rounded constants; the
# window, not the physics, is what is measured.
_MIC_DB_REF = 81.9384
def mic_count_to_db(count: int) -> float:
"""Convert a MicL ADC count to dB(L) for BW-display-compatible output.
Empirical formula (confirmed 2026-05-11 against V70 fixture: count=813
→ 140.1 dB; count=±1 → ±81.94 dB; count=±24 → ±109.5 dB):
dB = sign(count) × (81.9384 + 20 × log10(|count|)) for |count| ≥ 1
dB = 0.0 for count == 0
dB = sign(count) × (81.94 + 20 × log10(|count|)) for |count| ≥ 1
dB = 0.0 for count == 0
The constant 81.94 corresponds to 10^(81.94/20) ≈ 12490 mic ADC counts
being the dB(L) reference level — almost certainly a calibration
constant from the device's mic.
81.9384 ≈ 20 log10(0.25 Pa / 20 µPa); see _MIC_DB_REF.
count=±1 → ±81.94 dB; count=813 → 140.14 dB (the V70 fixture).
"""
if count == 0:
return 0.0
sign = 1.0 if count > 0 else -1.0
return sign * (81.94 + 20.0 * math.log10(abs(count)))
return sign * (_MIC_DB_REF + 20.0 * math.log10(abs(count)))
# ── A5-frame entry point ────────────────────────────────────────────────────
+1 -1
View File
@@ -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 = [
+27
View File
@@ -179,3 +179,30 @@ def test_interval_pvs_per_interval():
# Blastware's interval table, first four "Geo PVS" values
for got, want in zip(pvs[:4], (0.065, 0.034, 0.015, 0.461)):
assert abs(got * 0.005 - want) <= 0.0005 + 1e-9, (got, want)
# ── The mic: one count = 0.25 Pa ────────────────────────────────────────────
# Measured 2026-10-31 against 1,729,253 DL2 histogram intervals' "MicL Peak"
# columns: count x 0.25 Pa matches Blastware's psi(L) on every one, and
# 20 log10(count x 0.25 Pa / 20 uPa) its dB(L) on all but 17 exact half-way
# cases. The old psi factor (a "~0.5 psi full-scale" guess) was ~95x small.
from minimateplus.waveform_codec import mic_count_to_db # noqa: E402
@pytest.mark.parametrize("count,printed", [
(1, "81.94"), # XML sample cell
(119, "123.4"), # Blastware interval tables, where 81.94 + 20 log10 gave 123.451
(132, "124.3"), # ... and 124.351
(129, "124.2"), # 162 intervals; exactly 0.25 Pa gives 124.149997, a hair under half-way
(813, "140.14"), # V70 fixture, Blastware display
])
def test_mic_db_matches_blastware(count, printed):
d = len(printed.split(".")[1])
assert abs(mic_count_to_db(count) - float(printed)) <= 0.5 * 10 ** -d + 1e-9
def test_mic_peak_in_psi():
# Blastware: MicL PSPL 106.0 dB(L) = 20 uPa x 10^(106/20) = 3.990 Pa = 5.787e-4 psi.
ev = read_blastware_file(_FIX / "decode-checker-10-29-26/M529L4XQ.R30H")
assert ev.peak_values.micl == pytest.approx(5.787e-4, rel=0.01)
+5
View File
@@ -142,3 +142,8 @@ def test_pvs_carveout_needs_the_clipped_channel_at_the_ceiling():
side.values["TranPPV"] = 1.256
res = {r.field: r for r in compare(side, ref, CARVEOUTS)}
assert res["PeakVectorSum"].verdict == "mismatch"
def test_interval_mic_psi_matches():
# psi(L) report: every interval's "MicL Peak psi(L)" now converts right
assert _results("T004JTRF.ME0H")["intervals.MicL Peak psi(L)"].verdict == "match"