Skip to content

Commit

Permalink
Merge branch 'main' into 909-ruff-linting
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Feb 28, 2024
2 parents b3e98a1 + 767640c commit 596857c
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 8 deletions.
1 change: 1 addition & 0 deletions apstools/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
# from .flyer_motor_scaler import _SMFlyer_Step_1
# from .flyer_motor_scaler import _SMFlyer_Step_2
# from .flyer_motor_scaler import _SMFlyer_Step_3
from .hhl_slits import HHLSlits

from .kohzu_monochromator import KohzuSeqCtl_Monochromator

Expand Down
68 changes: 68 additions & 0 deletions apstools/devices/hhl_slits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from ophyd import Component as Cpt
from ophyd import Device
from ophyd import FormattedComponent as FCpt
from ophyd import EpicsMotor


class HHLSlits(Device):
"""
High Heat Load Slit.
There are no independent parts to move, so each axis only has center and size.
Based on the 25-ID-A whitebeam slits.
The motor parameters listed below specify which motor records
control which axis. The last piece of the PV prefix will be
removed, and the motor number added on. For example, if the prefix
is "255ida:slits:US:", and the pitch motor is "255ida:slits:m3",
then *pitch_motor* should be "m3".
Parameters
==========
prefix:
EPICS prefix required to communicate with HHL Slit IOC, ex: "25ida:slits:US:"
pitch_motor:
The motor record suffix controlling the real pitch motor, ex "m3"
yaw_motor:
The motor record suffix controlling the real yaw motor, ex "m4"
horizontal_motor:
The motor record suffix controlling the real horizontal motor, ex: "m1"
diagonal_motor:
The motor record suffix controlling the real diagonal motor, ex: "m2"
"""

def __init__(
self,
prefix: str,
pitch_motor: str,
yaw_motor: str,
horizontal_motor: str,
diagonal_motor: str,
*args,
**kwargs,
):
# Determine the prefix for the motors
pieces = prefix.strip(":").split(":")
self.motor_prefix = ":".join(pieces[:-1])

self._pitch_motor = pitch_motor
self._yaw_motor = yaw_motor
self._horizontal_motor = horizontal_motor
self._diagonal_motor = diagonal_motor

super().__init__(prefix, *args, **kwargs)

class SlitAxis(Device):
size = Cpt(EpicsMotor, "Size", labels={"motors"})
center = Cpt(EpicsMotor, "Center", labels={"motors"})

# Individual slit directions
h = Cpt(SlitAxis, "h")
v = Cpt(SlitAxis, "v")

# Real motors that directly control the slits
pitch = FCpt(EpicsMotor, "{motor_prefix}:{_pitch_motor}", labels={"motors"})
yaw = FCpt(EpicsMotor, "{motor_prefix}:{_yaw_motor}", labels={"motors"})
horizontal = FCpt(EpicsMotor, "{motor_prefix}:{_horizontal_motor}", labels={"motors"})
diagonal = FCpt(EpicsMotor, "{motor_prefix}:{_diagonal_motor}", labels={"motors"})
7 changes: 7 additions & 0 deletions docs/source/api/_devices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ Slits

.. autosummary::

~apstools.devices.hhl_slits.HHLSlits
~apstools.devices.xia_slit.XiaSlit2D
~apstools.synApps.db_2slit.Optics2Slit1D
~apstools.synApps.db_2slit.Optics2Slit2D_HV
Expand Down Expand Up @@ -317,6 +318,12 @@ All Submodules
:show-inheritance:
:inherited-members:
.. automodule:: apstools.devices.hhl_slits
:members:
:private-members:
:show-inheritance:
:inherited-members:

.. automodule:: apstools.devices.kohzu_monochromator
:members:
:private-members:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/de_0_adsim_hdf5_basic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We must configure `adsimdet` so the HDF5 plugin (by its attribute name `hdf1`) will be called during `adsimdet.read()`, as used by data acquisition. This plugin is already `enabled` (above) but we must change the [`kind`](https://blueskyproject.io/ophyd/user_v1/reference/signals.html#kind) attribute. Ophyd support will check this attribute to see if the plugin should be [`read`](https://blueskyproject.io/ophyd/user_v1/tutorials/device.html#assign-a-kind-to-components) during data acquisition. If we don't change this, the area detector image(s) will not be reported in the run's documents.\n",
"We must configure `adsimdet` so the HDF5 plugin (by its attribute name `hdf1`) will be called during `adsimdet.read()`, as used by data acquisition. This plugin is already `enabled` (above) but we must change the [kind](https://blueskyproject.io/ophyd/user_v1/reference/signals.html#kind) attribute. Ophyd support will check this attribute to see if the plugin should be [read](https://blueskyproject.io/ophyd/user_v1/tutorials/device.html#assign-a-kind-to-components) during data acquisition. If we don't change this, the area detector image(s) will not be reported in the run's documents.\n",
"\n",
"**Note**: Here, we assign the `kind` attribute by number `3`, a shorthand which is interpreted by ophyd as `ophyd.Kind.config | ophyd.Kind.normal`."
]
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/de_scaler_motor_flyer.ipynb_i763
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Augment the *standard* (a.k.a. bluesky pre-assembled) [`bp.fly()`](https://blueskyproject.io/bluesky/generated/bluesky.plans.fly.html#bluesky.plans.fly) plan to save the peak statistics to a separate stream in the run after the fly scan is complete."
"Augment the *standard* (a.k.a. bluesky pre-assembled) [bp.fly()](https://blueskyproject.io/bluesky/generated/bluesky.plans.fly.html#bluesky.plans.fly) plan to save the peak statistics to a separate stream in the run after the fly scan is complete."
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/fw_specfile_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's view file `spec1.dat` from disk storage (using the [`pycat`](https://ipython.readthedocs.io/en/stable/interactive/magics.html?highlight=pycat#magic-pycat) IPython magic function):"
"Let's view file `spec1.dat` from disk storage (using the [pycat](https://ipython.readthedocs.io/en/stable/interactive/magics.html?highlight=pycat#magic-pycat) IPython magic function):"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/source/examples/ho_contingency.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"\n",
"#### Exceptions\n",
"\n",
"An unhandled Python [`Exception`](https://docs.python.org/3/library/exceptions.html) will terminate a plan run by `bluesky.RunEngine`.\n",
"An unhandled Python [Exception](https://docs.python.org/3/library/exceptions.html) will terminate a plan run by `bluesky.RunEngine`.\n",
"\n",
"Next, we create `MyException`, a custom exception, and `my_plan`, a bluesky plan that can raise this custom exception. If `MyException` is raised, then `bp.count` will not be run and `After count` will not be printed.\n",
"\n",
Expand Down Expand Up @@ -312,7 +312,7 @@
"**Exception handling in generator coroutines**\n",
"\n",
"Generator coroutines [expose exception throwing](https://tacaswell.github.io/coroutines-i.html) as a user communication channel. This means\n",
"there is some [in-band encoding](https://youtu.be/iKzOBWOHGFE?si=XAtQKhk3eHboHcL-&t=1011) of Python's control exceptions with the users exceptions. When the `close()` [method](https://docs.python.org/3/reference/expressions.html#generator.close) is called on a generator coroutine, Python will throw a [`GeneratorExit`](https://docs.python.org/3/library/exceptions.html#GeneratorExit) exception into the coroutine. If you catch this exception and try to yield another `Msg`, either explicitly in an `except` block or in a `finally` block, Python will raise a `RuntimeError` at the call site.\n",
"there is some [in-band encoding](https://youtu.be/iKzOBWOHGFE?si=XAtQKhk3eHboHcL-&t=1011) of Python's control exceptions with the users exceptions. When the `close()` [method](https://docs.python.org/3/reference/expressions.html#generator.close) is called on a generator coroutine, Python will throw a [GeneratorExit](https://docs.python.org/3/library/exceptions.html#GeneratorExit) exception into the coroutine. If you catch this exception and try to yield another `Msg`, either explicitly in an `except` block or in a `finally` block, Python will raise a `RuntimeError` at the call site.\n",
"\n",
"If you want to use `try..except..else..finally` directly, you must handle this case. See the source of these decorators for a guide.\n",
"\n",
Expand Down Expand Up @@ -763,7 +763,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The shutter will be zero when closed, and one when open. Looking at the list of pre-defined [suspenders](https://blueskyproject.io/bluesky/state-machine.html#built-in-suspenders), [`bluesky.suspenders.SuspendBoolLow`](https://blueskyproject.io/bluesky/generated/bluesky.suspenders.SuspendBoolLow.html#bluesky.suspenders.SuspendBoolLow) fits this pattern. Let's tell it to wait 5 seconds after the shutters open before releasing the suspension on the RunEngine."
"The shutter will be zero when closed, and one when open. Looking at the list of pre-defined [suspenders](https://blueskyproject.io/bluesky/state-machine.html#built-in-suspenders), [bluesky.suspenders.SuspendBoolLow](https://blueskyproject.io/bluesky/generated/bluesky.suspenders.SuspendBoolLow.html#bluesky.suspenders.SuspendBoolLow) fits this pattern. Let's tell it to wait 5 seconds after the shutters open before releasing the suspension on the RunEngine."
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/ho_list_control_objects.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@
"## `.summary()` method\n",
"\n",
"Every object using `ophyd.Device` (or a subclass) has a\n",
"[`.summary()`](https://github.com/bluesky/ophyd/blob/285b0c75da67c935a8073481d6442362723b127b/ophyd/device.py#L1209-L1213)\n",
"[.summary()](https://github.com/bluesky/ophyd/blob/285b0c75da67c935a8073481d6442362723b127b/ophyd/device.py#L1209-L1213)\n",
"method to describe its internal structure. (Note: a `Signal` does not have a\n",
"`.summary()` method.)\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/pl_excel_scan.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"to generalize.given a spreadsheet (named ``sample_example.xlsx``)\n",
"with content as shown in the next figure:\n",
"\n",
"![`sample_example.xlsx`](../resources/sample_example.jpg)\n",
"![sample_example.xlsx](../resources/sample_example.jpg)\n",
"\n",
"**Tip**: Place the column labels on the fourth row of the spreadsheet, starting\n",
"in the first column. The actions start on the next row. The first blank row\n",
Expand Down

0 comments on commit 596857c

Please sign in to comment.