Cookbook
This is the cookbook for using bluesky at the Optics Beamline. Many examples and many commands are explicitly written in a form that is easy for the user/operator to simply copy and paste them into the bluesky terminal as they are or with little modification.
Start Bluesky
From a terminal write
bluesky_start
Start Phoebus GUI
To start the screens run this line in a terminal:
phoebus_start
To open the gui panels navigate to the folder /opt/phoebus/gui.
Move motors
If you want to move a motor, or a set of motors you can simply type:
mov motor1 position1 motor2 position2
or using relative motions
movr motor1 relative_motion1 motor2 relative_motion2
On the reflectometer one can use the axis using absolute cordinates
mova r.axes absolute_position
Change the PGM cff
To set the cff value to 2.5 use:
mov pgm.cff 2.5
Note that this will not produce any movement in the monochromator. The new cff will be set once you change the energy to a new one.
Scan
Select Plotted detector
One can choose a detector to be plotted using giving the command plotselect():
In [1]: plotselect()
Current detector: ['kth01']
Press enter to exit
Available detectors:
1. accelerator_current
2. kth01
Select detectors by one or more numbers (e.g., '1', '1 2', '1,2')
Scan Syntax
| Command | Usage Example |
|---|---|
| Take readings from detectors. | count 5 delay=1 |
| absolute scan one motor | scan motor -1 1 10 |
| absolute scan multiple motors | scan motor -1 1 motor2 -2 3 10 |
| relative scan one motor | dscan motor -1 1 10 |
| relative mesh multiple motors | dmesh motor1 -1 1 10 motor2 -2 2 20 |
| absolute mesh multiple motors | amesh motor1 12 14 10 motor2 18 22 20 |
PTB scan
This scan let you choose how many times you want to mesure one single point, by settin the parameter repeat. One can add as many motor as desired, with the following syntax:
ptb_scan motor1 start1 stop1 motor2 start2 stop2 n_points repeat=2
# example of a scan with one motor
ptb_scan motor -1 1 10 repeat=2
# example of a scan with two motors
ptb_scan motor -1 1 motor2 -2 2 10 repeat=2
Continuous scans
The following scan is available for motors using an EPICS motor record
mov_count motor start_pos end_pos velocity
This scan will work with the following motors: fsu.
Continuous energy scan
This plan read detectors while flying pgm energy with start, stop, initial scan velocity, and the delay between det sample time
flyscan pgm.en start=400 stop=450 vel=0.2 delay=0
| Parameter | Type | Description | Default |
|---|---|---|---|
detectors |
list | A list of 'readable' objects. | None |
flyer |
FlyerDevice object | An object of FlyerDevice type. | None |
start |
float | The start value of the flyer. | None |
stop |
float | The stop value of the flyer. | None |
vel |
float | The initial velocity of the flyer. | 0 |
delay |
iterable or scalar | Time delay in seconds between successive readings. | 0.1 |
shutter |
Device | Device with open and close value attributes, used to control a shutter. | Optional |
md |
dict | A dictionary containing additional metadata. | Optional |
Settle Time (wait before measuring)
It is possible to define a settle time, which is a a number of seconds waited by a motor before reporting that the motion is completed.
motor.axis.settle_time = 5
Settle Time for all motors
The following function will change the value of the settle time for all the motors to the desired value. For instance to change it to 2 or to 5 seconds use one of the following
settle_time(2)
settle_time(5)
Autohios
It is possible to instruct bluesky to automatically set the High Order Suppressor (HIOS) motors to the desired values depending on the selected energy of the monochromator. There are three tables that can be used to select the HIOS motor positions. The tables are located in the folder ~/bluesky/beamlinetools/beamlinetools/hios
To activate autohios
autohios(1) # to select table number one
autohios(2) # to select table number two
autohios(3) # to select table number three
T0 deactivate autohios
autohios(0)
Keithleys
Average
When measuring with the Keithleys, it is possible to instruct them to repeat the measurement n times, and return the averaged value.
kth1.avg_type.set('Repeat')
kth1.avg_num.put(5)
Triggers before reading
By default at the Optics beamline the keithleys are triggered three times before being read. Once can change the number of times a keithley is triggered before being read setting the trigger repetion axis. For instance, for keithley 1:
kth1.trigger_rep.set(5)
Adding Custom Metadata to Scans
Custom metadata allows users to annotate scans with additional information that can be specific to the current context or experimental conditions. This metadata is added at the time of executing a scan plan by including a dictionary named md as a parameter in the scan command.
Below is an example of how to add custom metadata when executing a scan. In this example, the metadata includes the name of the operator and a description of the sample:
# Define the scan parameters and include custom metadata
scan motor 1 5 5 md={'operator':'John','sample':'gold'}
Abort Motion
Weather you are moving a motor or running a plan, the motion can be interrupted by pressing
ctrl+c
Magics
| Command | Description |
|---|---|
ct |
Shows a reading of all the detectors. |
wa |
Shows all the motor positions. You can select which motors to show using their label. |
where |
Draws a line of the current motor position in the last scan. |
pic |
Moves the motor to the highest value of the signal from the detector in the last scan. |
cen |
Moves the motor to the center of the signal from the detector in the last scan. |
com |
Moves the motor to the center of mass of the signal from the detector in the last scan. |
minimum |
Moves the motor to the minimum of the signal from the detector in the last scan. |
Data
The data is exported in a subfolder of ~/bluesky/data.
The data is exported as specfiles (that can be visualized with PyMCA), and as individual csv files.
Before starting taking measurements, make sure that you are exporting the data in the right folder.
User Data
Change your user folder using the following command:
bds.change_user('<user_name>')
Create an additional subfolder for each sample/part of the experiment (you need at least one).
bds.change_sample('<sample_name>')
This is the folder structure that you create
├── ~/bluesky/data
│ ├── user_name
│ │ └── sample_name
│ │ │ ├── csv
│ │ │ │ ├── 00001_meta.json
│ │ │ │ ├── 00001_primary.csv
│ │ │ │ └── 00001_baseline.csv
│ │ │ └── sample1.spec
Specfile
Specfiles can be visualized using PyMCA. To start the program click on it on the dock, or just write pymca in a terminal.
Individual csv files
The csv folder contains three files for each scan:
- scanNumber_baseline.csv: the baseline
- scanNumber_meta.json: the metadata
- scanNumber_primary.csv: the data
Suspenders
Bluesky can automatically pause a measurement in case some conditions are met, by using suspenders.
Injection
This suspender pause the measurements two seconds before and after the injection happens. To activate it and deactivate it use:
wait_for_injection()
Change Sample
One can save the coordinate of the tripod and goniometer for sample changing. The first time drive the sample to the change position manually and once you are happy with the coordinate save them using:
save_sample_position('my_positions')
To drive the tripod and goniometer to the same set of coordinates use:
# to use the default positions
sample_change()
# to use custom positions
sample_change('my_positions')
Finally, to start measuring:
sample_measure()