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:
1 parent
c9f41deadd
commit
9091fe75a9
14 files changed
+14345
-27
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user