Files
seismo-relay/tests/test_decode_check.py
T
serversdownandClaude Opus 5.5 3e69a2acdd feat(codec): SFM's side of the decode check, from the event bytes alone
decode_blastware_bytes with no filename and no report: the values SFM
produces today in Blastware's field names, its notes, channels and raw
counts, with its Normal-range assumption kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-10-29 19:24:31 -04:00

45 lines
1.8 KiB
Python

"""
The decode checker's SFM side and comparison (decode checker, Tasks 2-4).
Expected values come from the fixtures' Blastware XML reports. SFM's side is
built from the event bytes alone -- no filename, no report.
"""
from __future__ import annotations
from pathlib import Path
import pytest
from minimateplus.decode_check import sfm_side
FIX = Path(__file__).parent / "fixtures/decode-checker-10-29-26"
def test_waveform_side_from_bytes():
s = sfm_side((FIX / "R352HIUI.F40W").read_bytes())
assert s.values["SampleRate"] == 1024 and s.values["RecordTime"] == pytest.approx(1.0)
assert s.values["Pre-triggerLength"] == pytest.approx(-253 / 1024)
assert (s.values["EventDate"], s.values["EventTime"]) == ("2018-07-30", "16:13:52")
assert s.notes == ["JV 241 - 1425 Spanlers Mill Rad", "Walsh Granite JV",
"Terra-Mechanics Inc- D. Harrison", "Loc #1 - 1425 Spanlers Mill Rd"]
assert len(s.counts["Tran"]) == 1277 and s.job_number is None
def test_histogram_interval_peak_in_counts():
s = sfm_side((FIX / "M529L4XQ.R30H").read_bytes())
# Blastware: Tran interval peak 2.430 in/s = 7776 counts at 10/32000 in/s per count
assert s.counts["Tran"] == [7776] and s.values["NumberofIntervals"] == 1
def test_no_filename_reaches_the_decoder():
# The type must come from the bytes; today they can't tell it (#41), so this
# histogram reads as a waveform. Update to "Full Histogram" when #41 lands.
s = sfm_side((FIX / "M529L4XQ.R30H").read_bytes())
assert s.values["EventType"] == "Full Waveform"
def test_report_fields_stay_blank():
s = sfm_side((FIX / "T1905KDW.5F0W").read_bytes())
for tag in ("TranZCFreq", "TranPeakAcceleration", "BatteryLevel", "Calibration", "TranTestResults"):
assert s.values.get(tag) is None