pcdsdevices.areadetector.detectors.PCDSHDF5BlueskyTriggerable

class pcdsdevices.areadetector.detectors.PCDSHDF5BlueskyTriggerable(*args, write_path: str, always_acquire: bool = True, **kwargs)

Saves an HDF5 file in a bluesky plan.

This class takes care of all the standard setup for saving the files using the HDF5 plugin for our area detector setups at LCLS during bluesky scans, including configuration of the stage signals and various site-specific settings.

You can decide how many images we’ll take at each point by setting the num_images_per_point attribute.

There are two modes provided: “always aquire” and “aquire at points” with key differences in the behavior. You can select which one to use using the always_acquire keyword argument, which defaults to True.

With always_aquire=True (default): - Viewers will remain updated throughout the scan, even between

scan points.

  • The camera will be set to acquire at stage, if needed, which begins taking images. This happens early in the scan.

  • At each point, the capture feature of the HDF5 plugin will be toggled on until we’ve saved an image count equal to the num_images_per_point attribute. The counting is handled by the plugin.

  • If the camera or server lags during the aquisition, the scan will patiently wait for the correct number of images to be saved.

  • There is no guarantee that the images are sequential, there can be gaps, but each image that does get saved will be trigger-synchronized. (And therefore, beam-synchronized with beam-synchronized triggers).

  • Each point in the scan will have its own associate hdf5 file.

  • If the camera needed to be set to acquire at stage, it will revert to stop at unstage.

With always_acquire=False: - Viewers will only be updated at the specific scan points. - The HDF5 plugin will be set to capture at stage, and the camera

will be configured to take a fixed number of images per acquisition cycle.

  • At each point, the acquire bit will be turned on, which causes num_images_per_point images to be acquired.

  • If the camera or server lags during the acquisition, it will be unable to complete it cleanly.

  • There is a guarantee that the images are sequential.

  • All the points in the scan will be grouped into one larger hdf5 file.

This class can be also be used interactively via the save_images function.

Parameters:
  • prefix (str) – The PV prefix that leads us to this camera’s PVs.

  • write_path (str) – The directory to drop our hdf5 files into.

  • always_acquire (bool, optional) – Determines which mode we use to collect images as described above.

  • name (str, keyword-only) – A name to associate with the camera for bluesky.

Ophyd Device Components

Attribute

Class

Suffix

Docs

Kind

Notes

configuration_names

ArrayAttributeSignal

config

Inherited from PCDSAreaDetectorBase

cam (ADComponent)

CamBase

normal

Inherited from PCDSAreaDetectorBase

hdf51 (ADComponent)

HDF5FileStore

HDF51:

Save output as an HDF5 file

normal

Methods

collect_asset_docs()
configure(d: Dict[str, Any]) Tuple[Dict[str, Any], Dict[str, Any]]

Configure the device for something during a run

This default implementation allows the user to change any of the configuration_attrs. Subclasses might override this to perform additional input validation, cleanup, etc.

Parameters:

d (dict) – The configuration dictionary. To specify the order that the changes should be made, use an OrderedDict.

Returns:

  • (old, new) tuple of dictionaries

  • Where old and new are pre- and post-configure configuration states.

describe() OrderedDictType[str, Dict[str, Any]]

Provide schema and meta-data for read().

This keys in the OrderedDict this method returns must match the keys in the OrderedDict return by read().

This provides schema related information, (ex shape, dtype), the source (ex PV name), and if available, units, limits, precision etc.

Returns:

data_keys (OrderedDict) – The keys must be strings and the values must be dict-like with the event_model.event_descriptor.data_key schema.

dispatch(key, timestamp)

Notify plugins of acquisition being complete.

When a new acquisition is started, this method is called with a key which is a label like ‘light’, ‘dark’, or ‘gain8’.

It in turn calls generate_datum on all of the plugins that have that method.

File plugins are identified by searching for a generate_datum() method that must have the signature

def generate_datum(key: str, timestamp: float, datum_kwargs: dict):
   ...
Parameters:
  • key (str) – The label for the datum that should be generated

  • timestamp (float) – The time of the trigger

  • datum_kwargs (Dict[str, Any], optional) – Any datum kwargs that should go to all children.

find_signal(text, use_re=False, case_sensitive=False, match_fcn=None, f=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)

Search through the signal docs on this detector for the string text

Parameters:
  • text (str) – Text to find

  • use_re (bool, optional) – Use regular expressions

  • case_sensitive (bool, optional) – Case sensitive search

  • match_fcn (callable, optional) – Function to call when matches are found Defaults to a function that prints matches to f

  • f (file-like, optional) – File-like object that the default match function prints to (Defaults to sys.stdout)

generate_datum(key, timestamp, datum_kwargs=None)

Notify plugins of acquisition being complete.

When a new acquisition is started, this method is called with a key which is a label like ‘light’, ‘dark’, or ‘gain8’.

It in turn calls generate_datum on all of the plugins that have that method.

File plugins are identified by searching for a generate_datum() method that must have the signature

def generate_datum(key: str, timestamp: float, datum_kwargs: dict):
   ...
Parameters:
  • key (str) – The label for the datum that should be generated

  • timestamp (float) – The time of the trigger

  • datum_kwargs (Dict[str, Any], optional) – Any datum kwargs that should go to all children.

get(**kwargs)

Get the value of all components in the device

Keyword arguments are passed onto each signal.get(). Components beginning with an underscore will not be included.

get_asyn_digraph()

Get the directed graph of the ASYN ports

Returns:

  • G (networkx.DiGraph) – Directed graph of pipelines

  • port_map (dict) – Mapping between port_name and ADBase objects

get_asyn_port_dictionary()

Return port name : component map

Returns:

port_map (dict) – Mapping between port_name and ADBase objects

get_plugin_by_asyn_port(port_name)

Get the plugin which has the given asyn port name

Parameters:

port_name (str) – The port name to search for

Returns:

ret (ADBase or None) – Either the requested plugin or None if not found

get_plugin_graph_edges(*, use_names=True, include_cam=False)

Get a list of (source, destination) ports for all plugin chains.

Parameters:
  • use_names (bool, optional) – By default, the ophyd names for each plugin are used. Set this to False to instead get the AreaDetector port names.

  • include_cam (bool, optional) – Include plugins with ‘CAM’ as the source. As it is easy to assume that a camera without an explicit source is CAM, by default this method does not include it in the list.

make_data_key()
missing_plugins()

Find missing ports

read() OrderedDictType[str, Dict[str, Any]]

Read data from the device.

This method is expected to be as instantaneous as possible, with any substantial acquisition time taken care of in trigger().

The OrderedDict returned by this method must have identical keys (in the same order) as the OrderedDict returned by describe().

By convention, the first key in the return is the ‘primary’ key and maybe used by heuristics in bluesky.

The values in the ordered dictionary must be dict (-likes) with the keys {'value', 'timestamp'}. The 'value' may have any type, the timestamp must be a float UNIX epoch timestamp in UTC.

Returns:

data (OrderedDict) – The keys must be strings and the values must be dict-like with the keys {'value', 'timestamp'}

read_configuration() OrderedDictType[str, Dict[str, Any]]

Dictionary mapping names to value dicts with keys: value, timestamp

To control which fields are included, change the Component kinds on the device, or modify the configuration_attrs list.

save_images() None

Save images interactively as if we were currently at a scan point.

screen(main: bool = False) None

Open camViewer screen for camera.

Parameters:

main (bool, optional) – Set to True to bring up ‘main’ edm config screen. Defaults to False, which opens python viewer.

stop(*, success=False)

Stop the Device and all (instantiated) subdevices

summary()
trigger()

Trigger one acquisition.

validate_asyn_ports()

Validate that all components of pipeline are known

Raises:

RuntimeError – If there any input ports to known plugins where the source is not known to ophyd

visualize_asyn_digraph(ax=None, *args, **kwargs)

This generates a figure showing the current asyn port layout.

This method generates a plot showing all of the currently enabled Areadetector plugin asyn ports and their relationships. The current ports and relationships are found using self.get_asyn_digraph.

Parameters:
  • ax (matplotlib axes) – if None (default) then a new figure is created otherwise it is plotted on the specified axes.

  • *args (networkx.draw_networkx args and kwargs.) – For the allowed args and kwargs see the networkx.draw_networkx documentation

  • **kwargs (networkx.draw_networkx args and kwargs.) –

    For the allowed args and kwargs see the networkx.draw_networkx documentation

Attributes

ad_root
configuration_attrs
connected
hints
kind
num_images_per_point

The number of images to save at each point in the scan.

subscriptions: ClassVar[FrozenSet[str]] = frozenset({'acq_done'})