def __init__(self, widget): super().__init__() self.widget = widget self.beamline = Registry.get_utility(IBeamline) self.collector = DataCollector() self.collecting = False self.stopping = False self.pause_info = False self.start_time = 0 self.frame_monitor = None self.first_frame = True self.monitors = {} self.image_viewer = ImageViewer() self.microscope = Registry.get_utility(IMicroscope) self.run_editor = datawidget.RunEditor() self.editor_frame = arrowframe.ArrowFrame() self.editor_frame.add(self.run_editor.data_form) self.widget.datasets_overlay.add_overlay(self.editor_frame) self.run_store = Gio.ListStore(item_type=datawidget.RunItem) self.run_store.connect('items-changed', self.on_runs_changed) self.collector.connect('done', self.on_done) self.collector.connect('paused', self.on_pause) self.collector.connect('stopped', self.on_stopped) self.collector.connect('progress', self.on_progress) self.collector.connect('started', self.on_started) Registry.add_utility(IDatasets, self) self.setup()
def __init__(self, view, widget): super().__init__() self.view = view self.widget = widget # housekeeping self.start_time = 0 self.pause_dialog = None self.results = {} self.form = RasterForm( widget, fields=self.Fields, prefix='raster', persist=True, disabled=('lines', 'frames') ) self.beamline = Registry.get_utility(IBeamline) self.microscope = Registry.get_utility(IMicroscope) self.sample_store = Registry.get_utility(ISampleStore) self.collector = RasterCollector() self.manager = RasterResultsManager(self.view, colormap=self.microscope.props.grid_cmap) # signals self.microscope.connect('notify::grid-params', self.on_grid_changed) self.connect('notify::state', self.on_state_changed) self.beamline.aperture.connect('changed', self.on_aperture) self.beamline.goniometer.omega.connect('changed', self.on_angle) self.collector.connect('done', self.on_done) self.collector.connect('paused', self.on_pause) self.collector.connect('stopped', self.on_stopped) self.collector.connect('progress', self.on_progress) self.collector.connect('started', self.on_started) self.collector.connect('result', self.on_results) self.setup()
def __init__(self, view): super().__init__() self.view = view self.beamline = Registry.get_utility(IBeamline) self.sample_store = Registry.get_utility(ISampleStore) self.model = self.sample_store.sort_model self.auto_queue = self.model.filter_new() self.auto_queue.set_visible_func(self.queued_data) self.view.set_model(self.auto_queue) self.setup()
def __init__(self, console=False): from mxdc.conf import settings super().__init__() self.console = console self.config_files = settings.get_configs() self.registry = {} self.config = DotDict() self.lock = threading.RLock() self.logger = get_module_logger(self.__class__.__name__) self.load_config() Registry.add_utility(IBeamline, self)
def __init__(self, view, widget): super().__init__() self.model = Gtk.ListStore(*self.Data.TYPES) self.search_model = self.model.filter_new() self.search_model.set_visible_func(self.search_data) self.sort_model = Gtk.TreeModelSort(model=self.search_model) self.group_model = Gio.ListStore(item_type=GroupItem) self.group_registry = {} self.prefetch_pending = False self.initializing = True # initialize properties self.props.next_sample = {} self.props.current_sample = {} self.props.ports = set() self.props.containers = set() cache = load_cache('samples') self.props.cache = set() if not cache else set(cache) self.filter_text = '' self.view = view self.widget = widget self.view.set_model(self.sort_model) self.beamline = Registry.get_utility(IBeamline) self.setup() self.model.connect('row-changed', self.on_sample_row_changed) self.widget.samples_selectall_btn.connect('clicked', self.on_select_all) self.widget.samples_selectnone_btn.connect('clicked', self.on_unselect_all) self.view.connect('key-press-event', self.on_key_press) self.widget.samples_reload_btn.connect('clicked', lambda x: self.import_mxlive()) self.beamline.automounter.connect('sample', self.on_sample_mounted) self.beamline.automounter.connect('next-port', self.on_prefetched) self.beamline.automounter.connect('ports', self.update_states) self.widget.samples_mount_btn.connect('clicked', lambda x: self.mount_action()) self.widget.samples_dismount_btn.connect( 'clicked', lambda x: self.dismount_action()) self.widget.samples_search_entry.connect('search-changed', self.on_search) self.widget.mxdc_main.connect('realize', self.import_mxlive) self.connect('notify::cache', self.on_cache) self.connect('notify::current-sample', self.on_cur_changed) self.connect('notify::next-sample', self.on_next_changed) Registry.add_utility(ISampleStore, self)
def __init__(self, root, threshold=0.5): super().__init__(threshold=threshold) self.name = root self.x = self.add_pv(f'{root}:x') self.y = self.add_pv(f'{root}:y') self.score = self.add_pv(f'{root}:score') self.w = self.add_pv(f'{root}:w') self.h = self.add_pv(f'{root}:h') self.label = self.add_pv(f'{root}:label') self.status = self.add_pv(f'{root}:status') self.score.connect('changed', self.on_score) Registry.add_utility(ICenter, self)
def __init__(self, widget): super().__init__() self.widget = widget self.beamline = Registry.get_utility(IBeamline) self.sample_store = Registry.get_utility(ISampleStore) self.collector = SingleCollector() self.form = gui.FormManager(self, fields=self.Fields, prefix=self.prefix, persist=True) self.humidifier = self.beamline.humidifier self.labels = {} self.limits = {} self.formats = {} self.entries = {} self.diff_devices = { 'cell': SimPositioner('Max Cell Dimension', pos=numpy.nan, delay=False, noise=0), 'score': SimPositioner('Diffraction Score', pos=numpy.nan, delay=False, noise=0), 'resolution': SimPositioner('Diffraction Resolution', pos=numpy.nan, delay=False, noise=0), } self.plotter = ticker.ChartManager(interval=500, view=240) self.setup() self.humidifier.connect('active', self.activate) self.collector.connect('done', self.on_collector_done) self.collector.connect('result', self.on_collector_result) self.humidity_diff_btn.connect('clicked', self.on_collect) self.plot_options = { 'cell': self.humidity_cell_option, 'drop': self.humidity_drop_option, 'score': self.humidity_score_option, 'resolution': self.humidity_resolution_option } for key, option in list(self.plot_options.items()): option.connect('toggled', self.on_plot_option)
def configure(self, method='loop'): from mxdc.controllers.samplestore import ISampleStore from mxdc.engines.rastering import IRasterCollector self.sample_store = Registry.get_utility(ISampleStore) self.collector = Registry.get_utility(IRasterCollector) self.device = Registry.get_utility(ICenter) if method in self.methods: self.method = self.methods[method] elif self.device: self.method = self.center_external() else: self.method = self.center_loop
def __init__(self): super().__init__() self.pending_results = set() self.runs = [] self.results = {} self.config = {} self.total_frames = 0 self.count = 0 self.analyst = Registry.get_utility(IAnalyst) self.analysis_link = self.beamline.detector.connect( 'progress', self.on_frame_collected) self.unwatch_frames() Registry.add_utility(IRasterCollector, self)
def __init__(self, widget, store): super().__init__() self.widget = widget self.store = store self.beamline = Registry.get_utility(IBeamline) self.setup() self.failure_dialog = None self.messages = [(None, "")] self.props.layout = {} self.props.ports = {} self.props.containers = [] self.beamline.automounter.connect('status', self.on_state_changed) self.beamline.automounter.connect('ports', self.on_layout_changed) self.beamline.automounter.connect('layout', self.on_layout_changed) self.beamline.automounter.connect('containers', self.on_layout_changed) self.beamline.automounter.connect('sample', self.on_layout_changed) self.beamline.automounter.connect('failure', self.on_failure_changed) self.store.connect('notify::ports', self.on_layout_changed) self.store.connect('notify::containers', self.on_layout_changed) self.beamline.automounter.connect('active', self.on_state_changed) self.beamline.automounter.connect('busy', self.on_state_changed) self.beamline.automounter.connect('health', self.on_state_changed) self.beamline.automounter.connect('message', self.on_messages)
def __init__(self): super().__init__() self.pause_message = '' self.total = 1 self.collector = Registry.get_utility(IDataCollector) self.centering = centering.Centering()
def use_strategy(self, *args, **kwargs): strategy = self.reports.strategy dataset_controller = Registry.get_utility(IDatasets) if strategy: default_rate = self.beamline.config[ 'default_delta'] / self.beamline.config['default_exposure'] exposure_rate = strategy.get('exposure_rate', default_rate) max_delta = strategy.get('max_delta', self.beamline.config['default_delta']) run = { 'attenuation': strategy.get('attenuation', 0.0), 'start': strategy.get('start_angle', 0.0), 'range': strategy.get('total_angle', 180), 'resolution': strategy.get('resolution', 2.0), 'exposure': max_delta / exposure_rate, 'delta': max_delta, 'name': 'data', } dataset_controller.add_runs([run]) data_page = self.widget.main_stack.get_child_by_name('Data') self.widget.main_stack.child_set(data_page, needs_attention=True) self.widget.notifier.notify( "Datasets added. Switch to Data page to proceed.")
def _scan_sync(self): self.set_state(message='Scanning ...', busy=True) with self._lock: self._scanning = True bl = Registry.get_utility(IBeamline) config = self.omega.get_config() logger.debug('Starting scan at: %s' % datetime.now().isoformat()) logger.debug('Moving to scan starting position') bl.fast_shutter.open() self.omega.move_to(self.settings['angle'] - 0.05, wait=True) scan_speed = float(self.settings['range']) / self.settings['time'] self.omega.configure(speed=scan_speed) self.trigger_index = 0 self.trigger_positions = numpy.arange( self.settings['angle'], self.settings['angle'] + self.settings['range'], self.settings['range'] / self.settings.get('frames', 1)) if self.supports(GonioFeatures.TRIGGERING): GLib.idle_add(self.send_triggers) self.omega.move_to(self.settings['angle'] + self.settings['range'] + 0.05, wait=True) bl.fast_shutter.close() self.omega.configure(speed=config['speed']) logger.debug('Scan done at: %s' % datetime.now().isoformat()) self.set_state(message='Scan complete!', busy=False) self._scanning = False
def __init__(self): super().__init__() self.run_list = [] self.runs = [] self.results = [] self.config = {} self.total = 1 self.current_wedge = None self.analyst = Registry.get_utility(IAnalyst) self.progress_link = self.beamline.detector.connect( 'progress', self.on_progress) self.unwatch_frames() #self.beamline.synchrotron.connect('ready', self.on_beam_change) Registry.add_utility(IDataCollector, self)
def __init__(self, size=680): super(ImageViewer, self).__init__() self.setup_gui() self.set(0.5, 0.5, 1, 1) self.dataset = None self.canvas = None self.size = size self.following = False self.collecting = False self.following_id = None self.last_follow_time = 0 self.directory = None self.reflections = [] self.build_gui() Registry.add_utility(IImageViewer, self)
def __init__(self, widget): self.plotter = plotter.Plotter() self.fit = Fit(self.plotter) self.widget = widget self.widget.scan_box.pack_start(self.plotter, True, True, 0) self.axis = self.plotter.axis.get('default') self.start_time = 0 self.scan = None self.scan_links = [] self.scan_callbacks = { 'started': self.on_start, 'new-point': self.on_new_point, 'progress': self.on_progress, 'done': self.on_done, 'error': self.on_error, 'stopped': self.on_stop, 'new-row': self.on_new_row, } Registry.add_utility(IScanPlotter, self)
def __init__(self, widget): super().__init__() self.widget = widget self.beamline = Registry.get_utility(IBeamline) self.sample_store = None self.reports = ReportManager(self.widget.proc_reports_view) self.analyst = Analyst(self.reports) self.browser = WebKit2.WebView() self.options = {} self.setup()
def __init__(self): super().__init__() self.pending_results = set() self.runs = [] self.results = {} self.config = {} self.total_frames = 0 self.count = 0 self.analyst = Registry.get_utility(IAnalyst)
def __init__(self, widget): super().__init__() self.timeout_id = None self.max_fps = 20 self.fps_update = 0 self.video_ready = False self.queue_overlay() self.overlay_surface = None self.overlay_ctx = None self.props.grid = None self.props.grid_xyz = None self.props.points = [] self.props.grid_bbox = [] self.props.grid_scores = {} self.props.grid_params = {} self.props.grid_state = self.GridState.PENDING self.props.grid_cmap = colors.ColorMapper(min_val=0, max_val=100) self.props.tool = self.ToolState.DEFAULT self.prev_tool = self.tool self.tool_cursors = { self.ToolState.DEFAULT: None, self.ToolState.CENTERING: Gdk.Cursor.new_from_name(Gdk.Display.get_default(), 'pointer'), self.ToolState.GRID: Gdk.Cursor.new_from_name(Gdk.Display.get_default(), 'cell'), self.ToolState.MEASUREMENT: Gdk.Cursor.new_from_name(Gdk.Display.get_default(), 'crosshair'), } self.ruler_box = numpy.array([[0, 0], [0, 0]]) self.widget = widget self.beamline = Registry.get_utility(IBeamline) self.camera = self.beamline.sample_video self.centering = centering.Centering() self.setup() Registry.add_utility(IMicroscope, self) self.load_from_cache()
def __init__(self, widget): super().__init__() self.widget = widget self.beamline = Registry.get_utility(IBeamline) self.cryojet = self.beamline.cryojet self.stopped = True self.labels = {} self.limits = {} self.formats = {} self.setup() self._animation = GdkPixbuf.PixbufAnimation.new_from_resource("/org/mxdc/data/active_stop.gif")
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # update converters based on beamline configuration self.beamline = Registry.get_utility(IBeamline) self.fields['energy'].set_converter( Validator.Float(*self.beamline.config['energy_range'], self.beamline.config['default_energy']) ) self.fields['distance'].set_converter( Validator.Float(*self.beamline.config['distance_limits'], self.beamline.config['default_distance']) ) self.exposure_rate = 1.
def __init__(self): self.setup_gui() self.beamline = Registry.get_utility(IBeamline) self.points = Gtk.ListStore(int, str, object) self.form = DataForm(self, fields=self.Fields, prefix='data', persist=False, disabled=self.disabled) self.new_run = True self.run_index = 0 self.item = None self.item_links = [] self.handlers = {} self.build_gui() self.exposure_rate = 1.0 self.dir_template_btn.connect('clicked', self.on_dir_template)
def __init__(self, widget): super().__init__() self.widget = widget self.props.ports = {} self.props.containers = {} self.beamline = Registry.get_utility(IBeamline) self.microscope = microscope.Microscope(self.widget) self.cryo_tool = cryo.CryoController(self.widget) self.sample_dewar = automounter.DewarController(self.widget, self) self.sample_dewar.connect('selected', self.on_dewar_selected) self.beamline.automounter.connect('sample', self.on_sample_mounted) self.setup()
def __init__(self, app_window, container): super().__init__() self.app = app_window self.container = container # fetch and add diagnostics self.diagnostics = [ DiagnosticDisplay(diagnostic, self.app.notifier) for diagnostic in Registry.get_subscribers(IDiagnostic) ] for diagnostic in self.diagnostics: self.container.add(diagnostic) self.container.show_all()
def __init__(self, widget): self.widget = widget self.beamline = Registry.get_utility(IBeamline) self.messages = Gio.ListStore(item_type=Message) self.configs = {} self.add_avatars() self.widget.chat_messages.bind_model(self.messages, self.create_message) self.widget.chat_user_fbk.set_text(misc.get_project_name().upper()) self.widget.avatar_box.connect('child-activated', self.select_avatar) self.widget.chat_config_btn.set_popover(self.widget.chat_avatars_pop) self.widget.chat_msg_entry.connect('activate', self.send_message) self.widget.chat_messages.connect('size-allocate', self.adjust_view) self.beamline.messenger.connect('message', self.show_message) self.beamline.messenger.connect('config', self.update_configs) self.configs = {}
def __init__(self, widget): super().__init__() self.widget = widget self.beamline = Registry.get_utility(IBeamline) self.sample_store = Registry.get_utility(ISampleStore) self.plotter = plotter.Plotter(xformat='%g', dpi=90) min_energy, max_energy = self.beamline.config['energy_range'] self.edge_selector = periodictable.EdgeSelector( min_energy=min_energy, max_energy=max_energy, xrf_offset=self.beamline.config['xrf_energy_offset']) self.xrf_scanner = XRFScanController(XRFScan(), self.plotter, widget, self.edge_selector) self.xas_scanner = XASScanController(XASScan(), self.plotter, widget, self.edge_selector) self.mad_scanner = MADScanController(MADScan(), self.plotter, widget, self.edge_selector) # connect scanners self.status_monitor = common.StatusMonitor( self.widget, devices=(self.mad_scanner.scanner, self.xas_scanner.scanner, self.xrf_scanner.scanner)) self.setup()
def __init__(self, widget): super().__init__() self.init_start = time.time() self.widget = widget self.beamline = Registry.get_utility(IBeamline) self.microscope = microscope.Microscope(self.widget) self.cryo_tool = cryo.CryoController(self.widget) self.sample_store = samplestore.SampleStore(self.widget.samples_list, self.widget) if hasattr(self.beamline, 'humidifier'): self.humidity_controller = humidity.HumidityController(self.widget) self.raster_tool = rastering.RasterController(self.widget.raster_list, self.widget) self.beamline.automounter.connect('sample', self.on_sample_mounted) self.setup()
def on_result_activated(self, view, path, column=None): itr = self.manager.model.get_iter(path) item = self.manager.get_item(itr) if self.manager.model.iter_has_child(itr): self.beamline.goniometer.omega.move_to(item['angle'], wait=True) grid = self.results[item['uuid']] self.microscope.load_grid( grid['grid'], {'origin': grid['config']['origin'], 'angle': grid['config']['angle']}, grid['scores'] ) self.widget.dsets_dir_fbk.set_text(grid['config']['directory']) else: image_viewer = Registry.get_utility(IImageViewer) self.beamline.goniometer.stage.move_xyz(item['x_pos'], item['y_pos'], item['z_pos']) image_viewer.open_frame(item['filename'])
def __init__(self): super().__init__() self.name = misc.normalize_name(self.__class__.__name__) self.config = misc.DotDict({}) # data variables self.data = None self.data_units = {} self.raw_data = [] self.data_row = [] self.data_ids = {} self.data_type = {} self.data_scale = [] self.extending = False self.plotter = Registry.get_utility(IScanPlotter) if self.plotter: self.plotter.link_scan(self)
def __init__(self, scanner, plotter, widget, edge_selector): super().__init__() self.widget = widget self.plotter = plotter self.scanner = scanner self.form = FormManager(self.widget, fields=self.Fields, prefix=self.prefix, persist=True, disabled=self.disabled) self.edge_selector = edge_selector self.sample_store = Registry.get_utility(ISampleStore) self.pause_dialog = None self.start_time = 0 self.scan = None self.scan_links = [] self.results = self.result_class(self.results_view) self.setup()