Skip to content

Tomo export: skip unfinished runs automatically; export recorded projections by hand - #112

Open
Anthony Sligar (sligara7) wants to merge 2 commits into
NSLS2:mainfrom
sligara7:hex-tomo-export-aborted-run
Open

Anthony Sligar (sligara7) wants to merge 2 commits into
NSLS2:mainfrom
sligara7:hex-tomo-export-aborted-run

Conversation

@sligara7

Copy link
Copy Markdown
Contributor

Fixes the auto-export failure on HEX scan 14 (2026-10-26): 422: Can not reshape (2335,) array data to (570, 4) reading primary/rotation_angle.

Cause: the scan (3601 projections × 4 images) was aborted after 570 projections. The run recorded 570 × 4 PandA captures, but the PandA kept capturing until it was disarmed and its file holds 2335. Tiled reshapes the whole dataset to the recorded shape, so it refuses to serve it, and the averaging step from #100 failed.

Change

  • auto_export_run skips runs whose exit_status is not success (logged, and recorded as skipped in the CSV).
  • export_tomo_flyscan_to_h5, run by hand on a run that recorded fewer events than num_points, reads each PandA capture from its HDF5 file up to the recorded events (read_recorded_captures) and averages over the recorded projections. Finished runs are still read through Tiled as before.

Not handled (Jakub Wlodek (@jwlodek), your call): after an abort the detector's .nxs link can still point at frames past the last recorded projection; the exporter logs a warning.

Verified: new tests/test_export_unfinished_run.py uses the incident's numbers (570 recorded, 2335 in the file). Before the change the auto-exporter called the exporter on aborted/stopped/failed runs and the aborted export failed; now all pass, and the finished-run paths are unchanged. Full suite: 423 passed (the 2 tomo flyscan tests that fail on main in my env, which lacks bps.fly_stub, were deselected). Mock tests only; not run on the beamline.

…ed projections by hand

An aborted tomo flyscan records fewer events than the PandA captured before it was disarmed, so Tiled refuses to serve the capture (422 'Can not reshape (2335,) array data to (570, 4)', HEX scan 14, 2026-10-26) and the auto-export failed. The auto-exporter now skips runs that did not end in success and records them as skipped. export_tomo_flyscan_to_h5, run by hand on such a run, reads each PandA capture from its file up to the recorded events and averages over the recorded projections.

Assisted-by: copilot:claude-opus-5-5
Copilot AI balanced review requested due to automatic review settings October 26, 2026 20:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused changes have regression coverage, preserve completed-run behavior, and explicitly warn about the remaining detector-link limitation.

No open issues 🎉

What changed in this PR

Prevents automatic export failures on unsuccessful runs and supports manual export of recorded tomography projections when PandA files contain extra captures.

Changes:

  • Skips automatic exports for non-successful runs and records skipped in the CSV.
  • Reads only recorded PandA captures for incomplete tomography runs, preserving Tiled reads for completed runs and warning about untrimmed detector links.
  • Adds regression tests for the aborted-scan incident, short capture files, and completed-run behavior.
File Description
tests/​test_export_unfinished_run.py Tests skipped exports, capture limits, and incomplete/completed tomography exports.
src/​hextools/​exporters/​utils.py Adds bounded HDF5 capture reads with short-file validation.
src/​hextools/​exporters/​tomography.py Exports recorded projections for incomplete runs.
src/​hextools/​exporters/​auto_exporter.py Skips unsuccessful runs and records explicit export outcomes.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 27, 2026 14:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused changes address the reported failure, preserve complete-run behavior, and have regression coverage with no identified blocking issues.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

No deployments
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.

2 participants