Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/sophys/common/plans/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .cumulative_scans import *
from .cumulative_scans import cumulative_rel_scan
from .scan_with_delay import scan_with_delay
71 changes: 71 additions & 0 deletions src/sophys/common/plans/scan_with_delay.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from bluesky.plans import scan
from bluesky.plan_stubs import move_per_step, sleep, trigger_and_read
from sophys.common.plans.annotated_default_plans import (
DETECTORS_TYPE,
PER_STEP_TYPE,
MD_TYPE,
)


def scan_with_delay(
detectors: DETECTORS_TYPE,
/,
*args,
num: int = None,
delay: float = 0.2,
per_step: PER_STEP_TYPE = None,
md: MD_TYPE = None,
):
"""
Scan over one multi-motor trajectory.

Parameters
----------
detectors : list or tuple
list of 'readable' objects
*args :
For one dimension, ``motor, start, stop``.
In general:

.. code-block:: python

motor1, start1, stop1,
motor2, start2, stop2,
...,
motorN, startN, stopN

-.-motor,start,stop;the n-th motor to move from slowest to fastest,the starting point in the motor's trajectory relative to the current position,the ending point in the motor's trajectory relative to the current position;__MOVABLE__,typing.Any,typing.Any-.-
num : integer
Comment thread
RafaelLyra8 marked this conversation as resolved.
number of points
delay : integer
Delay between the triggers of the scan.
per_step : callable, optional
hook for customizing action of inner loop (messages per step).
See docstring of :func:`bluesky.plan_stubs.one_nd_step` (the default)
with and sleep plan after it.
md : dict, optional
metadata

See Also
--------
:func:`bluesky.plans.rel_grid_scan`
:func:`bluesky.plans.inner_product_scan`
:func:`bluesky.plans.scan_nd`
"""

def one_nd_step_with_delay(detectors, step, pos_cache):
"This is a copy of bluesky.plan_stubs.one_nd_step with a sleep added."
motors = step.keys()
yield from move_per_step(step, pos_cache)
yield from sleep(delay)
yield from trigger_and_read(list(detectors) + list(motors))

def per_step_with_delay(detectors, step, pos_cache):
yield from per_step(detectors, step, pos_cache)
yield from sleep(delay)
Comment on lines +64 to +65

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will always cause the sleep to occur after the trigger_and_read (or similar). There really does not seem to be a good way of making custom per_steps work in all cases in this plan. I'd remove that possibility altogether, and direct users to use a simple scan plan if that's what they need.


per_step_scan = one_nd_step_with_delay
if per_step is not None:
per_step_scan = per_step_with_delay

yield from scan(detectors, *args, num=num, per_step=per_step_scan, md=md)
Loading