Skip to content

feat(scripts): add dump_scan_h5.py — offline Tiled→HDF5 scan export#46

Merged
Garrett Bischof (gwbischof) merged 1 commit into
mainfrom
h6a/dump-scan-h5
Jun 9, 2026
Merged

feat(scripts): add dump_scan_h5.py — offline Tiled→HDF5 scan export#46
Garrett Bischof (gwbischof) merged 1 commit into
mainfrom
h6a/dump-scan-h5

Conversation

@gwbischof

Copy link
Copy Markdown
Collaborator

H6a of the #37 decomposition — the offline scan-export tool added in #37.

What

scripts/dump_scan_h5.py dumps a Tiled scan to HDF5 in the hxn_to_vit format (dp + points + self-describing scalar attrs), for offline analysis and for feeding detect_orientation.py (H5a) / ptychoml-predict without running the live pipeline. Exposed via the dump-scan-h5 pixi task (feature.replay).

It's standalone — nothing in the live pipeline imports it (the only reference in #37 is the pixi task).

ptychoml reuse

Lifted from #37, with the inline _D4 transform dict replaced by ptychoml.apply_d4 / D4_NAMES so the dump applies the exact same orientation set the live ImagePreprocessorOp uses — verified bit-identical to #37's _D4 across all 8 transforms. The rest stays local because it isn't a clean ptychoml drop-in: the HXN geometry conversions, the chunked, memory-bounded normalization scan (can't load the whole stack like compute_intensity_normalization), and the Tiled/HDF5 I/O.

Tests

tests/test_dump_scan_h5.py covers the HXN geometry helpers (_ratio_from_scale sign/default, _lambda_from_energy, _energy_from_dcm_th formula + monotonicity). D4 is ptychoml-tested; the Tiled fetch + dump path is integration-only. --help works without a GPU.

pixi run test   # 95 passed; the 2 vit_inference/ptycho_holo smoke failures are pre-existing.

Standalone tool to dump a Tiled scan to HDF5 in the hxn_to_vit format
(dp + points + self-describing scalar attrs), for offline analysis and for
feeding detect_orientation.py / ptychoml-predict without the live pipeline.
Added in #37; exposed via the `dump-scan-h5` pixi task
(feature.replay).

Lifted from #37, with the inline D4 transform dict replaced by
ptychoml.apply_d4 / D4_NAMES so it applies the exact same orientation set the
live ImagePreprocessorOp uses (verified bit-identical to #37's _D4). The HXN
geometry conversions (_ratio_from_scale, _energy_from_dcm_th,
_lambda_from_energy), the chunked memory-bounded normalization scan, and the
Tiled/HDF5 I/O stay local.

tests/test_dump_scan_h5.py covers the geometry helpers (ratio sign/default,
lambda-from-energy, energy-from-DCM-angle formula + monotonicity). D4 is
ptychoml-tested; the Tiled fetch + dump path is integration-only.

H6a of the #37 decomposition.

Co-authored-by: Himanshu Goel <4122621+himanshugoel2797@users.noreply.github.com>
@gwbischof Garrett Bischof (gwbischof) merged commit 5590f80 into main Jun 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant