diff --git a/CHANGELOG.md b/CHANGELOG.md index 914b4ad..b4fa04a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,37 @@ All notable changes to seismo-relay are documented here. --- +## v0.24.0 — 2026-08-22 + +**Waveform-shape metrics on events.** The `events` table and the `/db/events` +feed now carry per-event crest factor and points-near-peak, computed from the +decoded waveform samples at ingest — groundwork for Terra-View's +false-trigger detection (Phase B). + +### Added + +- **`events` columns** `shape_crest_factor`, `shape_near_peak_count`, + `shape_sample_count`, `shape_axis`. Added via the existing incremental + `_migrate` ADD COLUMN pass — **auto-migrates on `SeismoDb()` construction, + no manual migration**. `query_events` / `get_event` (and thus `/db/events`) + return them automatically (`SELECT *`). +- **Populated at ingest** — crest factor + near-peak-count are computed from + the decoded samples in every save path (`shape_from_h5`/ + `shape_from_samples`), and `insert_events` persists them on INSERT and + UPSERT. +- **Backfill** `scripts/backfill_event_shape.py` — fills the columns for + existing events from their on-disk `.h5` waveform samples (idempotent, + UPDATE-only). + +### Upgrade Notes + +Run the backfill once after deploying, against the events DB + waveform store: +`python3 scripts/backfill_event_shape.py --db-path --store-root ` +Events with no decodable samples (or no waveform file) stay NULL and render +"—" downstream. + +--- + ## v0.23.0 — 2026-08-04 **Per-channel ZC frequency in the events store.** The `events` table and the diff --git a/pyproject.toml b/pyproject.toml index 11f37d4..2a51e33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "seismo-relay" -version = "0.23.0" +version = "0.24.0" description = "Python client and REST server for MiniMate Plus seismographs" requires-python = ">=3.10" dependencies = [ diff --git a/sfm/server.py b/sfm/server.py index 81041c4..ea0c92a 100644 --- a/sfm/server.py +++ b/sfm/server.py @@ -90,7 +90,7 @@ app = FastAPI( "Implements the minimateplus RS-232 protocol library.\n" "Proxied by terra-view at /api/sfm/*." ), - version="0.23.0", + version="0.24.0", ) # Allow requests from the waveform viewer opened as a local file (file://) diff --git a/tests/test_db_events_exposes_shape.py b/tests/test_db_events_exposes_shape.py new file mode 100644 index 0000000..9590ab8 --- /dev/null +++ b/tests/test_db_events_exposes_shape.py @@ -0,0 +1,29 @@ +from __future__ import annotations +import os, sys +from pathlib import Path + +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from sfm.database import SeismoDb +from minimateplus.models import Event + +SHAPE_COLS = ( + "shape_crest_factor", + "shape_near_peak_count", + "shape_sample_count", + "shape_axis", +) + + +def test_query_events_row_includes_shape_keys(tmp_path: Path): + db = SeismoDb(tmp_path / "s.db") + + ev = Event(index=0) + ev._waveform_key = bytes.fromhex("0111abcd") + + db.insert_events([ev], serial="BE1") + row = db.query_events(serial="BE1")[0] + + for k in SHAPE_COLS: + assert k in row + assert row[k] is None