fix(idf): a Thor file's own settings, notes and time (#44, #45)

A Micromate event read without Thor's report (SFM's own downloads) came out
with sample rate, pre-trigger and record time 0, empty notes, and a
1970-01-01 time; every Micromate .h5, report or not, stored pre-trigger 0.

- The settings were found by the bytes be 80 00 00 00 00 -- a -0.25 s
  pre-trigger and Fixed stop mode, not a marker -- so any other pre-trigger
  left them unread.  The event's settings record is now found by its own
  signature 00 2a 04 00 00 (fields at the live 0x1A block's head offsets).
- The event time is read at settings record + 0x34, not two fixed offsets
  that miss a header shape.
- The four notes are read at 0x23c ([label 22][value 42] x 4).
- IdfEvent.to_minimateplus_event sets pretrig_samples.
- save_imported_idf fills the pre-trigger and notes from the file when the
  report lacks them.

Measured against Thor's own reports on 2,027 corpus files: sample rate and
notes 2,027 / 2,027; record time and pre-trigger 291 / 291 waveforms; event
time = filename on 2,384 / 2,384.  The issues' 20 UM12947 bench files now
store 4096 S/s, 4096 pre-trigger samples (1.0 s), 3 s and their notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R9LdWawLzUxwewZGA1
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-11-20 14:45:52 -05:00
1 parent c0561f9de6
commit f7a02b1fee
12 files changed
+5856 -33

No files matched your search

+51
View File
@@ -405,6 +405,57 @@ Header bytes 0–5: `00 12 01 00 00 00`. Followed immediately by the
strings (Operator name, etc.) and on through the project / client /
title strings. No `STRT` record observed in this layout.
### The event's settings, notes and time, from the file (2026-11-20, #44 / #45)
✅ Measured on **2,384** Signature-A files, **2,027** of them with Thor's own report
beside them (`thor-watcher/example-data`, `thor-csv-req`, and SFM's 2026-10-25 bench
downloads of UM12947). Code: `micromate.idf_file.extract_binary_metadata`.
**The settings record.**
- **Signature:** `[00 2a][04 00 00]`. The fields sit at the same offsets as the head
of the live `0x1A` setup block (`micromate/setup_block.py`):
| offset | field |
|---|---|
| `[5]` | record mode, 1–4 |
| `[6:8]` | sample rate, uint16 BE |
| `[12:16]` | this event's pre-trigger, f32 BE, negative seconds |
| `[17]` | stop mode |
| `[18:22]` | record time, f32 BE |
- **Where it sits:** at 0x910, 0x946, 0x98e or 0x9c4 (seen), depending on the
header's shape, so it is found by its signature, not its offset. Every one of the
2,384 starts `00 2a 04 00 00`. The one other `00 2a` that passed the field checks
(UM11402_20250610173039.IDFH at 0x915) had `92` in place of `04`.
- **Sample rate:** matches the report on **2,027 / 2,027**.
- **Record time:** matches on **291 / 291** waveforms.
- **Pre-trigger:** matches on **291 / 291** waveforms within the report's 0.01 s
rounding. The file holds the event's exact value: UM12947_20250929144014 has
193 samples = 0.18848 s, and the report prints 0.19. As in Series 3 (reference
D.6.2), it is the event's own pre-trigger, which can be shorter than the setting.
- **Histograms (`.IDFH`):** the record's sample rate is right, but its `[18:22]`
varies file to file (0.3 s to 840 s), so it is not a setting. Thor's report prints
no record time or pre-trigger for a histogram.
- ⚠ **Retracted:** the old reader found these by the bytes `be 80 00 00 00 00`,
the Series-3 "stable anchor". Those are a −0.25 s pre-trigger and Fixed stop
mode, so any other pre-trigger (UM12947's 1.0 s) left the sample rate and record
time unread (#44).
**The event time** is at settings record + `0x34`: it equals the filename's time on
**2,384 / 2,384**. The old fixed offsets 0x97A / 0x9F8 are that place for records at
0x946 / 0x9c4 only. A record at 0x910 left the time unread, and the event came out
1970-01-01.
**The notes** are four `[label 22][value 42]` pairs, 64 bytes apart, from **0x23c**,
at that fixed offset in every file seen. This is the live setup block's note layout.
In order, they are Thor's TitleString1–4, which the report maps to project, client,
operator and notes. All four match the report on **2,027 / 2,027**. The setup name
(e.g. `thump.MMB`) sits at 0x1ec in the bench files; not yet read.
**Also seen:** Thor writes `.MLG` monitor logs too
(`THORDATA_example/UPMC Presby/UM11719/UM11719_20231219161648.MLG`). Not examined;
compare with the Blastware `.MLG` (`instantel_protocol_reference.md` D.4).
### Signature B — older firmware (2 files: BE9439 from 2020)
```