pcdshub / Bug-Reports-and-Requests

Issue Tracking for PCDS Software
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Return to original position after scan #29

Open silkenelson opened 4 years ago

silkenelson commented 4 years ago

Feature Request Devices scanned should return to their start position.

Existing Alternatives Have to add this step by hand.

Context This was the behavior in old python. I also believe this is the intended behavior here, but it's not what the code does.

ZLLentz commented 4 years ago

This can be done using the reset_positions_wrapper in bluesky.preprocessors, or the equivalent reset_positions_decorator.

Quick example:

from bluesky.preprocessors import reset_positions_decorator

@reset_positions_decorator
def my_scan(*args, **kwargs):
    yield from some_plan()

In this way we can apply this to any plan that wants this. At LCLS I suspect this is desired on most scans, the only exception being if the pre-scan positions are further from the first point than the end positions...

Internally this is doing some voodoo to restore all moved devices to their original positions. If you don't want to do this to every device, you need to pass in a list of which devices to restore. See https://github.com/bluesky/bluesky/blob/master/bluesky/preprocessors.py#L1078

dlzhu commented 4 years ago

I would say half the scans we would like to return to original position, and another half we actually would want to go to the peak (being it a fitting position or simply the maximum). The 'maximum' option probably need some sanity check for 'noisy' scans, if no clear peak is present, can be a query at the end of the scan.

ZLLentz commented 4 years ago

This is something that can be done. Bluesky has hooks for soliciting user input, and we can cache all points from the scan and use the peak as the end of scan goal position. We need some way to determine the user's desired end of scan behavior, but we can probably bake this in as a standard scan arg.