示例#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
示例#2
0
        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
        xs = np.hstack((xs, xs[0]))
        ys = np.hstack((ys, ys[0]))
示例#3
0
        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])
    print 'dead time1= ', dt

    g.set_x_title('# Airshots', plotid=1)
    g.set_x_title('Dead Time (ns)', plotid=0)

    g.set_y_title('40Ar/36Ar', plotid=1)
    g.set_y_title('MSWD', plotid=0)

    g.add_vertical_rule(dt)