feat: add waveform store handling #16
Reference in New Issue
Block a user
Delete Branch "sfm-waveform-store"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
### Added - **Layered event storage architecture.** Each event now lands as four files in the per-serial waveform store, each with a clear role: - `<filename>` — the Blastware-readable binary (BW file). Untouched. - `<filename>.a5.pkl` — the raw 5A frames (regenerative source). - `<filename>.h5` — clean per-channel waveform arrays in physical units (in/s for geo, psi for mic) plus event metadata (HDF5 with gzip compression). This is the canonical format for downstream analysis tools. - `<filename>.sfm.json` — the modern review/metadata sidecar (peaks, project, source provenance, review state, extensions). SQLite (`seismo_relay.db`) is the searchable index over all four. - **Plot-ready waveform JSON (`sfm.plot.v1`).** The `/device/event/{idx}/waveform` and `/db/events/{id}/waveform.json` endpoints now return samples in physical units with explicit time-axis metadata, peak markers, and per-channel unit hints — no more guessing the ADC-to-velocity scale client-side. The webapp waveform viewer was rewritten to consume this shape. - **In-app waveform viewer accuracy fix.** The standalone SFM webapp viewer was scaling geophone amplitudes by `geoAdcScale / 32767` (≈ 6.206 / 32767), where `geoAdcScale = 6.206053` is the device's *in/s per V* hardware constant — not the ADC-counts-to-velocity factor. This silently scaled every plot ~38% too low for Normal-range geophones (the correct full-scale is 10.0 in/s, or 1.25 in/s for Sensitive). Conversion is now done server-side using the geo_range from compliance config; the client just plots. - New `sfm/event_hdf5.py` module: `write_event_hdf5()`, `read_event_hdf5()`, plus a plot-JSON helper. - Backfill script extended to also emit `.h5` for existing events. ### Dependencies - Added `h5py>=3.10` and `numpy>=1.24` for the HDF5 storage layer. - Added `python-multipart>=0.0.7` (required by FastAPI for the `/db/import/blastware_file` endpoint introduced in this release).