Skip to content

Commit

Permalink
ENH: use very custom hdf5 filestore plugins
Browse files Browse the repository at this point in the history
Do not assume each point as the same number of frames, requires
changes to the schema of the resource and datum + a new handler.
  • Loading branch information
tacaswell committed Feb 19, 2020
1 parent 017ca39 commit ee1e759
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions startup/10-area-detector.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ophyd import Component as Cpt
from ophyd.areadetector.filestore_mixins import FileStoreHDF5IterativeWrite
from ophyd.areadetector.filestore_mixins import (
FileStoreHDF5IterativeWrite, FileStoreIterativeWrite, FileStorePluginBase)
from ophyd import EpicsSignal, AreaDetector
from ophyd import (
ImagePlugin,
Expand Down Expand Up @@ -40,9 +41,19 @@ def ensure_nonblocking(self):
cpt.ensure_nonblocking()


class HDF5PluginWithFileStore(HDF5Plugin, FileStoreHDF5IterativeWrite):
class HDF5PluginWithFileStore(HDF5Plugin, FileStorePluginBase):
# AD v2.2.0 (at least) does not have this. It is present in v1.9.1.
file_number_sync = None
filestore_spec = 'AD_HDF5_v1'

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# can not be class level because parent sets this in __init__ :(
self.stage_sigs.update([('file_template', '%s%s_%6.6d.h5'),
('file_write_mode', 'Stream'),
('capture', 1)
])
self._current_index = 0

def get_frames_per_point(self):
return self.parent.cam.num_images.get()
Expand All @@ -52,6 +63,21 @@ def make_filename(self):
self._ret = super().make_filename()
return self._ret

def stage(self):
super().stage()
self._current_index = 0
res_kwargs = {}
self._generate_resource(res_kwargs)

def generate_datum(self, key, timestamp, datum_kwargs):
step = self.get_frames_per_point()
self._current_index += step

datum_kwargs = datum_kwargs or {}
datum_kwargs.update({'offset': self._current_index,
'num_frames': step})
return super().generate_datum(key, timestamp, datum_kwargs)


class AndorKlass(SingleTriggerV33, DetectorBase):
cam = Cpt(AndorCam, "cam1:")
Expand Down

0 comments on commit ee1e759

Please sign in to comment.