fix(decode): the mic's own range -- a range-1 mic reads an eighth
The mic's channel block carries a range byte at the geophones' offset (label + 29, reference D.6.4). At 1 each count is an eighth, 0.25 / 8 Pa: set on 7 DL2 events, all of them Blastware's values divided by 8, and on none of the other 70,026 -- independently of the geophone range (28 events have Sensitive geophones and a range-0 mic). SFM read those 7 mics 8x high: K557J1XQ.GF0W is 79.4 dB(L), not 97.5. Event.mic_range; the decoded mic peak (and so the .h5 mic samples, whose scale is the peak's) and the checker's mic conversions follow it. 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
af8dde5114
commit
836c9e864b
7 files changed
+3266
-12
No files matched your search
@@ -719,6 +719,15 @@ _HIST_GEO_COUNTS_PER_UNIT = 16
|
||||
# 0.0125 / 32768, that read every mic peak ~95x low (2026-10-31).
|
||||
_PA_PER_PSI = 6894.757
|
||||
_MIC_PSI_PER_COUNT = _wc.MIC_PA_PER_COUNT / _PA_PER_PSI
|
||||
# The mic's own range byte (its channel block, label + 29, as the geophones'):
|
||||
# at 1 each count is an eighth. Set on 7 DL2 events, all of them Blastware's
|
||||
# values divided by 8, and on none of the other 70,026 (2026-11-09).
|
||||
_MIC_COUNTS_PER_UNIT_BY_RANGE = {0: 1, 1: 8}
|
||||
|
||||
|
||||
def mic_count_divisor(mic_range: Optional[int]) -> int:
|
||||
"""How many of a mic's counts make one 0.25 Pa unit at its range."""
|
||||
return _MIC_COUNTS_PER_UNIT_BY_RANGE.get(mic_range, 1)
|
||||
|
||||
|
||||
def _decode_strt(strt: bytes) -> dict:
|
||||
@@ -755,7 +764,8 @@ def _decode_samples_4ch_int16_le(stream: bytes) -> dict[str, list[int]]:
|
||||
|
||||
|
||||
def _peaks_from_samples(samples: dict[str, list[int]],
|
||||
geo_fs_ins: float = _GEO_NORMAL_FS_INS) -> PeakValues:
|
||||
geo_fs_ins: float = _GEO_NORMAL_FS_INS,
|
||||
mic_divisor: int = 1) -> PeakValues:
|
||||
"""
|
||||
Compute peaks from raw int16 samples at the given geophone full scale
|
||||
(Normal, 10 in/s, unless the file's range says otherwise). Used by the
|
||||
@@ -772,9 +782,9 @@ def _peaks_from_samples(samples: dict[str, list[int]],
|
||||
vert = _peak_ins(samples.get("Vert", []))
|
||||
long_ = _peak_ins(samples.get("Long", []))
|
||||
|
||||
# Mic in psi: one count = 0.25 Pa
|
||||
# Mic in psi: one count = 0.25 Pa, an eighth of that on a range-1 mic
|
||||
mic_ch = samples.get("MicL", []) or []
|
||||
mic = max((abs(int(v)) for v in mic_ch), default=0) * _MIC_PSI_PER_COUNT
|
||||
mic = max((abs(int(v)) for v in mic_ch), default=0) * _MIC_PSI_PER_COUNT / mic_divisor
|
||||
|
||||
# Peak vector sum: max over time of sqrt(T^2 + V^2 + L^2)
|
||||
pvs = 0.0
|
||||
@@ -1396,6 +1406,7 @@ def _setup_trigger(raw: bytes, k: int) -> dict:
|
||||
if m >= 0:
|
||||
out["trigger_level_mic_psi"] = struct.unpack_from(">f", raw, m + _TRIGGER_LEVEL_AFTER_LABEL)[0]
|
||||
out["mic_type"] = int.from_bytes(raw[m + _MIC_TYPE_AFTER_LABEL:m + _MIC_TYPE_AFTER_LABEL + 4], "big")
|
||||
out["mic_range"] = raw[m + _RANGE_AFTER_LABEL]
|
||||
return out
|
||||
|
||||
|
||||
@@ -1703,7 +1714,8 @@ def decode_blastware_bytes(raw: bytes, *, name: Optional[str] = None) -> Event:
|
||||
has_samples = any(samples.get(ch) for ch in ("Tran", "Vert", "Long", "MicL"))
|
||||
# The geophone full scale is the file's range; Normal when it wasn't read.
|
||||
geo_fs = _GEO_FS_BY_RANGE.get(ev.geo_range, _GEO_NORMAL_FS_INS)
|
||||
ev.peak_values = _peaks_from_samples(samples, geo_fs) if has_samples else None
|
||||
ev.peak_values = (_peaks_from_samples(samples, geo_fs, mic_count_divisor(ev.mic_range))
|
||||
if has_samples else None)
|
||||
if (is_waveform_body and ev.peak_values is not None and ev.sample_rate
|
||||
and ev.pretrig_samples is not None):
|
||||
_waveform_peak_detail(ev.peak_values, samples, geo_fs, ev.sample_rate, ev.pretrig_samples)
|
||||
|
||||
Reference in new issue
Block a user