Example #1
0
 def _sniff_graph_default(self):
     g = StackedGraph(container_dict=dict(padding=5, bgcolor='gray',
                                          stack_order=self.stack_order,
                                          spacing=5),
                      bind_index=False,
                      use_data_tool=False,
                      padding_bottom=35)
     g.page_name = 'Equil.'
     return g
Example #2
0
    def _update_half_ring_graph(self):
        self.ring_graph = g = StackedGraph()
        g.plotcontainer.spacing = 10
        g.plotcontainer.stack_order = 'top_to_bottom'
        poss = list(self._group_rings())[0]
        g.new_plot()
        for m in (2, 3, 5, 10):
            monitors, unknowns = [], []
            for i, p in enumerate(poss):
                if not i % m:
                    monitors.append(p)
                else:
                    unknowns.append(p)

            # monitors = poss[::5]
            # unknowns = poss[1::2]

            x, y, z, ze, j, je, sj, sje = self._extract_position_arrays(
                monitors)

            unkpts = [(p.x, p.y) for p in unknowns]
            unkj = [p.mean_j for p in unknowns]
            fx, fy, mx, my = self.model_plane(x, y, z, ze, model_points=unkpts)

            x, y = zip(*unkpts)
            mx = arctan2(x, y)
            ys = (unkj - my) / unkj * 100
            s = g.new_series(mx, ys)[0]
Example #3
0
    def setup_graph(self, an):

        container = HPlotContainer()

        sg = StackedGraph()
        sg.plotcontainer.spacing = 5
        sg.plotcontainer.stack_order = 'top_to_bottom'

        isos = an.sorted_values(reverse=False)
        for i, iso in enumerate(isos):
            sniff = iso.sniff
            sg.new_plot(ytitle=iso.name, xtitle='Time (s)', title='Equilibration')
            if sniff.xs.shape[0]:
                sg.new_series(sniff.offset_xs, sniff.ys, marker='circle', type='scatter')
            sg.set_y_limits(pad='0.1', plotid=i)

        bg = StackedRegressionGraph()
        bg.plotcontainer.spacing = 5
        bg.plotcontainer.stack_order = 'top_to_bottom'

        for i, iso in enumerate(isos):
            baseline = iso.baseline
            bg.new_plot(ytitle=baseline.detector, xtitle='Time (s)', title='Baseline')
            if baseline.xs.shape[0]:
                bg.new_series(baseline.offset_xs, baseline.ys,
                              color='red', type='scatter', fit=baseline.fit)
            bg.set_y_limits(pad='0.1', plotid=i)

        ig = StackedRegressionGraph()
        ig.plotcontainer.spacing = 5
        ig.plotcontainer.stack_order = 'top_to_bottom'

        for i, iso in enumerate(isos):
            ig.new_plot(ytitle=iso.name, xtitle='Time (s)', title='Isotope')
            if iso.xs.shape[0]:
                ig.new_series(iso.offset_xs, iso.ys,
                              color='blue', type='scatter', fit=iso.fit)
            ig.set_y_limits(pad='0.1', plotid=i)

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

        self.container = container
Example #4
0
    def setup_graph(self, response_data, request_data, setpoint_data):
        self.graph = g = StackedGraph(container_dict={'spacing': 10})
        ret = False
        pid = 0
        if response_data:
            try:
                x, y = unpack(response_data, fmt='<ff', decode=True)
                if x[1:]:
                    p = g.new_plot()
                    p.value_range.tight_bounds = False
                    g.set_x_title('Time (s)')
                    g.set_y_title('Temp C')
                    g.new_series(x[1:], y[1:])
                    pid += 1
                    ret = True

                    if setpoint_data:
                        x, y = unpack(setpoint_data, fmt='<ff', decode=True)
                        if x[1:]:
                            g.new_series(x[1:], y[1:])

            except ValueError:
                pass

        if request_data:
            try:
                x, y = unpack(request_data, fmt='<ff', decode=True)
                if x[1:]:
                    p = self.graph.new_plot()

                    g.set_x_title('Time')
                    g.set_y_title('% Power')
                    g.new_series(x[1:], y[1:])
                    g.set_y_limits(min_=0, max_=max(y) * 1.1, plotid=pid)
                    ret = True
            except ValueError:
                pass

        return ret
Example #5
0
    def _graph_default(self):
        g = StackedGraph(container_dict=dict(padding=5))
        plot = g.new_plot(
            #                   show_legend='ul',
            padding=5)

        plot.overlays.append(
            ZoomTool(plot,
                     minimum_screen_delta=5,
                     enable_wheel=False,
                     drag_button='left',
                     tool_mode='range',
                     always_on_top=True,
                     axis='index'))

        #        plot.on_trait_change(self._update, 'index_mapper.range.updated')
        plot.overlays.append(LegendOverlay(plot))
        g.set_axis_traits(axis='y', visible=False)
        g.set_axis_traits(axis='x', visible=False)
        g.set_grid_traits(grid='x', visible=False)
        g.set_grid_traits(grid='y', visible=False)
        return g
Example #6
0
    def _graph_default(self):
        g = StackedGraph(container_dict=dict(padding=5))
        plot = g.new_plot(
#                   show_legend='ul',
                   padding=5)


        plot.overlays.append(ZoomTool(plot,
                                      minimum_screen_delta=5,
                                      enable_wheel=False,
                                      drag_button='left',
                                      tool_mode='range',
                                      always_on_top=True,
                                      axis='index'
                                      ))

#        plot.on_trait_change(self._update, 'index_mapper.range.updated')
        plot.overlays.append(LegendOverlay(plot))
        g.set_axis_traits(axis='y', visible=False)
        g.set_axis_traits(axis='x', visible=False)
        g.set_grid_traits(grid='x', visible=False)
        g.set_grid_traits(grid='y', visible=False)
        return g
Example #7
0
        return v


if __name__ == '__main__':
    # m = MLLabel()
    # m.text = '<sup>40</sup>Ar'
    # d = Demo()
    # d.plot = Plot()
    # d.plot.padding_left = 80
    # d.plot.data = ArrayPlotData()
    # d.plot.data['x'] = [1, 2, 3, 4]
    # d.plot.data['y'] = [1, 2, 3, 4]
    # d.plot.plot(('x', 'y'))
    from pychron.graph.stacked_graph import StackedGraph

    g = StackedGraph()
    plot = g.new_plot(padding_left=100, padding_bottom=100)
    xa = plot.x_axis
    xa.title_color = 'red'
    xa.title = 'sasfas'
    nxa = MPlotAxis()
    nxa.title = '<sup>39</sup>Ar/<sup>40</sup>Ar'
    # nxa.title = '39Ar/40Ar'
    nxa.clone(xa)

    ya = plot.y_axis
    ya.title_color = 'red'
    ya.title = 'sasfas'
    ya.title_font = 'modern 36'
    nya = MPlotAxis()
    nya.title = '<sup>39</sup>Ar/<sup>40</sup>Ar'
Example #8
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)
            x, y = array([
                struct.unpack('<ff', blob[i:i + 8])
                for i in xrange(0, len(blob), 8)
            ]).T
            x[0] = 0
            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)
Example #9
0
    def _update_ring_graph(self):
        self.ring_graph = g = StackedGraph()
        g.plotcontainer.spacing = 10
        g.plotcontainer.stack_order = 'top_to_bottom'

        self.deviation_graph = dg = StackedGraph()
        dg.plotcontainer.spacing = 10
        dg.plotcontainer.stack_order = 'top_to_bottom'

        self.spoke_graph = sg = StackedGraph()
        sg.plotcontainer.spacing = 10
        sg.plotcontainer.stack_order = 'top_to_bottom'

        l, h = 0, 0
        dl, dh = 0, 0
        for poss in self._group_rings():
            poss = list(poss)

            x, y, z, ze, j, je, sj, sje = self._extract_position_arrays(poss)

            fx, fy, mx, my = self.model_plane(x, y, z, ze)

            x = arctan2(x, y)
            plot = g.new_plot(padding_left=100,
                              padding_top=20,
                              padding_right=10,
                              padding_bottom=30)

            s = g.new_series(x, z, yerror=ze, type='scatter')[0]
            ebo = ErrorBarOverlay(component=s, orientation='y')

            s.underlays.append(ebo)

            g.new_series(x, j, color='green')
            # g.new_series(x, sj)
            g.new_series(fx, fy, color='blue')

            l = min(min(x), l)
            h = max(max(x), h)

            plot = dg.new_plot(padding_left=100,
                               padding_top=20,
                               padding_right=10,
                               padding_bottom=30)

            ds = (j - z) / z * 100
            ds2 = (my - z) / z * 100

            # dg.new_series(x, (my-j)/j*100)
            dg.new_series(x, ds, color='green')
            dg.new_series(mx, ds2, color='blue')

            dl = min(min(ds), dl)
            dh = max(max(ds), dh)

        for i, p in enumerate(g.plots):
            g.set_x_limits(l, h, plotid=i, pad='0.05')

            dg.set_x_limits(l, h, plotid=i, pad='0.05')
            dg.set_y_limits(dl, dh, plotid=i, pad='0.05')

        for spoke, poss in self._group_spokes():
            print(spoke)
            x, y, z, ze, j, je, sj, sje = self._extract_position_arrays(poss)
            x = (x**2 + y**2)**0.5
            plot = sg.new_plot(padding_left=100,
                               padding_top=20,
                               padding_right=10,
                               padding_bottom=30)

            s = sg.new_series(x, z, yerror=ze, type='scatter')[0]
            ebo = ErrorBarOverlay(component=s, orientation='y')

            s.underlays.append(ebo)
            sg.new_series(x, j, color='green')
Example #10
0
    def _make_graph(self, lumens, duration):
        g = StackedGraph(container_dict=dict(stack_order='top_to_bottom'))
        g.new_plot(ytitle='Output (W)')
        g.new_series()
        g.new_plot(ytitle='Residual')
        g.new_series(plotid=1)
        g.new_plot(ytitle='Lumens', xtitle='time (s)')
        g.new_series(plotid=2)

        g.add_horizontal_rule(lumens, plotid=2)
        g.set_x_limits(0, duration * 1.1)
        return g
Example #11
0
    def _make_graph(self, lumens, duration):
        g = StackedGraph(container_dict=dict(stack_order='top_to_bottom'))
        g.new_plot(
                   ytitle='Output (W)'
                   )
        g.new_series()
        g.new_plot(
                   ytitle='Residual'
                   )
        g.new_series(plotid=1)
        g.new_plot(
                   ytitle='Lumens',
                   xtitle='time (s)')
        g.new_series(plotid=2)

        g.add_horizontal_rule(lumens, plotid=2)
        g.set_x_limits(0, duration * 1.1)
        return g
Example #12
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)
Example #13
0
        return v


if __name__ == '__main__':
    # m = MLLabel()
    # m.text = '<sup>40</sup>Ar'
    # d = Demo()
    # d.plot = Plot()
    # d.plot.padding_left = 80
    # d.plot.data = ArrayPlotData()
    # d.plot.data['x'] = [1, 2, 3, 4]
    # d.plot.data['y'] = [1, 2, 3, 4]
    # d.plot.plot(('x', 'y'))
    from pychron.graph.stacked_graph import StackedGraph

    g = StackedGraph()
    plot = g.new_plot(padding_left=100, padding_bottom=100)
    xa = plot.x_axis
    xa.title_color = 'red'
    xa.title = 'sasfas'
    nxa = MPlotAxis()
    nxa.title = '<sup>39</sup>Ar/<sup>40</sup>Ar'
    # nxa.title = '39Ar/40Ar'
    nxa.clone(xa)

    ya = plot.y_axis
    ya.title_color = 'red'
    ya.title = 'sasfas'
    ya.title_font = 'modern 36'
    nya = MPlotAxis()
    nya.title = '<sup>39</sup>Ar/<sup>40</sup>Ar'
Example #14
0
 def _graph_default(self):
     g = StackedGraph()
     g.new_plot(show_legend=True, padding=[30, 20, 10, 40], ytitle='Ar40', xtitle='# points')
     g.new_plot(padding=[30, 20, 10, 10], ytitle='Ar40_err')
     g.new_plot(padding=[30, 20, 10, 40], ytitle='Ar36')
     g.new_plot(padding=[30, 20, 10, 10], ytitle='Ar36_err')
     g.new_plot(padding=[30, 20, 10, 10], ytitle='Ar40/Ar36')
     g.new_plot(padding=[30, 20, 10, 10], ytitle='%Diff')
     #        g.new_plot(padding=[20, 20, 10, 10], ytitle='Ar40_err')
     return g
Example #15
0
 def _graph_default(self):
     g = StackedGraph()
     g.new_plot(show_legend=True,
                padding=[30, 20, 10, 40],
                ytitle='Ar40',
                xtitle='# points')
     g.new_plot(padding=[30, 20, 10, 10], ytitle='Ar40_err')
     g.new_plot(padding=[30, 20, 10, 40], ytitle='Ar36')
     g.new_plot(padding=[30, 20, 10, 10], ytitle='Ar36_err')
     g.new_plot(padding=[30, 20, 10, 10], ytitle='Ar40/Ar36')
     g.new_plot(padding=[30, 20, 10, 10], ytitle='%Diff')
     #        g.new_plot(padding=[20, 20, 10, 10], ytitle='Ar40_err')
     return g
Example #16
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