In this notebook you will:
bsui
in a beamline computer terminal sessionRecommend Prerequisites:
#pip install -U --pre databroker[all]
Hosted by Andi
However, bluesky offers lots of flexiblity and often beamline staff want to further customize bluesky for the majority of their users.
Other beamlines like the flexibility and choose to largely rely on lower level aquistion plans.
Below, setup the "beamline" configuration or profile.
%run -i gm_user/user_profile.py
Is bluesky alive and waiting on you?
RE.state
The cell should return:
'idle'
and it is
NotImplementedError: databroker 2.0.0 does not yet support 'temp' Broker
Then scroll up, uncomment, and run
pip install -U --pre databroker[all]
Then restart your kernel as suggested (Select Kernel, Restart Kernel).
RE.state
There are other states and manual ways to control the state of the RunEngine. We will learn about those in this notebook.
Now lets add customized RE metadata by editing gm_user/user_startup.py.
%run -i gm_user/user_startup.py
Confirm that your persistent metadata is as you like it.
RE.md
RE.md
Ok, but that is hard to read.
list(RE.md)
RE.md.keys()
RE.md["instrument"]
md_info()
Since the start of most experiments are setup and alignment, lets label all the data as such.
RE.md["purpose"] = "setup"
RE.md["purpose"] = "setup"
md_info()
In the example below, the Bluesky RE consmumes the plan count()
. count()
is an experiment plan used here to acquire one reading from a detector.
In this case, det
or noisy_det
is are point detectors. We will start with noisy_det
.
RE(count([noisy_det]))
The returned value above is a list of the run IDs that uniquely identify this data set (uid
's). The "scan number" (scan_id
) is easier to remember but is not good for long-term reference because it may not be unique.
What else can count
do to make your experiment better?
Hint: count
is like any other python function. You can view it's documentation in this notebook.
help(count)
count?
count??
Let's just get 5 readings for count
# five consecutive readings
RE(count([noisy_det], num=5))
Scan motor
from -10 to 10, stopping at 15 equally-spaced points and reading noisy_det
at each point.
RE(scan([noisy_det], motor, -10, 10, 15))
How do we know where motor
is now?
Bluesky magics (specific magics just for bluesky) can help us find the motor position
%wa
Hosted by Josh
Or interrogating the ophyd object's read attributes or read_attrs
.
motor
motor.readback
motor.readback.get()
motor.readback.read()
QUESTION: What is the difference between .read()
and .get()
?
Hosted by Andi
Bluesky has lower level plans (stub plans aka bluesky.plan_stubs
). This module contains smaller plans that can be used alone or as buildling blocks for larger plans.
Moving a motor (any other "set-able" object) can be accomplished with mv
.
Try to move motor
to the maximum detector value for the previous scan.
RE(mv(motor,0))
### Complete the line below
RE(mv(motor,))
The motor
scan was noisy. We can think of two ways to improve this:
Let's try less noise.
Let's inspect the device to see the options:
noisy_det
Since this isn't a real detector, we cannot increase the acquire_time
. What other configuration attributes (config_attrs
) can we adjust?
noisy_det.noise_multiplier.get()
Let's move noisy_det.noise_multiplier
to 0.001 and count again.
RE(mv(noisy_det.noise_multiplier, 0.001))
RE(scan([noisy_det], motor, -10, 10, 15))
Let's now try the following:
noisy_det.noise_multiplier
back to 0.1motor
to 0RE(mv(noisy_det.noise_multiplier, 0.1))
RE(scan([noisy_det], motor, -10, 10, 21))
RE(mv(motor, 0))
Try:
scan?
The last argument of scan()
is num
num : integer
number of points
Bluesky functions works always on the concept of number of points, not number of steps.
int(20/1+1)
21
It is natural to do the following for experienced researchers that visit many facilities:
RE(mv(noisy_det.noise_multiplier, 0.1)); RE(scan([noisy_det], motor, -10, 10, 21)); RE(mv(motor, 0))
It will work. However, if you have long count times or fast moving motors you may not be able to stop in time.
For predictable performance of bluesky, the above is not recommended.
In our next notebook, we will learn the recommended methods for assembling larger plans.
But first, lets see what happens when we stop the RE.
Hosted by Josh
At the beamline using a terminal window, there are two ways to interupt the RunEngine.
Interupt immediately: Cntl C
Cntl C
Interupt at the next convient time for the RE: Cntl C
But in a jupyter notebook, you must press the stop button (1 or 2 times).
Start the scan, interupt the RE and instruct it what to do next.
collect data every 3 seconds
delay = 3
infite timescan
num = None
RE(count([noisy_det], num = None, delay=3))
RE.state
RE.stop()
#RE.abort()
#RE.halt()
#RE.resume()
db[-1].stop["exit_status"]