Skip to content

Cookbook

This is the cookbook for using bluesky at the Belchem 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.

  • To open the keithley screens open the following files: /opt/phoebus/gui/keithleys/kth01.bob

  • To open the beamline screen open the following files: /opt/phoebus/gui/belchem/beamline.bob

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

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

Continuous scans

The following scan is available for motors using an EPICS motor record

mov_count motor start_pos end_pos velocity

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

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

Average keithleys measurements

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)

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()