Blastware's dB(L) / psi(L) labels do not hold for the mic on every report (DL2, 2026-11-09): - the mic peak carries its own <Units>, which 7 reports set to dB under a psi Units line and 3 the reverse: the checker now reads the peak in its own unit; - a mic sample table has no unit of its own and need not follow the line (S353JTHU.DT0W prints dB under psi): the checker reads it from its cells -- a mic dB value is never under 60, psi never over 1; - some reports mix the two inside one column: K441L9IN.OT0W prints psi '0.000' for counts of 1 to 3 in a dB table. Carve-out mic-units-mixed accepts a mic field when every cell SFM disagrees with is SFM's own value in the other unit: 19 DL2 events (14 sample tables, 5 peaks); a cell matching neither stays a mismatch. Not a decoder change: SFM's mic data were right. Checker run 20261109-141808: 78 of 88 fields, 0 regressions; no mic peak or mic sample table mismatches left. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
547 lines
25 KiB
Python
547 lines
25 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_event_type_comes_from_the_bytes():
|
|
# No filename reaches the decoder; the type is the STRT record-type byte (#41).
|
|
s = sfm_side((FIX / "M529L4XQ.R30H").read_bytes())
|
|
assert s.values["EventType"] == "Full Histogram"
|
|
|
|
|
|
def test_report_fields_stay_blank():
|
|
s = sfm_side((FIX / "T1905KDW.5F0W").read_bytes())
|
|
# (BatteryLevel and Calibration are read since 2026-11-03, peak acceleration
|
|
# since 2026-11-04, ZC frequency and displacement since 2026-11-05:
|
|
# test_the_setup_fields_match_blastware, test_waveform_peak_detail_*,
|
|
# test_zc_frequency_and_displacement_match_blastware. Its Tran ZC is N/A.)
|
|
for tag in ("TranZCFreq",): # (sensor check results since 2026-11-06)
|
|
assert s.values.get(tag) is None
|
|
|
|
|
|
# ── Task 3: the comparison ──────────────────────────────────────────────────
|
|
|
|
from minimateplus.bw_xml_report import parse_xml_report_file # noqa: E402
|
|
from minimateplus.decode_check import compare, matches_printed # noqa: E402
|
|
|
|
|
|
def _results(stem, carveouts=()):
|
|
raw = (FIX / stem).read_bytes()
|
|
ref = parse_xml_report_file(FIX / (stem.replace(".", "_") + "_XML.XML"))
|
|
return {r.field: r for r in compare(sfm_side(raw), ref, carveouts)}
|
|
|
|
|
|
def test_matches_printed_rounds_half_away():
|
|
assert matches_printed(-0.0625, "-0.063") and matches_printed(0.0015, "0.002")
|
|
assert not matches_printed(0.0026, "0.002")
|
|
|
|
|
|
def test_full_waveform_row_verdicts():
|
|
res = _results("R352HIUI.F40W")
|
|
for f in ("SampleRate", "RecordTime", "Pre-triggerLength", "EventDate", "EventTime",
|
|
"notes", "samples.Tran", "samples.Vert", "samples.Long"):
|
|
assert res[f].verdict == "match", (f, res[f])
|
|
assert res["TranZCFreq"].verdict == "match" # ">100", the unit's own (2026-11-05)
|
|
assert res["BatteryLevel"].verdict == "match" # 6.72 V, printed "6.7 Volts"
|
|
assert "FileName" not in res
|
|
|
|
|
|
def test_ragged_rows_match_by_running_channels():
|
|
# Tran/Vert/MicL end 3 samples before Long, in SFM and in Blastware's table alike
|
|
res = _results("T438HGTZ.B30W")
|
|
for ch in ("Tran", "Vert", "Long"):
|
|
assert res[f"samples.{ch}"].verdict == "match", res[f"samples.{ch}"]
|
|
|
|
|
|
def test_an_extra_reference_row_is_a_mismatch_with_detail():
|
|
raw = (FIX / "T1905KDW.5F0W").read_bytes()
|
|
ref = parse_xml_report_file(FIX / "T1905KDW_5F0W_XML.XML")
|
|
ref.sample_rows.append(["0.000", "0.000", "0.000", "0.000"])
|
|
res = {r.field: r for r in compare(sfm_side(raw), ref)}
|
|
assert res["samples.Tran"].verdict == "mismatch"
|
|
assert "row_length_disagreements=1" in res["samples.Tran"].detail
|
|
|
|
|
|
def test_zc_frequency_na_and_above_range():
|
|
res = _results("T1905KDW.5F0W") # its JobNumber: test_the_job_number_matches_blastware
|
|
assert res["TranZCFreq"].verdict == "no_reference" # N/A
|
|
assert res["VertZCFreq"].verdict == "match" # >100: the unit's half-period
|
|
|
|
|
|
def test_mic_units_pick_the_conversion():
|
|
res = _results("T004JTRF.ME0H") # psi(L)
|
|
assert res["intervals.MicL Peak dB(L)"].verdict in ("match", "mismatch")
|
|
assert res["intervals.Tran Freq Hz"].verdict == "match" # read since 2026-11-03
|
|
fields = set(_results("R352HFZ7.530H")) # no mic
|
|
assert not any(f.startswith(("samples.MicL", "intervals.MicL")) for f in fields)
|
|
|
|
|
|
# ── Task 4: carve-outs ──────────────────────────────────────────────────────
|
|
|
|
from minimateplus.decode_check_carveouts import CARVEOUTS # noqa: E402
|
|
|
|
|
|
def _no_unit_peaks(side):
|
|
"""As for a file without the unit's summary: no over-range flags, so the
|
|
saturation carve-out decides (since 2026-11-09 the flags match first)."""
|
|
pv = side.event.peak_values
|
|
for ch in ("tran", "vert", "long", "mic", "pvs"):
|
|
setattr(pv, f"{ch}_over_range", False)
|
|
return side
|
|
|
|
|
|
def _results_without_unit_peaks(stem):
|
|
raw = (FIX / stem).read_bytes()
|
|
ref = parse_xml_report_file(FIX / (stem.replace(".", "_") + "_XML.XML"))
|
|
return {r.field: r for r in compare(_no_unit_peaks(sfm_side(raw)), ref, CARVEOUTS)}
|
|
|
|
|
|
@pytest.mark.parametrize("stem,clipped", [
|
|
# Blastware: Tran 5.445, Vert 6.310, Long OORANGE, PVS OORANGE; SFM Long 10.005, PVS 11.55
|
|
("T438HGTZ.B30W", ("LongPPV", "PeakVectorSum")),
|
|
# SFM reads the 1.250 range from the file; the clipped channels sit at 1.2506.
|
|
("M007HVWF.K30W", ("TranPPV", "PeakVectorSum")),
|
|
])
|
|
def test_a_clipped_event_matches_by_the_units_own_peak(stem, clipped):
|
|
res = _results(stem, CARVEOUTS)
|
|
for f in clipped:
|
|
assert res[f].verdict == "match", (f, res[f])
|
|
# Without the unit's summary the saturation carve-out still accepts them.
|
|
res = _results_without_unit_peaks(stem)
|
|
for f in clipped:
|
|
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 = _no_unit_peaks(sfm_side(raw)) # the carve-out's guard, not the unit's peaks
|
|
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"
|
|
|
|
|
|
def test_every_carveout_has_evidence():
|
|
assert all(c.id and c.fields and len(c.evidence) > 40 for c in CARVEOUTS)
|
|
|
|
|
|
def test_pvs_carveout_needs_oorange_from_blastware():
|
|
raw = (FIX / "T438HGTZ.B30W").read_bytes()
|
|
ref = parse_xml_report_file(FIX / "T438HGTZ_B30W_XML.XML")
|
|
ref.scalars["PeakVectorSum"] = "10.392" # a vector sum may exceed the range unclipped
|
|
res = {r.field: r for r in compare(sfm_side(raw), ref, CARVEOUTS)}
|
|
assert res["PeakVectorSum"].verdict == "mismatch"
|
|
|
|
|
|
def test_pvs_carveout_needs_the_clipped_channel_at_the_ceiling():
|
|
# 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.update(TranPPV="0.157", VertPPV="0.157", LongPPV="0.157")
|
|
side = _no_unit_peaks(sfm_side(raw))
|
|
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"
|
|
|
|
|
|
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])
|
|
|
|
|
|
def test_the_job_number_matches_blastware():
|
|
assert _results("T1905KDW.5F0W", CARVEOUTS)["JobNumber"].verdict == "match"
|
|
|
|
|
|
def test_a_hidden_job_number_is_not_reported():
|
|
# Flag off: Blastware prints no JobNumber, and SFM's side reports none either.
|
|
assert sfm_side((FIX / "R352HFZ7.530H").read_bytes()).job_number is None
|
|
|
|
|
|
def test_a_job_number_only_sfm_shows_is_a_mismatch():
|
|
side = sfm_side((FIX / "R352HFZ7.530H").read_bytes())
|
|
side.job_number = "1"
|
|
res = {r.field: r for r in compare(side, parse_xml_report_file(FIX / "R352HFZ7_530H_XML.XML"))}
|
|
assert res["JobNumber"].verdict == "mismatch"
|
|
|
|
|
|
@pytest.mark.parametrize("stem", ["T193KR5M.X90H", "K440HA3C.JM0H"])
|
|
def test_a_loud_short_histogram_matches_blastware(stem):
|
|
hd = FIX.parent / "histogram-decode-11-02-26"
|
|
res = {r.field: r for r in compare(sfm_side((hd / stem).read_bytes()),
|
|
parse_xml_report_file(hd / (stem.replace(".", "_", 1) + "_XML.XML")),
|
|
CARVEOUTS)}
|
|
for f in ("NumberofIntervals", "intervals.Tran Peak in/s", "intervals.Vert Peak in/s",
|
|
"intervals.Long Peak in/s"):
|
|
assert res[f].verdict == "match", (f, res[f])
|
|
|
|
|
|
def _count_case(extra, drop_rows=0):
|
|
jf = FIX.parent / "job-number-11-02-26"
|
|
ref = parse_xml_report_file(jf / "T438I4V5_DJ0H_XML.XML")
|
|
rows = len(ref.intervals)
|
|
ref.scalars["NumberofIntervals"] = f"{rows + extra}.00"
|
|
if drop_rows:
|
|
ref.intervals = ref.intervals[:-drop_rows]
|
|
side = sfm_side((jf / "T438I4V5.DJ0H").read_bytes())
|
|
return {r.field: r for r in compare(side, ref, CARVEOUTS)}["NumberofIntervals"]
|
|
|
|
|
|
def test_blastware_counting_the_monitoring_time_is_accepted():
|
|
# Blastware's Number of Intervals is (stop - start) / interval. When the
|
|
# unit never wrote the last minute, Blastware's own table lists one block
|
|
# fewer, and SFM matches the table (T193KSWP.FF0H: 2,880 against 2,850 rows).
|
|
r = _count_case(30)
|
|
assert (r.verdict, r.carveout) == ("accepted", "interval-count-is-duration")
|
|
|
|
|
|
def test_the_count_carveout_needs_blastwares_own_table_to_agree_with_sfm():
|
|
assert _count_case(30, drop_rows=1).verdict == "mismatch"
|
|
|
|
|
|
_GROUP_A = ("SerialNumber", "Version", "Calibration", "BatteryLevel", "Trigger",
|
|
"GeoTriggerLevel", "MicTriggerLevel", "RecordStopMode", "Microphone", "Units")
|
|
|
|
|
|
@pytest.mark.parametrize("stem,printed", [
|
|
("T189HUD6.QE0W", set(_GROUP_A)),
|
|
("T438L713.RY0W", set(_GROUP_A)), # 130.8 dB(L): 0.01 psi at 6895 Pa/psi
|
|
("K558L4KY.440H", {"SerialNumber", "Version", "Calibration", "BatteryLevel",
|
|
"Microphone", "Units"}), # histogram; battery 6.25 -> "6.3"
|
|
])
|
|
def test_the_setup_fields_match_blastware(stem, printed):
|
|
sf = FIX.parent / "setup-fields-11-03-26"
|
|
res = {r.field: r for r in compare(sfm_side((sf / stem).read_bytes()),
|
|
parse_xml_report_file(sf / (stem.replace(".", "_", 1) + "_XML.XML")),
|
|
CARVEOUTS)}
|
|
assert printed <= set(res)
|
|
for f in printed:
|
|
assert res[f].verdict == "match", (f, res[f])
|
|
|
|
|
|
def test_a_manual_trigger_matches():
|
|
res = _results("T1905KDW.5F0W", CARVEOUTS)
|
|
assert res["Trigger"].verdict == "match"
|
|
|
|
|
|
def _units_case(sfm_units):
|
|
sf = FIX.parent / "setup-fields-11-03-26"
|
|
ref = parse_xml_report_file(sf / "T189HUD6_QE0W_XML.XML")
|
|
ref.scalars["Units"] = "in/s and psi(L)"
|
|
side = sfm_side((sf / "T189HUD6.QE0W").read_bytes())
|
|
if sfm_units is not None:
|
|
side.values["Units"] = sfm_units
|
|
return {r.field: r for r in compare(side, ref, CARVEOUTS)}["Units"]
|
|
|
|
|
|
def test_dB_or_psi_is_blastwares_display_preference():
|
|
# Blastware writes its report in its PC's current preference; DL2's reports
|
|
# switch fleet-wide in 61 clean runs by write time, and no byte in the file
|
|
# tells them apart.
|
|
r = _units_case(None)
|
|
assert (r.verdict, r.carveout) == ("accepted", "units-is-a-display-preference")
|
|
|
|
|
|
def test_the_units_carveout_still_needs_the_mic():
|
|
assert _units_case("in/s").verdict == "mismatch"
|
|
|
|
|
|
def test_a_mic_trigger_level_is_read_in_the_unit_it_is_printed_in():
|
|
# K441LA17.IN0W: Units "in/s and psi(L)", yet MicTriggerLevel "125.0 dB(L)".
|
|
# The printed value states its own unit; that is the one to compare in.
|
|
sf = FIX.parent / "setup-fields-11-03-26"
|
|
ref = parse_xml_report_file(sf / "T189HUD6_QE0W_XML.XML") # 128.0 dB(L)
|
|
ref.event_units = "in/s and psi(L)"
|
|
res = {r.field: r for r in compare(sfm_side((sf / "T189HUD6.QE0W").read_bytes()), ref, CARVEOUTS)}
|
|
assert res["MicTriggerLevel"].verdict == "match", res["MicTriggerLevel"]
|
|
|
|
|
|
@pytest.mark.parametrize("path", [FIX / "T004JTRF.ME0H",
|
|
FIX.parent / "histogram-intervals-11-03-26" / "T190LD42.T00H"])
|
|
def test_histogram_interval_detail_matches_blastware(path):
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
|
|
for f in ("IntervalSize", "HistogramStopDate", "HistogramStopTime", "intervals.Tran Freq Hz",
|
|
"intervals.Vert Freq Hz", "intervals.Long Freq Hz", "intervals.MicL Freq Hz",
|
|
"intervals.Geo PVS in/s"):
|
|
assert res[f].verdict == "match", (f, res[f])
|
|
|
|
|
|
@pytest.mark.parametrize("halfp,sr,want", [
|
|
(0, 1024, "N/A"), (5, 1024, ">100"), (5, 2048, ">200"), (1024, 1024, "<1.0"),
|
|
])
|
|
def test_blastwares_interval_frequency_words(halfp, sr, want):
|
|
# N/A for a half-period of 0, ">100" / ">200" at 5 samples or fewer, "<1.0"
|
|
# below 1 Hz -- on ~3.1 M DL2 cells, 2026-11-03.
|
|
from minimateplus.decode_check import interval_frequency
|
|
assert interval_frequency(halfp, sr) == want
|
|
|
|
|
|
def _pvs_oorange(unclamp=False):
|
|
hb = FIX.parent / "histogram-intervals-11-03-26"
|
|
ref = parse_xml_report_file(hb / "T190LD5Q_LD0H_XML.XML") # Geo PVS OORANGE, Vert OORANGE
|
|
if unclamp:
|
|
cols = ref.interval_columns
|
|
t, row = ref.intervals[0]
|
|
row = list(row)
|
|
row[cols.index("Vert Peak in/s")] = "0.500"
|
|
ref.intervals[0] = (t, row)
|
|
side = sfm_side((hb / "T190LD5Q.LD0H").read_bytes())
|
|
# The carve-out's own path: SFM's numeric interval sums, as before it
|
|
# rendered OORANGE itself (2026-11-09).
|
|
side.interval_values["Geo PVS in/s"] = list(side.event.interval_pvs)
|
|
res = {r.field: r for r in compare(side, ref, CARVEOUTS)}
|
|
return res["intervals.Geo PVS in/s"]
|
|
|
|
|
|
def test_an_oorange_interval_vector_sum_is_saturation():
|
|
# Blastware prints OORANGE for an interval's vector sum above the range when
|
|
# it clamped a channel in that interval: 17 / 17 DL2 cells, SFM's sum
|
|
# 10.01 .. 17.33 (= sqrt 3 x 10.005).
|
|
r = _pvs_oorange()
|
|
assert (r.verdict, r.carveout) == ("accepted", "saturation")
|
|
|
|
|
|
@pytest.mark.parametrize("path,columns", [
|
|
# a Vert interval past full scale: its peak and the interval's vector sum
|
|
(FIX.parent / "histogram-intervals-11-03-26" / "T190LD5Q.LD0H", ("Vert Peak in/s", "Geo PVS in/s")),
|
|
# a mic interval past full scale (2,001 counts)
|
|
(FIX.parent / "over-range-11-09-26" / "K558KD43.NZ0H", ("MicL Peak dB(L)", "MicL Peak psi(L)")),
|
|
])
|
|
def test_interval_over_range_matches_blastware(path, columns):
|
|
# Inside an interval the rule is the event's: a peak past 2,000 units (the
|
|
# mic in counts) is OORANGE, and the vector sum when any geophone is. DL2:
|
|
# numeric up to 1,846 / 1,414, OORANGE from 2,001; vector sums 16 / 16
|
|
# OORANGE with a geophone over, 2,862 / 2,862 numeric without (2026-11-09).
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
|
|
for c in columns:
|
|
if c in (ref.interval_columns or []):
|
|
assert res[f"intervals.{c}"].verdict == "match", (c, res[f"intervals.{c}"])
|
|
|
|
|
|
def test_an_oorange_vector_sum_needs_a_clamped_channel_in_that_interval():
|
|
assert _pvs_oorange(unclamp=True).verdict == "mismatch"
|
|
|
|
|
|
_PEAK_TIMES = ("TranPeakDate", "TranPeakTime", "VertPeakDate", "VertPeakTime", "LongPeakDate",
|
|
"LongPeakTime", "PeakVectorSumDate", "PeakVectorSumTime", "MicLDate", "MicLTime")
|
|
|
|
|
|
@pytest.mark.parametrize("path", [FIX / "T004JTRF.ME0H", # 1 interval
|
|
FIX.parent / "footer-11-03-26" / "T003LCYV.JD0H", # 145
|
|
FIX.parent / "histogram-decode-11-02-26" / "K440HA3C.JM0H"]) # 8 x 5 s
|
|
def test_histogram_times_match_blastware(path):
|
|
# #51: an interval's printed time is its end -- start + (n + 1) x interval,
|
|
# capped at the stop -- and each peak's date and time are its interval's:
|
|
# 2,308,524 / 2,308,524 rows and 2,000 / 2,000 peaks each on a DL2 sample.
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
|
|
for f in (("HistogramStartDate", "HistogramStartTime", "HistogramStopTime", "intervals.Time")
|
|
+ tuple(t for t in _PEAK_TIMES if t in ref.scalars)):
|
|
assert res[f].verdict == "match", (f, res[f])
|
|
|
|
|
|
@pytest.mark.parametrize("path", [FIX / "R352HIUI.F40W",
|
|
FIX.parent / "setup-fields-11-03-26" / "T189HUD6.QE0W"])
|
|
def test_waveform_peak_detail_matches_blastware(path):
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
|
|
for f in ("TranTimeofPeak", "VertTimeofPeak", "LongTimeofPeak", "MicLTimeofPeak",
|
|
"PeakVectorSumTimeSum", "TranPeakAcceleration", "VertPeakAcceleration",
|
|
"LongPeakAcceleration"):
|
|
assert res[f].verdict == "match", (f, res[f])
|
|
|
|
|
|
# ── Group D, part 2: the unit's own summary (2026-11-05) ────────────────────
|
|
_US = FIX.parent / "unit-summary-11-05-26"
|
|
_ZC_AND_DISP = ([f"{ch}ZCFreq" for ch in ("Tran", "Vert", "Long", "MicL")]
|
|
+ [f"{ch}PeakDisplacement" for ch in ("Tran", "Vert", "Long")])
|
|
|
|
|
|
@pytest.mark.parametrize("path", [
|
|
FIX / "R352HIUI.F40W", FIX / "T1905KDW.5F0W",
|
|
FIX.parent / "setup-fields-11-03-26" / "T189HUD6.QE0W",
|
|
FIX / "T004JTRF.ME0H", FIX / "M529L4XQ.R30H", # histograms
|
|
_US / "K558IKSJ.P20W", # "<1.0" and N/A
|
|
_US / "O117I1NK.R70W", # the mic's ">100"; clipped
|
|
])
|
|
def test_zc_frequency_and_displacement_match_blastware(path):
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
|
|
checked = 0
|
|
for f in _ZC_AND_DISP:
|
|
printed = ref.scalars.get(f)
|
|
if printed is None:
|
|
continue
|
|
want = "no_reference" if printed == "N/A" else "match"
|
|
assert res[f].verdict == want, (f, res[f])
|
|
checked += want == "match"
|
|
assert checked >= 3
|
|
|
|
|
|
def test_a_clipped_events_peak_times_match_blastware():
|
|
path = _US / "O117I1NK.R70W"
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
|
|
for f in ("TranTimeofPeak", "VertTimeofPeak", "LongTimeofPeak", "MicLTimeofPeak",
|
|
"PeakVectorSumTimeSum"):
|
|
assert res[f].verdict == "match", (f, res[f])
|
|
|
|
|
|
|
|
# ── Group E: the sensor check results (2026-11-06) ──────────────────────────
|
|
_SENSOR_CHECK = [f"{ch}Test{f}" for ch in ("Tran", "Vert", "Long", "MicL")
|
|
for f in ("Results", "Freq", "Ratio", "Amplitude")]
|
|
|
|
|
|
@pytest.mark.parametrize("path", [
|
|
FIX / "R352HIUI.F40W", FIX / "T1905KDW.5F0W", FIX / "T004JTRF.ME0H", FIX / "M529L4XQ.R30H",
|
|
_US / "K440HJCN.AS0W", # two Checks
|
|
_US / "K558IKSJ.P20W", _US / "O117I1NK.R70W",
|
|
])
|
|
def test_sensor_check_results_match_blastware(path):
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
|
|
checked = 0
|
|
for f in _SENSOR_CHECK:
|
|
if ref.scalars.get(f) is None:
|
|
continue
|
|
assert res[f].verdict == "match", (f, res[f])
|
|
checked += 1
|
|
assert checked >= 4
|
|
|
|
|
|
# ── Group F: the monitor log (2026-11-08) ───────────────────────────────────
|
|
_ML = FIX.parent / "monitor-log-11-08-26"
|
|
|
|
|
|
@pytest.mark.parametrize("path", [
|
|
FIX / "R352HIUI.F40W", FIX / "T004JTRF.ME0H", FIX / "M529L4XQ.R30H",
|
|
_US / "K440HJCN.AS0W", _US / "O117I1NK.R70W",
|
|
_ML / "T189INWA.060H", _ML / "K559HCQ7.IU0H", _ML / "T192JWEL.0Y0H", _ML / "T189JZY7.L60H",
|
|
])
|
|
def test_the_monitor_log_matches_blastware(path):
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
|
|
assert res["MonitorLog"].verdict == "match", res["MonitorLog"]
|
|
|
|
|
|
# ── Over range (2026-11-09) ─────────────────────────────────────────────────
|
|
_OR = FIX.parent / "over-range-11-09-26"
|
|
|
|
|
|
@pytest.mark.parametrize("path", [
|
|
_US / "O117I1NK.R70W", # everything over, the "Out of Range" line
|
|
_OR / "O121L4L1.GU0H", # Tran over: its PPV and the vector sum
|
|
_OR / "K558KD43.NZ0H", # the mic over, the "Out of Range" line
|
|
_OR / "M007JC05.OI0H", # vector sum 14.49 in/s, printed as a number
|
|
])
|
|
def test_over_range_matches_blastware(path):
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
|
|
for f in ("TranPPV", "VertPPV", "LongPPV", "PeakVectorSum", "MicLPSPL", "OORANGE"):
|
|
if ref.scalars.get(f) is not None:
|
|
assert res[f].verdict == "match", (f, res[f])
|
|
|
|
|
|
def test_an_over_range_flag_against_a_printed_number_is_a_mismatch():
|
|
path = _OR / "M007JC05.OI0H"
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
sfm = sfm_side(path.read_bytes())
|
|
sfm.event.peak_values.pvs_over_range = True # SFM would print OORANGE; Blastware printed 14.49
|
|
res = {r.field: r for r in compare(sfm, ref, CARVEOUTS)}
|
|
assert res["PeakVectorSum"].verdict == "mismatch"
|
|
|
|
|
|
|
|
def test_a_range_1_mic_matches_blastware():
|
|
# Its mic range byte is 1: every count is an eighth (79.4 dB(L), not 97.5).
|
|
path = _OR / "K557J1XQ.GF0W"
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
|
|
for f in ("MicLPSPL", "samples.MicL"):
|
|
assert res[f].verdict == "match", (f, res[f])
|
|
|
|
|
|
# ── The unit Blastware printed, field by field (2026-11-09) ─────────────────
|
|
# A report's event Units line does not always say what its mic values are in:
|
|
# 7 DL2 reports print the mic peak in dB under a psi line, 3 the reverse, and
|
|
# S353JTHU prints its sample table in dB under psi on both. The peak carries
|
|
# its own unit, and a mic table's cells are unmistakable (dB >= 60, psi < 1).
|
|
_UL = FIX.parent / "mic-units-11-09-26"
|
|
|
|
|
|
def _res(path, side=None):
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
return {r.field: r for r in compare(side or sfm_side(path.read_bytes()), ref, CARVEOUTS)}
|
|
|
|
|
|
@pytest.mark.parametrize("path,field", [
|
|
(_UL / "K441L9IN.OT0W", "MicLPSPL"), # psi line; the peak in dB, saying so
|
|
(_UL / "K888JOU7.8K0H", "MicLPSPL"), # the same on a histogram
|
|
])
|
|
def test_a_mic_peak_is_read_in_its_own_unit(path, field):
|
|
assert _res(path)[field].verdict == "match", _res(path)[field]
|
|
|
|
|
|
@pytest.mark.parametrize("path", [
|
|
_UL / "K441L9IN.OT0W", # a dB table with psi cells ("0.000", "-0.000") for counts of 1 to 3
|
|
_UL / "S353JTHU.DT0W", # psi rows, then dB rows, all under a psi line
|
|
])
|
|
def test_a_mic_column_mixing_dB_and_psi_is_accepted(path):
|
|
r = _res(path)["samples.MicL"]
|
|
assert (r.verdict, r.carveout) == ("accepted", "mic-units-mixed"), r
|
|
|
|
|
|
def test_the_mixed_units_carveout_needs_every_cell_in_one_unit_or_the_other():
|
|
path = _UL / "S353JTHU.DT0W"
|
|
ref = parse_xml_report_file(path.with_name(path.name.replace(".", "_", 1) + "_XML.XML"))
|
|
i = ref.channels.index("MicL")
|
|
ref.sample_rows[0][i] = "50.00" # neither SFM's dB nor its psi
|
|
res = {r.field: r for r in compare(sfm_side(path.read_bytes()), ref, CARVEOUTS)}
|
|
assert res["samples.MicL"].verdict == "mismatch"
|