feat(decode): a waveform's time of peak, vector-sum time and peak acceleration

Group D, part 1, measured on 400 DL2 waveforms (2026-11-04):
- time of peak = (first peak sample - pre-trigger samples) / sample
  rate, per channel including the mic: 1,197 / 1,197 geophone values
- the vector sum's time, the same on sqrt(T^2 + V^2 + L^2): 398 / 399
- peak acceleration = the largest |v[i+1] - v[i]| x sample rate / g,
  with Blastware's g = 9.81 m/s^2: 1,190 / 1,197 (the standard 9.80665
  gives 1,073).  Blastware's manuals: 'subtracts two velocity readings
  and divides the result by the elapsed time between them'.

PeakValues gains *_time_of_peak, pvs_time and *_peak_accel_g, filled
for waveforms only.  The checker reports them.  Displacement (84% with
the manuals' half-cycle integral) and ZC frequency (46%) are not shipped
yet -- Blastware does something more there.

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-04 15:19:53 -05:00
1 parent 9b458b5d92
commit 233289d029
5 files changed
+99 -2

No files matched your search

+27
View File
@@ -495,3 +495,30 @@ def test_a_histogram_without_its_record_falls_back_to_the_footer_and_says_so():
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 = 9.81 m/s^2 (386.2205 in/s^2): 1,190 / 1,197 (9.80665 gives 1,073)
@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)