AmiDet API

class pcdsdaq.ami.AmiDet(prefix, *, name, filter_string=None, min_duration=0, normalize=True)

Detector that gets data from pyami scalars.

The data will be in the form of an accumulated mean, rms, and number of entries used in the calculations. The raw data is not avaiable via pyami.

This only supports scalars. The array features are known to crash both the python session and active ami clients, so don’t use them.

Parameters:
  • prefix (str) – The ami name to use to retrieve the data.

  • name (str, required keyword) – The shorter name to use to label the data.

  • filter_str (str, optional) – If provided, we’ll filter the incoming data using this filter string. If omitted or None, we’ll use the last set_l3t string. If False, but not None, we’ll do no filtering at all. This includes the empty string.

  • min_duration (float, optional) – If provided, we’ll wait this many seconds before declaring the acquisition as complete. Otherwise, we’ll stop acquring on read.

  • normalize (bool or AmiDet, optional) – Determines the normalization behavior of this detector. The default is True, which means normalize to the current monitor_det. See set_monitor_det. False means do not normalize. You can also pass in any other detector to normalize against something that is not the monitor_det.

get(*args, **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.

put(*args, **kwargs)

Put a value to all components of the device

Keyword arguments are passed onto each signal.put()

Parameters:

dev_t (DeviceTuple or tuple) – The device tuple with the value(s) to put (see get_device_tuple)

read(*args, **kwargs)

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 – The keys must be strings and the values must be dict-like with the keys {'value', 'timestamp'}

Return type:

OrderedDict

set_det_filter(*args, event_codes=None, operator='&')

Set the filter on this detector only.

This lets you override the l3t filter for a single AmiDet. Call with no arguments to revert to the last l3t filter. Call with a simple False to disable filtering on this detector. Call as you would to set the l3t filter to setup a normal filtering override.

Parameters:
  • *args ((AmiDet, float, float) n times) – A sequence of (detector, low, high), which create filters that make sure the detector is between low and high. If instead, the first argument is False, we’ll disable filtering on this detector.

  • event_codes (list, optional) – A list of event codes to include in the filter. l3pass will be when the event code is present.

  • operator (str, optional) – The operator for combining the detector ranges and event codes. This can either be | to or the conditions together, so l3pass will happen if any filter passes, or it can be left at the default & to and the conditions together, so l3pass will only happen if all filters pass.

stage()

Called early in a bluesky scan to initialize the pyami.Entry object.

Note that pyami.Entry objects begin accumulating data immediately.

This will be when the filter_string is used to determine how to filter the pyami data. Setting the filter_string after stage is called will have no effect.

Internally this creates a new pyami.Entry object. These objects start accumulating data immediately.

trigger()

Called during a bluesky scan to clear the accumulated pyami data.

This must be done because the pyami.Entry objects continually accumulate data forever. You can stop it by deleting the objects as in unstage, and you can clear it here to at least start from a clean slate.

If min_duration is zero, this will return a status already marked done and successful. Otherwise, this will return a status that will be marked done after min_duration seconds.

If there is a normalization detector in use and it has not been staged, it will be staged during the first trigger in a scan.

unstage()

Called late in a bluesky scan to remove the pyami.Entry object and the monitor.

auto_setup_pyami

Does a best-guess at the ami configuration, if it has not yet been setup.

set_pyami_proxy

Pick the hostname or group to use for the pyami connection.

set_l3t_file

Pick the file to write out for the l3t trigger

set_monitor_det

Designate one AmiDet as the monitor.

set_pyami_filter

Set up the l3t filters.

dets_filter

Return valid l3t/pyami filter strings in a useful format.

basic_filter

Helper function for creating an ami filter string.

evr_filter

Helper function that creates a filter for a certain event code.

concat_filter_strings

Helper function to combine ami filter strings