feat(decode): ZC frequency, peak displacement and times of peak from the unit's own event summary

After its embedded event record, every Blastware event file carries the
unit's own per-channel summary: a chain of [length][id][payload] records,
ids 0x32 Tran .. 0x35 MicL, each with min, max, peak sample,
half-period and a displacement integral; the event record itself holds
the vector-sum peak's sample.  Blastware prints these as they are
(measured on DL2, 2026-11-05):

- ZC frequency = (rate / 2) / half-period: 15,844 / 15,844 waveform and
  104,000 / 104,000 histogram values; every word too (">100" at <= 5
  samples, "N/A" at 0, "<1.0" beyond rate / 2).  Recomputing from the
  samples had reached 46%: the unit works at full resolution.
- peak displacement = half the integral x 16 counts x in/s per count /
  rate: 19,479 / 19,479 (84% recomputed).
- times of peak and the vector-sum time now come from the unit's peak
  samples.  They equal the samples' argmax on 25,962 / 25,966 channels;
  the 4 others are O117I1NK.R70W, whose stored samples wrap at the
  trigger (Blastware's own sample table has the same wrapped values).

The event-record readers return the validated record's offset, so the
summary is read from that spot only.  No summary: nothing is set, and
times of peak stay the samples'.

The checker reports ZC frequency and displacement, and reads the mic's
above-range flag under its real name (mic_zc_above_range).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-11-05 14:00:13 -05:00
1 parent c9f41deadd
commit 9091fe75a9
14 files changed
+14345 -27

No files matched your search

+12 -2
View File
@@ -145,9 +145,18 @@ def sfm_side(raw: bytes) -> SfmSide:
("PeakVectorSumTimeSum", pv.pvs_time),
("TranPeakAcceleration", pv.tran_peak_accel_g),
("VertPeakAcceleration", pv.vert_peak_accel_g),
("LongPeakAcceleration", pv.long_peak_accel_g)):
("LongPeakAcceleration", pv.long_peak_accel_g),
("TranPeakDisplacement", pv.tran_peak_disp_in),
("VertPeakDisplacement", pv.vert_peak_disp_in),
("LongPeakDisplacement", pv.long_peak_disp_in)):
if value is not None:
values[tag] = value
# The unit's ZC frequency, every record type. Above range it is judged
# by its flag (_compare_scalar); below 1 Hz Blastware prints a word.
for tag, hz in (("TranZCFreq", pv.tran_zc_freq), ("VertZCFreq", pv.vert_zc_freq),
("LongZCFreq", pv.long_zc_freq), ("MicLZCFreq", pv.mic_zc_freq)):
if hz is not None:
values[tag] = "<1.0" if hz < 1.0 else hz
if counts["MicL"]:
values["MicLPSPL dB(L)"] = mic_count_to_db(max(abs(c) for c in counts["MicL"]))
values["MicLPSPL psi(L)"] = pv.micl if pv is not None else None
@@ -264,7 +273,8 @@ def _compare_scalar(tag: str, printed: str, sfm: SfmSide, ref: XmlReport) -> Fie
return FieldResult(tag, "sfm_blank", printed, None)
if printed.startswith(">"):
# ZC frequency above range: SFM agrees only by setting its flag.
flag = getattr(sfm.event.peak_values, tag[:-len("ZCFreq")].lower() + "_zc_above_range", False)
ch = tag[:-len("ZCFreq")].lower()
flag = getattr(sfm.event.peak_values, ("mic" if ch == "micl" else ch) + "_zc_above_range", False)
return FieldResult(tag, "match" if flag else "mismatch", printed, str(value))
if printed == "OORANGE":
return FieldResult(tag, "mismatch", printed, str(value))
+112 -20
View File
@@ -31,7 +31,8 @@ from . import blastware_file as _bw # avoid circular reference at module load
from .bw_ascii_report import BwAsciiReport
from . import waveform_codec as _wc
from .waveform_codec import decode_waveform_v2, decoded_to_adc_counts
from .histogram_codec import channels_from_records, decode_histogram_body, decode_histogram_body_full
from .histogram_codec import (channels_from_records, decode_histogram_body, decode_histogram_body_full,
half_period_to_hz)
# Reference pressure for dB(L) → psi conversion (20 µPa expressed in psi).
# Same constant as sfm/sfm_webapp.html so server-side and browser-side
@@ -833,6 +834,47 @@ def _waveform_peak_detail(pv: PeakValues, samples: dict[str, list[int]], geo_fs_
pv.pvs_time = (j - pretrig) / sample_rate
def _zc_from_half_period(halfp: int, sample_rate: int) -> tuple[Optional[float], bool]:
"""(ZC frequency, above range) as Blastware reports it: None for a
half-period of 0 ("N/A"); Blastware's threshold, flagged, at 5 samples or
fewer (">100", ">200" at 2048 sps); else (rate / 2) / half-period, which
Blastware prints as "<1.0" below 1 Hz."""
if halfp == 0:
return None, False
hz = half_period_to_hz(halfp, sample_rate)
if hz is None:
return 100.0 * sample_rate / 1024, True
return hz, False
def _apply_unit_summary(pv: PeakValues, summary: dict, geo_fs_ins: float, sample_rate: int,
pretrig: Optional[int]) -> None:
"""The unit's own values from its event summary, on `pv`. Blastware prints
them as they are (DL2, 2026-11-05):
* ZC frequency, every record type: 15,844 / 15,844 waveform and
104,000 / 104,000 histogram values, and every word
* a waveform's peak displacement = half its integral: 19,479 / 19,479
* a waveform's times of peak and vector-sum time, from the unit's peak
samples (`pretrig` given): they replace the samples' own, which differ
only where the stored samples wrap (O117I1NK.R70W)."""
# The summary's geophone values are decoder units, as a histogram's are.
unit_ins = _HIST_GEO_COUNTS_PER_UNIT * geo_fs_ins / _GEO_INT16_FS
for ch, attr in (("Tran", "tran"), ("Vert", "vert"), ("Long", "long"), ("MicL", "mic")):
c = summary.get(ch)
if c is None:
continue
hz, above = _zc_from_half_period(c["half_period"], sample_rate)
setattr(pv, f"{attr}_zc_freq", hz)
setattr(pv, f"{attr}_zc_above_range", above)
if pretrig is None:
continue
setattr(pv, f"{ch.lower()}_time_of_peak", (c["peak_sample"] - pretrig) / sample_rate)
if ch != "MicL":
setattr(pv, f"{attr}_peak_disp_in", c["disp_integral"] * unit_ins / sample_rate / 2)
if pretrig is not None and all(ch in summary for ch in ("Tran", "Vert", "Long")):
pv.pvs_time = (summary["pvs_sample"] - pretrig) / sample_rate
# STRT[18], the record-type byte (#41): 0x46 on every one of DL2's 6,577
# waveform files and 0x0A on every one of its 63,535 histograms (measured
# 2026-10-29). Manual / Event / Combo never occur there, so their bytes are
@@ -936,9 +978,10 @@ def _ts8(b: bytes) -> Optional[datetime.datetime]:
def _embedded_event_record(
raw: bytes, end: int, start: Optional[datetime.datetime],
stop: Optional[datetime.datetime], record_time: Optional[float],
) -> tuple[Optional[datetime.datetime], str, Optional[int]]:
"""The trigger time and trigger source from the instrument's embedded event
record, or (None, why, None).
) -> tuple[Optional[datetime.datetime], str, Optional[int], Optional[int]]:
"""The trigger time, the trigger source and the offset of the record's
`fe 80` from the instrument's embedded event record, or (None, why, None,
None).
Every `fe 80` before `end` (the footer) is a candidate. One counts only if
its lead bytes match, both its times are well formed, the footer's session
@@ -951,7 +994,7 @@ def _embedded_event_record(
Blastware's Trigger on 6,493 / 6,493 DL2 waveforms (2026-11-03).
"""
if start is None or stop is None:
return None, "the footer has no start and stop to check one against", None
return None, "the footer has no start and stop to check one against", None, None
found, rejected = [], 0
i = raw.find(_EVENT_RECORD_MARKER, 6)
while 0 <= i and i + 18 <= end:
@@ -967,15 +1010,15 @@ def _embedded_event_record(
<= _EVENT_RECORD_SLACK_S[1])
)
if valid:
found.append((trig, int.from_bytes(raw[i - 2:i], "big")))
found.append((trig, int.from_bytes(raw[i - 2:i], "big"), i))
else:
rejected += 1
i = raw.find(_EVENT_RECORD_MARKER, i + 1)
if len(found) == 1:
return found[0][0], "", found[0][1]
return found[0][0], "", found[0][1], found[0][2]
if found:
return None, f"{len(found)} candidates validate", None
return None, (f"{rejected} candidate(s), none valid" if rejected else "no candidate"), None
return None, f"{len(found)} candidates validate", None, None
return None, (f"{rejected} candidate(s), none valid" if rejected else "no candidate"), None, None
# A histogram's event record: the same lead, the source 0x0400, marker fe f5,
@@ -1001,11 +1044,12 @@ def interval_times(start: datetime.datetime, interval_sec: int,
def _histogram_event_record(
raw: bytes, end: int, start: Optional[datetime.datetime],
stop: Optional[datetime.datetime],
) -> tuple[Optional[datetime.datetime], Optional[datetime.datetime], str]:
"""(start, stop) from a histogram's own event record, or (None, None, why).
Exactly one record may validate against the footer's start and stop."""
) -> tuple[Optional[datetime.datetime], Optional[datetime.datetime], str, Optional[int]]:
"""(start, stop, "", offset of its `fe f5`) from a histogram's own event
record, or (None, None, why, None). Exactly one record may validate against
the footer's start and stop."""
if start is None or stop is None:
return None, None, "the footer has no start and stop to check one against"
return None, None, "the footer has no start and stop to check one against", None
found, rejected = [], 0
i = raw.find(_HISTOGRAM_RECORD_MARKER, 6)
while 0 <= i and i + 18 <= end:
@@ -1014,15 +1058,57 @@ def _histogram_event_record(
and a is not None and b is not None and a <= b
and 0 <= (a - start).total_seconds() <= 1
and 0 <= (stop - b).total_seconds() <= 1):
found.append((a, b))
found.append((a, b, i))
elif raw[i - 6:i - 2] == _EVENT_RECORD_LEAD:
rejected += 1
i = raw.find(_HISTOGRAM_RECORD_MARKER, i + 1)
if len(found) == 1:
return found[0][0], found[0][1], ""
return found[0][0], found[0][1], "", found[0][2]
if found:
return None, None, f"{len(found)} candidates validate"
return None, None, (f"{rejected} candidate(s), none valid" if rejected else "no candidate")
return None, None, f"{len(found)} candidates validate", None
return None, None, (f"{rejected} candidate(s), none valid" if rejected else "no candidate"), None
# The unit's own event summary (measured on DL2, 2026-11-05). The event record
# is the first of a chain of [length uint16 BE][id][payload] records, so the
# next record starts `length` + 2 bytes after its lead. Its payload holds the
# vector-sum peak's sample at [22:26] past the marker. The four that follow,
# 22 bytes each, are one per channel (ids 0x32 Tran .. 0x35 MicL; a unit
# without a mic has no 0x35):
# [0] 0 [1:3] min [3:5] max (int16 BE; geophones in units of 16 counts)
# [5:9] peak sample [9:11] half-period, samples [11:15] displacement
# integral, units x samples [15:21] not identified
# min, max and peak sample equal the samples' own on 25,962 / 25,966 DL2
# channels (the 4 others: O117I1NK.R70W, whose samples wrap at the trigger).
_SUMMARY_CHANNELS = {0x32: "Tran", 0x33: "Vert", 0x34: "Long", 0x35: "MicL"}
_SUMMARY_CHANNEL_LEN = 22
_RECORD_LEAD_TO_MARKER = 6 # the lead `00 28 05 00` and the source sit before the marker
_SUMMARY_PVS_SAMPLE_AT = 22 # past the marker
def _unit_summary(raw: bytes, marker_at: int) -> Optional[dict]:
"""The unit's per-channel event summary after the validated event record
whose marker is at `marker_at`: {"pvs_sample": int, "Tran": {...}, ...},
each channel {"min", "max", "peak_sample", "half_period",
"disp_integral"}. None when no channel record follows the event record."""
lead = marker_at - _RECORD_LEAD_TO_MARKER
off = lead + 2 + int.from_bytes(raw[lead:lead + 2], "big")
out: dict = {"pvs_sample": int.from_bytes(
raw[marker_at + _SUMMARY_PVS_SAMPLE_AT:marker_at + _SUMMARY_PVS_SAMPLE_AT + 4], "big")}
while off + 2 + _SUMMARY_CHANNEL_LEN <= len(raw):
ch = _SUMMARY_CHANNELS.get(raw[off + 2])
if int.from_bytes(raw[off:off + 2], "big") != _SUMMARY_CHANNEL_LEN or ch is None or ch in out:
break
p = raw[off + 3:off + 2 + _SUMMARY_CHANNEL_LEN]
out[ch] = {
"min": struct.unpack(">h", p[1:3])[0],
"max": struct.unpack(">h", p[3:5])[0],
"peak_sample": int.from_bytes(p[5:9], "big"),
"half_period": int.from_bytes(p[9:11], "big"),
"disp_integral": int.from_bytes(p[11:15], "big"),
}
off += 2 + _SUMMARY_CHANNEL_LEN
return out if len(out) > 1 else None
def _parse_record_time_seconds(raw: bytes) -> Optional[float]:
@@ -1450,13 +1536,15 @@ def decode_blastware_bytes(raw: bytes, *, name: Optional[str] = None) -> Event:
# and its histogram may share a second.
# ⚠ RETRACTED 2026-11-03: "histograms stay on ts1" -- that held only while
# events were unique on (serial, timestamp).
_record_at = None # the validated event record, which the unit's summary follows
if is_waveform_body and ts2 is not None:
_stop = datetime.datetime(ts2.year, ts2.month, ts2.day,
ts2.hour, ts2.minute, ts2.second)
_rt = _parse_record_time_seconds(raw)
_start = (datetime.datetime(ts1.year, ts1.month, ts1.day, ts1.hour, ts1.minute, ts1.second)
if ts1 is not None else None)
_trig, _why, ev.triggered_by = _embedded_event_record(raw, footer_pos, _start, _stop, _rt)
_trig, _why, ev.triggered_by, _record_at = _embedded_event_record(
raw, footer_pos, _start, _stop, _rt)
if _trig is not None:
ev.timestamp_source = "event_record"
else:
@@ -1478,8 +1566,8 @@ def decode_blastware_bytes(raw: bytes, *, name: Optional[str] = None) -> Event:
hour=_trig.hour, minute=_trig.minute, second=_trig.second,
)
elif ts1 is not None:
_start, _hstop, _why = (_histogram_event_record(raw, footer_pos, ts1, ts2)
if record_type == "Histogram" else (None, None, ""))
_start, _hstop, _why, _record_at = (_histogram_event_record(raw, footer_pos, ts1, ts2)
if record_type == "Histogram" else (None, None, "", None))
if _start is not None:
ev.timestamp_source = "event_record"
ev.stop_time = _hstop
@@ -1522,6 +1610,10 @@ def decode_blastware_bytes(raw: bytes, *, name: Optional[str] = None) -> Event:
if (is_waveform_body and ev.peak_values is not None and ev.sample_rate
and ev.pretrig_samples is not None):
_waveform_peak_detail(ev.peak_values, samples, geo_fs, ev.sample_rate, ev.pretrig_samples)
_summary = _unit_summary(raw, _record_at) if _record_at is not None else None
if _summary is not None and ev.peak_values is not None and ev.sample_rate:
_apply_unit_summary(ev.peak_values, _summary, geo_fs, ev.sample_rate,
ev.pretrig_samples if is_waveform_body else None)
if ev.stop_time is None: # a histogram's record stop, else the footer's
ev.stop_time = ts2
if hist_records:
+9 -1
View File
@@ -356,6 +356,9 @@ class PeakValues:
long: Optional[float] = None # Longitudinal PPV (in/s) ✅
micl: Optional[float] = None # Air overpressure (psi) 🔶 (units uncertain)
peak_vector_sum: Optional[float] = None # Scalar geo PVS (in/s) ✅
# ZC frequency (Hz), from the unit's own summary in the file (2026-11-05) or
# a report. Above range, the value is Blastware's threshold (100 Hz at
# 1024 sps) and the flag is set; None is Blastware's "N/A".
tran_zc_freq: Optional[float] = None
vert_zc_freq: Optional[float] = None
long_zc_freq: Optional[float] = None
@@ -364,7 +367,8 @@ class PeakValues:
vert_zc_above_range: bool = False
long_zc_above_range: bool = False
mic_zc_above_range: bool = False
# A waveform's peak detail, from its samples (2026-11-04); None for a histogram.
# A waveform's peak detail (2026-11-04); None for a histogram. Times of peak
# are the unit's own peak samples, acceleration comes from the samples.
tran_time_of_peak: Optional[float] = None # s from the trigger; negative = pre-trigger
vert_time_of_peak: Optional[float] = None
long_time_of_peak: Optional[float] = None
@@ -373,6 +377,10 @@ class PeakValues:
tran_peak_accel_g: Optional[float] = None
vert_peak_accel_g: Optional[float] = None
long_peak_accel_g: Optional[float] = None
# Peak displacement (in), from the unit's own summary (2026-11-05).
tran_peak_disp_in: Optional[float] = None
vert_peak_disp_in: Optional[float] = None
long_peak_disp_in: Optional[float] = None
# ── Project / operator metadata ───────────────────────────────────────────────
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large. Load diff
Binary file not shown.
File diff suppressed because it is too large. Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
+80
View File
@@ -522,3 +522,83 @@ def test_waveform_peak_detail_comes_from_the_samples(rel, times, pvs_time, accel
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_without_the_units_summary_nothing_is_guessed():
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
pv = decode_blastware_bytes(bytes(raw), name=None).peak_values
assert (pv.tran_zc_freq, pv.mic_zc_freq, pv.tran_peak_disp_in) == (None, None, None)
assert abs(pv.tran_time_of_peak - 2.281) <= 0.0005 # the samples' peak, as before
+42 -4
View File
@@ -40,8 +40,10 @@ def test_event_type_comes_from_the_bytes():
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: test_the_setup_fields_match_blastware, test_waveform_peak_detail_*)
for tag in ("TranZCFreq", "TranPeakDisplacement", "TranTestResults"):
# 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", "TranTestResults"):
assert s.values.get(tag) is None
@@ -67,7 +69,7 @@ def test_full_waveform_row_verdicts():
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 in ("sfm_blank", "no_reference")
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
@@ -91,7 +93,7 @@ def test_an_extra_reference_row_is_a_mismatch_with_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 == "sfm_blank" # >100, SFM has no flag yet
assert res["VertZCFreq"].verdict == "match" # >100: the unit's half-period
def test_mic_units_pick_the_conversion():
@@ -355,3 +357,39 @@ def test_waveform_peak_detail_matches_blastware(path):
"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])