merge: dev into feat/series4-sfm-parity -- the geophone range from the file, and v0.33.0

Brings 057df47 (fix 4844135, changelog be58b4f) from the decode checker's branch
-- Event.geo_range from the file's setup channel block (label+29: 0 Normal,
1 Sensitive, None not read), peaks and histogram PVS scaled by it,
write_event_hdf5(geo_range=None) using it -- and dev's v0.33.0 release commit
(6c7c6b0).

Conflicts, resolved as agreed with the decode session:
- sfm/waveform_store.py save_imported_bw: dev dropped the forced
  geo_range="normal"; this branch keeps its geo_range parameter, now
  Optional, default None -- an import uses the file's own range, an explicit
  value (a live download's) still wins.
- CLAUDE.md: dev's newer 'Where things stand (updated 2026-11-01)' date.

Measured on the merged tree: K557J1KB.RQ0W (Sensitive waveform) decodes
0.019 / 0.055 / 0.019, PVS 0.061 -- Blastware's report -- and its imported
.h5 peaks 0.0194 / 0.055 / 0.0194 (forcing 'normal' gives 8x: 0.155 / 0.44).
M010HR6K.OA0H (Sensitive histogram) likewise.  The live path still passes the
unit's 1A range or 'normal' when unread -- unchanged by this merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-11-02 12:06:35 -05:00
commit d0c14aaec8
17 files changed
+3724 -62

No files matched your search

BIN
View File
Binary file not shown.
File diff suppressed because it is too large. Load diff
BIN
View File
Binary file not shown.
+167
View File
@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<Event>
<FileVersion>8.0</FileVersion>
<EventType>Full Histogram</EventType>
<SerialNumber>BE11010</SerialNumber>
<Version>V 10.72-8.17 MiniMate Plus</Version>
<FileName>M010HR6K.OA0H</FileName>
<HistogramStartTime>17:02:34</HistogramStartTime>
<HistogramStartDate>2019-01-08</HistogramStartDate>
<HistogramStopTime>17:20:00</HistogramStopTime>
<HistogramStopDate>2019-01-08</HistogramStopDate>
<Channels>
<Channel>Tran</Channel>
<Channel>Vert</Channel>
<Channel>Long</Channel>
<Channel>MicL</Channel>
</Channels>
<NumberofIntervals>18.00</NumberofIntervals>
<IntervalSize>1 minute</IntervalSize>
<SampleRate>1024 sps</SampleRate>
<BatteryLevel>6.8 Volts</BatteryLevel>
<Calibration>December 17, 2018 by Instantel</Calibration>
<Units>in/s and dB(L)</Units>
<Project>Wampum Ave-ECMS 29301-215 Joseph St</Project>
<Client>Brayman Construction</Client>
<UserName>Terra-Mechanics Inc - D. Bartholomae</UserName>
<Seis.Loc>Loc, #1 - 215 Joseph Street</Seis.Loc>
<GeoRange>
<Value>1.250</Value>
<Units>in/s</Units>
</GeoRange>
<TranPPV>
<Value>0.008</Value>
<Units>in/s</Units>
</TranPPV>
<VertPPV>
<Value>0.009</Value>
<Units>in/s</Units>
</VertPPV>
<LongPPV>
<Value>0.005</Value>
<Units>in/s</Units>
</LongPPV>
<TranZCFreq>
<Value>11</Value>
<Units>Hz</Units>
</TranZCFreq>
<VertZCFreq>
<Value>73</Value>
<Units>Hz</Units>
</VertZCFreq>
<LongZCFreq>
<Value>16</Value>
<Units>Hz</Units>
</LongZCFreq>
<TranPeakTime>17:11:34</TranPeakTime>
<TranPeakDate>2019-01-08</TranPeakDate>
<VertPeakTime>17:03:34</VertPeakTime>
<VertPeakDate>2019-01-08</VertPeakDate>
<LongPeakTime>17:11:34</LongPeakTime>
<LongPeakDate>2019-01-08</LongPeakDate>
<PeakVectorSum>
<Value>0.009</Value>
<Units>in/s</Units>
</PeakVectorSum>
<PeakVectorSumTime>17:11:34</PeakVectorSumTime>
<PeakVectorSumDate>2019-01-08</PeakVectorSumDate>
<Microphone>Linear Weighting</Microphone>
<MicLPSPL>
<Value>134.1</Value>
<Units>dB(L)</Units>
</MicLPSPL>
<MicLTime>17:03:34</MicLTime>
<MicLDate>2019-01-08</MicLDate>
<MicLZCFreq>
<Value>9.7</Value>
<Units>Hz</Units>
</MicLZCFreq>
<TranTestFreq>7.2 Hz.</TranTestFreq>
<TranTestRatio>4.3</TranTestRatio>
<TranTestResults>Passed</TranTestResults>
<VertTestFreq>7.6 Hz.</VertTestFreq>
<VertTestRatio>3.4</VertTestRatio>
<VertTestResults>Passed</VertTestResults>
<LongTestFreq>7.2 Hz.</LongTestFreq>
<LongTestRatio>3.8</LongTestRatio>
<LongTestResults>Passed</LongTestResults>
<MicLTestFreq>20.1 Hz.</MicLTestFreq>
<MicLTestAmplitude>583 mv</MicLTestAmplitude>
<MicLTestResults>Passed</MicLTestResults>
<UsbSummaryChannels>
</UsbSummaryChannels>
<MonitorLog>2019-01-08 17:02:33 - 2019-01-08 17:20:00 &quot;Event Recorded Modem Exit&quot;</MonitorLog>
<HistogramData>
<HistogramDataColumnTitle>
<ColumnTitle> Tran Peak in/s </ColumnTitle>
<ColumnTitle> Tran Freq Hz </ColumnTitle>
<ColumnTitle> Vert Peak in/s </ColumnTitle>
<ColumnTitle> Vert Freq Hz </ColumnTitle>
<ColumnTitle> Long Peak in/s </ColumnTitle>
<ColumnTitle> Long Freq Hz </ColumnTitle>
<ColumnTitle> Geo PVS in/s </ColumnTitle>
<ColumnTitle> MicL Peak psi(L) </ColumnTitle>
<ColumnTitle> MicL Peak dB(L) </ColumnTitle>
<ColumnTitle> MicL Freq Hz </ColumnTitle>
</HistogramDataColumnTitle>
<HistogramDataIntervals>
<Time>2019-01-08 17:03:34</Time>
<Row>
<Cell>0.003</Cell><Cell>47</Cell><Cell>0.009</Cell><Cell>73</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.009</Cell><Cell>0.015</Cell><Cell>134.1</Cell><Cell>9.7</Cell></Row>
<Time>2019-01-08 17:04:34</Time>
<Row>
<Cell>0.003</Cell><Cell>21</Cell><Cell>0.007</Cell><Cell>27</Cell><Cell>0.002</Cell><Cell>85</Cell><Cell>0.007</Cell><Cell>0.000</Cell><Cell>87.96</Cell><Cell>&gt;100</Cell></Row>
<Time>2019-01-08 17:05:34</Time>
<Row>
<Cell>0.004</Cell><Cell>20</Cell><Cell>0.004</Cell><Cell>&gt;100</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.005</Cell><Cell>0.003</Cell><Cell>119.1</Cell><Cell>7.5</Cell></Row>
<Time>2019-01-08 17:06:34</Time>
<Row>
<Cell>0.003</Cell><Cell>34</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.002</Cell><Cell>51</Cell><Cell>0.003</Cell><Cell>0.000</Cell><Cell>81.94</Cell><Cell>&gt;100</Cell></Row>
<Time>2019-01-08 17:07:34</Time>
<Row>
<Cell>0.003</Cell><Cell>51</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.003</Cell><Cell>0.000</Cell><Cell>91.48</Cell><Cell>39</Cell></Row>
<Time>2019-01-08 17:08:34</Time>
<Row>
<Cell>0.004</Cell><Cell>12</Cell><Cell>0.004</Cell><Cell>16</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.005</Cell><Cell>0.000</Cell><Cell>91.48</Cell><Cell>13</Cell></Row>
<Time>2019-01-08 17:09:34</Time>
<Row>
<Cell>0.002</Cell><Cell>51</Cell><Cell>0.002</Cell><Cell>64</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.003</Cell><Cell>0.000</Cell><Cell>81.94</Cell><Cell>&gt;100</Cell></Row>
<Time>2019-01-08 17:10:34</Time>
<Row>
<Cell>0.003</Cell><Cell>12</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.004</Cell><Cell>0.000</Cell><Cell>81.94</Cell><Cell>&gt;100</Cell></Row>
<Time>2019-01-08 17:11:34</Time>
<Row>
<Cell>0.008</Cell><Cell>11</Cell><Cell>0.005</Cell><Cell>13</Cell><Cell>0.005</Cell><Cell>16</Cell><Cell>0.009</Cell><Cell>0.000</Cell><Cell>91.48</Cell><Cell>19</Cell></Row>
<Time>2019-01-08 17:12:34</Time>
<Row>
<Cell>0.006</Cell><Cell>13</Cell><Cell>0.004</Cell><Cell>14</Cell><Cell>0.004</Cell><Cell>51</Cell><Cell>0.007</Cell><Cell>0.000</Cell><Cell>91.48</Cell><Cell>20</Cell></Row>
<Time>2019-01-08 17:13:34</Time>
<Row>
<Cell>0.003</Cell><Cell>57</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.003</Cell><Cell>0.000</Cell><Cell>87.96</Cell><Cell>&gt;100</Cell></Row>
<Time>2019-01-08 17:14:34</Time>
<Row>
<Cell>0.003</Cell><Cell>47</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.003</Cell><Cell>0.000</Cell><Cell>91.48</Cell><Cell>13</Cell></Row>
<Time>2019-01-08 17:15:34</Time>
<Row>
<Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.004</Cell><Cell>0.000</Cell><Cell>95.92</Cell><Cell>2.5</Cell></Row>
<Time>2019-01-08 17:16:34</Time>
<Row>
<Cell>0.003</Cell><Cell>13</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.002</Cell><Cell>85</Cell><Cell>0.004</Cell><Cell>0.000</Cell><Cell>93.98</Cell><Cell>9.1</Cell></Row>
<Time>2019-01-08 17:17:34</Time>
<Row>
<Cell>0.003</Cell><Cell>17</Cell><Cell>0.002</Cell><Cell>85</Cell><Cell>0.002</Cell><Cell>73</Cell><Cell>0.003</Cell><Cell>0.000</Cell><Cell>81.94</Cell><Cell>&gt;100</Cell></Row>
<Time>2019-01-08 17:18:34</Time>
<Row>
<Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.004</Cell><Cell>0.000</Cell><Cell>87.96</Cell><Cell>&gt;100</Cell></Row>
<Time>2019-01-08 17:19:34</Time>
<Row>
<Cell>0.003</Cell><Cell>73</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.003</Cell><Cell>20</Cell><Cell>0.004</Cell><Cell>0.000</Cell><Cell>91.48</Cell><Cell>6.1</Cell></Row>
<Time>2019-01-08 17:20:00</Time>
<Row>
<Cell>0.002</Cell><Cell>37</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.002</Cell><Cell>&gt;100</Cell><Cell>0.003</Cell><Cell>0.000</Cell><Cell>91.48</Cell><Cell>18</Cell></Row>
</HistogramDataIntervals>
</HistogramData>
<HistogramDataUsbChannels>
</HistogramDataUsbChannels>
</Event>
+70
View File
@@ -206,3 +206,73 @@ 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)
# ── The geophone range: Normal or Sensitive ─────────────────────────────────
# In the setup's channel blocks, the byte 29 after each geophone label is the
# range: 0x00 Normal (10 in/s full scale), 0x01 Sensitive (1.25 in/s). It
# matches Blastware's GeoRange on 70,042 / 70,042 DL2 events, all three
# channels agreeing on every one (35 Sensitive), measured 2026-11-01. Until
# now SFM assumed Normal, so a Sensitive event read 8x high.
from minimateplus.event_file_io import _setup_name_at # noqa: E402
@pytest.mark.parametrize("rel,want", [
("bw-import-fields-10-29-26/R352HIUI.F40W", 0),
("geo-range-11-01-26/K557J1KB.RQ0W", 1), # waveform, XML GeoRange 1.250
("geo-range-11-01-26/M010HR6K.OA0H", 1), # histogram, XML GeoRange 1.250
])
def test_geo_range_comes_from_the_file(rel, want):
assert read_blastware_file(_FIX / rel).geo_range == want
# (file, Blastware's Tran / Vert / Long PPV and Peak Vector Sum, from its XML)
@pytest.mark.parametrize("rel,peaks", [
("geo-range-11-01-26/K557J1KB.RQ0W", ("0.019", "0.055", "0.019", "0.061")),
("geo-range-11-01-26/M010HR6K.OA0H", ("0.008", "0.009", "0.005", "0.009")),
])
def test_sensitive_range_peaks_are_not_8x(rel, peaks):
pv = read_blastware_file(_FIX / rel).peak_values
for got, want in zip((pv.tran, pv.vert, pv.long, pv.peak_vector_sum), peaks):
assert abs(got - float(want)) <= 0.0005 + 1e-9, (got, want)
def test_channels_that_disagree_give_no_range_and_a_problem():
raw = bytearray((_FIX / "geo-range-11-01-26/K557J1KB.RQ0W").read_bytes())
i = raw.find(b"\x00\x00\x01Vert", _setup_name_at(bytes(raw)))
raw[i + 3 + 29] = 0x00 # Vert Normal, Tran / Long Sensitive
ev = decode_blastware_bytes(bytes(raw), name=None)
assert ev.geo_range is None
assert any("range" in p for p in ev.decode_problems)
def test_the_h5_takes_the_events_range(tmp_path):
import h5py
from sfm import event_hdf5
ev = read_blastware_file(_FIX / "geo-range-11-01-26/K557J1KB.RQ0W")
event_hdf5.write_event_hdf5(tmp_path / "e.h5", ev, serial="BE9557")
with h5py.File(tmp_path / "e.h5", "r") as f:
assert f.attrs["geo_range"] == "sensitive"
assert abs(float(abs(f["samples/Vert"][:]).max()) - 0.055) <= 0.0005 + 1e-9
def test_an_imported_file_and_the_backfill_store_its_range(tmp_path):
import h5py
import scripts.backfill_sidecars as backfill
from sfm import event_hdf5
from sfm.waveform_store import WaveformStore
src = _FIX / "geo-range-11-01-26/K557J1KB.RQ0W"
store = WaveformStore(tmp_path / "waveforms")
ev, _ = store.save_imported_bw(src.read_bytes(), source_path=src)
h5 = store.hdf5_path_for("BE9557", src.name)
with h5py.File(h5, "r") as f:
assert f.attrs["geo_range"] == "sensitive"
# A file stored before this fix carries "normal"; the backfill rewrites it.
event_hdf5.write_event_hdf5(h5, ev, serial="BE9557", geo_range="normal")
assert backfill.main(["--store-root", str(tmp_path / "waveforms"),
"--db-path", str(tmp_path / "seismo_relay.db"), "--force"]) == 0
with h5py.File(h5, "r") as f:
assert f.attrs["geo_range"] == "sensitive"
+3 -2
View File
@@ -28,7 +28,8 @@ def test_find_pairs_dedupes_and_pairs(tmp_path):
def test_check_event_rows_and_attrs():
out = run.check_event("M007HVWF.K30W", str(FIX / "M007HVWF.K30W"), str(FIX / "M007HVWF_K30W_XML.XML"))
assert out["attrs"]["range"] == "1.250" and out["attrs"]["model"] == "MiniMate Plus"
assert any(r[0] == "TranPPV" and r[1] == "mismatch" for r in out["results"])
# clipped at its own 1.250 ceiling: accepted under the saturation carve-out
assert ["TranPPV", "accepted"] in [r[:2] for r in out["results"]]
def test_bad_input_is_one_error_row(tmp_path):
@@ -128,7 +129,7 @@ def test_compare_to_marks_the_summary(tmp_path):
def test_file_prints_one_event(tmp_path, capsys):
assert run.main([str(FIX), str(FIX), "--file", "M007HVWF.K30W"]) == 0
out = capsys.readouterr().out
assert any("TranPPV" in line and "mismatch" in line for line in out.splitlines())
assert any("TranPPV" in line and "accepted" in line for line in out.splitlines())
# ── Final review fixes ──────────────────────────────────────────────────────
+30 -5
View File
@@ -114,8 +114,23 @@ def test_clipped_normal_range_is_accepted():
assert (res[f].verdict, res[f].carveout) == ("accepted", "saturation")
def test_sensitive_range_8x_stays_a_mismatch():
def test_a_clipped_sensitive_event_is_accepted_at_its_own_ceiling():
# SFM reads the 1.250 range from the file; the clipped channels sit at 1.2506.
res = _results("M007HVWF.K30W", CARVEOUTS)
assert res["GeoRange"].verdict == "match" and res["samples.Tran"].verdict == "match"
for f in ("TranPPV", "PeakVectorSum"):
assert (res[f].verdict, res[f].carveout) == ("accepted", "saturation")
def test_the_carveout_never_accepts_an_8x_value():
# What SFM produced while it assumed Normal on a Sensitive unit: 8x high.
# The saturation rule must leave it a mismatch.
raw = (FIX / "M007HVWF.K30W").read_bytes()
side = sfm_side(raw)
side.values.update(TranPPV=10.005, VertPPV=10.005, LongPPV=10.005, PeakVectorSum=17.33)
side.geo_ips_per_count = 10.0 / 32000
res = {r.field: r for r in compare(side, parse_xml_report_file(FIX / "M007HVWF_K30W_XML.XML"),
CARVEOUTS)}
assert res["TranPPV"].verdict == "mismatch" and res["samples.Tran"].verdict == "mismatch"
assert res["PeakVectorSum"].verdict == "mismatch"
@@ -133,13 +148,14 @@ def test_pvs_carveout_needs_oorange_from_blastware():
def test_pvs_carveout_needs_the_clipped_channel_at_the_ceiling():
# 1.250 range, Blastware PVS OORANGE; an UNclipped channel's 8x value happens to land
# in the 1.250 band -- that must not let SFM's 8x vector sum through.
# 1.250 range, Blastware PVS OORANGE, but no channel Blastware clamped: an
# UNclipped channel's 8x value landing in the 1.250 band must not let a vector
# sum through, even one inside the sqrt(3) bound.
raw = (FIX / "M007HVWF.K30W").read_bytes()
ref = parse_xml_report_file(FIX / "M007HVWF_K30W_XML.XML")
ref.scalars["TranPPV"] = "0.157"
ref.scalars.update(TranPPV="0.157", VertPPV="0.157", LongPPV="0.157")
side = sfm_side(raw)
side.values["TranPPV"] = 1.256
side.values.update(TranPPV=1.256, PeakVectorSum=2.0)
res = {r.field: r for r in compare(side, ref, CARVEOUTS)}
assert res["PeakVectorSum"].verdict == "mismatch"
@@ -147,3 +163,12 @@ def test_pvs_carveout_needs_the_clipped_channel_at_the_ceiling():
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"
def test_a_sensitive_range_event_now_matches():
gr = FIX.parent / "geo-range-11-01-26"
raw = (gr / "K557J1KB.RQ0W").read_bytes()
res = {r.field: r for r in compare(sfm_side(raw), parse_xml_report_file(gr / "K557J1KB_RQ0W_XML.XML"))}
for f in ("GeoRange", "TranPPV", "VertPPV", "LongPPV", "PeakVectorSum",
"samples.Tran", "samples.Vert", "samples.Long"):
assert res[f].verdict == "match", (f, res[f])