-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically open the shutters when executing plans #338
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
925f862
Moved Bluesky preprocessors to their own module.
canismarko 29d42c5
Implemented the ``open_shutters`` wrapper and decorator.
canismarko 5b82b14
Updated shutter devices so their readings have the right format for `…
canismarko 20e2867
Open shutters preprocessor now uses the bps.rd plan instead of bps.read.
canismarko 1428acd
``plans`` module now has decorated plans for general use.
canismarko b156728
Ophyd-async device for XIA PFCU4 filter bank.
canismarko 29b05da
Updated PFCU signals with correct PVs and types.
yannachen d91a5e6
Updated XIA PFCU device to use correct data types.
canismarko 1e8d6fc
Standardized the readback and setpoint data types for an XIA PFCU fil…
canismarko 7f94472
Fixed XIA derived signals and added a check for out-of-bounds shutters.
yannachen bc3dd6e
Positioner is now locatable.
yannachen 353bcb3
Fixed a test, plus linting and de-cluttering old code.
canismarko 5412505
Added documentation for shutters and filters.
canismarko 997cdd4
Fixed a numpy precision issue in a test.
canismarko fcb2653
Merge branch 'main' into auto_shutter
canismarko 564e4dc
Fixed tests so they pass with pytest-asyncio==0.25.2
canismarko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
#################### | ||
Shutters and Filters | ||
#################### | ||
|
||
A shutter is any device that has "shutters" in its `_ophyd_labels_` | ||
attribute. | ||
|
||
.. contents:: Table of Contents | ||
:depth: 3 | ||
|
||
Automatic Shutter Control | ||
========================= | ||
|
||
To reduce radiation does, it is useful to include plans that | ||
automatically open and close the shutters as needed. Additionally, the | ||
run engine should be temporarily paused (suspeneded) when shutter | ||
permit is lost. | ||
|
||
Auto-Open Shutters | ||
------------------ | ||
|
||
In the case of **radiation-sensitive samples**, the experiment may | ||
require **keeping the shutter closed** except when collecting | ||
data. Haven includes two preprocessors that can be used to | ||
automatically open shutters that are closed: | ||
:py:func:`~haven.preprocessors.open_shutters_decorator` and | ||
:py:func:`~haven.preprocessors.open_shutters_wrapper`. Both the | ||
end-station PSS shutter, and a secondary fast shutter can both be left | ||
closed and then opened automatically only when needed for recording | ||
data. This feature is enabled by default on plans in | ||
:py:mod:`haven.plans` that trigger detectors (except for | ||
:py:func:`haven.plans.record_dark_current`). :py:mod:`~haven.plans` | ||
also includes wrapped versions of common Bluesky plans, like | ||
:py:func:`haven.plans.scan`. | ||
|
||
**Fast shutters** (those with ``"fast_shutters"`` in their | ||
`_ophyd_labels_` attribute) will be opened before each "trigger" | ||
message emitted by a plan, and closed after the subsequent "wait" | ||
message. The "wait" message's *group* will be tracked, ensuring that | ||
the fast shutters will only close after all triggers have been | ||
awaited. | ||
|
||
**Slow shutters** (those without ``"fast_shutters"`` in their | ||
`_ophyd_labels_` attribute) will be opened at the start of the wrapped | ||
plan, and closed again at the end. | ||
|
||
Shutters that are open at the start of the plan, or haven *allow_open* | ||
or *allow_close* set to ``False`` will be ignored. | ||
|
||
|
||
Record Ion Chamber Dark Current | ||
------------------------------- | ||
|
||
The :py:func:`~haven.plans.record_dark_current` plan accepts a | ||
sequence of shutter devices as an optional argument: *shutters*. Any | ||
devices included will automatically be closed before measuring the | ||
dark current, and opened again if they were initially open. | ||
|
||
|
||
Suspend When Shutter Permit is Lost | ||
----------------------------------- | ||
|
||
.. note:: | ||
|
||
This is still a work in progress. If you have an interest in this | ||
feature, please join the discussion. | ||
|
||
|
||
Personnel Safety System (PSS) Shutters | ||
====================================== | ||
|
||
The PSS shutters are typically large and slow to move. The APS PSS | ||
shutters are controlled via three PVs: | ||
|
||
- Open signal | ||
- Close signal | ||
- Beam blocking signal | ||
|
||
Activating the open signal directly will instruct the IOC to open the | ||
shutter, but will return a put complete before the shutter has | ||
actually opened. This is not useful when actuating shutters in a | ||
Bluesky plan. As such, the PSS shutters | ||
(:py:class:`haven.devices.shutter.PssShutter`) are **implemented as | ||
positioners** so that :py:meth:`haven.devices.shutter.PssShutter.set` | ||
**completes only when** the beam blocking signal reports that the shutter | ||
is open. | ||
|
||
.. code-block:: python | ||
|
||
from haven.devices import PssShutter, ShutterState | ||
shutter = PssShutter(prefix="S255ID-PSS:FES:", name="front_end_shutter")] | ||
# Waits for the shutter to actually close: | ||
await shutter.set(ShutterState.CLOSED) | ||
|
||
Or add the following to a **TOML file** read by the beamline startup: | ||
|
||
.. code:: toml | ||
|
||
[[ pss_shutter ]] | ||
name = "front_end_shutter" | ||
prefix = "S255ID-PSS:FES:" | ||
# allow_close = true # Default | ||
# allow_open = true # Default | ||
|
||
The optional arguments *allow_open* and *allow_close* control whether | ||
the device should be allowed to open and close the shutter. Typically, | ||
if either *allow_open* or *allow_close* are false, the shutter will be | ||
ignored by tools that automatically actuate the shutters, like | ||
:py:func:`~haven.preprocessors.open_shutters_wrapper` and | ||
:py:func:`~haven.plans.record_dark_current`. | ||
|
||
|
||
XIA PFCU-4 Filter Bank | ||
===================== | ||
|
||
One XIA PFCU controller can control four filters in a single | ||
4-position PF4 filter box. Two filters in one box can be combined to | ||
produce a shutter. | ||
|
||
To **create a filter bank**: | ||
|
||
.. code-block:: python | ||
|
||
from haven.devices import PFCUFilterBank | ||
filter_bank = PFCUFilterBank("255idc:pfcu0:", name="filter_bank") | ||
|
||
Or add the following to a **TOML file** read by the beamline startup: | ||
|
||
.. code-block:: toml | ||
|
||
[[ pfcu4 ]] | ||
name = "filter_bank1" | ||
prefix = "255idc:pfcu1:" | ||
|
||
Each :py:class:`~haven.devices.xia_pfcu.PFCUFilterBank` device is a | ||
positioner, and can be set with a string of the bits for all | ||
filters. For example, ``await filter_bank.set("1100")`` will close | ||
(``"1"``) filters 0 and 1, and open (``"0"``) filters 2 and 3. The | ||
ophyd-async device uses this to set both blades on a shutter at once. | ||
|
||
|
||
XIA PFCU Filter | ||
--------------- | ||
|
||
The :py:class:`~haven.devices.xia_pfcu.PFCUFilterBank` has an | ||
attribute *filters* which holds | ||
:py:class:`~haven.devices.xia_pfcu.PFCUFilter` instances for the | ||
individual filters in the bank. The **key for each filter** is its | ||
position in the filter box, starting from 0. Some **filters may be | ||
absent** if they are used for shutters, described below. | ||
|
||
|
||
.. warning:: | ||
|
||
A **TimeoutError** may occur when attempting to set multiple | ||
filters on the same filter bank concurrently. The IOC will often | ||
not process these requests properly, and one of the filters will | ||
not move. It is recommended to move filters individually, e.g.: | ||
|
||
.. code-block:: python | ||
|
||
RE(bps.mv(filter_bank.filters[0], FilterState.IN)) | ||
RE(bps.mv(filter_bank.filters[1], FilterState.IN)) | ||
|
||
instead of combining into a single move plan. | ||
|
||
|
||
XIA PFCU Shutter | ||
---------------- | ||
|
||
Two filters in one filter bank can be combined to produce a | ||
shutter. Provide the indices (starting from 0) of the filters to use | ||
when creating the filter bank: | ||
|
||
.. code-block:: | ||
|
||
filter_bank = PFCUFilterBank(..., shutters=[[3, 2]]) | ||
|
||
The first number listed (``3``) is the index of the filter holding the | ||
top of the shutter, that is the filter that should be ``"In"`` to block | ||
X-rays. The second number (``2``) is the index of the bottom | ||
filter. **If the shutter is open when it should be closed**, consider | ||
swapping the order of these numbers. | ||
|
||
The resulting :py:class:`~haven.devices.xia_pfcu.PFCUShutter` instance | ||
is available in the *shutters* device vector, with keys based on their | ||
order in the original *shutters* argument. The recommended way to | ||
**actuate the shutter** is by setting it directly rather than moving | ||
the individual filters: | ||
|
||
.. code-block:: python | ||
|
||
from haven.devices import ShutterState | ||
|
||
shutter = filter_bank.shutters[0] | ||
await shutter.set(ShutterState.CLOSED) | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we set it to "CLOSED," do filters 2 and 3 close simultaneously or one by one? As Debora and I discussed, the shutter should close simultaneously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, both filters should move together. The steps are:
This way, they should move together.