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.

Start Pymca

To start the screens run this line in a terminal:

pymca

Remember, data is saved at ~/bluesky/data

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

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

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

These work only on 1 D scans.

Command Description
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

Enable and Disable Devices

Sometimes you need to disable a device that is in your environment. For example, the focus chamber is no longer available in your network.

Devices are managed in the file /home/beamline_user/bluesky/beamlinetools/beamlinetools/beamline_config/beamline_devices/beamline_devices.yml

For example, to disable the focus chamber you would change the value of the key active to False


- type: FocusChamber
  active: False
  class: beamlinetools.devices.focus_chamber.FocusChamber
  prefix: "MICFOCFL:"
  instance_name: focus
  class_kwargs: []
  class_args: []
  connection_timeout: 5
  apply_rml_on: False
  nx_class: someNxClass
  baseline: False
  silent: False

Once you make a change here, you must close and reopen the bluesky terminal for changes to take effect.