Quick reference#
Task-oriented reference for slightly less common things than the cheat sheet covers. Skim the headings; jump to what you need.
Plans and stubs#
A plan publishes Bluesky documents – it brackets a run with
open_run / close_run and produces a catalog entry.
A plan stub does not publish documents – it is a building block that does part of a plan’s work.
Module |
What’s in it |
Example |
|---|---|---|
|
Full plans |
|
|
Plan stubs |
|
Both can be passed to RE(...). See
Plans and stubs for the
distinction.
The @plan decorator#
from bluesky.utils import plan
@plan
def my_plan(...):
yield from bps.mv(motor, 5)
yield from bp.count([det])
Apply to every plan and plan stub you author. Without it, the
common mistake my_plan(...) (missing RE(...)) silently does
nothing. With it, you get a RuntimeWarning pointing at the
mistake.
Where to add new code#
Adding… |
Goes in… |
|---|---|
A standard EPICS motor |
|
A custom motor class (per-axis) |
|
A new Device class (bundle + extras) |
|
An interlock between two devices |
|
A plan |
|
A run-document subscriber callback |
|
A suspender |
|
A new doc page |
|
A new dependency |
|
See the specific how-to guides:
Editing and rebuilding the docs#
cd docs
make html # builds to build/html/
make clean # also clears auto-generated source/api/
Requires pip install -e .[doc].
New pages: drop a .md in the right docs/source/<section>/
subdirectory and add to <section>/index.md’s toctree.
Full guide: Edit and build docs.
IPython magics#
%wa # where all -- list devices by label
%wa motors # filter by label
%mov motor1 5 # interactive move (uses bps.mv)
%movr motor1 0.1 # interactive relative move
%ct # count once with default detectors
These are the apstools magics, registered by startup.py.
Catalog basics#
cat # session-level Tiled client
len(cat) # number of runs
cat[-1] # most recent run
cat[uid] # by UID
cat.search(Key("plan_name") == "scan")
run = cat[-1]
run.metadata["start"] # everything from the plan's open_run
run.metadata["stop"] # success/abort/fail info
run.primary.read() # main data stream as an xarray Dataset
run.baseline.read() # baseline snapshot at run start and end
list(run) # all streams in the run
Devices: introspection#
device.summary() # pretty-print every Signal + kind
device.read() # dict of hinted+normal signals
device.read_configuration() # dict of config signals
device.component_names # tuple of every Component
device.read_attrs # what read() will include
device.configuration_attrs # what read_configuration() will include
device.connected # True/False
device.wait_for_connection(timeout=5)
For signals:
signal.get() # one current value
signal.put(value) # one CA put
signal.subscribe(cb) # register a monitor callback
signal.unsubscribe(cid)
signal.kind # 'hinted' | 'normal' | 'config' | 'omitted'
RunEngine controls#
RE.state # 'idle' | 'running' | 'paused'
RE.md # session-wide metadata dict
RE.md["beamline"] = "3-ID-C" # set persistent metadata
RE.subscribe(cb) # add a callback
RE.unsubscribe(token)
RE.install_suspender(s) # install a suspender
RE.remove_suspender(s)
RE.abort() # while paused
RE.resume()
RE.stop()
RE.halt()
Interlocks#
The omega <-> laser_optics interlock is installed automatically by
startup.py. To inspect:
sample_stage.omega.interlock # the permit callable
sample_stage.omega.interlock_description
sample_stage.omega.interlock_watch # tuple of watch signals
Setting either to None disables it for the current session. See Motion interlocks.
Time and units#
All Bluesky timestamps are unix epoch seconds (float).
All ophyd readings carry a
timestampfield in the dict.Motor positions are in the motor’s EGU (engineering units) as set in the IOC; ophyd does no unit conversion.
See also#
Cheat sheet – shorter, denser.
Configuration – iconfig.yml, devices.yml, qserver.
Auto-generated API – module-by-module reference.