Skip to content

Bluesky Training

We will use:

Start Jupyter Hub and containers

From a terminal write

bluesky_start

If it there is an error and bluesky does not start give the command again and it should work.

podman ls -a

You can access with your browser at:

0.0.0.0:8888

If you want to stop using containers and Jupyter notebook kill the process running in the terminal with ctrl+c.

Move motors and set values

Move motors

Read the position of the motor or detector:

motor1.read()

If you want to move a motor by running a plan, or a set of motors you can simply type:

RE(mv(motor1,position1))

or with magics

%mov motor1 position1 motor2 position2

or using relative motions

%movr motor1 relative_motion1 motor2 relative_motion2

Exported data

The data is exported in multiple files format.

Individual files

In the folder csv you find individual files for every scan, in particular:

  • scanNumber_baseline.csv: here are contained the measured values for all the devices in the baseline (measured once before and once after the scan)
  • scanNumber_meta.json: here are contained the metadata relative to the scan
  • scanNumber_primary.csv: here are contained the data for the scan.

Scan Types

Several scan types are available by default in Bluesky. For a complete list and the documentation refer to the official documentation

Original syntax

Plans have to be passed as an argument to the Run Engine, and they are functions themselfs. For instance the count plan should be invoked like this: RE(count([noisy_det],5,delay=1))

Simplified syntax

Experimental ipython magics are available that aim to simplify the syntax. By prefixing the symbol % to the plan name, it is possible to use a spec-like syntax. For instance, the same count plan as above can be invoked like this: %count [noisy_det] 5 delay=1

In case of problems, please report it to the beamline scientist and use the original syntax.

  • count: take one or more readings from detectors. Usage (5 counts, 1 sec delay):

  • %count [noisy_det] 5 delay=1

  • scan or ascan: scan over one multi-motor trajectory. Usage (scan motor1 between -1 and 1 in 10 points)

  • %ascan [noisy_det] motor1 -1 1 10

  • relative_scan or dscan: scan over one multi-motor trajectory relative to current position. Usage (scan motor1 between -1 and 1 in 10 points)

  • %dscan [noisy_det] motor1 -1 1 10

  • list_scan: scan over one or more variables in steps simultaneously (inner product). Usage (scan motor1 on a list of given points)

  • %dscan [noisy_det] motor1 [point1, point2, ...]

  • grid_scan: Scan over a mesh; each motor is on an independent trajectory.

  • RE(grid_scan[noisy_det], motor1, start1, stop1, num1, motor2, start2, stop2, num2)

Add metadata to the scans

Custom metadata can be entered by the user at the execution time of a plan. Suppose that we are exectuing a plan called scan() (for brevity we omit the parameters that we need to pass to the scan function). One can add the metadata either like this:

  • RE(scan(), operator='John', sample='pure_gold')

Another way is to add the metadata directly in the plan. In this case we need to use a python dictionary.

  • RE(scan([det], motor, 1, 5, 5, md={'operator':'John', 'sample':'gold'}))

or using the symplified syntax:

  • %scan [det] 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.

RunEngineInterrupted: 
Your RunEngine is entering a paused state. These are your options for changing
the state of the RunEngine:

RE.resume()    Resume the plan.
RE.abort()     Perform cleanup, then kill plan. Mark exit_stats='aborted'.
RE.stop()      Perform cleanup, then kill plan. Mark exit_status='success'.
RE.halt()      Emergency Stop: Do not perform cleanup --- just stop.

To check the state of the Run engine you can: RE.state