def __init__(self, *args, **kw): super(Scanner, self).__init__(*args, **kw) graph = Graph() self.graph = graph p = graph.new_plot(padding_top=30, padding_right=10) self._add_bounds(p) self._add_mftable_overlay(p) self._add_limit_tool(p) p.index_range.on_trait_change(self._handle_xbounds_change, 'updated') # graph.set_x_limits(self.min_dac, self.max_dac) graph.new_series() graph.set_x_title('Magnet DAC (Voltage)') graph.set_y_title('Intensity') self._use_mftable_limits_fired()
# 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) # g.add_plot_label('dead time (ns)= {:0.2f}'.format(dt), 235, 100) # g.add_data_label('dead time (ns)= {:0.2f}'.format(dt), dt, 30, plotid=0) g.add_data_label(dt, polyval(coeffs1, dt), plotid=0) # g.set_series_label('{} (ns)'.format(tau), plotid=1, series=0) g.configure_traits() #======== EOF ================================