feat(scripts): add dump_scan_h5.py — offline Tiled→HDF5 scan export#46
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
H6a of the #37 decomposition — the offline scan-export tool added in #37.
What
scripts/dump_scan_h5.pydumps a Tiled scan to HDF5 in thehxn_to_vitformat (dp+points+ self-describing scalar attrs), for offline analysis and for feedingdetect_orientation.py(H5a) /ptychoml-predictwithout running the live pipeline. Exposed via thedump-scan-h5pixi 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
_D4transform dict replaced byptychoml.apply_d4/D4_NAMESso the dump applies the exact same orientation set the liveImagePreprocessorOpuses — verified bit-identical to #37's_D4across 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 likecompute_intensity_normalization), and the Tiled/HDF5 I/O.Tests
tests/test_dump_scan_h5.pycovers the HXN geometry helpers (_ratio_from_scalesign/default,_lambda_from_energy,_energy_from_dcm_thformula + monotonicity). D4 is ptychoml-tested; the Tiled fetch + dump path is integration-only.--helpworks without a GPU.