feat(decode): a histogram's interval detail -- frequencies (#50), vector sums, interval size, stop
Group B of the file-only decode, measured on DL2 2026-11-03: - Frequency = (sample rate / 2) / half-period: 527,915 / 527,915 cells at 1024 sps and 1,725 / 1,725 at 2048. #50: half_period_to_hz took a fixed 512 and halved every 2048-sps frequency; it now takes the rate (default 1024). Blastware prints 'N/A' for a half-period of 0, '>100' ('>200' at 2048) at 5 samples or fewer, '<1.0' below 1 Hz. - Each interval's vector sum, sqrt(PVS^2) at the event's range: 771,354 / 771,354. - Interval size: uint16 seconds at k - 40 (Series IV [8:10]). - Stop: the footer's (2,995 / 2,999 sampled; 4 print a second earlier). Event gains histogram_interval_sec, interval_half_periods, interval_pvs and stop_time; the .h5 gains /intervals/half_period/<ch>, /intervals/pvs_ips and a histogram_interval_sec attr. The decoder walks a histogram once (histogram_codec.channels_from_records) and takes the event's PVS from the same records. The checker compares each interval column, number or Blastware's word; the test that pinned Tran Freq Hz as blank now pins the match. 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
67b3ef8d0a
commit
2b698e74cf
10 files changed
+312
-32
No files matched your search
@@ -429,3 +429,45 @@ def test_the_h5_carries_the_setup_fields(tmp_path):
|
||||
assert abs(float(a["trigger_level_mic_psi"]) - ev.trigger_level_mic_psi) < 1e-9
|
||||
assert (str(a["firmware_version"]), str(a["dsp_version"]), str(a["calibration_date"])) == (
|
||||
"S338.17", "10.72", "2019-02-20")
|
||||
|
||||
|
||||
# ── Group B: histogram interval detail ──────────────────────────────────────
|
||||
# Interval size is the setup's uint16 seconds at k - 40 (Series IV [8:10]); the
|
||||
# stop is the footer's. Each interval keeps its half-periods and its vector sum
|
||||
# (PVS^2). Frequency = (sample rate / 2) / half-period: 527,915 / 527,915 cells
|
||||
# at 1024 sps and 1,725 / 1,725 at 2048 (#50: the old fixed 512 halved every
|
||||
# 2048-sps frequency). Measured 2026-11-03.
|
||||
from minimateplus.histogram_codec import half_period_to_hz # noqa: E402
|
||||
|
||||
_HB = "histogram-intervals-11-03-26"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("rel,sr,freqs,pvs,stop", [
|
||||
# Blastware: 1 minute; Tran 32, Vert 47, Long 14, MicL 47 Hz; PVS 1.358; stop 12:49:33
|
||||
("decode-checker-10-29-26/T004JTRF.ME0H", 1024,
|
||||
{"Tran": 32, "Vert": 47, "Long": 14, "MicL": 47}, 1.358, (2022, 12, 28, 12, 49, 33)),
|
||||
# Blastware: 1 minute at 2048 sps; Tran 15.5, Vert 64, Long 17.7, MicL 51 Hz; PVS 2.644
|
||||
(f"{_HB}/T190LD42.T00H", 2048,
|
||||
{"Tran": 15.5, "Vert": 64, "Long": 17.7, "MicL": 51}, 2.644, (2025, 12, 8, 13, 29, 37)),
|
||||
])
|
||||
def test_histogram_interval_detail_comes_from_the_file(rel, sr, freqs, pvs, stop):
|
||||
ev = read_blastware_file(_FIX / rel)
|
||||
assert (ev.sample_rate, ev.histogram_interval_sec) == (sr, 60)
|
||||
for ch, hz in freqs.items():
|
||||
got = half_period_to_hz(ev.interval_half_periods[ch][0], ev.sample_rate)
|
||||
d = 1 if isinstance(hz, float) else 0
|
||||
assert abs(got - hz) <= 0.5 * 10 ** -d + 1e-9, (ch, got, hz)
|
||||
assert abs(ev.interval_pvs[0] - pvs) <= 0.0005 + 1e-9
|
||||
t = ev.stop_time
|
||||
assert (t.year, t.month, t.day, t.hour, t.minute, t.second) == stop
|
||||
|
||||
|
||||
def test_the_h5_carries_the_interval_detail(tmp_path):
|
||||
import h5py
|
||||
from sfm import event_hdf5
|
||||
ev = read_blastware_file(_FIX / _HB / "T190LD42.T00H")
|
||||
event_hdf5.write_event_hdf5(tmp_path / "e.h5", ev, serial="BE18190")
|
||||
with h5py.File(tmp_path / "e.h5", "r") as f:
|
||||
assert int(f.attrs["histogram_interval_sec"]) == 60
|
||||
assert list(f["intervals/half_period/Vert"][:]) == ev.interval_half_periods["Vert"]
|
||||
assert abs(float(f["intervals/pvs_ips"][0]) - 2.644) <= 0.0005 + 1e-9
|
||||
Reference in new issue
Block a user