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
def __init__(self, topic, **kwargs): """Initialization. :param str topic: topic, e.g. SCS, MID, DET, etc. """ super().__init__() self._topic_st = topic self.setWindowTitle(f"EXtra-foam {__version__} - " f"special suite - {self._title}") self._com_ctrl_st = _SharedCtrlWidgetS(**kwargs) cv = Condition() catalog = SourceCatalog() queue = SimpleQueue(maxsize=1) self._client_st = self._client_instance_type(queue, cv, catalog) self._worker_st = self._worker_instance_type(queue, cv) self._worker_thread_st = QThread() self._ctrl_widget_st = self._ctrl_instance_type(topic) if isinstance(self._client_st, QThreadFoamClient): self._com_ctrl_st.updateDefaultPort(config["EXTENSION_PORT"]) # book-keeping plot widgets self._plot_widgets_st = WeakKeyDictionary() # book-keeping ImageView widget self._image_views_st = WeakKeyDictionary() self._data_st = None self._gui_logger_st = GuiLogger(parent=self) logger.addHandler(self._gui_logger_st) self._cw_st = QSplitter() self._cw_st.setChildrenCollapsible(False) self.setCentralWidget(self._cw_st) self._plot_timer_st = QTimer() self._plot_timer_st.setInterval(config["GUI_PLOT_UPDATE_TIMER"]) self._plot_timer_st.timeout.connect(self.updateWidgetsST) # init UI self._left_panel_st = QSplitter(Qt.Vertical) self._left_panel_st.addWidget(self._com_ctrl_st) self._left_panel_st.addWidget(self._ctrl_widget_st) self._left_panel_st.addWidget(self._gui_logger_st.widget) self._left_panel_st.setChildrenCollapsible(False) self._cw_st.addWidget(self._left_panel_st) # init Connections self._client_st.log.logOnMainThread(self) self._worker_st.log.logOnMainThread(self) # start/stop/reset self._com_ctrl_st.start_btn.clicked.connect(self._onStartST) self._com_ctrl_st.stop_btn.clicked.connect(self._onStopST) self._com_ctrl_st.reset_btn.clicked.connect(self._onResetST) # dark operation self._com_ctrl_st.record_dark_btn.toggled.connect( self._worker_st.onRecordDarkToggledST) self._com_ctrl_st.record_dark_btn.toggled.emit( self._com_ctrl_st.record_dark_btn.isChecked()) self._com_ctrl_st.load_dark_run_btn.clicked.connect( self._onSelectDarkRunDirectoryST) self._com_ctrl_st.remove_dark_btn.clicked.connect( self._worker_st.onRemoveDark) self._com_ctrl_st.dark_subtraction_cb.toggled.connect( self._worker_st.onSubtractDarkToggledST) self._com_ctrl_st.dark_subtraction_cb.toggled.emit( self._com_ctrl_st.dark_subtraction_cb.isChecked()) self._com_ctrl_st.auto_level_btn.clicked.connect(self._onAutoLevelST) # ROI ctrl self._com_ctrl_st.roi_geometry_change_sgn.connect( self._worker_st.onRoiGeometryChange)