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
@@ -40,6 +40,13 @@ iterate 32-stride and stop before the tail.
|
||||
[24:28] 4-byte variable purpose unknown (possibly CRC or timestamp delta)
|
||||
[28:32] block-end signature see "Two block tails" below
|
||||
|
||||
⚠ CORRECTED 2026-10-30 (measured): [21:25] is the interval's peak vector sum
|
||||
SQUARED, uint32 BE in 0.005 in/s units. sqrt([21:25]) x 0.005 is the "Geo PVS"
|
||||
Blastware prints for the interval, on 1,668,073 / 1,668,074 standard DL2
|
||||
intervals checked against the _XML.XML reports. [21:23] is zero only while the
|
||||
square is below 65,536 (PVS < 1.28 in/s), which is why it looked constant; only
|
||||
[25:28] is still unexplained. `interval_pvs` reads it.
|
||||
|
||||
**Every per-channel field is uint16 BIG-endian** (confirmed 2026-08-25).
|
||||
Only ``block_ctr`` at [2:4] is little-endian.
|
||||
|
||||
@@ -124,6 +131,7 @@ record list.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
import struct
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
@@ -216,6 +224,7 @@ def _decode_block(block: bytes) -> Optional[dict]:
|
||||
"m_peak": m_peak,
|
||||
"m_halfp": m_halfp,
|
||||
"meta_var": var_meta,
|
||||
"pvs_sq": int.from_bytes(block[21:25], "big"),
|
||||
"is_terminal": block[28:32] == _BLOCK_TAIL_TERMINAL,
|
||||
}
|
||||
|
||||
@@ -319,6 +328,16 @@ def decode_histogram_body_full(body: bytes) -> Optional[List[dict]]:
|
||||
return records if records else None
|
||||
|
||||
|
||||
def interval_pvs(body: bytes) -> Optional[List[float]]:
|
||||
"""Each interval's peak vector sum, in the geo peak units (0.005 in/s at
|
||||
Normal range): the square root of the square the device stores with every
|
||||
interval. This is the vector sum at an instant, as Blastware prints it --
|
||||
not the magnitude of the three channel peaks, which can come from
|
||||
different moments. None when the body has no valid blocks."""
|
||||
records = _walk_auto(body)
|
||||
return [math.sqrt(r["pvs_sq"]) for r in records] if records else None
|
||||
|
||||
|
||||
def half_period_to_hz(halfp: int) -> Optional[float]:
|
||||
"""Convert a half-period in samples to frequency in Hz.
|
||||
|
||||
@@ -356,7 +375,10 @@ def geo_count_to_ins(count: int) -> float:
|
||||
# [4] 0x0a
|
||||
# [5 ...] one record per interval: per channel a BIG-endian uint16 peak and
|
||||
# half-period (Tran, Vert, Long[, MicL]), then 0x0000, then one more
|
||||
# word ("meta_var" keeps those 4 bytes)
|
||||
# word ("meta_var" keeps those 4 bytes). Measured 2026-10-30: those
|
||||
# 4 bytes are the interval's peak vector sum SQUARED, uint32 BE in
|
||||
# 0.005 in/s units -- sqrt matches Blastware's "Geo PVS" on 34.5 M
|
||||
# DL2 sub-minute intervals; the 0x0000 is its high word
|
||||
# [-7:] trailer: 3 bytes, then the 4-byte tail -- 9c 06 00 42 on the
|
||||
# stream's LAST block
|
||||
#
|
||||
@@ -486,6 +508,7 @@ def _decode_record(body: bytes, q: int, rec: int, off: int) -> dict:
|
||||
"m_peak": be16(q + 12) if mic else None,
|
||||
"m_halfp": be16(q + 14) if mic else None,
|
||||
"meta_var": bytes(body[q + z:q + z + 4]),
|
||||
"pvs_sq": int.from_bytes(body[q + z:q + z + 4], "big"),
|
||||
"is_terminal": False,
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user