예제 #1
0
def test_deregister():
    test_reg = fsa._FS_SINGLETON.handler_reg
    test_spec_name = str(uuid.uuid4())
    fsa.register_handler(test_spec_name, SynHandlerMod)
    assert test_reg[test_spec_name] is SynHandlerMod
    fsa.deregister_handler(test_spec_name)
    assert test_spec_name not in test_reg
예제 #2
0
    def dtype(self):
        return self.pixel_type
    
    @property
    def shape(self):
        return self.frame_shape

class LazyEigerHandler(HandlerBase):
    specs = {'AD_EIGER'} | HandlerBase.specs
    def __init__(self, fpath, frame_per_point, mapping=None):
        # create pims handler
        self.vals_dict = EIGER_MD_DICT.copy()
        if mapping is not None:
            self.vals_dict.update(mapping)
        self._base_path = fpath
        self.fpp = frame_per_point

    def __call__(self, seq_id):
        import h5py
        master_path = '{}_{}_master.h5'.format(self._base_path, seq_id)
        md = {}
        print('hdf5 path = %s' % master_path)
        with h5py.File(master_path, 'r') as f:
            md = {k: f[v].value for k, v in self.vals_dict.items()}
            
        # TODO Return a multi-dimensional PIMS seq.
        return FixedEigerImages(master_path, md)

deregister_handler('AD_EIGER')
register_handler('AD_EIGER', LazyEigerHandler)
예제 #3
0
        # 1  -- gap
        # 2  -- dead
        # 4  -- under-responsive
        # 8  -- over-responsive
        # 16 -- noisy
        pixel_mask = md['pixel_mask']
        pixel_mask[pixel_mask > 0] = 1
        pixel_mask[pixel_mask == 0] = 2
        pixel_mask[pixel_mask == 1] = 0
        pixel_mask[pixel_mask == 2] = 1
        md['framerate'] = 1. / md['frame_time']
        # TODO Return a multi-dimensional PIMS seq
        return FixedEigerImages(master_path, md)


deregister_handler('AD_EIGER')
_HANDLER_CACHE.clear()
register_handler('AD_EIGER', LazyEigerHandler)


def print_attrs(name, obj):
    print(name)
    for key, val in obj.attrs.items():
        print("    %s: %s" % (key, val))


###################################################
##for  image process
###################################################

예제 #4
0
def teardown_module(module):
    fs_teardown()
    deregister_handler('AD_HDF5')
    deregister_handler('AD_HDF5_SWMR')
    deregister_handler('AD_HDF5_TS')
    deregister_handler('AD_HDF5_SWMR_TS')
예제 #5
0

class FixedAreaDetectorTiffHandler(HandlerBase):
    specs = {'AD_TIFF'} | HandlerBase.specs
    def __init__(self, fpath, template, filename, frame_per_point=1):
        self._path = fpath
        self._fpp = frame_per_point
        self._template = template.replace('_%6.6d', '*')
        self._filename = self._template % (self._path,
                filename)
        self._image_sequence = pims.ImageSequence(self._filename)
    def __call__(self, point_number):
        start = int(point_number * self._fpp)
        stop = int((point_number + 1) * self._fpp)
        if stop > len(self._image_sequence):
            # if asking for an image past the end, make sure we have an up
            # to
            # date list of the existing files
            self._image_sequence = pims.ImageSequence(self._filename)
            if stop > len(self._image_sequence):
                # if we _still_ don't have enough files, raise
                raise IntegrityError("Seeking Frame {0} out of {1} "
                " frames.".format(stop, len(self._image_sequence)))
        return np.asarray(list(self._image_sequence[start:stop])).squeeze()


import databroker  # so that built-in handlers are registered
from filestore.api import deregister_handler, register_handler
deregister_handler('AD_TIFF')
register_handler('AD_TIFF', FixedAreaDetectorTiffHandler)
예제 #6
0
        # 1  -- gap
        # 2  -- dead
        # 4  -- under-responsive
        # 8  -- over-responsive
        # 16 -- noisy
        pixel_mask = md["pixel_mask"]
        pixel_mask[pixel_mask > 0] = 1
        pixel_mask[pixel_mask == 0] = 2
        pixel_mask[pixel_mask == 1] = 0
        pixel_mask[pixel_mask == 2] = 1
        md["framerate"] = 1.0 / md["frame_time"]
        # TODO Return a multi-dimensional PIMS seq
        return FixedEigerImages(master_path, md)


deregister_handler("AD_EIGER")
_HANDLER_CACHE.clear()
register_handler("AD_EIGER", LazyEigerHandler)


def print_attrs(name, obj):
    print(name)
    for key, val in obj.attrs.items():
        print("    %s: %s" % (key, val))


###################################################
##for  image process
###################################################

예제 #7
0
def teardown():
    deregister_handler('AD_HDF5')
    db_disconnect()
    # if we know about a connection, drop the database
    if conn:
        conn.drop_database(db_name)
예제 #8
0
def teardown_module(module):
    fs_teardown()
    deregister_handler('syn-mod')