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
@@ -21,7 +21,7 @@ from typing import Callable, Optional, Sequence
|
||||
|
||||
from .bw_xml_report import XmlReport
|
||||
from .event_file_io import (interval_times, _GEO_FS_BY_RANGE, _GEO_INT16_FS, _GEO_NORMAL_FS_INS, _MIC_PSI_PER_COUNT,
|
||||
decode_blastware_bytes)
|
||||
decode_blastware_bytes, mic_count_divisor)
|
||||
from .histogram_codec import half_period_to_hz
|
||||
from .models import Event
|
||||
from .waveform_codec import mic_count_to_db
|
||||
@@ -87,6 +87,7 @@ class SfmSide:
|
||||
channels: list[str] # channels with decoded data, in Tran/Vert/Long/MicL order
|
||||
counts: dict[str, list[int]] # waveform samples or histogram interval peaks
|
||||
geo_ips_per_count: float = GEO_IPS_PER_COUNT # at the event's range, as SFM read it
|
||||
mic_divisor: int = 1 # mic counts per 0.25 Pa, at the mic's range
|
||||
# interval column -> SFM's value per interval (a number, or Blastware's word)
|
||||
interval_values: dict[str, list[object]] = field(default_factory=dict)
|
||||
interval_times: Optional[list[str]] = None # each interval's printed time
|
||||
@@ -174,7 +175,8 @@ def sfm_side(raw: bytes) -> SfmSide:
|
||||
if value is not None:
|
||||
values[f"{ch}{tag}"] = value
|
||||
if counts["MicL"]:
|
||||
values["MicLPSPL dB(L)"] = mic_count_to_db(max(abs(c) for c in counts["MicL"]))
|
||||
values["MicLPSPL dB(L)"] = mic_count_to_db(max(abs(c) for c in counts["MicL"])
|
||||
/ mic_count_divisor(ev.mic_range))
|
||||
values["MicLPSPL psi(L)"] = pv.micl if pv is not None else None
|
||||
values.update(_setup_values(ev))
|
||||
if ev.stop_time is not None:
|
||||
@@ -212,6 +214,7 @@ def sfm_side(raw: bytes) -> SfmSide:
|
||||
channels=[ch for ch in _CHANNELS if counts[ch]],
|
||||
counts=counts,
|
||||
geo_ips_per_count=_GEO_FS_BY_RANGE.get(ev.geo_range, _GEO_NORMAL_FS_INS) / _GEO_INT16_FS,
|
||||
mic_divisor=mic_count_divisor(ev.mic_range),
|
||||
interval_values=interval_values,
|
||||
interval_times=times,
|
||||
)
|
||||
@@ -264,12 +267,13 @@ def _same_text(a: object, b: str) -> bool:
|
||||
return " ".join(str(a).split()) == " ".join(b.split())
|
||||
|
||||
|
||||
def _mic_converter(ref: XmlReport) -> Optional[Callable[[int], float]]:
|
||||
def _mic_converter(ref: XmlReport, sfm: SfmSide) -> Optional[Callable[[int], float]]:
|
||||
units = ref.event_units or ""
|
||||
d = sfm.mic_divisor
|
||||
if "dB(L)" in units:
|
||||
return mic_count_to_db
|
||||
return lambda c: mic_count_to_db(c / d)
|
||||
if "psi(L)" in units:
|
||||
return lambda c: c * _MIC_PSI_PER_COUNT
|
||||
return lambda c: c * _MIC_PSI_PER_COUNT / d
|
||||
return None
|
||||
|
||||
|
||||
@@ -339,7 +343,7 @@ def _series_result(field: str, n_bw: int, n_sfm: int, diffs: list[tuple[int, flo
|
||||
def _sample_converters(sfm: SfmSide, ref: XmlReport) -> dict[str, Callable[[int], float]]:
|
||||
k = sfm.geo_ips_per_count
|
||||
convert: dict[str, Callable[[int], float]] = {ch: (lambda c: c * k) for ch in _GEO}
|
||||
mic = _mic_converter(ref)
|
||||
mic = _mic_converter(ref, sfm)
|
||||
if mic is not None:
|
||||
convert["MicL"] = mic
|
||||
return convert
|
||||
@@ -350,10 +354,11 @@ def _interval_converter(title: str, sfm: SfmSide) -> Optional[Callable[[int], fl
|
||||
ch, _, rest = title.partition(" ")
|
||||
if rest.startswith("Peak") and ch in _GEO:
|
||||
return lambda c: c * sfm.geo_ips_per_count
|
||||
d = sfm.mic_divisor
|
||||
if ch == "MicL" and rest == "Peak dB(L)":
|
||||
return mic_count_to_db
|
||||
return lambda c: mic_count_to_db(c / d)
|
||||
if ch == "MicL" and rest == "Peak psi(L)":
|
||||
return lambda c: c * _MIC_PSI_PER_COUNT
|
||||
return lambda c: c * _MIC_PSI_PER_COUNT / d
|
||||
return None
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user