The mic's channel block carries a range byte at the geophones' offset (label + 29, reference D.6.4). At 1 each count is an eighth, 0.25 / 8 Pa: set on 7 DL2 events, all of them Blastware's values divided by 8, and on none of the other 70,026 -- independently of the geophone range (28 events have Sensitive geophones and a range-0 mic). SFM read those 7 mics 8x high: K557J1XQ.GF0W is 79.4 dB(L), not 97.5. Event.mic_range; the decoded mic peak (and so the .h5 mic samples, whose scale is the peak's) and the checker's mic conversions follow it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
762 lines
37 KiB
Python
762 lines
37 KiB
Python
"""
|
|
Setup and note fields read from a Blastware event file alone (#44, #45).
|
|
|
|
Every expected value below comes from Blastware's own output for the same
|
|
file -- its ASCII report or its `_XML.XML` event report -- or, for the bench
|
|
file with neither, from the record length and the MiniMate Plus spec, as
|
|
written up in #44/#45. None is derived from the decoder under test.
|
|
|
|
The STRT record's bytes are not these fields: STRT[18] is the record-type
|
|
marker (0x46 waveform, 0x0A histogram), which is why every waveform used to
|
|
read "70 s".
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from minimateplus.event_file_io import read_blastware_file
|
|
|
|
_FIX = Path(__file__).resolve().parent / "fixtures"
|
|
|
|
# (file, sample rate, record time s, pre-trigger samples, total samples)
|
|
_WAVEFORMS = [
|
|
# ASCII report: 1024 sps, 3.0 s, -0.25 s; 3328 samples per channel.
|
|
("5-11-26/M529LL1A.SP0", 1024, 3.0, 256, 3328),
|
|
# ASCII report: 1024 sps, 1.0 s, -0.25 s.
|
|
("decode-re-5-8-26/event-c/M529LK44.AB0", 1024, 1.0, 256, 1280),
|
|
# #44/#45: BE9441 bench at 4096 sps, 5 s, 0.25 s -> 21,504 samples.
|
|
("minimate-bench-10-26-26-blastware/blastware/K441LTOF.ZI0", 4096, 5.0, 1024, 21504),
|
|
# XML: setup "BE16352.set", 1024 sps, 1.0 s, -0.247 s, 1277 sample rows.
|
|
("bw-import-fields-10-29-26/R352HIUI.F40W", 1024, 1.0, 253, 1277),
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize("rel,sr,rt,pretrig,total", _WAVEFORMS)
|
|
def test_waveform_setup_fields_come_from_the_file(rel, sr, rt, pretrig, total):
|
|
ev = read_blastware_file(_FIX / rel)
|
|
assert ev.sample_rate == sr
|
|
assert ev.rectime_seconds == pytest.approx(rt)
|
|
assert ev.pretrig_samples == pretrig
|
|
assert ev.total_samples == total
|
|
|
|
|
|
# (file, sample rate) -- ASCII report / XML
|
|
_HISTOGRAMS = [
|
|
("histogram-mic-off-10-26-26/K441LTOK.QZ0", 2048),
|
|
("ts-fix/K441LKZU.C30H", 1024),
|
|
("bw-import-fields-10-29-26/M529L4XQ.R30H", 1024),
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize("rel,sr", _HISTOGRAMS)
|
|
def test_histogram_sample_rate_comes_from_the_file(rel, sr):
|
|
ev = read_blastware_file(_FIX / rel)
|
|
assert ev.sample_rate == sr
|
|
|
|
|
|
@pytest.mark.parametrize("rel,sr", _HISTOGRAMS)
|
|
def test_histogram_has_no_record_time_or_pretrigger(rel, sr):
|
|
# Blastware reports neither for a histogram; the STRT record-type byte
|
|
# (0x0A = 10) is not a record time.
|
|
ev = read_blastware_file(_FIX / rel)
|
|
assert ev.rectime_seconds is None
|
|
assert ev.pretrig_samples is None
|
|
|
|
|
|
# (file, setup name, project, client, operator, sensor location)
|
|
_NOTES = [
|
|
# ASCII report; default labels, location spelled "Seis Loc:".
|
|
("5-11-26/M529LL1A.SP0", "Standard Recording Setup",
|
|
"Test-5-8-26", "New Client", "Terra-Mechanics - Harrison", "Still Catbed."),
|
|
# ASCII report; location spelled "Seis. Loc:". BE9441's bench setup is
|
|
# saved as "Standard Recording Setup.set" (#45).
|
|
("histogram-mic-off-10-26-26/K441LTOK.QZ0", "Standard Recording Setup.set",
|
|
"TestUnit-Minimate", "Terra-Mechanics", "Terra-Mechanics Inc. - Harrison", "Test unit 1"),
|
|
# XML; a setup not named "Standard Recording Setup".
|
|
("bw-import-fields-10-29-26/R352HIUI.F40W", "BE16352.set",
|
|
"JV 241 - 1425 Spanlers Mill Rad", "Walsh Granite JV",
|
|
"Terra-Mechanics Inc- D. Harrison", "Loc #1 - 1425 Spanlers Mill Rd"),
|
|
# XML (<Location>Test Loc</Location> only); the operator relabelled the
|
|
# four note slots "Location:", "Client:", "User Name:", "General:" and
|
|
# filled in only the first. Slots are positional, as in the ASCII parser.
|
|
("bw-import-fields-10-29-26/M529L4XQ.R30H", "Standard Recording Setup",
|
|
"Test Loc", None, None, None),
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize("rel,setup,project,client,operator,location", _NOTES)
|
|
def test_notes_come_from_the_file_by_position(rel, setup, project, client, operator, location):
|
|
pi = read_blastware_file(_FIX / rel).project_info
|
|
assert pi.setup_name == setup
|
|
assert pi.project == project
|
|
assert pi.client == client
|
|
assert pi.operator == operator
|
|
assert pi.sensor_location == location
|
|
|
|
|
|
def test_import_without_a_report_stores_the_file_fields(tmp_path: Path):
|
|
"""The watcher path with no ASCII report: the sidecar carries what the
|
|
file holds, not blanks and not the STRT bytes."""
|
|
from sfm.waveform_store import WaveformStore
|
|
|
|
src = _FIX / "bw-import-fields-10-29-26/R352HIUI.F40W"
|
|
store = WaveformStore(tmp_path / "waveforms")
|
|
store.save_imported_bw(src.read_bytes(), source_path=src)
|
|
|
|
sc = store.load_sidecar("BE16352", src.name)
|
|
assert sc["event"]["sample_rate"] == 1024
|
|
assert sc["event"]["rectime_seconds"] == pytest.approx(1.0)
|
|
assert sc["event"]["pretrig_samples"] == 253
|
|
assert sc["project_info"]["project"] == "JV 241 - 1425 Spanlers Mill Rad"
|
|
assert sc["project_info"]["sensor_location"] == "Loc #1 - 1425 Spanlers Mill Rd"
|
|
|
|
|
|
# ── #41: the record type comes from the bytes ───────────────────────────────
|
|
# STRT[18] is the record-type byte: 0x46 on every one of DL2's 6,577 waveform
|
|
# files, 0x0A on every one of its 63,535 histograms (measured 2026-10-29).
|
|
|
|
from minimateplus import blastware_file as _bw # noqa: E402
|
|
from minimateplus.event_file_io import decode_blastware_bytes # noqa: E402
|
|
|
|
_TYPES = [
|
|
("bw-import-fields-10-29-26/R352HIUI.F40W", "Waveform"),
|
|
("bw-import-fields-10-29-26/M529L4XQ.R30H", "Histogram"),
|
|
("5-11-26/M529LL1A.SP0", "Waveform"), # name carries no type
|
|
("histogram-mic-off-10-26-26/K441LTOK.QZ0", "Histogram"), # name carries no type
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize("rel,want", _TYPES)
|
|
def test_record_type_comes_from_the_bytes_without_a_name(rel, want):
|
|
assert decode_blastware_bytes((_FIX / rel).read_bytes(), name=None).record_type == want
|
|
|
|
|
|
def test_the_bytes_win_over_a_filename_that_disagrees(caplog):
|
|
raw = (_FIX / "bw-import-fields-10-29-26/M529L4XQ.R30H").read_bytes()
|
|
ev = decode_blastware_bytes(raw, name="M529L4XQ.R30W")
|
|
assert ev.record_type == "Histogram"
|
|
assert "record type" in caplog.text
|
|
|
|
|
|
def test_an_unknown_type_byte_is_unknown_not_a_guess():
|
|
raw = bytearray((_FIX / "bw-import-fields-10-29-26/R352HIUI.F40W").read_bytes())
|
|
raw[_bw._WAVEFORM_HEADER_SIZE + 18] = 0x99
|
|
ev = decode_blastware_bytes(bytes(raw), name=None)
|
|
assert ev.record_type is None
|
|
assert any("record type" in p for p in ev.decode_problems)
|
|
|
|
|
|
# ── A histogram's peak vector sum is read, not computed from channel peaks ──
|
|
# Each interval stores the square of its vector sum (uint32 BE, in 0.005 in/s
|
|
# units): bytes [21:25] of a standard block, the last 4 bytes of a sub-minute
|
|
# record. sqrt(stored) x 0.005 matches Blastware's printed interval PVS on
|
|
# 1,668,073 / 1,668,074 standard and 34.5 M sub-minute DL2 intervals
|
|
# (measured 2026-10-30). The old value combined each channel's interval peak,
|
|
# which can come from different moments, and read high on 86% of histograms.
|
|
|
|
from minimateplus.histogram_codec import interval_pvs # noqa: E402
|
|
|
|
# (file, Blastware's summary Peak Vector Sum)
|
|
_HIST_PVS = [
|
|
("decode-checker-10-29-26/M529L4XQ.R30H", 3.095), # XML; 1-minute
|
|
("decode-checker-10-29-26/T004JTRF.ME0H", 1.358), # XML; SFM used to say 1.782
|
|
("histogram-mic-off-10-26-26/K441LTOK.QZ0", 1.083), # ASCII report; 2 s, mic off
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize("rel,pvs", _HIST_PVS)
|
|
def test_histogram_peak_vector_sum_is_the_stored_one(rel, pvs):
|
|
got = read_blastware_file(_FIX / rel).peak_values.peak_vector_sum
|
|
assert abs(got - pvs) <= 0.0005 + 1e-9, got
|
|
|
|
|
|
def test_interval_pvs_per_interval():
|
|
raw = (_FIX / "histogram-mic-off-10-26-26/K441LTOK.QZ0").read_bytes()
|
|
pvs = interval_pvs(raw[_bw._WAVEFORM_HEADER_SIZE + 21:])
|
|
assert len(pvs) == 22
|
|
# 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)
|
|
|
|
|
|
# ── 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"
|
|
|
|
|
|
# ── The job number ──────────────────────────────────────────────────────────
|
|
# Series IV's 0x1A layout again: report flags at k - 9 (bit 0x02 = job number
|
|
# shown) and the number, uint16 BE, at k - 8, kept while switched off. The flag
|
|
# matches Blastware's JobNumber on 2,997 / 2,997 DL2 events that print one and
|
|
# 66,986 / 66,986 that don't (measured 2026-11-02). Every printed value is 1;
|
|
# hidden ones hold real numbers (802, 1012, 1013, 622).
|
|
|
|
@pytest.mark.parametrize("rel,enabled,number", [
|
|
("decode-checker-10-29-26/T1905KDW.5F0W", True, 1), # XML JobNumber 1
|
|
("job-number-11-02-26/T438I4V5.DJ0H", True, 1), # histogram, XML JobNumber 1
|
|
("job-number-11-02-26/K557I55Y.I20H", False, 802), # no JobNumber in the XML
|
|
("decode-checker-10-29-26/R352HFZ7.530H", False, 1),
|
|
])
|
|
def test_job_number_comes_from_the_file(rel, enabled, number):
|
|
pi = read_blastware_file(_FIX / rel).project_info
|
|
assert (pi.job_number_enabled, pi.job_number) == (enabled, number)
|
|
|
|
|
|
def test_the_h5_carries_the_job_number(tmp_path):
|
|
import h5py
|
|
from sfm import event_hdf5
|
|
ev = read_blastware_file(_FIX / "job-number-11-02-26/K557I55Y.I20H")
|
|
event_hdf5.write_event_hdf5(tmp_path / "e.h5", ev, serial="BE9557")
|
|
with h5py.File(tmp_path / "e.h5", "r") as f:
|
|
assert (bool(f.attrs["job_number_enabled"]), int(f.attrs["job_number"])) == (False, 802)
|
|
|
|
|
|
# ── Histograms: the codec follows the record type, and loud short blocks ─────
|
|
_HD = "histogram-decode-11-02-26"
|
|
|
|
|
|
def test_a_histogram_body_goes_to_the_histogram_codec():
|
|
# BE9440, 2018, 5 s intervals. The waveform codec accepted this body when
|
|
# it was tried first, and returned ~5x too many "samples". Blastware's
|
|
# report: 6,976 intervals, PPV 0.180 / 0.195 / 0.215, PVS 0.270, start
|
|
# 2018-04-26 07:53:41.
|
|
ev = read_blastware_file(_FIX / _HD / "K440HDXX.XH0H")
|
|
assert ev.record_type == "Histogram"
|
|
assert len(ev.raw_samples["Tran"]) == 6976
|
|
pv = ev.peak_values
|
|
for got, want in zip((pv.tran, pv.vert, pv.long, pv.peak_vector_sum),
|
|
(0.180, 0.195, 0.215, 0.270)):
|
|
assert abs(got - want) <= 0.0005 + 1e-9, (got, want)
|
|
ts = ev.timestamp
|
|
assert (ts.year, ts.month, ts.day) == (2018, 4, 26)
|
|
|
|
|
|
@pytest.mark.parametrize("name,n", [
|
|
("T193KR5M.X90H", 9), # 2 s; its 8th interval is 5.8 in/s of vector sum
|
|
("K440HA3C.JM0H", 8), # 5 s
|
|
])
|
|
def test_a_loud_interval_does_not_hide_a_short_histogram(name, n):
|
|
# A short (one-block) sub-minute histogram is found by its record layout.
|
|
# An interval louder than 1.28 in/s has a vector sum squared above 65,535,
|
|
# which the old "first word is 0000" test rejected.
|
|
ev = read_blastware_file(_FIX / _HD / name)
|
|
assert len(ev.raw_samples["Tran"]) == n
|
|
|
|
|
|
# ── The footer is the file's last 26 bytes ──────────────────────────────────
|
|
# Every DL2 file ends in a valid footer (70,041 / 70,041: 0e 08 and two valid
|
|
# times). A few also hold an earlier "0e 08 + date" record, ~1.1 KB before
|
|
# the end: the stop time followed by zeros. The first-match footer search took
|
|
# it, so a histogram started at its own stop -- a day late on BE9558's daily
|
|
# histograms -- and a waveform lost its stop and its trigger time.
|
|
_FT = "footer-11-03-26"
|
|
|
|
|
|
def test_a_histogram_starts_at_its_footer_not_at_an_earlier_stop_record():
|
|
ts = read_blastware_file(_FIX / _FT / "K558L9XP.FK0H").timestamp
|
|
# Blastware: 2025-10-07 19:14:08 (SFM read 2025-10-08 19:10:01)
|
|
assert (ts.year, ts.month, ts.day, ts.hour, ts.minute) == (2025, 10, 7, 19, 14)
|
|
|
|
|
|
def test_a_histogram_with_the_early_record_gets_its_time():
|
|
ts = read_blastware_file(_FIX / _FT / "T003LCYV.JD0H").timestamp
|
|
# Blastware: 2025-12-05 18:04:25 (SFM had no time at all)
|
|
assert ts is not None
|
|
assert (ts.year, ts.month, ts.day, ts.hour, ts.minute) == (2025, 12, 5, 18, 4)
|
|
|
|
|
|
def test_a_waveform_with_the_early_record_is_timed_from_its_trigger():
|
|
ev = read_blastware_file(_FIX / _FT / "K440I4LG.JK0W")
|
|
ts = ev.timestamp
|
|
# Blastware: 2019-09-26 11:14:08, record time 4 s (SFM read the stop, 11:14:12)
|
|
assert (ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second) == (2019, 9, 26, 11, 14, 8)
|
|
assert ev.timestamp_source in ("event_record", "estimate")
|
|
|
|
|
|
# ── Group A: identity, battery, trigger ─────────────────────────────────────
|
|
# The identity block before the setup name is what the live read gets from
|
|
# SUB FE (DeviceInfo): serial k-202, firmware k-147, DSP version k-138,
|
|
# calibration date k-132 and "by" k-128, manufacturer k-94, model k-72; the
|
|
# battery is a uint16 of hundredths of a volt at k-190. Measured against every
|
|
# DL2 report 2026-11-03 (serial, version, calibration 69,983 / 69,983).
|
|
import datetime as _dt # noqa: E402
|
|
|
|
_SF = "setup-fields-11-03-26"
|
|
|
|
|
|
def test_the_identity_block_is_read():
|
|
# Blastware: BE18189, "V 10.72-8.17 MiniMate Plus",
|
|
# "February 20, 2019 by Instantel", "6.8 Volts"
|
|
ev = read_blastware_file(_FIX / _SF / "T189HUD6.QE0W")
|
|
di = ev.device_info
|
|
assert (di.serial, di.firmware_version, di.dsp_version, di.manufacturer, di.model) == (
|
|
"BE18189", "S338.17", "10.72", "Instantel", "MiniMate Plus")
|
|
assert di.firmware_minor == 17
|
|
assert (di.calibration_date, di.calibrated_by) == (_dt.date(2019, 2, 20), "Instantel")
|
|
assert abs(ev.battery_volts - 6.8) <= 0.05 + 1e-9
|
|
|
|
|
|
def test_the_battery_is_kept_exact():
|
|
# Blastware prints "6.3 Volts" for a stored 6.25: it rounds half up.
|
|
assert read_blastware_file(_FIX / _SF / "K558L4KY.440H").battery_volts == 6.25
|
|
|
|
|
|
# (file, Blastware's Trigger as the event record's bitmask, geo level in/s,
|
|
# mic level psi or None, mic a trigger source)
|
|
@pytest.mark.parametrize("rel,by,geo,mic_psi,mic_src", [
|
|
(f"{_SF}/T189HUD6.QE0W", 0x0008, 0.050, 0.0072, True), # MicL, 128.0 dB(L)
|
|
(f"{_SF}/T438L713.RY0W", 0x0002, 0.500, 0.0100, True), # Vert, 130.8 dB(L)
|
|
(f"{_SF}/M529I6LG.3Y0W", 0x0004, 0.050, 0.005, True), # Long, 0.005 psi(L)
|
|
("bw-import-fields-10-29-26/R352HIUI.F40W", 0x0001, 0.400, None, False), # Tran
|
|
("decode-checker-10-29-26/T1905KDW.5F0W", 0x0200, None, None, None), # Manual
|
|
])
|
|
def test_the_trigger_comes_from_the_file(rel, by, geo, mic_psi, mic_src):
|
|
ev = read_blastware_file(_FIX / rel)
|
|
assert ev.triggered_by == by
|
|
if geo is not None:
|
|
assert abs(ev.trigger_level_geo - geo) <= 0.0005 + 1e-9
|
|
if mic_psi is not None:
|
|
assert abs(ev.trigger_level_mic_psi - mic_psi) <= 0.0005 + 1e-9 # psi to 3 places, as printed
|
|
if mic_src is not None:
|
|
assert bool(ev.trigger_sources & 0x08) == mic_src
|
|
assert (ev.record_stop_mode, ev.mic_type) == (0, 2) # Fixed, Linear Weighting
|
|
|
|
|
|
def test_the_h5_carries_the_setup_fields(tmp_path):
|
|
import h5py
|
|
from sfm import event_hdf5
|
|
ev = read_blastware_file(_FIX / _SF / "T189HUD6.QE0W")
|
|
event_hdf5.write_event_hdf5(tmp_path / "e.h5", ev, serial="BE18189")
|
|
with h5py.File(tmp_path / "e.h5", "r") as f:
|
|
a = f.attrs
|
|
assert abs(float(a["battery_volts"]) - 6.8) <= 0.05 + 1e-9
|
|
assert (int(a["triggered_by"]), int(a["trigger_sources"])) == (0x0008, ev.trigger_sources)
|
|
assert abs(float(a["trigger_level_geo_ips"]) - 0.050) <= 0.0005 + 1e-9
|
|
assert abs(float(a["trigger_level_mic_psi"]) - ev.trigger_level_mic_psi) < 1e-9
|
|
assert (str(a["firmware_version"]), str(a["dsp_version"]), str(a["calibration_date"])) == (
|
|
"S338.17", "10.72", "2019-02-20")
|
|
|
|
|
|
# ── Group B: histogram interval detail ──────────────────────────────────────
|
|
# Interval size is the setup's uint16 seconds at k - 40 (Series IV [8:10]); the
|
|
# stop is the footer's. Each interval keeps its half-periods and its vector sum
|
|
# (PVS^2). Frequency = (sample rate / 2) / half-period: 527,915 / 527,915 cells
|
|
# at 1024 sps and 1,725 / 1,725 at 2048 (#50: the old fixed 512 halved every
|
|
# 2048-sps frequency). Measured 2026-11-03.
|
|
from minimateplus.histogram_codec import half_period_to_hz # noqa: E402
|
|
|
|
_HB = "histogram-intervals-11-03-26"
|
|
|
|
|
|
@pytest.mark.parametrize("rel,sr,freqs,pvs,stop", [
|
|
# Blastware: 1 minute; Tran 32, Vert 47, Long 14, MicL 47 Hz; PVS 1.358; stop 12:49:33
|
|
("decode-checker-10-29-26/T004JTRF.ME0H", 1024,
|
|
{"Tran": 32, "Vert": 47, "Long": 14, "MicL": 47}, 1.358, (2022, 12, 28, 12, 49, 33)),
|
|
# Blastware: 1 minute at 2048 sps; Tran 15.5, Vert 64, Long 17.7, MicL 51 Hz; PVS 2.644
|
|
(f"{_HB}/T190LD42.T00H", 2048,
|
|
{"Tran": 15.5, "Vert": 64, "Long": 17.7, "MicL": 51}, 2.644, (2025, 12, 8, 13, 29, 37)),
|
|
])
|
|
def test_histogram_interval_detail_comes_from_the_file(rel, sr, freqs, pvs, stop):
|
|
ev = read_blastware_file(_FIX / rel)
|
|
assert (ev.sample_rate, ev.histogram_interval_sec) == (sr, 60)
|
|
for ch, hz in freqs.items():
|
|
got = half_period_to_hz(ev.interval_half_periods[ch][0], ev.sample_rate)
|
|
d = 1 if isinstance(hz, float) else 0
|
|
assert abs(got - hz) <= 0.5 * 10 ** -d + 1e-9, (ch, got, hz)
|
|
assert abs(ev.interval_pvs[0] - pvs) <= 0.0005 + 1e-9
|
|
t = ev.stop_time
|
|
assert (t.year, t.month, t.day, t.hour, t.minute, t.second) == stop
|
|
|
|
|
|
def test_the_h5_carries_the_interval_detail(tmp_path):
|
|
import h5py
|
|
from sfm import event_hdf5
|
|
ev = read_blastware_file(_FIX / _HB / "T190LD42.T00H")
|
|
event_hdf5.write_event_hdf5(tmp_path / "e.h5", ev, serial="BE18190")
|
|
with h5py.File(tmp_path / "e.h5", "r") as f:
|
|
assert int(f.attrs["histogram_interval_sec"]) == 60
|
|
assert list(f["intervals/half_period/Vert"][:]) == ev.interval_half_periods["Vert"]
|
|
assert abs(float(f["intervals/pvs_ips"][0]) - 2.644) <= 0.0005 + 1e-9
|
|
|
|
|
|
# ── #51: a histogram's start and stop from its own event record ─────────────
|
|
# The footer's start runs a second early on 97%. The histogram's event record
|
|
# (lead 00 28 05 00, source 04 00, marker fe f5) holds Blastware's start and
|
|
# stop: 63,490 / 63,490 DL2 histograms each (2026-11-03).
|
|
|
|
def test_a_histogram_starts_at_its_event_records_start():
|
|
ev = read_blastware_file(_FIX / "decode-checker-10-29-26/T004JTRF.ME0H")
|
|
t, s = ev.timestamp, ev.stop_time
|
|
# Blastware: start 2022-12-28 12:49:26, stop 12:49:33
|
|
assert (t.year, t.month, t.day, t.hour, t.minute, t.second) == (2022, 12, 28, 12, 49, 26)
|
|
assert (s.hour, s.minute, s.second) == (12, 49, 33)
|
|
assert ev.timestamp_source == "event_record"
|
|
|
|
|
|
def test_a_histogram_without_its_record_falls_back_to_the_footer_and_says_so():
|
|
raw = bytearray((_FIX / "decode-checker-10-29-26/T004JTRF.ME0H").read_bytes())
|
|
i = raw.find(b"\xfe\xf5")
|
|
raw[i] = 0x00 # break the record's marker
|
|
ev = decode_blastware_bytes(bytes(raw), name=None)
|
|
assert ev.timestamp_source == "footer"
|
|
assert ev.timestamp.second == 25 # the footer's start, a second early
|
|
assert any("histogram event record" in p for p in ev.decode_problems)
|
|
|
|
|
|
# ── Group D, part 1: time of peak, vector-sum time, peak acceleration ───────
|
|
# Measured on 400 DL2 waveforms (2026-11-04):
|
|
# time of peak = (peak sample - pre-trigger samples) / sample rate: 1,197 / 1,197
|
|
# vector-sum time, the same on sqrt(T^2 + V^2 + L^2): 398 / 399
|
|
# peak acceleration = largest |v[i+1] - v[i]| x rate / g, with Blastware's g
|
|
# fitted to [386.2236, 386.2240] in/s^2 by every DL2 value: 19,475 / 19,479
|
|
|
|
@pytest.mark.parametrize("rel,times,pvs_time,accel", [
|
|
(f"{_SF}/T189HUD6.QE0W",
|
|
{"tran": 0.004, "vert": 0.001, "long": 0.024, "micl": 0.003}, 0.016, (0.027, 0.013, 0.027)),
|
|
("decode-checker-10-29-26/R352HIUI.F40W",
|
|
{"tran": 0.000, "vert": 0.000, "long": 0.000, "micl": 0.005}, 0.000, (1.617, 0.278, 0.318)),
|
|
])
|
|
def test_waveform_peak_detail_comes_from_the_samples(rel, times, pvs_time, accel):
|
|
pv = read_blastware_file(_FIX / rel).peak_values
|
|
for ch, t in times.items():
|
|
assert abs(getattr(pv, f"{ch}_time_of_peak") - t) <= 0.0005 + 1e-9, (ch, getattr(pv, f"{ch}_time_of_peak"))
|
|
assert abs(pv.pvs_time - pvs_time) <= 0.0005 + 1e-9
|
|
for got, want in zip((pv.tran_peak_accel_g, pv.vert_peak_accel_g, pv.long_peak_accel_g), accel):
|
|
assert abs(got - want) <= 0.0005 + 1e-9, (got, want)
|
|
|
|
|
|
def test_a_histogram_has_no_waveform_peak_detail():
|
|
pv = read_blastware_file(_FIX / "decode-checker-10-29-26/T004JTRF.ME0H").peak_values
|
|
assert (pv.tran_time_of_peak, pv.pvs_time, pv.tran_peak_accel_g) == (None, None, None)
|
|
|
|
|
|
# ── Group D, part 2: the unit's own event summary ───────────────────────────
|
|
# After its embedded event record a file carries the unit's per-channel summary,
|
|
# one 24-byte record each (ids 0x32 Tran .. 0x35 MicL): min, max, peak sample,
|
|
# half-period and a displacement integral (measured on DL2, 2026-11-05):
|
|
# ZC frequency = (rate / 2) / half-period: 15,844 / 15,844 waveform values and
|
|
# 104,000 / 104,000 histogram values; every word too (">100" at <= 5 samples,
|
|
# "N/A" at 0, "<1.0" beyond rate / 2)
|
|
# displacement = integral x 16 counts x in/s per count / rate / 2: 19,479 / 19,479
|
|
# Every expected value below is Blastware's own, from the file's _XML.XML report.
|
|
|
|
_US = "unit-summary-11-05-26"
|
|
|
|
|
|
def _prints_as(value, printed):
|
|
d = len(printed.split(".")[1]) if "." in printed else 0
|
|
return abs(value - float(printed)) <= 0.5 * 10 ** -d + 1e-9
|
|
|
|
|
|
@pytest.mark.parametrize("rel,printed", [
|
|
# (Tran, Vert, Long, MicL) ZC Freq as Blastware prints it; None = no channel
|
|
(f"{_US}/I145L6UJ.3Y0W", ("43", "37", "39", "43")), # 1024 sps
|
|
(f"{_US}/K557L7FX.SC0W", (">200", "171", ">200", "26")), # 2048 sps
|
|
(f"{_US}/R349KMF7.9O0W", ("17.4", "66", "12.6", "19.5")), # 4096 sps
|
|
(f"{_US}/K558IKSJ.P20W", ("N/A", "<1.0", "N/A", "N/A")),
|
|
(f"{_US}/O117I1NK.R70W", (">100", ">100", ">100", ">100")),
|
|
(f"{_US}/R352HFZ7.5D0W", ("73", "30", "24", None)), # a unit without a mic
|
|
(f"{_US}/T193HLJ3.X80H", (">100", ">100", "73", "57")), # a histogram
|
|
])
|
|
def test_zc_frequency_is_the_units_own(rel, printed):
|
|
pv = read_blastware_file(_FIX / rel).peak_values
|
|
for ch, want in zip(("tran", "vert", "long", "mic"), printed):
|
|
got, above = getattr(pv, f"{ch}_zc_freq"), getattr(pv, f"{ch}_zc_above_range")
|
|
if want in (None, "N/A"):
|
|
assert (got, above) == (None, False), ch
|
|
elif want.startswith(">"):
|
|
assert (got, above) == (float(want[1:]), True), ch # Blastware's threshold, flagged
|
|
elif want == "<1.0":
|
|
assert 0 < got < 1.0 and not above, (ch, got)
|
|
else:
|
|
assert _prints_as(got, want) and not above, (ch, got, want)
|
|
|
|
|
|
@pytest.mark.parametrize("rel,printed", [
|
|
(f"{_US}/I145L6UJ.3Y0W", ("0.000", "0.000", "0.000")),
|
|
(f"{_US}/K558IKSJ.P20W", ("0.000", "0.046", "0.000")),
|
|
(f"{_US}/R349KMF7.9O0W", ("0.004", "0.001", "0.012")), # 4096 sps
|
|
(f"{_US}/R352HFZ7.5D0W", ("0.003", "0.010", "0.006")),
|
|
(f"{_US}/O117I1NK.R70W", ("1.480", "1.483", "2.616")), # clipped: beyond the samples
|
|
])
|
|
def test_peak_displacement_is_the_units_own(rel, printed):
|
|
pv = read_blastware_file(_FIX / rel).peak_values
|
|
for ch, want in zip(("tran", "vert", "long"), printed):
|
|
got = getattr(pv, f"{ch}_peak_disp_in")
|
|
assert got is not None and _prints_as(got, want), (ch, got, want)
|
|
|
|
|
|
def test_a_histogram_has_no_peak_displacement():
|
|
pv = read_blastware_file(_FIX / f"{_US}/T193HLJ3.X80H").peak_values
|
|
assert (pv.tran_peak_disp_in, pv.vert_peak_disp_in, pv.long_peak_disp_in) == (None, None, None)
|
|
|
|
|
|
def test_time_of_peak_is_the_units_own_peak_sample():
|
|
# O117I1NK clips: its stored samples wrap at the trigger, so their largest
|
|
# lands elsewhere, but the unit's summary has every peak at the trigger --
|
|
# Blastware prints 0.000 on all four channels and the vector sum.
|
|
pv = read_blastware_file(_FIX / f"{_US}/O117I1NK.R70W").peak_values
|
|
for ch in ("tran", "vert", "long", "micl"):
|
|
assert getattr(pv, f"{ch}_time_of_peak") == 0.0, ch
|
|
assert pv.pvs_time == 0.0
|
|
|
|
|
|
def test_an_unreadable_channel_record_leaves_only_that_channel_unread():
|
|
raw = bytearray((_FIX / f"{_US}/I145L6UJ.3Y0W").read_bytes())
|
|
i = raw.find(b"\x00\x16\x32")
|
|
raw[i + 2] = 0x00 # break the Tran record's id; the chain holds
|
|
pv = decode_blastware_bytes(bytes(raw), name=None).peak_values
|
|
assert (pv.tran_zc_freq, pv.tran_peak_disp_in) == (None, None)
|
|
assert abs(pv.tran_time_of_peak - 2.281) <= 0.0005 # the samples' peak, as before
|
|
assert _prints_as(pv.mic_zc_freq, "43") # the others are read
|
|
|
|
|
|
def test_without_a_whole_record_chain_nothing_is_guessed():
|
|
# The chain from the event record ends exactly at the file's end on all
|
|
# 70,041 DL2 files; one that does not is not read at all.
|
|
raw = bytearray((_FIX / f"{_US}/I145L6UJ.3Y0W").read_bytes())
|
|
i = raw.find(b"\x00\xd4\x3c") # the Tran sensor-check record, length 212
|
|
raw[i + 1] = 0xd3 # one byte short
|
|
ev = decode_blastware_bytes(bytes(raw), name=None)
|
|
assert ev.sensor_check_results is None
|
|
pv = ev.peak_values
|
|
assert (pv.tran_zc_freq, pv.mic_zc_freq, pv.tran_peak_disp_in) == (None, None, None)
|
|
|
|
|
|
|
|
# ── Group E: the sensor check results ───────────────────────────────────────
|
|
# Records 0x3c Tran .. 0x3f MicL, after the unit's summary, carry the sensor
|
|
# check the unit ran: its trace (minimateplus.sensor_check) and, in the record's
|
|
# header, its results (measured on DL2, 2026-11-06):
|
|
# [2] channel type (1 geophone, 2 mic, 0 check disabled) [4] status, 0 = passed
|
|
# [5:7] frequency x 10 [7:9] ratio x 10 [9:11] amplitude, mV
|
|
# Blastware prints them as they are: 209,943 / 209,943 geophone frequencies and
|
|
# ratios, 69,975 / 69,975 mic frequencies and amplitudes; "Passed" on status 0,
|
|
# "Check" on every other status, "Disabled" on type 0.
|
|
|
|
@pytest.mark.parametrize("rel,want", [
|
|
# channel: (result, frequency Hz, ratio, amplitude mV), Blastware's _XML.XML
|
|
(f"{_US}/I145L6UJ.3Y0W", {"Tran": ("Passed", 7.3, 3.7, None), "Vert": ("Passed", 7.2, 3.9, None),
|
|
"Long": ("Passed", 7.2, 3.9, None), "MicL": ("Passed", 19.7, None, 592)}),
|
|
(f"{_US}/K440HJCN.AS0W", {"Tran": ("Check", 9.6, 13.8, None), "Vert": ("Check", 8.5, 7.2, None),
|
|
"Long": ("Passed", 7.3, 1.9, None), "MicL": ("Passed", 19.7, None, 519)}),
|
|
(f"{_US}/R349KMF7.9O0W", {"Tran": ("Passed", 7.4, 3.8, None), "Vert": ("Passed", 7.5, 3.5, None),
|
|
"Long": ("Passed", 7.8, 3.6, None), "MicL": ("Check", 0.0, None, 0)}),
|
|
(f"{_US}/R352HFZ7.5D0W", {"Tran": ("Disabled", None, None, None), # no mic; check disabled
|
|
"Vert": ("Disabled", None, None, None),
|
|
"Long": ("Disabled", None, None, None)}),
|
|
(f"{_US}/T193HLJ3.X80H", {"Tran": ("Passed", 7.4, 3.9, None), "Vert": ("Passed", 7.2, 3.9, None),
|
|
"Long": ("Passed", 7.5, 4.1, None), "MicL": ("Passed", 20.1, None, 556)}),
|
|
])
|
|
def test_sensor_check_results_are_the_units_own(rel, want):
|
|
got = read_blastware_file(_FIX / rel).sensor_check_results
|
|
assert set(got) == set(want)
|
|
for ch, (result, freq, ratio, amp) in want.items():
|
|
r = got[ch]
|
|
assert r.result == result, ch
|
|
assert r.freq_hz == (pytest.approx(freq) if freq is not None else None), ch
|
|
assert r.ratio == (pytest.approx(ratio) if ratio is not None else None), ch
|
|
assert r.amplitude_mv == amp, ch
|
|
|
|
|
|
def test_a_check_keeps_the_units_status_code():
|
|
# Blastware prints only "Check"; the code's bits are not decoded (K559L6N1's
|
|
# Tran is a Check at 8.1 Hz and 3.3, inside every passing range).
|
|
got = read_blastware_file(_FIX / f"{_US}/K440HJCN.AS0W").sensor_check_results
|
|
assert [got[ch].status for ch in ("Tran", "Vert", "Long", "MicL")] == [11, 2, 0, 0]
|
|
|
|
|
|
# ── Group F: the monitor log ────────────────────────────────────────────────
|
|
# Blastware prints one Monitor Log line per event: the footer's start and stop,
|
|
# and words from the footer's flag word [18:20]. 69,983 / 69,983 DL2 lines,
|
|
# character for character (2026-11-08). Expected lines are Blastware's own,
|
|
# from each file's _XML.XML report.
|
|
|
|
_ML = "monitor-log-11-08-26"
|
|
|
|
|
|
def _log_line(ml):
|
|
return f'{ml.start:%Y-%m-%d %H:%M:%S} - {ml.stop:%Y-%m-%d %H:%M:%S} "{ml.description}"'
|
|
|
|
|
|
@pytest.mark.parametrize("rel,line", [
|
|
(f"{_US}/I145L6UJ.3Y0W", '2025-08-08 18:23:55 - 2025-08-08 18:24:01 "Event Recorded "'),
|
|
(f"{_US}/O117I1NK.R70W", '2019-07-31 06:59:31 - 2019-07-31 06:59:33 "Event Recorded "'),
|
|
(f"{_US}/T193HLJ3.X80H", '2018-09-20 20:07:55 - 2018-09-21 13:20:01 "Event Recorded Modem Exit"'),
|
|
(f"{_ML}/T189INWA.060H", '2020-10-05 16:04:53 - 2020-10-05 16:06:09 "Event Recorded Keyboard Exit"'),
|
|
(f"{_ML}/K559HCQ7.IU0H", '2018-04-02 17:06:30 - 2018-04-02 17:07:47 "Event Recorded Remote Exit"'),
|
|
(f"{_ML}/T192JWEL.0Y0H", '2023-02-17 21:58:09 - 2023-02-17 22:00:00 "Event Recorded Timer Stop"'),
|
|
(f"{_ML}/T189JZY7.L60H", '2023-04-27 20:00:41 - 2023-04-27 20:01:42 "Event Recorded Battery Low Exit"'),
|
|
])
|
|
def test_the_monitor_log_is_the_footers(rel, line):
|
|
assert _log_line(read_blastware_file(_FIX / rel).monitor_log) == line
|
|
|
|
|
|
from minimateplus.event_file_io import monitor_log_description # noqa: E402
|
|
|
|
|
|
@pytest.mark.parametrize("flags,words", [
|
|
(0x0001, "Event Recorded "),
|
|
(0x0003, "Event Recorded Keyboard Exit"),
|
|
(0x0005, "Event Recorded Remote Exit"),
|
|
(0x0009, "Event Recorded Selfcheck Passed"),
|
|
(0x0011, "Event Recorded Timer Stop"),
|
|
(0x0021, "Event Recorded Modem Exit"),
|
|
(0x0201, "Event Recorded Battery Low Exit"),
|
|
(0x0801, "Event Recorded Memory Full Exit"),
|
|
# One DL2 line sets Modem and Timer; Blastware prints Modem: the higher
|
|
# bit wins (one file, so the order of the others is inferred).
|
|
(0x0031, "Event Recorded Modem Exit"),
|
|
])
|
|
def test_the_monitor_log_words(flags, words):
|
|
assert monitor_log_description(flags) == words
|
|
|
|
|
|
def test_without_a_whole_record_chain_there_is_no_monitor_log():
|
|
raw = bytearray((_FIX / f"{_US}/I145L6UJ.3Y0W").read_bytes())
|
|
i = raw.find(b"\x00\xd4\x3c")
|
|
raw[i + 1] = 0xd3 # one byte short: the footer is not proven
|
|
assert decode_blastware_bytes(bytes(raw), name=None).monitor_log is None
|
|
|
|
|
|
# ── Over range: the unit's true peak beyond full scale ──────────────────────
|
|
# A channel is over range when the unit's own peak (its summary's min / max,
|
|
# D.6.12) passes 2,000: 32,000 counts, full scale, on either geophone range;
|
|
# the mic in counts. Blastware then prints OORANGE for that channel's peak,
|
|
# for the vector sum when any geophone is over, and its "Out of Range" line when
|
|
# the mic is. DL2, 2026-11-09: numeric up to 1,991 (geophones) / 1,933 (mic),
|
|
# OORANGE from 2,001; the vector sum is OORANGE on all 43 events with a
|
|
# geophone over and on none of the 38 whose vector sum alone passes 10 in/s.
|
|
|
|
_OR = "over-range-11-09-26"
|
|
|
|
|
|
@pytest.mark.parametrize("rel,over", [
|
|
# (tran, vert, long, mic, vector sum)
|
|
(f"{_US}/O117I1NK.R70W", (True, True, True, True, True)),
|
|
(f"{_OR}/O121L4L1.GU0H", (True, False, False, False, True)),
|
|
(f"{_OR}/K558KD43.NZ0H", (False, False, False, True, False)),
|
|
(f"{_OR}/M007JC05.OI0H", (False, False, False, False, False)), # vector sum 14.49 in/s, a number
|
|
(f"{_US}/I145L6UJ.3Y0W", (False, False, False, False, False)),
|
|
])
|
|
def test_over_range_is_the_units_peak_beyond_full_scale(rel, over):
|
|
pv = read_blastware_file(_FIX / rel).peak_values
|
|
assert (pv.tran_over_range, pv.vert_over_range, pv.long_over_range,
|
|
pv.mic_over_range, pv.pvs_over_range) == over
|
|
|
|
|
|
# ── The mic's own range ─────────────────────────────────────────────────────
|
|
# The mic's channel block carries a range byte at the geophones' offset (label
|
|
# + 29, D.6.4): 1 makes each count an eighth -- 0.25 / 8 Pa. It is set on 7 DL2
|
|
# events, all of them Blastware's ÷8 values, and on none of the 70,026 others,
|
|
# independently of the geophone range (28 events have Sensitive geophones and
|
|
# a range-0 mic). SFM read those 7 mics 8x high (2026-11-09).
|
|
|
|
def test_a_range_1_mic_reads_an_eighth():
|
|
ev = read_blastware_file(_FIX / f"{_OR}/K557J1XQ.GF0W")
|
|
assert ev.mic_range == 1
|
|
peak = max(abs(c) for c in ev.raw_samples["MicL"]) # 6 counts
|
|
# Blastware: 79.4 dB(L) = 6 / 8 counts; as a range-0 mic it would be 97.5
|
|
assert ev.peak_values.micl == pytest.approx(peak * 0.25 / 8 / 6894.757, rel=1e-6)
|
|
|
|
|
|
def test_a_range_0_mic_is_unchanged():
|
|
ev = read_blastware_file(_FIX / f"{_US}/I145L6UJ.3Y0W")
|
|
assert ev.mic_range == 0
|
|
peak = max(abs(c) for c in ev.raw_samples["MicL"])
|
|
assert ev.peak_values.micl == pytest.approx(peak * 0.25 / 6894.757, rel=1e-6)
|