Skip to content

Commit 4fc8df5

Browse files
committed
Redefine
1 parent b8adc68 commit 4fc8df5

File tree

5 files changed

+25
-23
lines changed

5 files changed

+25
-23
lines changed

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@
9595
"lmfit": ("https://lmfit.github.io/lmfit-py/", None),
9696
"typing_extensions": ("https://typing-extensions.readthedocs.io/en/latest/", None),
9797
"ibex_user_manual": ("https://isiscomputinggroup.github.io/ibex_user_manual/", None),
98+
"genie_python": ("https://isiscomputinggroup.github.io/genie/", None),
9899
}

doc/plan_stubs/external_code.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# `call_sync` (calling external code)
2-
3-
API reference: [`call_sync`](ibex_bluesky_core.plan_stubs.call_sync)
1+
# Calling external code ({py:obj}`~ibex_bluesky_core.plan_stubs.call_sync`)
42

53
All interaction with the "outside world" should be via bluesky messages, and **not** directly called from
64
within a plan. For example, the following is **bad**:
@@ -16,18 +14,18 @@ def bad_plan():
1614
```
1715

1816
```{danger}
19-
External I/O - including most `genie_python` or `inst` functions - should never be done directly in a plan,
17+
External I/O - including most {py:obj}`genie_python <genie>` or `inst` functions - should never be done directly in a plan,
2018
as it will break:
2119
- Rewindability (for example, the ability to interrupt a scan and then later seamlessly continue it)
22-
- Simulation (the `cset` above would be executed during a simulation)
20+
- Simulation (the {py:obj}`~genie.cset` above would be executed during a simulation)
2321
- Error handling (including ctrl-c handling)
2422
- Ability to emit documents
2523
- Ability to use bluesky signals
2624
- ...
2725
```
2826

2927
In the above case, a good plan, which uses bluesky messages in a better way using
30-
a bluesky-native `Block` object, would be:
28+
a [bluesky-native block object](/devices/blocks), would be:
3129

3230
```python
3331
import bluesky.plan_stubs as bps
@@ -44,7 +42,7 @@ def good_plan():
4442
```
4543

4644
However, if the functionality you want to use is not yet natively available in bluesky, a fallback option
47-
for synchronous functions is available using the [`call_sync`](ibex_bluesky_core.plan_stubs.call_sync) plan stub:
45+
for synchronous functions is available using the {py:obj}`ibex_bluesky_core.plan_stubs.call_sync` plan stub:
4846

4947
```python
5048
import bluesky.plan_stubs as bps
@@ -61,6 +59,6 @@ def good_plan():
6159
```
6260

6361
It is strongly recommended that any functions run in this way are "fast" (i.e. less than a few seconds).
64-
In particular, avoid doing arbitrarily-long waits - for example, waiting for detector data
65-
or sample environment. For these long-running tasks, seek to implement at least the long-running parts using
62+
In particular, avoid doing arbitrarily long waits - for example, waiting for detector data
63+
or sample environment. For these long running tasks, seek to implement at least the long-running parts using
6664
native bluesky mechanisms.

doc/plan_stubs/matplotlib_helpers.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
# [`call_qt_aware`](ibex_bluesky_core.plan_stubs.call_qt_aware) (matplotlib helpers)
1+
# Matplotlib helpers ({py:obj}`~ibex_bluesky_core.plan_stubs.call_qt_aware`)
22

3-
When attempting to use `matplotlib` UI functions directly in a plan, and running `matplotlib` using a `Qt`
3+
When attempting to use {py:obj}`matplotlib` UI functions directly in a plan, and running {py:obj}`matplotlib` using a Qt
44
backend (e.g. in a standalone shell outside IBEX), you may see a hang or an error of the form:
55

66
```
77
UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail.
88
fig, ax = plt.subplots()
99
```
1010

11-
This is because the `RunEngine` runs plans in a worker thread, not in the main thread, which then requires special
11+
This is because the bluesky run engine runs plans in a worker thread, not in the main thread, which then requires special
1212
handling when calling functions that will update a UI.
1313

14-
The [`call_qt_aware`](ibex_bluesky_core.plan_stubs.call_qt_aware) plan stub can call `matplotlib` functions in a
14+
The {py:obj}`~ibex_bluesky_core.plan_stubs.call_qt_aware` plan stub can call {py:obj}`matplotlib` functions in a
1515
Qt-aware context, which allows them to be run directly from a plan. It allows the same arguments and
1616
keyword-arguments as the underlying matplotlib function it is passed.
1717

1818
```{note}
19-
Callbacks such as `LivePlot` and `LiveFitPlot` already route UI calls to the appropriate UI thread by default.
20-
The following plan stubs are only necessary if you need to call functions which will create or update a matplotlib
19+
Callbacks such as {py:obj}`~ibex_bluesky_core.callbacks.LivePlot` and {py:obj}`~bluesky.callbacks.mpl_plotting.LiveFitPlot` already route UI calls to the appropriate UI thread by default.
20+
The {py:obj}`~ibex_bluesky_core.plan_stubs.call_qt_aware` plan stub is only necessary if you need to call functions which will create or update a matplotlib
2121
plot from a plan directly - for example to create or close a set of axes before passing them to callbacks.
2222
```
2323

doc/plan_stubs/polling.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Continuous polling
22

3-
[`polling_plan`](ibex_bluesky_core.plans.polling_plan) - is used for moving a motor and dropping updates from a "readable" if no motor updates are provided. An example of this is a laser reading which updates much more quickly than a motor might register it's moved, so the laser readings are not really useful information.
3+
{py:obj}`ibex_bluesky_core.plans.polling_plan` can be used to perform a software continuous scan - setting off a motor
4+
move, and then monitoring both the motor position and a readable, zipping them together into a single dataset suitable
5+
for our usual plotting and fitting callbacks.
46

5-
This in itself doesn't start a bluesky "run" so you will need to use a `run_decorator` on any outer plan which calls this plan stub.
7+
Updates from the readable may be dropped if they occur at a higher rate than updates from the motor position.
68

9+
{py:obj}`ibex_bluesky_core.plans.polling_plan` does not start a bluesky run, so you will need to use a {py:obj}`~bluesky.preprocessors.run_decorator` on an outer plan which calls this plan stub. This is so that _multiple_ continuous moves can be done as part of the same bluesky run.

doc/plan_stubs/redefining.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The plan stubs in this module implement 'redefinition' of a parameter, where supported. That is, no physical movement
44
occurs, but the reported position changes to the given position.
55

6-
## `redefine_motor`
6+
## {py:obj}`~ibex_bluesky_core.plan_stubs.redefine_motor`
77

88
The {py:obj}`ibex_bluesky_core.plan_stubs.redefine_motor` plan stub can be used to redefine the current
99
position of a motor (for example a {py:obj}`ibex_bluesky_core.devices.block.BlockMot`) to a new value.
@@ -28,16 +28,16 @@ def my_plan():
2828
yield from redefine_motor(motor, 0.)
2929
```
3030

31-
By default, the {py:obj}`redefine_motor <ibex_bluesky_core.plan_stubs.redefine_motor>`
31+
By default, the {py:obj}`~ibex_bluesky_core.plan_stubs.redefine_motor`
3232
plan stub sleeps for 1 second after redefining the motor. This avoids race conditions, where a motor is moved too soon
3333
after being redefined to a new position, and the redefined position has not yet been read back from the controller.
3434
This behaviour can be controlled with the `sleep` keyword argument to
35-
{py:obj}`redefine_motor <ibex_bluesky_core.plan_stubs.redefine_motor>`.
35+
{py:obj}`~ibex_bluesky_core.plan_stubs.redefine_motor`.
3636

37-
## `redefine_refl_parameter`
37+
## {py:obj}`~ibex_bluesky_core.plan_stubs.redefine_refl_parameter`
3838

3939
The {py:obj}`ibex_bluesky_core.plan_stubs.redefine_refl_parameter` plan stub can be used to redefine the current
40-
position of a {py:obj}`ibex_bluesky_core.devices.reflectometry.ReflParameter` to a new value. Note that some reflectometry parameters ie. `Theta` cannot be redefined, so these must be constructed with `has_redefine=False`. This plan stub will handle this case and raise an error if a user tries to redefine it.
40+
position of a {py:obj}`~ibex_bluesky_core.devices.reflectometry.ReflParameter` to a new value. Note that some reflectometry parameters (e.g. `Theta`) cannot be redefined, so these must be constructed with `has_redefine=False`. {py:obj}`ibex_bluesky_core.plan_stubs.redefine_refl_parameter` will raise an error if a user tries to redefine a parameter that was created with `has_redefine=False`.
4141

42-
This plan stub has an identical API to that of the {py:obj}`ibex_bluesky_core.plan_stubs.redefine_motor` plan stub
42+
This plan stub has an identical API to that of the {py:obj}`~ibex_bluesky_core.plan_stubs.redefine_motor` plan stub
4343
described above, but operates on a reflectometry parameter rather than a motor.

0 commit comments

Comments
 (0)