def _setup_peak_center(self, detectors, isotope, period, center_dac, directions, plot_panel, new, standalone_graph, name): spec = self.spectrometer ref = detectors[0] self.reference_detector = ref self.reference_isotope = isotope if len(detectors) > 1: ad = detectors[1:] else: ad = [] pc = self.peak_center if not pc or new: pc = PeakCenter() pc.trait_set(center_dac=center_dac, period=period, directions=directions, reference_detector=ref, additional_detectors=ad, reference_isotope=isotope, spectrometer=spec) self.peak_center = pc graph = pc.graph graph.name = name if plot_panel: plot_panel.set_peak_center_graph(graph) else: graph.close_func = self.close if standalone_graph: # bind to the graphs close_func # self.close is called when graph window is closed # use so we can stop the timer # set graph window attributes graph.window_title = 'Peak Center {}({}) @ {:0.3f}'.format(ref, isotope, center_dac) graph.window_width = 300 graph.window_height = 250 self.open_view(graph)
def _setup_peak_center(self, detectors, isotope, period, center_dac, directions, plot_panel): spec = self.spectrometer ref = detectors[0] self.reference_detector = ref self.reference_isotope = isotope if len(detectors) > 1: ad = detectors[1:] else: ad = [] pc = self.peak_center if not pc: pc = PeakCenter() pc.trait_set(center_dac=center_dac, period=period, directions=directions, reference_detector=ref, additional_detectors=ad, reference_isotope=isotope, spectrometer=spec) self.peak_center = pc graph = pc.graph if plot_panel: # plot_panel.peak_center_graph = graph plot_panel.set_peak_center_graph(graph) else: # bind to the graphs close_func # self.close is called when graph window is closed # use so we can stop the timer graph.close_func = self.close # set graph window attributes graph.window_title = 'Peak Center {}({}) @ {:0.3f}'.format( ref, isotope, center_dac) graph.window_width = 300 graph.window_height = 250 self.open_view(graph)
def setup_peak_center(self, detector=None, isotope=None, integration_time=1.04, directions='Increase', center_dac=None, plot_panel=None, new=False, standalone_graph=True, name='', show_label=False, window=0.015, step_width=0.0005, min_peak_height=1.0, percent=80, deconvolve=None, use_interpolation=False, interpolation_kind='linear', dac_offset=None, calculate_all_peaks=False, config_name=None, use_configuration_dac=True): if deconvolve is None: n_peaks, select_peak = 1, 1 if dac_offset is not None: use_dac_offset = True spec = self.spectrometer spec.save_integration() self.debug('setup peak center. detector={}, isotope={}'.format(detector, isotope)) self._setup_config() pcc = None if detector is None or isotope is None: self.debug('ask user for peak center configuration') self.peak_center_config.load(dac=spec.magnet.dac) if config_name: self.peak_center_config.active_name = config_name info = self.peak_center_config.edit_traits() if not info.result: return else: pcc = self.peak_center_config.active_item elif config_name: self.peak_center_config.load(dac=spec.magnet.dac) self.peak_center_config.active_name = config_name pcc = self.peak_center_config.active_item if pcc: if not detector: detector = pcc.active_detectors if not isotope: isotope = pcc.isotope directions = pcc.directions integration_time = pcc.integration_time window = pcc.window min_peak_height = pcc.min_peak_height step_width = pcc.step_width percent = pcc.percent use_interpolation = pcc.use_interpolation interpolation_kind = pcc.interpolation_kind n_peaks = pcc.n_peaks select_peak = pcc.select_n_peak use_dac_offset = pcc.use_dac_offset dac_offset = pcc.dac_offset calculate_all_peaks = pcc.calculate_all_peaks if center_dac is None and use_configuration_dac: center_dac = pcc.dac spec.set_integration_time(integration_time) period = int(integration_time * 1000 * 0.9) if not isinstance(detector, (tuple, list)): detector = (detector,) ref = detector[0] ref = self.spectrometer.get_detector(ref) self.reference_detector = ref self.reference_isotope = isotope if center_dac is None: center_dac = self.get_center_dac(ref, isotope) if len(detector) > 1: ad = detector[1:] else: ad = [] pc = self.peak_center if not pc or new: pc = PeakCenter() pc.trait_set(center_dac=center_dac, period=period, window=window, percent=percent, min_peak_height=min_peak_height, step_width=step_width, directions=directions, reference_detector=ref, additional_detectors=ad, reference_isotope=isotope, spectrometer=spec, show_label=show_label, use_interpolation=use_interpolation, interpolation_kind=interpolation_kind, n_peaks=n_peaks, select_peak=select_peak, use_dac_offset=use_dac_offset, dac_offset=dac_offset, calculate_all_peaks=calculate_all_peaks) self.peak_center = pc graph = pc.graph graph.name = name if plot_panel: plot_panel.set_peak_center_graph(graph) else: graph.close_func = self.close if standalone_graph: # set graph window attributes graph.window_title = 'Peak Center {}({}) @ {:0.3f}'.format(ref, isotope, center_dac) graph.window_width = 300 graph.window_height = 250 open_view(graph) return self.peak_center
def setup_peak_center(self, detector=None, isotope=None, integration_time=1.04, directions='Increase', center_dac=None, plot_panel=None, new=False, standalone_graph=True, name='', show_label=False, window=0.015, step_width=0.0005, min_peak_height=1.0, percent=80, deconvolve=None, use_interpolation=False, interpolation_kind='linear', dac_offset=None, calculate_all_peaks=False, config_name=None, use_configuration_dac=True): if deconvolve is None: n_peaks, select_peak = 1, 1 if dac_offset is not None: use_dac_offset = True spec = self.spectrometer spec.save_integration() self.debug('setup peak center. detector={}, isotope={}'.format( detector, isotope)) self._setup_config() pcc = None if detector is None or isotope is None: self.debug('ask user for peak center configuration') self.peak_center_config.load(dac=spec.magnet.dac) if config_name: self.peak_center_config.active_name = config_name info = self.peak_center_config.edit_traits() if not info.result: return else: pcc = self.peak_center_config.active_item elif config_name: self.peak_center_config.load(dac=spec.magnet.dac) self.peak_center_config.active_name = config_name pcc = self.peak_center_config.active_item if pcc: if not detector: detector = pcc.active_detectors if not isotope: isotope = pcc.isotope directions = pcc.directions integration_time = pcc.integration_time window = pcc.window min_peak_height = pcc.min_peak_height step_width = pcc.step_width percent = pcc.percent use_interpolation = pcc.use_interpolation interpolation_kind = pcc.interpolation_kind n_peaks = pcc.n_peaks select_peak = pcc.select_n_peak use_dac_offset = pcc.use_dac_offset dac_offset = pcc.dac_offset calculate_all_peaks = pcc.calculate_all_peaks if center_dac is None and use_configuration_dac: center_dac = pcc.dac spec.set_integration_time(integration_time) period = int(integration_time * 1000 * 0.9) if not isinstance(detector, (tuple, list)): detector = (detector, ) ref = detector[0] ref = self.spectrometer.get_detector(ref) self.reference_detector = ref self.reference_isotope = isotope if center_dac is None: center_dac = self.get_center_dac(ref, isotope) if len(detector) > 1: ad = detector[1:] else: ad = [] pc = self.peak_center if not pc or new: pc = PeakCenter() pc.trait_set(center_dac=center_dac, period=period, window=window, percent=percent, min_peak_height=min_peak_height, step_width=step_width, directions=directions, reference_detector=ref, additional_detectors=ad, reference_isotope=isotope, spectrometer=spec, show_label=show_label, use_interpolation=use_interpolation, interpolation_kind=interpolation_kind, n_peaks=n_peaks, select_peak=select_peak, use_dac_offset=use_dac_offset, dac_offset=dac_offset, calculate_all_peaks=calculate_all_peaks) self.peak_center = pc graph = pc.graph graph.name = name if plot_panel: plot_panel.set_peak_center_graph(graph) else: graph.close_func = self.close if standalone_graph: # set graph window attributes graph.window_title = 'Peak Center {}({}) @ {:0.3f}'.format( ref, isotope, center_dac) graph.window_width = 300 graph.window_height = 250 open_view(graph) return self.peak_center
def setup_peak_center(self, detector=None, isotope=None, integration_time=1.04, directions='Increase', center_dac=None, plot_panel=None, new=False, standalone_graph=True, name='', show_label=False, window=0.015, step_width=0.0005, min_peak_height=1.0, percent=80): spec = self.spectrometer spec.save_integration() self.debug('setup peak center. detector={}, isotope={}'.format(detector, isotope)) if detector is None or isotope is None: self.debug('ask user for peak center configuration') pcc = self.peak_center_config pcc.dac = spec.magnet.dac info = pcc.edit_traits() if not info.result: return else: detector = pcc.detector.name isotope = pcc.isotope directions = pcc.directions integration_time = pcc.integration_time window = pcc.window min_peak_height = pcc.min_peak_height step_width = pcc.step_width percent = pcc.percent # if not pcc.use_current_dac: center_dac = pcc.dac spec.set_integration_time(integration_time) period = int(integration_time * 1000 * 0.9) if isinstance(detector, (tuple, list)): ref = detector[0] detectors = detector else: ref = detector detectors = (ref,) if center_dac is None: center_dac = self.get_center_dac(ref, isotope) ref = detectors[0] self.reference_detector = ref self.reference_isotope = isotope if len(detectors) > 1: ad = detectors[1:] else: ad = [] pc = self.peak_center if not pc or new: pc = PeakCenter() pc.trait_set(center_dac=center_dac, period=period, window=window, percent=percent, min_peak_height=min_peak_height, step_width=step_width, directions=directions, reference_detector=ref, additional_detectors=ad, reference_isotope=isotope, spectrometer=spec, show_label=show_label) self.peak_center = pc graph = pc.graph graph.name = name if plot_panel: plot_panel.set_peak_center_graph(graph) else: graph.close_func = self.close if standalone_graph: # set graph window attributes graph.window_title = 'Peak Center {}({}) @ {:0.3f}'.format(ref, isotope, center_dac) graph.window_width = 300 graph.window_height = 250 self.open_view(graph) return self.peak_center