fix(decode): one MicL count is 0.25 Pa -- the mic psi was ~95x low

SFM converted mic counts to psi with a '~0.5 psi full-scale' guess
(0.0125 / 32768 psi per count).  Measured against 1,729,253 DL2
histogram intervals' 'MicL Peak' columns: one count is exactly 0.25 Pa.
count x 0.25 Pa matches Blastware's psi(L) on every interval, and
20 log10(count x 0.25 Pa / 20 uPa) its dB(L) on all but 17 exact
half-way cases.

- event_file_io: _MIC_FS_PSI -> _MIC_PSI_PER_COUNT = 0.25 / 6894.757
  (3.626e-5 psi per count, was 3.81e-7).  The event's mic peak in psi,
  and with it the .h5 mic trace (event_hdf5 back-solves its scale from
  that peak), come right on events with no report.
- waveform_codec.mic_count_to_db: the offset is 20 log10(0.25 / 20e-6)
  = 81.938, not 81.94 -- the old value missed 49 of those intervals at a
  rounding edge (count 119 printed 123.4, 81.94 gave 123.451).

The decoded count was always right: count 16 on K441LTON.900 is
Blastware's 106.0 dB.

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-10-31 01:28:23 -04:00
1 parent dc42ae041a
commit 5644dbd5ad
5 files changed
+56 -18

No files matched your search

+26
View File
@@ -179,3 +179,29 @@ def test_interval_pvs_per_interval():
# Blastware's interval table, first four "Geo PVS" values
for got, want in zip(pvs[:4], (0.065, 0.034, 0.015, 0.461)):
assert abs(got * 0.005 - want) <= 0.0005 + 1e-9, (got, want)
# ── The mic: one count = 0.25 Pa ────────────────────────────────────────────
# Measured 2026-10-31 against 1,729,253 DL2 histogram intervals' "MicL Peak"
# columns: count x 0.25 Pa matches Blastware's psi(L) on every one, and
# 20 log10(count x 0.25 Pa / 20 uPa) its dB(L) on all but 17 exact half-way
# cases. The old psi factor (a "~0.5 psi full-scale" guess) was ~95x small.
from minimateplus.waveform_codec import mic_count_to_db # noqa: E402
@pytest.mark.parametrize("count,printed", [
(1, "81.94"), # XML sample cell
(119, "123.4"), # Blastware interval tables, where 81.94 + 20 log10 gave 123.451
(132, "124.3"), # ... and 124.351
(813, "140.14"), # V70 fixture, Blastware display
])
def test_mic_db_matches_blastware(count, printed):
d = len(printed.split(".")[1])
assert abs(mic_count_to_db(count) - float(printed)) <= 0.5 * 10 ** -d + 1e-9
def test_mic_peak_in_psi():
# Blastware: MicL PSPL 106.0 dB(L) = 20 uPa x 10^(106/20) = 3.990 Pa = 5.787e-4 psi.
ev = read_blastware_file(_FIX / "decode-checker-10-29-26/M529L4XQ.R30H")
assert ev.peak_values.micl == pytest.approx(5.787e-4, rel=0.01)
+5
View File
@@ -142,3 +142,8 @@ def test_pvs_carveout_needs_the_clipped_channel_at_the_ceiling():
side.values["TranPPV"] = 1.256
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"