Exemplo n.º 1
0
    def _graph_factory(self, with_image=False):
        g = Graph(

                  container_dict=dict(
                                        padding=0
                                        ))
        g.new_plot(
                   bounds=[250, 250],
                   resizable='',
                   padding=[30, 0, 0, 30])

        cx = self.cx
        cy = self.cy
        cbx = self.xbounds
        cby = self.ybounds
        tr = self.target_radius

#        if with_image:
#            px = self.pxpermm  #px is in mm
#            cbx, cby = self._get_crop_bounds()
#            #g.set_axis_traits(tick_label_formatter=lambda x: '{:0.2f}'.format((x - w / 2) / px))
#            #g.set_axis_traits(tick_label_formatter=lambda x: '{:0.2f}'.format((x - h / 2) / px), axis='y')
#
#            bx, by = g.plots[0].bounds
#            g.plots[0].x_axis.mapper = LinearMapper(high_pos=bx,
#                                                    range=DataRange1D(low_setting=self.xbounds[0],
#                                                                      high_setting=self.xbounds[1]))
#            g.plots[0].y_axis.mapper = LinearMapper(high_pos=by,
#                                                    range=DataRange1D(low_setting=self.ybounds[0],
#                                                                      high_setting=self.ybounds[1]))
#            cx += self.image_width / 2
#            cy += self.image_height / 2
#            tr *= px

        g.set_x_limits(*cbx)
        g.set_y_limits(*cby)

        lp, _plot = g.new_series()
        t = TargetOverlay(component=lp,
                      cx=cx,
                      cy=cy,
                      target_radius=tr)

        lp.overlays.append(t)
        overlap_overlay = OverlapOverlay(component=lp,
                                              visible=self.show_overlap
                                              )
        lp.overlays.append(overlap_overlay)

        g.new_series(type='scatter', marker='circle')
        g.new_series(type='line', color='red')
        return g
    def _graph_factory(self):
        graph = Graph(container_dict=dict(padding=5,
                                          bgcolor='lightgray'))

        graph.new_plot(
                       padding=[50, 5, 5, 50],
#                       title='{}'.format(self.title),
                       xtitle='CDD Operating Voltage (V)',
                       ytitle='Intensity (fA)',
                       )
        graph.new_series(type='scatter',
                         marker='pixel')
        return graph
Exemplo n.º 3
0
    def _graph_factory(self):
        g = Graph(window_title='Coincidence Scan',
                  container_dict=dict(padding=5, bgcolor='lightgray')
                  )
        g.new_plot(padding=[50, 5, 5, 50],
                   ytitle='Intensity (fA)',
                   xtitle='Operating Voltage (V)')

        for di in self.spectrometer.detectors:
            g.new_series(
                         name=di.name,
                         color=di.color)

        return g
    def _execute_power_calibration_check(self):
        '''
        
        '''
        g = Graph()
        g.new_plot()
        g.new_series()
        g.new_series(x=[0, 100], y=[0, 100], line_style='dash')
        do_later(self._open_graph, graph=g)

        self._stop_signal = TEvent()
        callback = lambda pi, r: None
        self._iterate(self.check_parameters,
                      g, False, callback)
    def _graph_factory(self):
        gc = self.graph_cnt
        cnt = '' if not gc else gc
        self.graph_cnt += 1
        name = self.parent.name if self.parent else 'Foo'

        g = Graph(window_title='{} Power Calibration {}'.format(name, cnt),
                               container_dict=dict(padding=5),
                               window_x=500 + gc * 25,
                               window_y=25 + gc * 25
                               )

        g.new_plot(
                   xtitle='Setpoint (%)',
                   ytitle='Measured Power (W)')
        g.new_series()
        return g
Exemplo n.º 6
0
    def graph(poly, opoly, line):
        from src.graph.graph import Graph

        g = Graph()
        g.new_plot()

        for po in (poly, opoly):
            po = np.array(po)
            try:
                xs, ys = po.T
            except ValueError:
                xs, ys, _ = po.T
            xs = np.hstack((xs, xs[0]))
            ys = np.hstack((ys, ys[0]))
            g.new_series(xs, ys)

    #    for i, (p1, p2) in enumerate(lines):
    #        xi, yi = (p1[0], p2[0]), (p1[1], p2[1])
    #        g.new_series(xi, yi, color='black')
        return g
Exemplo n.º 7
0
    def _graph_default(self):
        g = Graph(container_dict=dict(padding=5,

                                      kind='h'))
        g.new_plot(xtitle='weight (mg)', ytitle='40Ar* (fA)',
                   padding=[60, 20, 60, 60]
#                   padding=60
                   )

        g.new_series()
        g.new_plot(xtitle='40Ar* (fA)', ytitle='%Error in Age',
                   padding=[30, 30, 60, 60]
                   )
        g.new_series()
#        fp = create_line_plot(([], []), color='red')
#        left, bottom = add_default_axes(fp)
#        bottom.visible = False
#        left.orientation = 'right'
#        left.axis_line_visible = False
#        bottom.axis_line_visible = False
#        left.visible = False

#        if self.kind == 'weight':
#            bottom.visible = True
#            bottom.orientation = 'top'
#            bottom.title = 'Error (ka)'
#            bottom.tick_color = 'red'
#            bottom.tick_label_color = 'red'
#            bottom.line_color = 'red'
#            bottom.title_color = 'red'
#        else:
#            left.title = 'Weight (mg)'
#        fp.visible = False
#        gd = GuideOverlay(fp, value=0.01, orientation='v')
#        fp.overlays.append(gd)
#        g.plots[0].add(fp)
#        self.secondary_plot = fp

        return g
    def _finish_calibration(self):
        super(FusionsCO2PowerCalibrationManager, self)._finish_calibration()
        g = Graph()
        g.new_plot()

        # plot W vs 8bit dac
        x = self.graph.get_data(axis=1)
        _, y = self.graph.get_aux_data()

        xf = self.graph.get_data(axis=1, series=2)
        _, yf = self.graph.get_aux_data(series=3)

#        print xf
#        print yf
        x, y = zip(*zip(x, y))
        xf, yf = zip(*zip(xf, yf))
        g.new_series(x, y)
        g.new_series(xf, yf)

        self._ipm_coeffs_w_v_r = self._regress(x, y, FITDEGREES['linear'])
        self. _ipm_coeffs_w_v_r1 = self._regress(xf, yf, FITDEGREES['linear'])

        self._open_graph(graph=g)
Exemplo n.º 9
0
    def _gc(self, p, det, kind):
        g = Graph(container_dict=dict(padding=5),
                  window_width=1000,
                  window_height=800,
                  window_x=40,
                  window_y=20
                  )
        with open(p, 'r') as fp:
            # gather data
            reader = csv.reader(fp)
            header = reader.next()
            groups = self._parse_data(reader)
            '''
                groups= [data,]
                data shape = nrow,ncols
                
            '''
            data = groups[0]
            x = data[0]
            y = data[header.index(det)]

        sy = smooth(y, window_len=120)  # , window='flat')

        x = x[::50]
        y = y[::50]
        sy = sy[::50]

        # smooth

        # plot
        g.new_plot(zoom=True, xtitle='Time (s)', ytitle='{} Baseline Intensity (fA)'.format(det))
        g.new_series(x, y, type=kind, marker='dot', marker_size=2)
        g.new_series(x, sy, line_width=2)
#        g.set_x_limits(500, 500 + 60 * 30)
#        g.edit_traits()
        return g
Exemplo n.º 10
0
    if use_convex_hull:
        poly = convex_hull(poly)
        xs, ys = poly.T
        cx, cy = xs.mean(), ys.mean()
        P = poly.T
        xs = np.hstack((xs, xs[0]))
        ys = np.hstack((ys, ys[0]))
    else:
        xs, ys = poly.T
        xs = np.hstack((xs, xs[0]))
        ys = np.hstack((ys, ys[0]))

    cx, cy = xs.mean(), ys.mean()

    # plot original
    g.new_series(xs, ys)
    g.set_x_limits(min(xs), max(xs), pad='0.1')
    g.set_y_limits(min(ys), max(ys), pad='0.1')
    for ps in npoints:
        for i in range(0, len(ps), 2):
            p1, p2 = ps[i], ps[i + 1]
            g.new_series((p1[0], p2[0]),
                         (p1[1], p2[1]), color='black')

    # plot offset polygon

#    poly = sort_clockwise(poly, poly)
    opoly = polygon_offset(poly, -500)
    if use_convex_hull:
        opoly = convex_hull(opoly)
        xs, ys, _ = opoly.T
Exemplo n.º 11
0
        x = range(1, 6)
        ratios1 = []
        errs1 = []
        for i in KEYS:
            m1, e1 = d._calculate_mean_ratio(nshots[i + '40'], nshots[i + '36cor'])
            ratios1.append(m1)
            errs1.append(e1)

        ms1 = calculate_mswd(ratios1, errs1)

        mswds1.append(ms1)

        rratios1.append(ratios1)

        if tau % 5 == 0:
            g.new_series(x, ratios1, plotid=1, type='line')
            i = int((tau / 5) - 1)
#            g.set_series_label('p', plotid=1, series=i)
#            g.set_series_label('{} (ns)'.format(tau), plotid=1, series=i)


#    g.plots[1].legend.plots = dict([(k, v[0]) for k, v in g.plots[1].plots.iteritems()])
#    print g.plots[1].legend.plots
    g.new_series(taus, mswds1, plotid=0, type='line_scatter')
    g.set_y_limits(min(mswds1) - 5, max(mswds1) + 5, plotid=0)

    # fit parabola and find minimum.
    coeffs1 = polyfit(taus, mswds1, 2)
    # min at dy=0   (ax2+bx+c)dx=dy==2ax+b
    # 2ax+b=0 , x=-b/(2a)
    dt = -coeffs1[1] / (2 * coeffs1[0])