Release v0.33.0 — SFM reads Series-3 events from the file alone #56

Merged
serversdown merged 34 commits from dev into main 2026-11-01 14:33:01 -05:00
2 changed files with 14 additions and 7 deletions
Showing only changes of commit 18951505f0 - Show all commits

No files matched your search

+13 -7
View File
@@ -630,20 +630,26 @@ 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.
# checked.
MIC_PA_PER_COUNT = 0.25
_MIC_DB_REF = 20.0 * math.log10(MIC_PA_PER_COUNT / 20e-6)
# Blastware's dB(L) offset sits a hair above the exact 20 log10(0.25 Pa /
# 20 uPa) = 81.93820: any value in [81.9383, 81.9385] matches its dB on
# 1,729,252 / 1,729,253 intervals (the one left printed "0.000"), while
# 81.93820 rounds count 129 (162 intervals) to 124.1 against Blastware's
# 124.2, and the 81.94 first fitted to a handful of values misses counts 119
# and 132. Its display chain presumably carries rounded constants; the
# window, not the physics, is what is measured.
_MIC_DB_REF = 81.9384
def mic_count_to_db(count: int) -> float:
"""Convert a MicL ADC count to dB(L) for BW-display-compatible output.
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.9384 + 20 × log10(|count|)) for |count| ≥ 1
dB = 0.0 for count == 0
81.9384 ≈ 20 log10(0.25 Pa / 20 µPa); see _MIC_DB_REF.
count=±1 → ±81.94 dB; count=813 → 140.14 dB (the V70 fixture).
"""
if count == 0:
+1
View File
@@ -194,6 +194,7 @@ from minimateplus.waveform_codec import mic_count_to_db # noqa: E402
(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
(129, "124.2"), # 162 intervals; exactly 0.25 Pa gives 124.149997, a hair under half-way
(813, "140.14"), # V70 fixture, Blastware display
])
def test_mic_db_matches_blastware(count, printed):