fix(decode): a histogram's peak vector sum is the one the unit stores
Every histogram interval carries its peak vector sum SQUARED, uint32 BE in 0.005 in/s units: bytes [21:25] of a standard block (long documented as 'constant 00 00' plus 'purpose unknown'), the last 4 bytes of a sub-minute record (the undecoded 'meta_var'). sqrt(stored) x 0.005 is the Geo PVS Blastware prints: 1,668,073 / 1,668,074 standard and 34.5 M sub-minute DL2 intervals checked against the _XML.XML reports. SFM computed the event's PVS from each channel's interval peak, which can come from different moments, and read high on 86% of DL2's histograms (T004JTRF.ME0H: 1.782 against Blastware's 1.358). It now takes the largest stored interval value. histogram_codec.interval_pvs returns the per-interval series; records gain 'pvs_sq'. Waveforms are unchanged. 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
b6fc71bd28
commit
625bc39116
3 files changed
+68
-2
No files matched your search
@@ -30,7 +30,7 @@ from . import blastware_file as _bw # avoid circular reference at module load
|
||||
from .bw_ascii_report import BwAsciiReport
|
||||
from . import waveform_codec as _wc
|
||||
from .waveform_codec import decode_waveform_v2, decoded_to_adc_counts
|
||||
from .histogram_codec import decode_histogram_body
|
||||
from .histogram_codec import decode_histogram_body, interval_pvs
|
||||
|
||||
# Reference pressure for dB(L) → psi conversion (20 µPa expressed in psi).
|
||||
# Same constant as sfm/sfm_webapp.html so server-side and browser-side
|
||||
@@ -704,6 +704,9 @@ _INT16_FS = 32768.0
|
||||
# sfm.event_hdf5._GEO_INT16_FS or sidecar peaks disagree with the plotted
|
||||
# waveform by 2.3%. Confirmed 2026-08-25 against the BW ASCII corpus.
|
||||
_GEO_INT16_FS = 32000.0
|
||||
# A histogram's geo values are in decoder units of 16 counts = 0.005 in/s at
|
||||
# the Normal range (the same assumption as the samples above).
|
||||
_HIST_GEO_UNIT_INS = 16 * _GEO_NORMAL_FS_INS / _GEO_INT16_FS
|
||||
|
||||
# Microphone scale factor, psi per ADC count. Approximate — exact factor
|
||||
# depends on the geophone-vs-mic ADC scaling and the firmware reference.
|
||||
@@ -1240,6 +1243,13 @@ def decode_blastware_bytes(raw: bytes, *, name: Optional[str] = None) -> Event:
|
||||
# report when one is supplied.
|
||||
has_samples = any(samples.get(ch) for ch in ("Tran", "Vert", "Long", "MicL"))
|
||||
ev.peak_values = _peaks_from_samples(samples) if has_samples else None
|
||||
if not is_waveform_body and ev.peak_values is not None:
|
||||
# A histogram stores each interval's vector sum (squared); the event's
|
||||
# is the largest. Combining the channel peaks instead read high on 86%
|
||||
# of DL2's histograms -- they can come from different moments.
|
||||
pvs = interval_pvs(body)
|
||||
if pvs:
|
||||
ev.peak_values.peak_vector_sum = max(pvs) * _HIST_GEO_UNIT_INS
|
||||
ev._a5_frames = None # not recoverable from BW file
|
||||
|
||||
return ev
|
||||
Reference in new issue
Block a user