diff --git a/minimateplus/event_file_io.py b/minimateplus/event_file_io.py index 4cffcab..c22efc4 100644 --- a/minimateplus/event_file_io.py +++ b/minimateplus/event_file_io.py @@ -794,9 +794,13 @@ def _peaks_from_samples(samples: dict[str, list[int]], ) -# Blastware's g for peak acceleration: 9.81 m/s^2. It matches 1,190 / 1,197 -# DL2 channel values; the standard 9.80665 m/s^2 gives 1,073 (2026-11-04). -_ACCEL_IPS2_PER_G = 9.81 / 0.0254 +# Blastware's g for peak acceleration, fitted: every printed acceleration in +# DL2 bounds it, and together they leave [386.2236, 386.2240] in/s^2 -- 19,475 / +# 19,479 values fit (the other 4: one odd file, O117I1NK.R70W, and one sample +# mismatch). That is 9.81 m/s^2 (386.2205) plus an offset not explained, as +# with the mic's fitted dB offset; 9.81 gives 19,423, the standard 9.80665 gives +# 17,806 (2026-11-04). +_ACCEL_IPS2_PER_G = 386.2238 def _waveform_peak_detail(pv: PeakValues, samples: dict[str, list[int]], geo_fs_ins: float, @@ -808,8 +812,8 @@ def _waveform_peak_detail(pv: PeakValues, samples: dict[str, list[int]], geo_fs_ 1,197 / 1,197; the vector-sum time is 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, - 1,190 / 1,197 -- Blastware's manuals: "subtracts two velocity readings - and divides the result by the elapsed time between them".""" + with Blastware's fitted g -- the manuals: "subtracts two velocity + readings and divides the result by the elapsed time between them".""" scale = geo_fs_ins / _GEO_INT16_FS geo = {} for ch in ("Tran", "Vert", "Long", "MicL"): diff --git a/tests/test_bw_file_fields.py b/tests/test_bw_file_fields.py index 2ae56d9..cb11557 100644 --- a/tests/test_bw_file_fields.py +++ b/tests/test_bw_file_fields.py @@ -501,8 +501,8 @@ def test_a_histogram_without_its_record_falls_back_to_the_footer_and_says_so(): # 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) +# peak acceleration = largest |v[i+1] - v[i]| x rate / g, with Blastware's g +# fitted to [386.2236, 386.2240] in/s^2 by every DL2 value: 19,475 / 19,479 @pytest.mark.parametrize("rel,times,pvs_time,accel", [ (f"{_SF}/T189HUD6.QE0W",