Make row packing toggleable: pad (default) or strict abort
A mis-triggered row cannot be written as it arrived — v6 declares n_frames per row in the header and has no per-row length field, so a short or long row would shift every later row in the file. Until now the only policy was to square it up, which keeps the scan running but leaves the affected row indistinguishable from a good one afterwards: nothing in the file records that it was padded. strict_rows selects the other trade. On any frame-count mismatch the scan stops instead of writing the row, so a data run either produces rows that mean what the header says they mean or fails loudly. Default stays pad, so existing behaviour is unchanged. _warn_frame_delta becomes _check_frame_delta, since it now decides rather than just reports. Both acquisition paths already call it before writing anything for the row (CH1 leads SCAN_CHANNELS, and the burst path checks every row up front), so an abort leaves the file on a whole-row boundary rather than a half-written row — test_strict_row_packing_writes_nothing_for_the_failed_row pins that. Plumbed through QtScanController to a checkbox in the scan panel, persisted in ScanDefaults alongside burst_mode. scan_format.md documents both policies and notes that the choice is not recorded in the file. The row-clipping setup in the padding test is now a _clip_one_row helper, reused by the strict tests. 92 tests passing, ruff clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+17
-3
@@ -222,9 +222,23 @@ re-armed for each acquiring pass. Row boundaries inside the burst come from
|
||||
`ACQuire:NUMFRAMESACQuired?` sampled after each pass — the burst itself carries
|
||||
no row markers. See `core/scope_burst.py`.
|
||||
|
||||
Either path squares each row up to the declared `n_frames` (zero-padding a
|
||||
short row, dropping the tail of a long one), because the format has no per-row
|
||||
length field and a mismatch would shift every later row.
|
||||
### Row packing
|
||||
|
||||
The format has no per-row length field, so a row that over- or under-triggers
|
||||
cannot be written as it arrived — that would shift every later row. Two
|
||||
policies are selectable (`ScanEngine(strict_rows=…)`, a checkbox in the app),
|
||||
and the choice is not recorded in the file:
|
||||
|
||||
| | Pad (default) | Strict |
|
||||
|---|---|---|
|
||||
| Short row | zero-padded to `n_frames`, warned | scan stops |
|
||||
| Long row | trailing frames dropped, warned | scan stops |
|
||||
|
||||
Pad keeps a scan running through an occasional mis-trigger, at the cost that
|
||||
the affected row is indistinguishable from a good one afterwards — nothing in
|
||||
the file records that it was padded. Strict is for data runs where that
|
||||
ambiguity is worse than a failed scan: it aborts before writing the row, so
|
||||
the file always ends on a whole-row boundary.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user