fix(sfm): Thor .h5 samples use Thor's LSB, not the MiniMate count scale (#42)
Every idf-import .h5 converted Thor's raw geo counts with the MiniMate body-codec scale, full_scale / _GEO_INT16_FS. A Thor count is 0.000310308 in/s (micromate.idf_file._GEO_LSB_IPS), so the float samples disagreed with the event's own peak by a constant: 10/32768 (until686ab6e, 2026-08-25) samples -1.65% 10/32000 (since) samples +0.71% v0.30.0's LSB fix (726c2ce) never reached this path. It corrected the decoder's peaks, which were already right in the DB, sidecar and h5 peak attrs. The sample arrays go through the shared .h5 writer instead. write_event_hdf5 now takes geo_ips_per_count. save_imported_idf and backfill_thor_events (which replays the same bridge with its own write) both pass _GEO_LSB_IPS. MiniMate callers are unchanged. Measured: all 8 thor-idf fixtures (4 IDFW + 4 IDFH, 24 channels) go from max|sample| / peak = 1.00706 to 1.00000 through the real ingest path. Operational consequence: no schema change, no migration, TOOL_VERSION not bumped here. Existing idf-import .h5 files keep the wrong scale until regenerated: scripts/backfill_thor_events.py (--force, or bump TOOL_VERSION at release), then backfill_event_shape.py, because the offset detector reads these samples. Series-3 files are unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
618fcb7770
commit
e506bcff9b
5 files changed
+124
-10
No files matched your search
@@ -287,7 +287,7 @@ def main(argv=None) -> int:
|
||||
if is_histogram and idf_intervals:
|
||||
# 1 sample per interval per channel — same
|
||||
# synthesis save_imported_idf uses. The h5
|
||||
# writer's count×geo_fs/32768 conversion turns
|
||||
# writer's count×_GEO_LSB_IPS conversion turns
|
||||
# each peak-ADC-count into the bar's physical
|
||||
# value.
|
||||
ev.raw_samples = {
|
||||
@@ -311,12 +311,15 @@ def main(argv=None) -> int:
|
||||
from micromate.sensor_check import decode_idf_sensor_check
|
||||
ev.sensor_check = decode_idf_sensor_check(binary_bytes) or None
|
||||
|
||||
# Thor counts, not MiniMate counts (issue #42).
|
||||
from micromate.idf_file import _GEO_LSB_IPS
|
||||
event_hdf5.write_event_hdf5(
|
||||
hdf5_path, ev,
|
||||
serial=serial,
|
||||
geo_range="normal",
|
||||
source_kind="idf-import",
|
||||
tool_version=event_file_io.TOOL_VERSION,
|
||||
geo_ips_per_count=_GEO_LSB_IPS,
|
||||
)
|
||||
h5_written += 1
|
||||
log.debug("%s/%s — .h5 written (%s)",
|
||||
|
||||
Reference in new issue
Block a user