def _create_catalog(self, src_name, key_name): catalog = SourceCatalog() src = f'{src_name} {key_name}' catalog.add_item( SourceItem('AGIPD', src_name, [], key_name, slice(None, None), None)) return src, catalog
def _create_catalog(self, src_name, key_name, n_modules=1): catalog = SourceCatalog() src = f'{src_name} {key_name}' modules = [] if n_modules == 1 else list(range(1, n_modules + 1)) catalog.add_item( SourceItem('JungFrau', src_name, modules, key_name, None, None, 1)) return src, catalog
def _create_catalog(self, mapping): """Generate source catalog. :param dict mapping: a dictionary with keys being the device categories and values being a list of (device ID, property). """ catalog = SourceCatalog() for ctg, srcs in mapping.items(): for src, ppt, ktype in srcs: catalog.add_item( SourceItem(ctg, src, [], ppt, None, None, ktype)) return catalog
def _create_catalog(self, src_name, key_name): catalog = SourceCatalog() src = f'{src_name} {key_name}' catalog.add_item(SourceItem('BaslerCamera', src_name, [], key_name, None, None)) return src, catalog
def data_with_assembled(cls, tid, shape, *, src_type=DataSource.BRIDGE, dtype=config['SOURCE_PROC_IMAGE_DTYPE'], gen='random', slicer=None, with_xgm=False, with_digitizer=False, **kwargs): imgs = cls._gen_images(gen, shape, dtype) processed = ProcessedData(tid) processed.image = ImageData.from_array(imgs, **kwargs) if imgs.ndim == 2: slicer = None else: slicer = slice(None, None) if slicer is None else slicer src_list = [('Foo', 'oof'), ('Bar', 'rab'), ('karaboFAI', 'extra_foam')] src_name, key_name = random.choice(src_list) catalog = SourceCatalog() ctg = 'ABCD' src = f'{src_name} {key_name}' catalog.add_item(SourceItem(ctg, src_name, [], key_name, slicer, None)) catalog._main_detector = src n_pulses = processed.n_pulses if with_xgm: # generate XGM data processed.pulse.xgm.intensity = np.random.rand(n_pulses) processed.xgm.intensity = random.random() processed.xgm.x = random.random() processed.xgm.y = random.random() if with_digitizer: # generate digitizer data digitizer = processed.pulse.digitizer digitizer.ch_normalizer = 'B' for ch in digitizer: digitizer[ch].pulse_integral = np.random.rand(n_pulses) data = { 'processed': processed, 'catalog': catalog, 'meta': { src: { 'timestamp.tid': tid, 'source_type': src_type, } }, 'raw': { src: dict() }, 'assembled': { 'data': imgs, } } if imgs.ndim == 2: data['assembled']['sliced'] = imgs else: data['assembled']['sliced'] = imgs[slicer] return data, processed
def _create_catalog(self, src_name, key_name): catalog = SourceCatalog() src = f'{src_name} {key_name}' catalog.add_item( SourceItem('FastCCD', src_name, [], key_name, None, None, 1)) return src, catalog
def _create_catalog(self, mapping): catalog = SourceCatalog() for ctg, src in mapping.items(): catalog.add_item(SourceItem(ctg, src, [], "ppt", None, None)) return catalog