Skip to content

Profile conversion 5d: xrd_map - #14

Merged
Anthony Sligar (sligara7) merged 3 commits into
NSLS2:pdf-profile-conversionfrom
sligara7:pdf-conv-05d-map
Oct 23, 2026
Merged

Anthony Sligar (sligara7) merged 3 commits into
NSLS2:pdf-profile-conversionfrom
sligara7:pdf-conv-05d-map

Conversation

@sligara7

@sligara7 Anthony Sligar (sligara7) commented Oct 23, 2026 •

Copy link
Copy Markdown

Ports the old xrd_map (71-map_scans.py) to pdftools.xrd, loaded into the profile session. Same arguments and terms as before (dwell_time, backoff, snake, fly_*/step_*).

One run; each row steps step_motor, then flies fly_motor across at the speed that spends dwell_time per pixel, one event per pixel with start_<fly>/stop_<fly> positions (same field names, dimensions hint and sp_* metadata as before). As configure_area_det did, a continuous-acquisition detector sums ceil(dwell_time / frame time) frames per pixel, and a dwell shorter than one frame is refused. The shutter is closed while the motors reposition; the fly velocity is restored afterwards, also on failure.

Changed from the old plan:

  • Optional frame_time sets the frame time (the old plan used whatever glbl['frame_acq_time'] had set).
  • Repositions at the motor's own velocity, not a hard-coded 10.
  • No 2 s sleep after opening (fs has its own settle time).
  • Detectors and shutter are passed in (shutter defaults to fs).
  • In-map darks (dark_plan, off by default, via bluesky_darkframes) are not ported; run xrd_dark before the map.

Verified: mock tests (tests/test_xrd_map.py: snake and typewriter paths, frames per dwell and fly speed, frame-time override, too-short dwell refused before anything moves, shutter closed for every reposition, restore on a detector fault). Not run on the beamline.

Port of pdf-profile-collection xrd_map (71-map_scans.py) onto the ophyd-async detectors: one run, one event per pixel with the fly motor's start/stop positions, snake or typewriter rows, the shutter closed while the motors reposition, and the fly velocity restored afterwards. In-map darks are not ported.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Backoff handling can misplace acquisition, while shutter timing and cleanup failures can cause unnecessary exposure or leave the fly velocity unrestored.

4 open issues
What changed in this PR

Ports the legacy xrd_map plan into pdftools.xrd and exposes it in the collection profile for single-run, two-dimensional XRD mapping.

Changes:

  • Adds snake and typewriter scanning with exposure-based fly speed and per-pixel position fields.
  • Adds shutter handling and fly-velocity restoration.
  • Adds mock tests for scan paths, event output, shutter sequencing, and detector-failure cleanup.
File Description
tests/​test_xrd_map.py Adds mock coverage for map acquisition and cleanup.
src/​pdftools/​xrd.py Implements the xrd_map acquisition plan.
src/​pdftools/​profiles/​collection.py Imports xrd_map into the collection session.

Review effort: Balanced

Comment thread src/pdftools/xrd.py Resolved
Comment thread src/pdftools/xrd.py Resolved
Comment thread src/pdftools/xrd.py Resolved
Comment thread src/pdftools/xrd.py Resolved
dwell_time is again the total time per pixel; continuous-acquisition detectors sum ceil(dwell_time / frame time) frames, a dwell shorter than one frame is refused, and an optional frame_time sets the frame time, as configure_area_det did.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Acquisition is not synchronized with the end of the backoff travel, shifting image coverage outside the requested row boundaries.

4 open issues

Review effort: Balanced

…ection, close before the overshoot

Images now start once the fly motor crosses the row start, so the backoff no longer eats pixels; the first backoff takes its sign from the fly direction; the shutter closes after each row's last image. Cleanup in xrd_map, xrd_jog and xrd_scan restores velocity/position even if closing the shutter fails. Found by Copilot review on NSLS2#14; the first two were in the old plan too.

Assisted-by: copilot:claude-opus-5-5
Copilot AI balanced review requested due to automatic review settings October 23, 2026 23:53
@sligara7
Anthony Sligar (sligara7) merged commit 3f49807 into NSLS2:pdf-profile-conversion Oct 23, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Failure cleanup can delay shutter closure until after detector teardown, and mapping can silently overwrite mismatched detector frame times.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Validate detector frame-time agreement before applying dwell time

src/​pdftools/​xrd.py:613

With frame_time=None, only the first continuous-acquisition detector's frame time is read, but _body() applies it to every detector. Panels initially at 0.1 s and 0.2 s therefore both become 0.1 s, accepting a 0.15 s dwell that is shorter than the second panel's existing frame time. Validate that their current frame times agree, and require an explicit frame_time override before changing mismatched panels.

4 resolved since last review

Review effort: Balanced

Comment thread src/pdftools/xrd.py
Comment on lines +676 to +677
@bpp.stage_decorator(detectors)
@bpp.run_decorator(md=map_md)
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