Without a paired ASCII report, a Blastware import stored no sample rate,
the record-type byte as its record time (every waveform read "70 s"), a
pre-trigger and sample count read from STRT bytes that are neither, and
blank notes (the reader stopped at the NUL after each label).
- The recording-setup block is found by structure -- 1c 08, the setup
name, NUL -- not by the name "Standard Recording Setup", which 37% of
DL2's files do not use. One match in each of 70,041 archive files.
- Sample rate (uint16 BE, name-42), pre-trigger (f32 BE, name-36) and
record time (f32 BE, name-30). A waveform's sample count is the
decoded count. A histogram gets a sample rate only: Blastware reports
neither a record time nor a pre-trigger for one.
- The setup name and the four user notes by position, as bw_ascii_report
reads them: the labels are operator-editable ("Seis. Loc:",
"Location:", "Project: ").
- STRT now yields only the waveform key.
Verified against Blastware's own _XML.XML event reports for the 70,042
DL2 archive events that have one (2016-2026): sample rate 70,042/70,042,
record time 6,524/6,524, pre-trigger 6,484/6,484, notes 70,042/70,042,
sample count 6,523/6,524 (one waveform the decoder ends 3 samples short;
separate). Events imported with an ASCII report are unchanged -- the
report still overlays.
Not changed: the waveform-time estimate still finds the record time by
the marker; moving it would add a validation constraint for 37% of files
and is to be measured first. The job number is not read yet (2,997
archive events carry one).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
114 lines
4.7 KiB
Python
114 lines
4.7 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"
|