Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: step_value handling

...

Code Block
languagetext
titlerix+_bluesky_scan.py demo
$ python rix_bluesky_scan.py 

Transient Scan ID: 1     Time: 2020-12-10 18:24:53
Persistent Unique Scan ID: '2092a9ca-160c-4b52-8683-256f699e1e01'
New stream: 'primary'
+-----------+------------+------------+
|   seq_num |       time |     motor1 |
+-----------+------------+------------+
|         1 | 18:24:58.5 |    -10.000 |
|         2 | 18:24:59.6 |     -8.571 |
|         3 | 18:25:00.6 |     -7.143 |
|         4 | 18:25:01.6 |     -5.714 |
|         5 | 18:25:02.7 |     -4.286 |
|         6 | 18:25:03.7 |     -2.857 |
|         7 | 18:25:04.8 |     -1.429 |
|         8 | 18:25:05.8 |      0.000 |
|         9 | 18:25:06.8 |      1.429 |
|        10 | 18:25:07.9 |      2.857 |
|        11 | 18:25:08.9 |      4.286 |
|        12 | 18:25:10.0 |      5.714 |
|        13 | 18:25:11.0 |      7.143 |
|        14 | 18:25:12.0 |      8.571 |
|        15 | 18:25:13.1 |     10.000 |
+-----------+------------+------------+
generator scan ['2092a9ca'] (scan num: 1)

...

Code Block
languagetext
titlerix_bluesky_scan.py help
usage: rix_bluesky_scan.py [-h] [-p {0,1,2,3,4,5,6,7}] [-C COLLECT_HOST]
                           [-t TIMEOUT] [-c READOUT_COUNT] [-g GROUP_MASK]
                           [--config ALIAS] [--detname DETNAME]
                           [--scantype SCANTYPE] [--record] [-v]

optional arguments:
  -h, --help            show this help message and exit
  -p {0,1,2,3,4,5,6,7}  platform (default 2)
  -C COLLECT_HOST       collection host (default drp-neh-ctl001)
  -t TIMEOUT            timeout msec (default 10000)
  -c READOUT_COUNT      # of events to aquire at each step (default 120)
  -g GROUP_MASK         bit mask of readout groups (default 36)
  --config ALIAS        configuration alias (default BEAM)
  --detname DETNAME     detector name (default 'scan')
  --scantype SCANTYPE   scan type (default 'scan')
  --record              enable recording of data
  -v                    be verbose

Detector Configuration Scans

These scans use the same "step" idea described above for EPICS PV step-scans, but instead alter a detector configuration object on each step.  Currently this has been done for the EPIX area detector to take data in the various gain ranges. Python code for this can be found here: https://github.com/slac-lcls/lcls2/blob/master/psdaq/psdaq/app/epixhr_pedestal_scan.py

Script Control of Run Stop/Start

One can control the DAQ (e.g. to stop and start runs on a timer) with scripts like this:

Code Block
languagebash
#!/bin/bash                                                                                      
while [ 1 ]
do
echo going to configured
daqstate -p 0 -P tmo -C drp-neh-ctl001 --state configured
sleep 5
echo going to running
daqstate -p 0 -P tmo -C drp-neh-ctl001 --state running
sleep 600
done

Running Scans with Hutch Python

An example hutch-python scan session in RIX.  "rix3" also takes a "--debug" option to increase verbosity.  TMO has a similar "tmo3" command.

step_value Handling

PV scans automatically generate a 1-based step counter named "step_value" and record it alongside motor positions, like so:

Code Block
languagetext
titlestep_value demo
$ xtcreader -f /cds/data/psdm/rix/rixx43518/xtc/rixx43518-r0518-s007-c000.xtc2 -d
  ...
event 3,   BeginStep transition: time 1003603961.730737554, env 0x06040024, payloadSize 147 extent 159
Found 4 names
0: 'step_value' rank 0, type 7
'step_value': 1
1: 'step_docstring' rank 1, type 10
'step_docstring': "{"detname": "scan", "scantype": "scan", "step": 1}"
2: 'fast_motor1' rank 0, type 9
'fast_motor1': 1.000000
3: 'fast_motor2' rank 0, type 9
'fast_motor2': 1.000000
  ...
event 8,   BeginStep transition: time 1003603961.964178292, env 0x060e0024, payloadSize 147 extent 159
Found 4 names
0: 'step_value' rank 0, type 7
'step_value': 2
1: 'step_docstring' rank 1, type 10
'step_docstring': "{"detname": "scan", "scantype": "scan", "step": 2}"
2: 'fast_motor1' rank 0, type 9
'fast_motor1': 3.250000
3: 'fast_motor2' rank 0, type 9
'fast_motor2': 3.250000
  ...

One can override "step_value" by creating a motor named "step_value" and including it among other motors in the scan. This step count also appears in the JSON formatted "step_docstring" automatically.

Detector Configuration Scans

These scans use the same "step" idea described above for EPICS PV step-scans, but instead alter a detector configuration object on each step.  Currently this has been done for the EPIX area detector to take data in the various gain ranges. Python code for this can be found here: https://github.com/slac-lcls/lcls2/blob/master/psdaq/psdaq/app/epixhr_pedestal_scan.py

Script Control of Run Stop/Start

One can control the DAQ (e.g. to stop and start runs on a timer) with scripts like this:

Code Block
languagebash
#!/bin/bash                                 
Code Block
languagetext
rix-daq:~> rix3
Loading local disk python env pcds-4.1.4
      _      _____       _   _                 
     (_)    |  __ \     | | | |                
while _[ 1 ]
do
echo going to configured
daqstate -p 0 -P tmo -C drp-neh-ctl001 --state configured
sleep 5
echo going to running
daqstate -p 0 -P tmo -C drp-neh-ctl001 --state running
sleep 600
done

Running Scans with Hutch Python

An example hutch-python scan session in RIX.  "rix3" also takes a "--debug" option to increase verbosity.  TMO has a similar "tmo3" command.

Code Block
languagetext
rix-daq:~> rix3
Loading local disk python env pcds-4.1.4
      _      _____       _   ___ ___  _| |__) |   _| |_| |__   ___  _ __  
| '__| \ \/ /  ___/ | | | __| '_ \ / _ \| '_ \ 
| |  | |>  <| |   | |_| | |_| | | | (_) | | | |
|_|  |_/_/\_\_|    \__, |\__|_| |_|\___/|_| |_|
                    __/ |                      
    
     (_)    |      |___/ \     | | | |              

INFO  
 _  Selected default hutch-python daq platform: 0
INFO     Loading debug tools...

(lines removed for brevity)

In [1]: daq.configure(motors=[sim.fast_motor1, sim.fast_motor2],events=10,record=True)
INFO     configure - configure: 2 motors
Out[1]: ({}, {})

In [2]: RE(bp.scan([daq], sim.fast_motor1, 1, 10, sim.fast_motor2, 1, 10, 5))


Transient Scan ID: 1     Time: 2021-10-20 12:06:21
Persistent Unique Scan ID: '81544aea-5fb7-4017-b03d-a1ea8d15c174'
New stream: 'primary'
+-----------+------------+-------------+-------------+
|   seq_num |       time | fast_motor1 | fast_motor2 |
+-----------+------------+-------------+-------------+
|__ ___  _| |__) |   _| |_| |__   ___  _ __  
| '__| \ \/ /  ___/ | | | __| '_ \ / _ \| '_ \ 
| |  | |>  <| |   | |_| | |_| | | | (_) | | | |
|_|  |_/_/\_\_|    \__, |\__|_| |_|\___/|_| |_|
                    1__/ | 12:06:33.3 |                1 |     
      1 |
|         2 | 12:06:34.4 |___/        3.25 |            3.25 |
|  

INFO     Selected default 3hutch-python |daq 12platform:06:35.5 | 0
INFO     Loading debug tools...

(lines removed 5.5 |         5.5 |
|for brevity)

In [1]: daq.configure(motors=[sim.fast_motor1, sim.fast_motor2],events=10,record=True)
INFO     configure - configure: 2  4 | 12:06:36.6 |        7.75 |motors
Out[1]: ({}, {})

In [2]: RE(bp.scan([daq], sim.fast_motor1, 1, 10, sim.fast_motor2, 1, 10, 5))


Transient Scan ID: 1     Time:   7.75 |
|         5 | 12:06:37.7 |   2021-10-20 12:06:21
Persistent Unique Scan ID: '81544aea-5fb7-4017-b03d-a1ea8d15c174'
New stream: 'primary'
+-----------+------------+-------------+-------------+
|   seq_num |       10time | fast_motor1         10| fast_motor2 |
+-----------+------------+-------------+-------------+
generator scan ['81544aea'] (scan num: 1)



Out[2]: ('81544aea-5fb7-4017-b03d-a1ea8d15c174',)

In [3]: quit
rix-daq:control>  

These are the parameters that are settable in daq.configure (see these with "daq.configure?" in hutch-python):

Code Block
Signature:
daq.configure(
    *,
    motors=None,
    group_mask=None,
    events=None,
    record=None,
    detname=None,
    scantype=None,
    serial_number=None,
    alg_name=None,
    alg_version=None,
)
Docstring:
Set parameters for scan.

Keyword arguments:
motors -- list of motors, optional
    Motors with positions to include in the data stream
group_mask -- int, optional
    Bit mask of readout groups
events -- int, optional
    Number of events per scan point
record -- bool, optional
    Enable recording of data
detname -- str, optional
    Detector name
scantype -- str, optional
    Scan type
serial_number -- str, optional
    Serial number
alg_name -- str, optional
    Algorithm name
alg_version -- list of 3 version numbers, optional
    Algorithm version
File:      /u1/rixopr/conda_envs/pcds-5.0.0/lib/python3.9/site-packages/psdaq/control/BlueskyScan.py
Type:      method

Other hutch-python parameters are settable in this per-hutch configuration file:

Code Block
rix-daq:control> more /cds/group/pcds/pyps/apps/hutch-python/rix/conf.yml 
hutch: rix

# Locate happi database
db: /reg/g/pcds/pyps/apps/hutch-python/device_config/db.json

# Hutch-specific imports
load: rix.beamline

# DAQ interface configuration
daq_type: lcls2

daq_host: drp-neh-ctl001

daq_platform:
  default: 2
rix-daq:control> 

step_value

+
|         1 | 12:06:33.3 |           1 |           1 |
|         2 | 12:06:34.4 |        3.25 |        3.25 |
|         3 | 12:06:35.5 |         5.5 |         5.5 |
|         4 | 12:06:36.6 |        7.75 |        7.75 |
|         5 | 12:06:37.7 |          10 |          10 |
+-----------+------------+-------------+-------------+
generator scan ['81544aea'] (scan num: 1)



Out[2]: ('81544aea-5fb7-4017-b03d-a1ea8d15c174',)

In [3]: quit
rix-daq:control>  

These are the parameters that are settable in daq.configure (see these with "daq.configure?" in hutch-python):

Code Block
Signature:
daq.configure(
    *,
    motors=None,
    group_mask=None,
    events=None,
    record=None,
    detname=None,
    scantype=None,
    serial_number=None,
    alg_name=None,
    alg_version=None,
)
Docstring:
Set parameters for scan.

Keyword arguments:
motors -- list of motors, optional
    Motors with positions to include in the data stream
group_mask -- int, optional
    Bit mask of readout groups
events -- int, optional
    Number of events per scan point
record -- bool, optional
    Enable recording of data
detname -- str, optional
    Detector name
scantype -- str, optional
    Scan type
serial_number -- str, optional
    Serial number
alg_name -- str, optional
    Algorithm name
alg_version -- list of 3 version numbers, optional
    Algorithm version
File:      /u1/rixopr/conda_envs/pcds-5.0.0/lib/python3.9/site-packages/psdaq/control/BlueskyScan.py
Type:      method

Other hutch-python parameters are settable in this per-hutch configuration file:

Code Block
rix-daq:control> more /cds/group/pcds/pyps/apps/hutch-python/rix/conf.yml 
hutch: rix

# Locate happi database
db: /reg/g/pcds/pyps/apps/hutch-python/device_config/db.json

# Hutch-specific imports
load: rix.beamline

# DAQ interface configuration
daq_type: lcls2

daq_host: drp-neh-ctl001

daq_platform:
  default: 2
rix-daq:control> 
Code Block
languagetext
titlestep_value demo
$ xtcreader -f /cds/data/psdm/rix/rixx43518/xtc/rixx43518-r0518-s007-c000.xtc2 -d
  ...
event 3,   BeginStep transition: time 1003603961.730737554, env 0x06040024, payloadSize 147 extent 159
Found 4 names
0: 'step_value' rank 0, type 7
'step_value': 1
1: 'step_docstring' rank 1, type 10
'step_docstring': "{"detname": "scan", "scantype": "scan", "step": 1}"
2: 'fast_motor1' rank 0, type 9
'fast_motor1': 1.000000
3: 'fast_motor2' rank 0, type 9
'fast_motor2': 1.000000
  ...
event 8,   BeginStep transition: time 1003603961.964178292, env 0x060e0024, payloadSize 147 extent 159
Found 4 names
0: 'step_value' rank 0, type 7
'step_value': 2
1: 'step_docstring' rank 1, type 10
'step_docstring': "{"detname": "scan", "scantype": "scan", "step": 2}"
2: 'fast_motor1' rank 0, type 9
'fast_motor1': 3.250000
3: 'fast_motor2' rank 0, type 9
'fast_motor2': 3.250000
  ...