示例#1
0
 def _func():
     open_view(im)
     if auto_close:
         minutes = 2
         t = Timer(60 * minutes, im.close_ui)
         t.setDaemon(True)
         t.start()
示例#2
0
 def show_summary(self):
     """
     show a summary view for ``spec`` using its ``result``
     :return:
     """
     if self.selected:
         open_view(self.selected[0].result)
示例#3
0
 def _func():
     open_view(im)
     if auto_close:
         minutes = 2
         t = Timer(60 * minutes, im.close_ui)
         t.setDaemon(True)
         t.start()
示例#4
0
    def _do_diff_fired(self):
        if self.selected_commits:

            lhs = self.selected_lhs
            rhs = self.selected_rhs

            lhsid = lhs.hexsha[:8]
            lhsdate = isoformat_date(lhs.date)

            rhsid = rhs.hexsha[:8]
            rhsdate = rhs.date.isoformat()

            diffs = []
            for a in ('blanks', 'icfactors', 'intercepts'):
                p = analysis_path((self.uuid, self.record_id), self.repository_identifier, modifier=a)
                dd = get_diff(self.repo, lhs.hexsha, rhs.hexsha, p)
                if dd:
                    diffs.append((a, dd))

            if diffs:
                v = DiffView(self.record_id, lhsid, rhsid, lhsdate, rhsdate)
                for a, (aa, bb) in diffs:
                    func = getattr(v, 'set_{}'.format(a))

                    a = aa.data_stream.read().decode('utf-8')
                    b = bb.data_stream.read().decode('utf-8')
                    func(json.loads(a), json.loads(b))
                v.finish()
                open_view(v)
            else:
                information(None, 'No Differences between {} and {}'.format(lhsid, rhsid))
示例#5
0
    def _make_correlation(self, idx, ytitle):
        fi = self.figures[0]
        plots = list(fi.options.get_plotable_aux_plots())
        tag = plots[idx].plot_name

        n = len(self.figures)

        r, c = filled_grid(n)
        g = RegressionGraph(container_dict={
            'kind': 'g',
            'shape': (r, c)
        },
                            window_title='Correlation')
        for i, fi in enumerate(self.figures):
            gi = fi.analysis_group
            p = g.new_plot(xtitle='age',
                           ytitle=ytitle,
                           title='{}({})'.format(gi.sample, gi.identifier))

            xs = [nominal_value(a.uage) for a in gi.clean_analyses()]
            ys = [nominal_value(a.get_value(tag)) for a in gi.clean_analyses()]

            g.new_series(xs,
                         ys,
                         fit='linear',
                         use_error_envelope=False,
                         plotid=i)
            g.add_correlation_statistics(plotid=i)

            g.set_x_limits(pad='0.1', plotid=i)
            g.set_y_limits(pad='0.1', plotid=i)

        g.refresh()

        open_view(g)
示例#6
0
    def _do_diff_fired(self):
        if self.selected_commits:

            lhs = self.selected_lhs
            rhs = self.selected_rhs

            lhsid = lhs.hexsha[:8]
            lhsdate = isoformat_date(lhs.date)

            rhsid = rhs.hexsha[:8]
            rhsdate = rhs.date.isoformat()

            diffs = []
            for a in ('blanks', 'icfactors', 'intercepts'):
                p = analysis_path((self.uuid, self.record_id),
                                  self.repository_identifier,
                                  modifier=a)
                dd = get_diff(self.repo, lhs.hexsha, rhs.hexsha, p)
                if dd:
                    diffs.append((a, dd))

            if diffs:
                v = DiffView(self.record_id, lhsid, rhsid, lhsdate, rhsdate)
                for a, (aa, bb) in diffs:
                    func = getattr(v, 'set_{}'.format(a))

                    a = aa.data_stream.read().decode('utf-8')
                    b = bb.data_stream.read().decode('utf-8')
                    func(json.loads(a), json.loads(b))
                v.finish()
                open_view(v)
            else:
                information(
                    None,
                    'No Differences between {} and {}'.format(lhsid, rhsid))
示例#7
0
    def perform(self, event):
        app = event.task.window.application
        # spec_man = app.get_service(SPECTROMETER_PROTOCOL)

        from pychron.spectrometer.readout_view import new_readout_view

        rv = app.get_service('pychron.spectrometer.readout_view.ReadoutView')
        v = new_readout_view(rv)
        open_view(rv, view=v)
示例#8
0
    def perform(self, event):
        app = event.task.window.application
        # spec_man = app.get_service(SPECTROMETER_PROTOCOL)

        from pychron.spectrometer.readout_view import new_readout_view

        rv = app.get_service('pychron.spectrometer.readout_view.ReadoutView')
        v = new_readout_view(rv)
        open_view(rv, view=v)
示例#9
0
    def _started_fired(self):
        st = self.startup_tester
        if st.results:
            v = ResultsView(model=st)
            open_view(v)

        if globalv.use_testbot:
            from pychron.testbot.testbot import TestBot

            testbot = TestBot(application=self)
            testbot.run()
示例#10
0
    def _started_fired(self):
        st = self.startup_tester
        if st.results:
            v = ResultsView(model=st)
            open_view(v)

        if globalv.use_testbot:
            from pychron.testbot.testbot import TestBot

            testbot = TestBot(application=self)
            testbot.run()
示例#11
0
    def start(self):
        super(ThermoSpectrometerPlugin, self).start()

        if to_bool(self.application.preferences.get('pychron.spectrometer.auto_open_readout')):
            from pychron.spectrometer.readout_view import new_readout_view
            #
            # spec = self.application.get_service(
            #     'pychron.spectrometer.base_spectrometer_manager.BaseSpectrometerManager')
            # ro, v = new_readout_view(spectrometer=spec.spectrometer)
            rv = self.application.get_service(ReadoutView)
            v = new_readout_view(rv)
            open_view(rv, view=v)
示例#12
0
    def _handle_figure_event(self, evt):
        kind, args = evt
        if kind == 'correlation':
            self._make_correlation(*args)
        elif kind == 'identify_peaks':
            ps =[]
            for fi in self.figures:
                print('peaks', fi.peaks)
                if fi.peaks is not None:
                    ps.extend(fi.peaks)

            from pychron.pipeline.identify_peak_view import IdentifyPeakView
            ipv = IdentifyPeakView(ps)
            open_view(ipv)
示例#13
0
 def show_summary(self):
     """
     show a summary view for ``spec`` using its ``result``
     :return:
     """
     if self.executed_selected:
         from pychron.core.ui.text_editor import myTextEditor
         v = View(UItem('summary', style='custom', editor=myTextEditor(editable=False,
                                                                       fontsize=14)),
                  title='Summary',
                  width=900,
                  kind='livemodal',
                  resizable=True)
         open_view(self.executed_selected[0].result, view=v)
示例#14
0
    def start(self):
        super(ThermoSpectrometerPlugin, self).start()

        if to_bool(
                self.application.preferences.get(
                    'pychron.spectrometer.auto_open_readout')):
            from pychron.spectrometer.readout_view import new_readout_view
            #
            # spec = self.application.get_service(
            #     'pychron.spectrometer.base_spectrometer_manager.BaseSpectrometerManager')
            # ro, v = new_readout_view(spectrometer=spec.spectrometer)
            rv = self.application.get_service(ReadoutView)
            v = new_readout_view(rv)
            open_view(rv, view=v)
示例#15
0
    def show_isotope_evolutions(self, isotopes=None, **kw):
        if isotopes:
            if isinstance(isotopes[0], (str, unicode)):
                isotopes = [self.isotopes[i] for i in isotopes]
        else:
            isotopes = self.isotopes.values()

        keys = [k.name for k in isotopes]

        self.load_raw_data(keys)
        g = show_evolutions_factory(self.record_id, isotopes, **kw)
        if g:
            open_view(g, handler=CloseHandler())

            return g
示例#16
0
    def _identify_peaks(self, ps):
        from pychron.pipeline.identify_peak_view import IdentifyPeakView

        source = self.application.get_service(
            'pychron.sparrow.sparrow.Sparrow')
        if source is None:
            self.warning_dialog(
                'At least on datasource plugin is required, e.g. Sparrow')
            return

        if source.connect():
            ipv = IdentifyPeakView(ps, source=source)
            open_view(ipv)
        else:
            self.warning_dialog('Failed to connect to a relevant datasource')
示例#17
0
    def show_isotope_evolutions(self, isotopes=None, **kw):
        if isotopes:
            if isinstance(isotopes[0], (str, unicode)):
                isotopes = [self.isotopes[i] for i in isotopes]
        else:
            isotopes = self.isotopes.values()

        keys = [k.name for k in isotopes]

        self.load_raw_data(keys)
        g = show_evolutions_factory(self.record_id, isotopes, **kw)
        if g:
            open_view(g, handler=CloseHandler())

            return g
示例#18
0
    def perform(self, event):
        path = self.path
        if path is None:
            dlg = FileDialog(action='open',
                             wildcard='*.log;*.json|log|*.json',
                             default_directory=paths.log_dir)
            if dlg.open() == OK:
                path = dlg.path

        if path:
            klass = TwistedLogModel if path.endswith('.json') else LogModel
            lm = klass()
            lm.open_file(path)
            lv = LogViewer(model=lm)
            open_view(lv)
示例#19
0
 def show_summary(self):
     """
     show a summary view for ``spec`` using its ``result``
     :return:
     """
     if self.executed_selected:
         from pychron.core.ui.text_editor import myTextEditor
         v = View(UItem('summary',
                        style='custom',
                        editor=myTextEditor(editable=False, fontsize=14)),
                  title='Summary',
                  width=900,
                  kind='livemodal',
                  resizable=True)
         open_view(self.executed_selected[0].result, view=v)
示例#20
0
def edit_conditionals(name,
                      detectors=None,
                      root=None,
                      save_as=False,
                      kinds=None,
                      title=''):
    if not root:
        root = paths.queue_conditionals_dir

    if not save_as:
        if not name and not save_as:
            path = get_file_path(root)
            if not path:
                return
        else:
            path = os.path.join(root, name)
    else:
        path = ''

    cev = ConditionalsEditView(detectors, root=root, title=title)
    cev.open(path, save_as)
    if kinds:
        cev.group_names = kinds

    info = open_view(cev, kind='livemodal')

    if info.result:
        cev.dump()
        return cev.name
示例#21
0
def edit_conditionals(name, detectors=None, root=None, save_as=False,
                      kinds=None, title=''):
    if not root:
        root = paths.queue_conditionals_dir

    if not save_as:
        if not name and not save_as:
            path = get_file_path(root)
            if not path:
                return
        else:
            path = os.path.join(root, name)
    else:
        path = ''

    cev = ConditionalsEditView(detectors, root=root, title=title)
    cev.open(path, save_as)
    if kinds:
        cev.group_names = kinds

    info = open_view(cev, kind='livemodal')

    if info.result:
        cev.dump()
        return cev.name
    def _application_initialized_fired(self):
        if globalv.use_startup_tests:
            st = StartupTester()
            for plugin in iter(self.plugin_manager):
                st.test_plugin(plugin)

            if st.results:
                if globalv.show_startup_results or not st.all_passed:
                    v = ResultsView(model=st)
                    open_view(v)

        if globalv.use_testbot:
            from pychron.testbot.testbot import TestBot

            testbot = TestBot(application=self)
            testbot.run()
示例#23
0
文件: __init__.py 项目: NMGRL/pychron
def do_import_analyses(dvc, sources):
    from pychron.data_mapper.view import DVCIrradiationImporterView, DVCAnalysisImporterView
    from pychron.data_mapper.model import DVCIrradiationImporterModel, DVCAnalysisImporterModel
    from pychron.envisage.view_util import open_view

    model = DVCAnalysisImporterModel(dvc=dvc, sources=sources)

    # model.source = next((k for k, v in sources.iteritems() if v == default_source), None)
    # model.source = sources.keys()[0]

    model.repository_identifier = 'wiscartest'
    model.extract_device = 'Laser'
    model.mass_spectrometer = 'Noblesse'
    model.principal_investigator = 'WiscAr'
    for k,v in sources.items():
        if isinstance(k, WiscArNuSource):
            model.source = k
            root = os.path.dirname(__file__)
            k.directory = os.path.join(root, 'tests', 'data', 'wiscar')
            k.nice_path = os.path.join(root, 'tests', 'data', 'wiscar.nice')
            k.metadata_path = os.path.join(root, 'tests', 'data', 'WISCAR_test_metadata.txt')
            break

    view = DVCAnalysisImporterView(model=model)
    info = open_view(view)
    return info.result
示例#24
0
def do_import_analyses(dvc, sources):
    from pychron.data_mapper.view import DVCIrradiationImporterView, DVCAnalysisImporterView
    from pychron.data_mapper.model import DVCIrradiationImporterModel, DVCAnalysisImporterModel
    from pychron.envisage.view_util import open_view

    model = DVCAnalysisImporterModel(dvc=dvc, sources=sources)

    # model.source = next((k for k, v in sources.iteritems() if v == default_source), None)
    # model.source = sources.keys()[0]

    model.repository_identifier = 'wiscartest'
    model.extract_device = 'Laser'
    model.mass_spectrometer = 'Noblesse'
    model.principal_investigator = 'WiscAr'
    for k, v in sources.items():
        if isinstance(k, WiscArNuSource):
            model.source = k
            root = os.path.dirname(__file__)
            k.directory = os.path.join(root, 'tests', 'data', 'wiscar')
            k.nice_path = os.path.join(root, 'tests', 'data', 'wiscar.nice')
            k.metadata_path = os.path.join(root, 'tests', 'data',
                                           'WISCAR_test_metadata.txt')
            break

    view = DVCAnalysisImporterView(model=model)
    info = open_view(view)
    return info.result
示例#25
0
def do_import_irradiation(dvc, sources, default_source=None):
    model = DVCImporterModel(dvc=dvc, sources=sources)

    model.source = next((k for k, v in sources.iteritems() if v == default_source), None)
    view = DVCImporterView(model=model)
    info = open_view(view)
    return info.result
示例#26
0
def do_import_irradiation(dvc, sources, default_source=None):
    model = DVCImporterModel(dvc=dvc, sources=sources)

    model.source = next(
        (k for k, v in sources.iteritems() if v == default_source), None)
    view = DVCImporterView(model=model)
    info = open_view(view)
    return info.result
示例#27
0
    def _pre_execute(self):
        pattern = self.pattern

        kind = pattern.kind
        if kind == 'SeekPattern':
            from pychron.graph.graph import Graph

            g = Graph(window_x=1000, window_y=100, window_height=900)
            self._info = open_view(g)
            self._seek_graph = g
示例#28
0
def do_import_irradiation(dvc, sources, default_source=None):
    from pychron.data_mapper.view import DVCIrradiationImporterView, DVCAnalysisImporterView
    from pychron.data_mapper.model import DVCIrradiationImporterModel, DVCAnalysisImporterModel
    from pychron.envisage.view_util import open_view

    model = DVCIrradiationImporterModel(dvc=dvc, sources=sources)
    # model.source = next((k for k, v in sources.iteritems() if v == default_source), None)
    view = DVCIrradiationImporterView(model=model)
    info = open_view(view)
    return info.result
示例#29
0
    def _pre_execute(self):
        pattern = self.pattern

        kind = pattern.kind
        if kind == 'SeekPattern':
            from pychron.graph.graph import Graph

            g = Graph(window_x=1000, window_y=100, window_height=900)
            self._info = open_view(g)
            self._seek_graph = g
示例#30
0
文件: __init__.py 项目: NMGRL/pychron
def do_import_irradiation(dvc, sources, default_source=None):
    from pychron.data_mapper.view import DVCIrradiationImporterView, DVCAnalysisImporterView
    from pychron.data_mapper.model import DVCIrradiationImporterModel, DVCAnalysisImporterModel
    from pychron.envisage.view_util import open_view

    model = DVCIrradiationImporterModel(dvc=dvc, sources=sources)
    # model.source = next((k for k, v in sources.iteritems() if v == default_source), None)
    view = DVCIrradiationImporterView(model=model)
    info = open_view(view)
    return info.result
示例#31
0
    def _pre_execute(self, evt):
        self.debug('pre execute')
        pattern = self.pattern

        kind = pattern.kind
        if kind in ('SeekPattern', 'DragonFlyPeakPattern'):
            self._info = open_view(pattern, view='execution_graph_view')

        if evt is not None:
            evt.set()
        self.debug('pre execute finished')
示例#32
0
    def _pre_execute(self, evt):
        self.debug('pre execute')
        pattern = self.pattern

        kind = pattern.kind
        if kind in ('SeekPattern', 'DragonFlyPeakPattern'):
            self._info = open_view(pattern, view='execution_graph_view')

        if evt is not None:
            evt.set()
        self.debug('pre execute finished')
示例#33
0
    def show_extraction_graph(self):
        if not self.has_active_editor(klass=RecallEditor):
            return

        from pychron.graph.stacked_graph import StackedGraph
        from numpy import array
        import struct
        import base64

        an = self.active_editor.analysis
        data = an.get_extraction_data()

        def extract_blob(blob):
            blob = base64.b64decode(blob)
            if blob != 'No Response':
                x, y = array([
                    struct.unpack('<ff', blob[i:i + 8])
                    for i in range(0, len(blob), 8)
                ]).T
                x[0] = 0
            else:
                x, y = [], []

            return x, y

        g = StackedGraph()
        g.window_title = 'Extraction Results - {}'.format(an.record_id)
        g.new_plot(padding=[70, 10, 10, 60])

        xx, yy = extract_blob(data['request'])
        g.new_series(xx, yy, plotid=0)
        g.set_y_limits(pad='0.1')

        g.new_plot(padding=[70, 10, 10, 10])
        xx, yy = extract_blob(data['response'])
        g.new_series(xx, yy, plotid=1)

        g.set_y_title('Temp (C)', plotid=0)
        g.set_x_title('Time (s)', plotid=0)
        g.set_y_title('% Output', plotid=1)
        open_view(g)
示例#34
0
    def show_extraction_graph(self):
        if not self.has_active_editor(klass=RecallEditor):
            return

        from pychron.graph.stacked_graph import StackedGraph
        from numpy import array
        import struct
        import base64

        an = self.active_editor.analysis
        data = an.get_extraction_data()

        def extract_blob(blob):
            blob = base64.b64decode(blob)
            if blob != 'No Response':
                x, y = array([struct.unpack('<ff', blob[i:i + 8]) for i in range(0, len(blob), 8)]).T
                x[0] = 0
            else:
                x, y = [], []

            return x, y

        g = StackedGraph()
        g.window_title = 'Extraction Results - {}'.format(an.record_id)
        g.new_plot(padding=[70, 10, 10, 60])

        xx, yy = extract_blob(data['request'])
        g.new_series(xx, yy, plotid=0)
        g.set_y_limits(pad='0.1')

        g.new_plot(padding=[70, 10, 10, 10])
        xx, yy = extract_blob(data['response'])
        g.new_series(xx, yy, plotid=1)

        g.set_y_title('Temp (C)', plotid=0)
        g.set_x_title('Time (s)', plotid=0)
        g.set_y_title('% Output', plotid=1)
        open_view(g)
示例#35
0
    def _make_correlation(self, refplot, xtitle):

        fi = self.figures[0]

        n = len(list(fi.options.get_plotable_aux_plots()))
        plots = list(reversed(fi.graph.plots))

        xs = refplot.data.get_data('y1')

        r, c = filled_grid(n - 1)
        g = RegressionGraph(container_dict={
            'kind': 'g',
            'shape': (r, c)
        },
                            window_title='Correlation')
        i = 0
        for pp in plots:
            ytitle = pp.y_axis.title
            if ytitle == xtitle:
                continue

            g.new_plot(xtitle=xtitle, ytitle=ytitle, padding=[80, 10, 10, 40])
            ys = pp.data.get_data('y1')
            g.new_series(xs,
                         ys,
                         fit='linear',
                         use_error_envelope=False,
                         plotid=i)
            g.add_correlation_statistics(plotid=i)

            g.set_x_limits(pad='0.1', plotid=i)
            g.set_y_limits(pad='0.1', plotid=i)
            i += 1

        g.refresh()

        open_view(g)
示例#36
0
    def _view_snapshot(self, local_path, remote_path, image):
        from pychron.lasers.laser_managers.snapshot_view import SnapshotView

        open_required = False
        try:
            sv = self.application.snapshot_view
        except AttributeError:
            sv = None
            open_required = True

        if sv is None:
            sv = SnapshotView()
            self.application.snapshot_view = sv

        sv.set_image(local_path, remote_path, image)
        if open_required:
            info = open_view(sv)
            self.application.snapshot_view_info = info
        else:
            if self.application.snapshot_view_info.control:
                self.application.snapshot_view_info.control.raise_()
            else:
                info = open_view(sv)
                self.application.snapshot_view_info = info
示例#37
0
    def _view_snapshot(self, local_path, remote_path, image):
        from pychron.lasers.laser_managers.snapshot_view import SnapshotView

        open_required = False
        try:
            sv = self.application.snapshot_view
        except AttributeError:
            sv = None
            open_required = True

        if sv is None:
            sv = SnapshotView()
            self.application.snapshot_view = sv

        sv.set_image(local_path, remote_path, image)
        if open_required:
            info = open_view(sv)
            self.application.snapshot_view_info = info
        else:
            if self.application.snapshot_view_info.control:
                self.application.snapshot_view_info.control.raise_()
            else:
                info = open_view(sv)
                self.application.snapshot_view_info = info
示例#38
0
    def get_selection(self):
        from pychron.loading.load_view_selection import LoadViewSelectionModel, LoadViewSelectionController

        self.setup()
        if self.loads:
            self.use_measured = True
            self.load_name = self.loads[-1]
            oeditable = self.canvas.editable
            self.canvas.editable = False
            lvsm = LoadViewSelectionModel(manager=self)
            lvc = LoadViewSelectionController(model=lvsm)
            info = open_view(lvc)
            self.canvas.editable = oeditable
            self.use_measured = False
            if info.result:
                return lvsm.selected_positions
        else:
            self.warning_dialog('No Loads available')
示例#39
0
    def get_selection(self):
        from pychron.loading.load_view_selection import LoadViewSelectionModel, LoadViewSelectionController

        self.setup()
        if self.loads:
            self.use_measured = True
            self.load_name = self.loads[-1]
            oeditable = self.canvas.editable
            self.canvas.editable = False
            lvsm = LoadViewSelectionModel(manager=self)
            lvc = LoadViewSelectionController(model=lvsm)
            info = open_view(lvc)
            self.canvas.editable = oeditable
            self.use_measured = False
            if info.result:
                return lvsm.selected_positions
        else:
            self.warning_dialog('No Loads available')
示例#40
0
    def edit_analysis(self):
        self.debug('Edit analysis data')
        if not self.has_active_editor():
            return

        editor = self.active_editor
        if not isinstance(editor, RecallEditor):
            self.warning_dialog('Active tab must be a Recall tab')
            return

        if hasattr(editor, 'edit_view') and editor.edit_view:
            editor.edit_view.show()
        else:

            e = AnalysisEditView(editor, dvc=self.dvc)

            info = open_view(e)
            e.control = info.control
            editor.edit_view = e
示例#41
0
    def edit_analysis(self):
        self.debug('Edit analysis data')
        if not self.has_active_editor():
            return

        editor = self.active_editor
        if not isinstance(editor, RecallEditor):
            self.warning_dialog('Active tab must be a Recall tab')
            return

        if hasattr(
                editor,
                'edit_view') and editor.edit_view and editor.edit_view.control:
            editor.edit_view.show()
        else:

            e = AnalysisEditView(editor, dvc=self.dvc)
            info = open_view(e)
            # info = e.edit_traits()
            e.control = info.control
            editor.edit_view = e
示例#42
0
 def cdd_operate_voltage_scan_task_factory(self):
     obj = CDDOperatingVoltageScan(spectrometer=self.spectrometer)
     info = obj.edit_traits(kind='livemodal')
     if info.result:
         open_view(obj.graph)
         obj.execute()
示例#43
0
 def controller_execute_button_changed(self, info):
     graph = self.model.make_graph()
     if self.model.execute():
         self.model.do_scan()
         open_view(graph)
示例#44
0
    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
示例#45
0
 def controller_execute_button_changed(self, info):
     graph = self.model.make_graph()
     if self.model.execute():
         self.model.do_scan()
         open_view(graph)
示例#46
0
    def perform(self, event):
        app = event.task.window.application
        man = app.get_service('pychron.hardware.flag_manager.FlagManager')

        open_view(man)
示例#47
0
    def _execute_scan(self):
        name = os.path.join(paths.scripts_dir, '{}_scan.yaml'.format(self.name))

        import csv

        d = os.path.join(paths.data_dir, 'diode_scans')
        p, _cnt = unique_path(d, 'scan', extension='csv')
        st = None

        py = self.laser_manager.pyrometer
        tc = self.laser_manager.get_device('temperature_monitor')
        yd = yaml.load(open(name).read())

        power = yd['power']
        duration = yd['duration']
        power_on = yd['power_on']
        power_off = yd['power_off']
        period = yd['period']
        if 'temp' in yd:
            temp = yd['temp']
        else:
            temp = None

        g = StreamStackedGraph()
        g.new_plot(scan_delay=1, )
        g.new_series(x=[], y=[])
        g.new_plot(scan_delay=1, )
        g.new_series(x=[], y=[], plotid=1)

        open_view(g)
        self.laser_manager.stage_manager.start_recording()
        time.sleep(1)

        def gfunc(v1, v2):
            g.record(v1)
            g.record(v2, plotid=1)

        pi = 0
        with open(p, 'w') as wfile:
            writer = csv.writer(wfile)
            t = 0
            ti = 0
            while ti <= duration:
                if self._cancel:
                    break
                # print ti, power_off, pi, ti >= power_off, (ti >= power_off and pi)
                if ti == power_on:
                    # turn on set laser to power
                    if temp:
                        self.laser_manager.set_laser_temperature(temp)
                        pi = temp
                    else:
                        pi = power
                        self.laser_manager.set_laser_power(power)
                elif ti >= power_off and pi:
                    print 'setting power off'
                    if temp:
                        self.laser_manager.set_laser_temperature(0)
                    else:
                        self.laser_manager.set_laser_power(0)
                    pi = 0

                if st is None:
                    st = time.time()

                t = time.time() - st

                py_t = py.read_temperature(verbose=False)
                tc_t = tc.read_temperature(verbose=False)
                gfunc(py_t, tc_t)

                writer.writerow((ti, pi, t, py_t, tc_t))
                ti += 1

                time.sleep(period)

        if temp:
            self.laser_manager.set_laser_temperature(0)
        else:
            self.laser_manager.set_laser_power(0)
        self.laser_manager.stage_manager.stop_recording()
        self._executing = False
示例#48
0
 def perform(self, event=None):
     pm = PatternMakerView()
     open_view(pm)
示例#49
0
 def perform(self, event=None):
     pm = PatternMakerView()
     if pm.load_pattern():
         open_view(pm)
 def open_pattern(self):
     pm = self._pattern_maker_view_factory()
     if pm.load_pattern():
         open_view(pm)
 def new_pattern(self):
     pm = self._pattern_maker_view_factory()
     open_view(pm)
示例#52
0
文件: base.py 项目: NMGRL/pychron
 def cdd_operate_voltage_scan_task_factory(self):
     obj = CDDOperatingVoltageScan(spectrometer=self.spectrometer)
     info = obj.edit_traits(kind='livemodal')
     if info.result:
         open_view(obj.graph)
         obj.execute()
示例#53
0
 def show_pattern(self):
     self.pattern.window_x = 50
     self.pattern.window_y = 50
     open_view(self.pattern, view='graph_view')
示例#54
0
 def perform(self, event):
     from pychron.extraction_line.stop_watch import StopWatch
     sw = StopWatch()
     open_view(sw)
示例#55
0
 def perform(self, event):
     man = self._get_manager(event)
     open_view(man.explanation)
示例#56
0
    def _execute_calibration(self):
        name = os.path.join(paths.scripts_dir, '{}_calibration_scan.yaml'.format(self.name))

        import csv

        d = os.path.join(paths.data_dir, 'diode_scans')
        p, _cnt = unique_path(d, 'calibration', extension='csv')
        #        st = None
        #
        #        py = self.laser_manager.pyrometer
        #        tc = self.laser_manager.get_device('temperature_monitor')

        g = StreamStackedGraph()
        g.clear()

        g.new_plot(scan_delay=1)
        g.new_series(x=[], y=[])
        g.new_plot(scan_delay=1)
        g.new_series(x=[], y=[], plotid=1)

        open_view(g)
        record = False
        if record:
            self.laser_manager.stage_manager.start_recording()
            time.sleep(1)
        # def gfunc(t, v1, v2):
        #            g.add_datum((t, v1))
        #            g.add_datum((t, v2), plotid=1)

        def gfunc(v1, v2):
            g.record(v1)
            g.record(v2, plotid=1)

        yd = yaml.load(open(name).read())

        start = yd['start']
        end = yd['end']
        step = yd['step']
        mean_tol = yd['mean_tol']
        std = yd['std']
        n = (end - start) / step + 1
        #        nn = 30
        #
        #        py = self.laser_manager.pyrometer
        #        tc = self.laser_manager.get_device('temperature_monitor')

        with open(p, 'w') as wfile:
            writer = csv.writer(wfile)
            st = time.time()
            for ti in linspace(start, end, n):
                if self._cancel:
                    break
                args = self._equilibrate_temp(ti, gfunc, st, mean_tol, std)
                if args:
                    self.info('{} equilibrated'.format(ti))
                    py_t, tc_t = args
                    writer.writerow((ti, py_t, tc_t))
                else:
                    break

        self.laser_manager.set_laser_temperature(0)
        if record:
            self.laser_manager.stage_manager.stop_recording()
        self._executing = False
示例#57
0
 def perform(self, event):
     manager = self._get_manager(event)
     open_view(manager.pyscript_editor)
示例#58
0
 def diff_selected(self):
     if self._validate_diff():
         if len(self.selected_commits) == 2:
             l, r = self.selected_commits
             dv = self._diff_view_factory(l, r)
             open_view(dv)
示例#59
0
 def perform(self, event):
     manager = self._get_manager(event)
     if manager.multiplexer_manager:
         open_view(manager.multiplexer_manager)