Example #1
0
    def setup_graph(self, iso):
        self.is_good = None

        g = StackedRegressionGraph()
        g.new_plot(padding=[60, 10, 10, 40])
        if iso:
            g.new_series(iso.xs, iso.ys,
                         fit=iso.fit,
                         filter_outliers_dict=iso.filter_outliers_dict)
            g.set_x_limits(min_=0, max_=iso.xs[-1] * 1.1)
            g.set_y_title(iso.name)

        g.set_x_title('Time (s)')

        g.refresh()
        self.graph = g
Example #2
0
    def setup_graph(self, iso):
        self.klass = None

        g = StackedRegressionGraph()
        g.new_plot(padding=[60, 10, 10, 40])
        if iso:
            g.new_series(iso.xs,
                         iso.ys,
                         fit=iso.fit,
                         filter_outliers_dict=iso.filter_outliers_dict)
            g.set_x_limits(min_=0, max_=iso.xs[-1] * 1.1)
            g.set_y_title(iso.name)

        g.set_x_title('Time (s)')

        g.refresh()
        self.graph = g
Example #3
0
    def handle_show_iso_evo(self, obj):
        from pychron.graph.stacked_regression_graph import StackedRegressionGraph

        self.manager.load_raw_data(self.model)

        g = StackedRegressionGraph()
        for ni in obj[::-1]:
            iso = next((i for i in self.model.isotopes.itervalues() if i.name == ni.name), None)
            g.new_plot(padding=[60, 10, 10, 40])
            g.new_series(iso.xs, iso.ys,
                         fit=iso.fit,
                         filter_outliers_dict=iso.filter_outliers_dict)
            g.set_x_limits(min_=0, max_=iso.xs[-1] * 1.1)
            g.set_x_title('Time (s)')
            g.set_y_title(iso.name)

        g.refresh()
        g.window_title = '{} {}'.format(self.name, ','.join([i.name for i in obj]))
        self.manager.application.open_view(g)
Example #4
0
    def handle_show_iso_evo(self, obj):
        from pychron.graph.stacked_regression_graph import StackedRegressionGraph

        self.manager.load_raw_data(self.model)

        g = StackedRegressionGraph()
        for ni in obj[::-1]:
            iso = next((i for i in self.model.isotopes.itervalues()
                        if i.name == ni.name), None)
            g.new_plot(padding=[60, 10, 10, 40])
            g.new_series(iso.xs,
                         iso.ys,
                         fit=iso.fit,
                         filter_outliers_dict=iso.filter_outliers_dict)
            g.set_x_limits(min_=0, max_=iso.xs[-1] * 1.1)
            g.set_x_title('Time (s)')
            g.set_y_title(iso.name)

        g.refresh()
        g.window_title = '{} {}'.format(self.name,
                                        ','.join([i.name for i in obj]))
        self.manager.application.open_view(g)
Example #5
0
    def show_blank_time_series(self):
        g = StackedRegressionGraph(window_height=0.75)
        isotopes = self.blank_selected[0].isotopes
        keys = sort_isotopes([iso.isotope for iso in isotopes], reverse=False)
        _mi, _ma = None, None

        for k in keys:
            iso = next((i for i in isotopes if i.isotope == k))
            # print iso.analyses
            g.new_plot(padding_right=10)
            g.set_time_xaxis()
            g.set_y_title(iso.isotope)

            g.new_series([self.timestamp], [iso.value],
                         marker_size=3,
                         fit=False,
                         type='scatter',
                         marker_color='black')
            vs = iso.values
            if vs:
                ts = [vi.timestamp for vi in vs]
                _mi = min(ts)
                _ma = max(ts)
                g.new_series(ts, [vi.value for vi in vs],
                             yerror=ArrayDataSource([vi.error for vi in vs]),
                             marker_size=3,
                             fit=(iso.fit, 'SD'),
                             type='scatter',
                             marker_color='red')

        if not _mi:
            _mi, _ma = self.timestamp - 86400, self.timestamp + 86400

        g.set_x_limits(_mi, _ma, pad='0.1')
        g.refresh()

        g.set_x_title('Time', plotid=0)
        g.edit_traits()
Example #6
0
    def show_blank_time_series(self):
        g = StackedRegressionGraph(window_height=0.75)
        isotopes = self.blank_selected[0].isotopes
        keys = sort_isotopes([iso.isotope for iso in isotopes], reverse=False)
        _mi, _ma = None, None

        for k in keys:
            iso = next((i for i in isotopes if i.isotope == k))
            # print iso.analyses
            g.new_plot(padding_right=10)
            g.set_time_xaxis()
            g.set_y_title(iso.isotope)

            g.new_series([self.timestamp], [iso.value],
                         marker_size=3,
                         fit=False,
                         type='scatter', marker_color='black')
            vs = iso.values
            if vs:
                ts = [vi.timestamp for vi in vs]
                _mi = min(ts)
                _ma = max(ts)
                g.new_series(ts,
                             [vi.value for vi in vs],
                             yerror=ArrayDataSource([vi.error for vi in vs]),
                             marker_size=3,
                             fit=(iso.fit, 'SD'),
                             type='scatter', marker_color='red')

        if not _mi:
            _mi, _ma = self.timestamp - 86400, self.timestamp + 86400

        g.set_x_limits(_mi, _ma, pad='0.1')
        g.refresh()

        g.set_x_title('Time', plotid=0)
        g.edit_traits()
Example #7
0
def show_evolutions_factory(record_id, isotopes, show_evo=True, show_equilibration=False, show_baseline=False):
    if WINDOW_CNT > 20:
        information(None, 'You have too many Isotope Evolution windows open. Close some before proceeding')
        return

    from pychron.graph.stacked_regression_graph import StackedRegressionGraph

    if not show_evo:
        xmi = Inf
        xma = -Inf
    else:
        xmi, xma = 0, -Inf

    g = StackedRegressionGraph(resizable=True)
    g.plotcontainer.spacing = 10
    g.window_height = min(275 * len(isotopes), 800)
    g.window_x = OX + XOFFSET * WINDOW_CNT
    g.window_y = OY + YOFFSET * WINDOW_CNT

    isotopes = sort_isotopes(isotopes, reverse=False, key=lambda x: x.name)

    for i, iso in enumerate(isotopes):
        ymi, yma = Inf, -Inf

        p = g.new_plot(padding=[80, 10, 10, 40])
        g.add_limit_tool(p, 'x')
        g.add_limit_tool(p, 'y')
        g.add_axis_tool(p, p.x_axis)
        g.add_axis_tool(p, p.y_axis)

        p.y_axis.title_spacing = 50
        if show_equilibration:
            sniff = iso.sniff
            g.new_series(sniff.xs, sniff.ys,
                         type='scatter',
                         fit=None,
                         color='red')
            ymi, yma = min_max(ymi, yma, sniff.ys)
            xmi, xma = min_max(xmi, xma, sniff.xs)

        if show_evo:
            g.new_series(iso.xs, iso.ys,
                         fit=iso.fit,
                         filter_outliers_dict=iso.filter_outliers_dict,
                         color='black')
            ymi, yma = min_max(ymi, yma, iso.ys)
            xmi, xma = min_max(xmi, xma, iso.xs)

        if show_baseline:
            baseline = iso.baseline
            g.new_series(baseline.xs, baseline.ys,
                         type='scatter', fit=baseline.fit,
                         filter_outliers_dict=baseline.filter_outliers_dict,
                         color='blue')
            ymi, yma = min_max(ymi, yma, baseline.ys)
            xmi, xma = min_max(xmi, xma, baseline.xs)

        g.set_x_limits(min_=xmi, max_=xma, pad='0.025,0.05')
        g.set_y_limits(min_=ymi, max_=yma, pad='0.05', plotid=i)
        g.set_x_title('Time (s)', plotid=i)
        g.set_y_title('{} (fA)'.format(iso.name), plotid=i)

    g.refresh()
    g.window_title = '{} {}'.format(record_id, ','.join([i.name for i in reversed(isotopes)]))

    return g
Example #8
0
def show_evolutions_factory(record_id,
                            isotopes,
                            show_evo=True,
                            show_equilibration=False,
                            show_baseline=False):
    if WINDOW_CNT > 20:
        information(
            None,
            'You have too many Isotope Evolution windows open. Close some before proceeding'
        )
        return

    from pychron.graph.stacked_regression_graph import StackedRegressionGraph

    if not show_evo:
        xmi = Inf
        xma = -Inf
    else:
        xmi, xma = 0, -Inf

    g = StackedRegressionGraph(resizable=True)
    g.plotcontainer.spacing = 10
    g.window_height = min(275 * len(isotopes), 800)
    g.window_x = OX + XOFFSET * WINDOW_CNT
    g.window_y = OY + YOFFSET * WINDOW_CNT

    isotopes = sort_isotopes(isotopes, reverse=False, key=lambda x: x.name)

    for i, iso in enumerate(isotopes):
        ymi, yma = Inf, -Inf

        p = g.new_plot(padding=[80, 10, 10, 40])
        g.add_limit_tool(p, 'x')
        g.add_limit_tool(p, 'y')
        g.add_axis_tool(p, p.x_axis)
        g.add_axis_tool(p, p.y_axis)

        p.y_axis.title_spacing = 50
        if show_equilibration:
            sniff = iso.sniff
            g.new_series(sniff.xs,
                         sniff.ys,
                         type='scatter',
                         fit=None,
                         color='red')
            ymi, yma = min_max(ymi, yma, sniff.ys)
            xmi, xma = min_max(xmi, xma, sniff.xs)

        if show_evo:
            g.new_series(iso.xs,
                         iso.ys,
                         fit=iso.fit,
                         filter_outliers_dict=iso.filter_outliers_dict,
                         color='black')
            ymi, yma = min_max(ymi, yma, iso.ys)
            xmi, xma = min_max(xmi, xma, iso.xs)

        if show_baseline:
            baseline = iso.baseline
            g.new_series(baseline.xs,
                         baseline.ys,
                         type='scatter',
                         fit=baseline.fit,
                         filter_outliers_dict=baseline.filter_outliers_dict,
                         color='blue')
            ymi, yma = min_max(ymi, yma, baseline.ys)
            xmi, xma = min_max(xmi, xma, baseline.xs)

        g.set_x_limits(min_=xmi, max_=xma, pad='0.025,0.05')
        g.set_y_limits(min_=ymi, max_=yma, pad='0.05', plotid=i)
        g.set_x_title('Time (s)', plotid=i)
        g.set_y_title('{} (fA)'.format(iso.name), plotid=i)

    g.refresh()
    g.window_title = '{} {}'.format(
        record_id, ','.join([i.name for i in reversed(isotopes)]))

    return g
Example #9
0
    def setup_graph(self, an):

        container = HPlotContainer()

        container_dict = {'spacing': 5, 'stack_order': 'top_to_bottom'}
        sg = StackedGraph(container_dict=container_dict)
        sg.plotcontainer.spacing = 5
        sg.plotcontainer.stack_order = 'top_to_bottom'

        isos = an.sorted_values(reverse=False)
        add_sniff = True

        sisos = [iso for iso in isos if iso.sniff.offset_xs.shape[0]]
        for i, iso in enumerate(sisos):
            sniff = iso.sniff
            sg.new_plot(ytitle=iso.name,
                        xtitle='Time (s)',
                        title='Equilibration')
            sg.new_series(sniff.offset_xs,
                          sniff.ys,
                          marker='circle',
                          type='scatter')
            sg.set_y_limits(pad='0.1', plotid=i)
            sg.set_x_limits(min_=0, max_=max(sniff.offset_xs) * 1.05, plotid=i)

        bg = StackedRegressionGraph(container_dict=container_dict)
        add_baseline = True

        ig = StackedRegressionGraph(container_dict=container_dict)

        iisos = [iso for iso in isos if iso.offset_xs.shape[0]]
        baselines = []
        for i, iso in enumerate(iisos):
            if iso.baseline.offset_xs.shape[0]:
                baselines.append(iso.baseline)
            ig.new_plot(ytitle='{}({})'.format(iso.name, iso.detector),
                        xtitle='Time (s)',
                        title='Isotope')
            ig.new_series(iso.offset_xs,
                          iso.ys,
                          display_filter_bounds=True,
                          filter_outliers_dict=iso.filter_outliers_dict,
                          color='blue',
                          type='scatter',
                          fit=iso.efit)
            ig.set_regressor(iso.regressor, i)
            ig.set_y_limits(pad='0.1', plotid=i)
            ig.set_x_limits(min_=0, max_=max(iso.offset_xs) * 1.05, plotid=i)

        ig.refresh()

        # bisos = [iso for iso in isos if iso.baseline.offset_xs.shape[0]]
        # plotted_baselines = []
        # for i, iso in enumerate(bisos):
        # baseline = iso.baseline
        # if baseline.detector in plotted_baselines:
        #     continue
        # plotted_baselines.append(baseline.detector)

        # for iso in bisos:
        for i, baseline in enumerate(baselines):

            bg.new_plot(ytitle=baseline.detector,
                        xtitle='Time (s)',
                        title='Baseline')
            bg.new_series(baseline.offset_xs,
                          baseline.ys,
                          filter_outliers_dict=baseline.filter_outliers_dict,
                          display_filter_bounds=True,
                          color='red',
                          type='scatter',
                          fit=baseline.efit)
            bg.set_regressor(baseline.regressor, i)
            bg.set_y_limits(pad='0.1', plotid=i)
            bg.set_x_limits(pad='0.025', plotid=i)

        bg.refresh()

        container.add(sg.plotcontainer)
        container.add(ig.plotcontainer)
        container.add(bg.plotcontainer)

        self.container = container