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:
1 parent
dc42ae041a
commit
5644dbd5ad
5 files changed
+56
-18
No files matched your search
@@ -628,23 +628,28 @@ def decoded_to_adc_counts(decoded: dict) -> dict:
|
||||
}
|
||||
|
||||
|
||||
# One MicL count is 0.25 Pa (measured 2026-10-31): count x 0.25 Pa matches
|
||||
# Blastware's "MicL Peak psi(L)" on all 1,729,253 DL2 histogram intervals
|
||||
# checked, and 20 log10(count x 0.25 Pa / 20 uPa) its dB(L) on all but 17
|
||||
# exact half-way cases. The dB offset below is that, 81.938 -- not the 81.94
|
||||
# first fitted to a handful of values, which missed 49 of those intervals.
|
||||
MIC_PA_PER_COUNT = 0.25
|
||||
_MIC_DB_REF = 20.0 * math.log10(MIC_PA_PER_COUNT / 20e-6)
|
||||
|
||||
|
||||
def mic_count_to_db(count: int) -> float:
|
||||
"""Convert a MicL ADC count to dB(L) for BW-display-compatible output.
|
||||
|
||||
Empirical formula (confirmed 2026-05-11 against V70 fixture: count=813
|
||||
→ 140.1 dB; count=±1 → ±81.94 dB; count=±24 → ±109.5 dB):
|
||||
dB = sign(count) × (20 log10(0.25 Pa / 20 µPa) + 20 × log10(|count|))
|
||||
= sign(count) × (81.938 + 20 × log10(|count|)) for |count| ≥ 1
|
||||
dB = 0.0 for count == 0
|
||||
|
||||
dB = sign(count) × (81.94 + 20 × log10(|count|)) for |count| ≥ 1
|
||||
dB = 0.0 for count == 0
|
||||
|
||||
The constant 81.94 corresponds to 10^(81.94/20) ≈ 12490 mic ADC counts
|
||||
being the dB(L) reference level — almost certainly a calibration
|
||||
constant from the device's mic.
|
||||
count=±1 → ±81.94 dB; count=813 → 140.14 dB (the V70 fixture).
|
||||
"""
|
||||
if count == 0:
|
||||
return 0.0
|
||||
sign = 1.0 if count > 0 else -1.0
|
||||
return sign * (81.94 + 20.0 * math.log10(abs(count)))
|
||||
return sign * (_MIC_DB_REF + 20.0 * math.log10(abs(count)))
|
||||
|
||||
|
||||
# ── A5-frame entry point ────────────────────────────────────────────────────
|
||||
|
||||
Reference in new issue
Block a user