area_detector_support#
Import: apstools.devices.area_detector_support
Area Detector Support#
|
Alternative to HDF5Plugin: EPICS area detector PV sets file name. |
|
Alternative to JPEGPlugin: EPICS area detector PV sets file name. |
|
Custom class to define image file name from EPICS. |
|
Alternative to TIFFPlugin: EPICS area detector PV sets file name. |
|
Custom class to define HDF5 image file name from EPICS PVs. |
|
intermediate class between AD_EpicsHdf5FileName and AD_EpicsFileNameHDF5Plugin |
|
Custom class to define JPEG image file name from EPICS PVs. |
|
intermediate class between AD_EpicsJPEGFileName and AD_EpicsFileNameJPEGPlugin |
|
Custom class to define TIFF image file name from EPICS PVs. |
|
intermediate class between AD_EpicsTIFFFileName and AD_EpicsFileNameTIFFPlugin |
Naming schemes for area detector frame types. |
|
|
Return AD plugin's Last filename using local filesystem path. |
|
Has area detector pushed an NDarray to the file writer plugin? True or False |
|
Prime this area detector's file writer plugin. |
|
Prime this area detector's file writer plugin. |
|
configure so frames are identified & handled by type (dark, white, or image) |
|
ADCore NDBadPixel, new in AD 3.13. |
|
Update cam support to AD release 3.1.1. |
|
Update cam support to AD release 3.1.1. |
|
Add data acquisition methods to HDF5Plugin. |
|
Variation of ophyd's SingleTrigger mixin supporting AcquireBusy. |
|
Ensure the AD file writing plugin is primed (warmed up), if allowed. |
Module Contents#
- class apstools.devices.area_detector_support.AD_EpicsFileNameHDF5Plugin(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.AD_EpicsFileNameHDF5PluginBases:
ophyd.areadetector.plugins.HDF5Plugin_V34,AD_EpicsHDF5IterativeWriterAlternative to HDF5Plugin: EPICS area detector PV sets file name.
Caution
Caveat emptor applies here. You assume expertise!
Uses
AD_EpicsHdf5FileName.EXAMPLE:
from apstools.devices import CamMixin_V34 from apstools.devices import SimDetectorCam_V34 from apstools.devices import SingleTrigger_V34 from apstools.devices.area_detector_support import AD_EpicsFileNameHDF5Plugin from ophyd import EpicsSignalWithRBV from ophyd.areadetector import ADComponent from ophyd.areadetector import DetectorBase from ophyd.areadetector.plugins import ImagePlugin_V34 as ImagePlugin from ophyd.areadetector.plugins import PvaPlugin_V34 as PvaPlugin import datetime import pathlib IOC = "ad:" IMAGE_DIR = "adsimdet/%Y/%m/%d" AD_IOC_MOUNT_PATH = pathlib.Path("/tmp") BLUESKY_MOUNT_PATH = pathlib.Path("/tmp/docker_ioc/iocad/tmp") # MUST end with a `/`, pathlib will NOT provide it WRITE_PATH_TEMPLATE = f"{AD_IOC_MOUNT_PATH / IMAGE_DIR}/" READ_PATH_TEMPLATE = f"{BLUESKY_MOUNT_PATH / IMAGE_DIR}/" class SimDetector_V34(SingleTrigger_V34, DetectorBase): '''ADSimDetector''' cam = ADComponent(SimDetectorCam_V34, "cam1:") image = ADComponent(ImagePlugin, "image1:") hdf1 = ADComponent( AD_EpicsFileNameHDF5Plugin, "HDF1:", write_path_template=WRITE_PATH_TEMPLATE, read_path_template=READ_PATH_TEMPLATE, ) pva = ADComponent(PvaPlugin, "Pva1:")
- class apstools.devices.area_detector_support.AD_EpicsFileNameJPEGPlugin(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.AD_EpicsFileNameJPEGPluginBases:
ophyd.areadetector.plugins.JPEGPlugin_V34,AD_EpicsJPEGIterativeWriterAlternative to JPEGPlugin: EPICS area detector PV sets file name.
Caution
Caveat emptor applies here. You assume expertise!
Uses
AD_EpicsJpegFileName.EXAMPLE:
from apstools.devices import CamMixin_V34 from apstools.devices import SimDetectorCam_V34 from apstools.devices import SingleTrigger_V34 from apstools.devices.area_detector_support import AD_EpicsFileNameJPEGPlugin from ophyd import EpicsSignalWithRBV from ophyd.areadetector import ADComponent from ophyd.areadetector import DetectorBase from ophyd.areadetector.plugins import ImagePlugin_V34 as ImagePlugin from ophyd.areadetector.plugins import PvaPlugin_V34 as PvaPlugin import datetime import pathlib IOC = "ad:" IMAGE_DIR = "adsimdet/%Y/%m/%d" AD_IOC_MOUNT_PATH = pathlib.Path("/tmp") BLUESKY_MOUNT_PATH = pathlib.Path("/tmp/docker_ioc/iocad/tmp") # MUST end with a `/`, pathlib will NOT provide it WRITE_PATH_TEMPLATE = f"{AD_IOC_MOUNT_PATH / IMAGE_DIR}/" READ_PATH_TEMPLATE = f"{BLUESKY_MOUNT_PATH / IMAGE_DIR}/" class SimDetector_V34(SingleTrigger_V34, DetectorBase): '''ADSimDetector''' cam = ADComponent(SimDetectorCam_V34, "cam1:") image = ADComponent(ImagePlugin, "image1:") jpeg1 = ADComponent( AD_EpicsFileNameHDF5Plugin, "JPEG1:", write_path_template=WRITE_PATH_TEMPLATE, read_path_template=READ_PATH_TEMPLATE, ) pva = ADComponent(PvaPlugin, "Pva1:")
- class apstools.devices.area_detector_support.AD_EpicsFileNameMixin(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.AD_EpicsFileNameMixinBases:
ophyd.areadetector.filestore_mixins.FileStorePluginBaseCustom class to define image file name from EPICS.
Used as part of AD_EpicsFileNameHDF5Plugin.
Caution
Caveat emptor applies here. You assume expertise!
Replace standard ophyd file naming algorithm (where file names are defined as UUID strings, virtually guaranteeing that no existing images files will ever be overwritten).
Caller is responsible for setting values of these Components:
array_counter
auto_increment
auto_save
compression (only HDF)
create_directory
file_name
file_number
file_path
file_template
num_capture
overrides default behavior: Get info from EPICS file writer plugin.
overrides default behavior
stage()Overrides default behavior of parent class.
To allow users to control the file name, we override the
make_filename()method here and we need to override some intervening classes.To allow users to control the file number, we override the
stage()method here and triple-comment out that line, and bring in sections from the methods we are replacing here.It is allowed to set the
file_template="%s%s.h5"so the file name does not include the file number.The image file name is set in
FileStoreBase.make_filename()fromophyd.areadetector.filestore_mixins. This is called (during device staging) fromFileStoreBase.stage()- stage()[source]#
Overrides default behavior of parent class.
Parent class items overridden here:
Sets file_name based on a UUID.
Sets file_path from write_path_template.
Sets file_number to 0.
Set EPICS items before device is staged, then copy EPICS naming template (and other items) to ophyd after staging.
- class apstools.devices.area_detector_support.AD_EpicsFileNameTIFFPlugin(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.AD_EpicsFileNameTIFFPluginBases:
ophyd.areadetector.plugins.TIFFPlugin_V34,AD_EpicsTIFFIterativeWriterAlternative to TIFFPlugin: EPICS area detector PV sets file name.
Caution
Caveat emptor applies here. You assume expertise!
Uses
AD_EpicsTIFFFileName.EXAMPLE:
from apstools.devices import CamMixin_V34 from apstools.devices import SimDetectorCam_V34 from apstools.devices import SingleTrigger_V34 from apstools.devices.area_detector_support import AD_EpicsFileNameTIFFPlugin from ophyd import EpicsSignalWithRBV from ophyd.areadetector import ADComponent from ophyd.areadetector import DetectorBase from ophyd.areadetector.plugins import ImagePlugin_V34 as ImagePlugin from ophyd.areadetector.plugins import PvaPlugin_V34 as PvaPlugin from ophyd.areadetector import SimDetectorCam import datetime import pathlib IOC = "ad:" IMAGE_DIR = "adsimdet/%Y/%m/%d" AD_IOC_MOUNT_PATH = pathlib.Path("/tmp") BLUESKY_MOUNT_PATH = pathlib.Path("/tmp/docker_ioc/iocad/tmp") # MUST end with a `/`, pathlib will NOT provide it WRITE_PATH_TEMPLATE = f"{AD_IOC_MOUNT_PATH / IMAGE_DIR}/" READ_PATH_TEMPLATE = f"{BLUESKY_MOUNT_PATH / IMAGE_DIR}/" class SimDetector_V34(SingleTrigger_V34, DetectorBase): '''ADSimDetector''' cam = ADComponent(SimDetectorCam_V34, "cam1:") image = ADComponent(ImagePlugin, "image1:") tiff1 = ADComponent( AD_EpicsFileNameTIFFPlugin, "TIFF1:", write_path_template=WRITE_PATH_TEMPLATE, read_path_template=READ_PATH_TEMPLATE, ) pva = ADComponent(PvaPlugin, "Pva1:")
- class apstools.devices.area_detector_support.AD_EpicsHDF5IterativeWriter(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.AD_EpicsHDF5IterativeWriterBases:
AD_EpicsHdf5FileName,ophyd.areadetector.filestore_mixins.FileStoreIterativeWriteintermediate class between AD_EpicsHdf5FileName and AD_EpicsFileNameHDF5Plugin
- class apstools.devices.area_detector_support.AD_EpicsHdf5FileName(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.AD_EpicsHdf5FileNameBases:
AD_EpicsFileNameMixinCustom class to define HDF5 image file name from EPICS PVs.
Used as part of AD_EpicsFileNameHDF5Plugin.
- filestore_spec = 'AD_HDF5'#
- class apstools.devices.area_detector_support.AD_EpicsJPEGFileName(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.AD_EpicsJPEGFileNameBases:
AD_EpicsFileNameMixinCustom class to define JPEG image file name from EPICS PVs.
Used as part of AD_EpicsFileNameJPEGPlugin.
- filestore_spec = 'AD_JPEG'#
- class apstools.devices.area_detector_support.AD_EpicsJPEGIterativeWriter(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.AD_EpicsJPEGIterativeWriterBases:
AD_EpicsJPEGFileName,ophyd.areadetector.filestore_mixins.FileStoreIterativeWriteintermediate class between AD_EpicsJPEGFileName and AD_EpicsFileNameJPEGPlugin
- class apstools.devices.area_detector_support.AD_EpicsTIFFFileName(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.AD_EpicsTIFFFileNameBases:
AD_EpicsFileNameMixinCustom class to define TIFF image file name from EPICS PVs.
Used as part of AD_EpicsFileNameTIFFPlugin.
- filestore_spec = 'AD_TIFF'#
- class apstools.devices.area_detector_support.AD_EpicsTIFFIterativeWriter(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.AD_EpicsTIFFIterativeWriterBases:
AD_EpicsTIFFFileName,ophyd.areadetector.filestore_mixins.FileStoreIterativeWriteintermediate class between AD_EpicsTIFFFileName and AD_EpicsFileNameTIFFPlugin
- apstools.devices.area_detector_support.AD_FrameType_schemes#
Naming schemes for area detector frame types.
- apstools.devices.area_detector_support.AD_full_file_name_local(plugin)[source]#
Import:
apstools.devices.area_detector_support.AD_full_file_name_localReturn AD plugin’s Last filename using local filesystem path.
Get the full name, in terms of the bluesky filesystem, for the image file recently-acquired by the area detector plugin.
Return the name as a pathlib object.
PARAMETERS
- plugin obj :
Instance of ophyd area detector file writing plugin.
- apstools.devices.area_detector_support.AD_plugin_primed(plugin)[source]#
Import:
apstools.devices.area_detector_support.AD_plugin_primedHas area detector pushed an NDarray to the file writer plugin? True or False
Returns
Trueimmediately (without connecting to the IOC) when the plugin’sstage_sigswill disable the plugin on stage, because the priming check is irrelevant for a disabled plugin.PARAMETERS
- plugin
obj : area detector plugin to be primed (such as
detector.hdf1)
EXAMPLE:
AD_plugin_primed(detector.hdf1)
Works around an observed issue: #598 NSLS-II/ophyd#598
If detector IOC has just been started and has not yet taken an image with the file writer plugin, then a TimeoutError will occur as the file writer plugin “Capture” is set to 1 (Start). In such case, first acquire at least one image with the file writer plugin enabled.
Also issue in apstools (needs a robust method to detect if primed): BCDA-APS/apstools#464
Since Area Detector release 2.1 (2014-10-14).
The prime process is not needed if you select the LazyOpen feature with Stream mode for the file plugin. LazyOpen defers file creation until the first frame arrives in the plugin. This removes the need to initialize the plugin with a dummy frame before starting capture.
- apstools.devices.area_detector_support.AD_prime_plugin(detector, plugin)[source]#
Import:
apstools.devices.area_detector_support.AD_prime_pluginPrime this area detector’s file writer plugin.
PARAMETERS
- detector
obj : area detector (such as
detector)- plugin
obj : area detector plugin to be primed (such as
detector.hdf1)
EXAMPLE:
AD_prime_plugin(detector, detector.hdf1)
- apstools.devices.area_detector_support.AD_prime_plugin2(plugin)[source]#
Import:
apstools.devices.area_detector_support.AD_prime_plugin2Prime this area detector’s file writer plugin.
Collect and push an NDarray to the file writer plugin. Works with all file writer plugins.
Based on
ophyd.areadetector.plugins.HDF5Plugin.warmup().PARAMETERS
- plugin
obj : area detector plugin to be primed (such as
detector.hdf1)
EXAMPLE:
AD_prime_plugin2(detector.hdf1)
- apstools.devices.area_detector_support.AD_setup_FrameType(prefix, scheme='NeXus')[source]#
Import:
apstools.devices.area_detector_support.AD_setup_FrameTypeconfigure so frames are identified & handled by type (dark, white, or image)
PARAMETERS
- prefix
str : EPICS PV prefix of area detector, such as
13SIM1:- scheme
str : any key in the
AD_FrameType_schemesdictionary
This routine prepares the EPICS Area Detector to identify frames by image type for handling by clients, such as the HDF5 file writing plugin. With the HDF5 plugin, the
FrameTypePV is added to the NDattributes and then used in the layout file to direct the acquired frame to the chosen dataset. TheFrameTypePV value provides the HDF5 address to be used.To use a different scheme than the defaults, add a new key to the
AD_FrameType_schemesdictionary, defining storage values for the fields of the EPICSmbborecord that you will be using.see: https://nbviewer.org/github/BCDA-APS/bluesky_training/blob/main/images_darks_flats.ipynb
EXAMPLE:
AD_setup_FrameType("2bmbPG3:", scheme="DataExchange")
Call this function before creating the ophyd area detector object
use lower-level PyEpics interface
- class apstools.devices.area_detector_support.BadPixelPlugin(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.BadPixelPluginBases:
ophyd.areadetector.plugins.PluginBaseADCore NDBadPixel, new in AD 3.13.
- file_name#
- class apstools.devices.area_detector_support.CamMixin_V34(prefix='', *, name, kind=None, read_attrs=None, configuration_attrs=None, parent=None, child_name_separator='_', connection_timeout=DEFAULT_CONNECTION_TIMEOUT, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.CamMixin_V34Bases:
CamMixin_V3_1_1Update cam support to AD release 3.1.1.
- class apstools.devices.area_detector_support.CamMixin_V3_1_1(prefix='', *, name, kind=None, read_attrs=None, configuration_attrs=None, parent=None, child_name_separator='_', connection_timeout=DEFAULT_CONNECTION_TIMEOUT, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.CamMixin_V3_1_1Bases:
ophyd.CamBaseUpdate cam support to AD release 3.1.1.
- acquire_busy#
- property is_busy#
- offset#
- pool_max_buffers = None#
- wait_for_plugins#
- class apstools.devices.area_detector_support.HDF5FileWriterPlugin(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.HDF5FileWriterPluginBases:
ophyd.areadetector.filestore_mixins.FileStoreHDF5IterativeWrite,ophyd.areadetector.plugins.HDF5Plugin_V34Add data acquisition methods to HDF5Plugin. Ophyd default file names.
File names are based on uuid.uuid4() strings.
stage()- prepare device PVs befor data acquisitionunstage()- restore device PVs after data acquisitiongenerate_datum()- coordinate image storage metadata
- stage()[source]#
Stage the device for data collection.
This method is expected to put the device into a state where repeated calls to
trigger()andread()will ‘do the right thing’.Staging not idempotent and should raise
RedundantStagingif staged twice without an intermediateunstage().This method should be as fast as is feasible as it does not return a status object.
The return value of this is a list of all of the (sub) devices stage, including it’s self. This is used to ensure devices are not staged twice by the
RunEngine.This is an optional method, if the device does not need staging behavior it should not implement stage (or unstage).
Returns#
- deviceslist
list including self and all child devices staged
- class apstools.devices.area_detector_support.SimDetectorCam_V34(prefix='', *, name, kind=None, read_attrs=None, configuration_attrs=None, parent=None, child_name_separator='_', connection_timeout=DEFAULT_CONNECTION_TIMEOUT, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.SimDetectorCam_V34Bases:
CamMixin_V34,ophyd.SimDetectorCamAdds triggering configuration and AcquireBusy support.
- nd_attr_status#
- class apstools.devices.area_detector_support.SingleTrigger_V34(*args, **kwargs)[source]#
Import:
apstools.devices.area_detector_support.SingleTrigger_V34Bases:
ophyd.SingleTriggerVariation of ophyd’s SingleTrigger mixin supporting AcquireBusy.
- apstools.devices.area_detector_support.ensure_AD_plugin_primed(plugin, allow=False)[source]#
Import:
apstools.devices.area_detector_support.ensure_AD_plugin_primedEnsure the AD file writing plugin is primed (warmed up), if allowed.
This function primes the plugin only if it is deemed necessary (for the use by ophyd).
PARAMETERS
- plugin
obj : area detector plugin to be primed (such as
detector.hdf1)- allow
bool : (default:
False) Should the detector be primed? This keyword argument might be provided by a local configuration setting, controlled externally, such as from configuration file or other ophyd Signal.
EXAMPLE:
from apstools.devices import ensure_AD_plugin_primed ensure_AD_plugin_primed(det.hdf1, True) # or from a boolean python object from local_configuration_settings import ok_to_prime ensure_AD_plugin_primed(det.hdf1, allow=ok_to_prime)
An area detector file writing plugin is primed (as considered by ophyd) if the plugin’s image array parameters (size, number of bits, & color mode) match those configured in the cam. This agreement is required by the bluesky RunEngine (via
area_detector_handlers) to generate a descriptor document for any ensuing image events.Use with these area detector file writing plugins (maybe others):
HDF5Plugin
JPEGPlugin
NetCDFPlugin
TIFFPlugin
Even with
lazy_open=1, ophyd (viaarea_detector_handlers) checks if the area detector file writing plugin has been primed.See also
ophyd.areadetector.plugins.UnprimedPlugin: bluesky/ophyd