Scan PVs

When using the DAQ, it is convenient to keep track of the state of the scan in EPICS to set up nice run tables. This is implemented as the ScanVars class.

In this document I will use “scan vars” and “scan pvs” interchangably.

Usage

Once instantiated, you can use ScanVars.enable and ScanVars.disable to control whether or not we will update the PVs during a scan.

The class is instantiated as scan_vars = ScanVars('XPP:SCAN', name='scan_vars', RE=RE), replacing XPP with the correct hutch.

PVs

PV Suffix

Function

ISTEP

Current scan step, 0-indexed by default

ISSCAN

1 if we are doing a scan, 0 otherwise

SCANVAR0{0,1,2}

The name of our {1st, 2nd, 3rd} positioner

MAX0{0,1,2}

The max scan position of each positioner

MIN0{0,1,2}

The min scan position of each positioner

NSTEPS

The total number of steps in the scan

NSHOTS

Number of events per point in the DAQ

API

The ScanVars class is an ophyd Device with special RunEngine subscription mechanisms for updating the scan PVs. It reads plan metadata and daq configuration to update the PVs.

class pcdsdaq.scan_vars.ScanVars(prefix, *, name, RE, i_start=0, **kwargs)

Collection of PVs to keep track of the scan state.

Use enable to set up automatic updating of these PVs during a RunEngine scan. This relies on proper metadata like the metadata in the built in scan and count plans to populate the PVS.

Use disable to remove this from the RunEngine.

Parameters:
  • prefix (str) – The PV prefix, e.g. XPP:SCAN

  • name (str, required keyword) – A name to refer to this object by

  • RE (RunEngine, required keyword) – The RunEngine instance associated with the session.

  • i_start (int, optional) – The starting count for the i_step tracker. This defaults to zero, which is offset by one from the one-indexed bluesky counter.

enable()

Enable automatic updating of PVs during a scan.

disable()

Disable automatic updating of PVs during a scan.

start(doc: dict[str, Any])

Initialize the scan variables at the start of a run.

This inspects the metadata dictionary and will set reasonable values if this metadata dictionary is well-formed as in bluesky built-ins like scan. It also inspects the daq object.

update_min_max(start: float, stop: float, index: int) None

Helper function for updating the min and max PVs for the scan table.

setup_inner_product(plan_pattern_args: dict[str, Any]) None

Handle max, min, number of steps for inner_product scans.

These are the plans whose arguments are (mot, start, stop) repeat, then a num later, such as the normal scan.

setup_outer_product(plan_pattern_args: dict[str, Any]) None

Handle max, min, number of steps for outer_product scans.

These are the plans whose arguments are (mot, start, stop, num) repeat, with snake directions intersperced starting after the second num (or not), such as grid_scan.

setup_inner_list_product(plan_pattern_args: dict[str, Any]) None

Handle max, min, number of steps for inner_list_product scans.

These are the plans whose arguments are (mot, list) repeat, where every list needs to have the same length because it’s a 1D scan with multiple motors, such as list_scan.

setup_outer_list_product(plan_pattern_args: dict[str, Any]) None

Handle max, min, number of steps for outer_list_product scans.

These are the plans whose arguments are (mot, list) repeat, where the lists can be any length because it’s a multi-dimensional mesh scan, like list_grid_scan.

event(doc)

Update the step counter at each scan step.

This actually sets the step counter for the next scan step, because this runs immediately after a scan step and recieves an event doc from the step that just ran.

stop(doc)

Set all fields to their default values at the end of a run.

These are all 0 for the numeric fields and empty strings for the string fields.