def _plot_default(self): # Create a GridContainer to hold all of our plots: 2 rows, 3 columns container = GridPlotContainer(shape=(2,3), spacing=(10,5), valign='top', bgcolor='lightgray') # Create x data x = linspace(-5, 15.0, 100) pd = ArrayPlotData(index = x) # Plot some Bessel functions and add the plots to our container for i in range(6): data_name = 'y{}'.format(i) pd.set_data(data_name, jn(i,x)) plot = Plot(pd) plot.plot(('index', data_name), color=COLOR_PALETTE[i], line_width=3.0) # Set each plot's aspect based on its position in the grid plot.set(height=((i % 3) + 1)*50, resizable='h') # Add to the grid container container.add(plot) return container
def _plot_default(self): # Create a GridContainer to hold all of our plots: 2 rows, 3 columns container = GridPlotContainer(shape=(2, 3), spacing=(10, 5), valign='top', bgcolor='lightgray') pd = ArrayPlotData(data=np.arange(36).reshape(6, 6)) plots = [] renderers = [] for i in range(6): plot = Plot(pd) r, = plot.img_plot("data") plots.append(plot) renderers.append(r) add_tools(r) # Add to the grid container container.add(plot) share_attr(plots, "range2d") share_attr([rend.index_mapper for rend in renderers], "range") return container
class DemoGUI (HasTraits): camera_list = List containter = Instance(GridPlotContainer) update_thread_plot = Bool(False) button_play = Button() # Defines GUI view -------------------------- traits_view = View(Item('container', editor=ComponentEditor(), show_label=False), Item('button_play', label='Play', show_label=False), width=1000, height=600, resizable=True, title="Demo") #--------------------------------------------------- # Constructor and Chaco windows initialization #--------------------------------------------------- def __init__(self, ptv=None, exp1=None): super(DemoGUI, self).__init__() self.exp1 = exp1 self.ptv1 = ptv self.n_camera = self.exp1.active_params.m_params.Num_Cam print self.n_camera self.orig_image = [] self.hp_image = [] if self.n_camera == 1: shape = (1, 1) else: shape = (2, int(self.n_camera / 2)) self.container = GridPlotContainer(shape=shape) for i in range(self.n_camera): self.camera_list.append(DemoWindow()) self.container.add(self.camera_list[i]._plot) self.orig_image.append(np.array([], dtype=np.ubyte)) self.hp_image.append(np.array([])) def _button_play_fired(self): self.tr_thread = DemoThread() self.tr_thread.seq_first = self.exp1.active_params.m_params.Seq_First self.tr_thread.seq_last = self.exp1.active_params.m_params.Seq_Last self.tr_thread.n_camera = self.n_camera self.tr_thread.temp_img = [] base_name = [] for i in range(self.n_camera): exec( "base_name.append(self.exp1.active_params.m_params.Basename_%d_Seq)" % (i + 1)) print base_name[i] self.tr_thread.base_name = base_name self.tr_thread.start() while (self.tr_thread and (self.tr_thread.isAlive() or len(self.tr_thread.temp_img) > 0)): # print len(self.tr_thread.temp_img) if len(self.tr_thread.temp_img) > 0: if len(self.tr_thread.temp_img[0]) == self.n_camera: # print len(self.tr_thread.temp_img) for i in range(self.n_camera): self.camera_list[i].update_image( self.tr_thread.temp_img[0][i], is_float=1) # self.camera_list[i]._plot.request_redraw() self.container.window.control.Update() del self.tr_thread.temp_img[0]
def grid_plot_component(self): container = GridPlotContainer(padding=50, fill_padding=True, shape=(1, len(self.plot_constructors)), spacing=(20, 20)) for plot_constructor in self.plot_constructors: plot = plot_constructor() container.add(plot) return container
def _create_window(self): # Create the model #try: # self.model = model = BrainModel() # cmap = bone #except SystemExit: # sys.exit() #except: # print "Unable to load BrainModel, using generated data cube." self.model = model = Model() cmap = jet self._update_model(cmap) datacube = self.colorcube # Create the plot self.plotdata = ArrayPlotData() self._update_images() # Center Plot centerplot = Plot(self.plotdata, padding=0) imgplot = centerplot.img_plot("xy", xbounds=(model.xs[0], model.xs[-1]), ybounds=(model.ys[0], model.ys[-1]), colormap=cmap)[0] self._add_plot_tools(imgplot, "xy") self.center = imgplot # Right Plot rightplot = Plot(self.plotdata, width=150, resizable="v", padding=0) rightplot.value_range = centerplot.value_range imgplot = rightplot.img_plot("yz", xbounds=(model.zs[0], model.zs[-1]), ybounds=(model.ys[0], model.ys[-1]), colormap=cmap)[0] self._add_plot_tools(imgplot, "yz") self.right = imgplot # Bottom Plot bottomplot = Plot(self.plotdata, height=150, resizable="h", padding=0) bottomplot.index_range = centerplot.index_range imgplot = bottomplot.img_plot("xz", xbounds=(model.xs[0], model.xs[-1]), ybounds=(model.zs[0], model.zs[-1]), colormap=cmap)[0] self._add_plot_tools(imgplot, "xz") self.bottom = imgplot # Create Container and add all Plots container = GridPlotContainer(padding=20, fill_padding=True, bgcolor="white", use_backbuffer=True, shape=(2,2), spacing=(12,12)) container.add(centerplot) container.add(rightplot) container.add(bottomplot) self.container = container return Window(self, -1, component=container)
def _add_line_plots(self, plot): """Adds curve line plots to the ChacoPlot""" line_plots = [] for plot_config in self.line_plot_configs: line_plot = ChacoPlot(self._plot_data) # Customize text line_plot.trait_set(title=plot_config.title, padding=75, line_width=1) line_plot.x_axis.title = plot_config.x_label line_plot.y_axis.title = plot_config.y_label # Add pan and zoom tools line_plot.tools.append(PanTool(line_plot)) line_plot.overlays.append(ZoomTool(line_plot)) for name, kwargs in plot_config.line_config.items(): line = line_plot.plot((f"x_line_{name}", f"y_line_{name}"), type="line", **kwargs)[0] self._sub_axes[f'{name}_line_plot'] = line line_plots.append(line_plot) container = GridPlotContainer(*line_plots, shape=self._grid_shape, spacing=(0, 0), valign='top', bgcolor="none") self._component = HPlotContainer(plot, container, bgcolor="none") self._line_plots = line_plots
def _create_window(self): self.model = model = Model() self.cmap = jet #self._update_model(self.cmap) # Create the plot self.plotdata = ArrayPlotData() self._update_images() # Center Plot centerplot = Plot(self.plotdata, padding=0) imgplot = centerplot.img_plot("xy", xbounds=(model.min_x, model.max_x), ybounds=(model.min_y, model.max_y), colormap=self.cmap)[0] self._add_plot_tools(imgplot, "xy") self.center = imgplot # Right Plot rightplot = Plot(self.plotdata, width=150, resizable="v", padding=0) rightplot.value_range = centerplot.value_range imgplot = rightplot.img_plot("yz", xbounds=(model.min_z, model.max_z), ybounds=(model.min_y, model.max_y), colormap=self.cmap)[0] self._add_plot_tools(imgplot, "yz") self.right = imgplot # Bottom Plot. Seismic plot axis1 (depth) down into earth # i.e. z is depth, to altitude. bottomplot = Plot(self.plotdata, height=150, resizable="h", padding=0, origin="top left") bottomplot.index_range = centerplot.index_range imgplot = bottomplot.img_plot("xz", xbounds=(model.min_x, model.max_x), ybounds=(model.min_z, model.max_z), colormap=self.cmap)[0] self._add_plot_tools(imgplot, "xz") self.bottom = imgplot # Create Container and add all Plots container = GridPlotContainer(padding=20, fill_padding=True, bgcolor="white", use_backbuffer=True, shape=(2, 2), spacing=(20, 20)) container.add(centerplot) container.add(rightplot) container.add(bottomplot) self.container = container return Window(self, -1, component=container)
def __init__(self, ptv=None, exp1=None): super(DemoGUI, self).__init__() self.exp1 = exp1 self.ptv1 = ptv self.n_camera = self.exp1.active_params.m_params.Num_Cam print self.n_camera self.orig_image = [] self.hp_image = [] if self.n_camera == 1: shape = (1, 1) else: shape = (2, int(self.n_camera / 2)) self.container = GridPlotContainer(shape=shape) for i in range(self.n_camera): self.camera_list.append(DemoWindow()) self.container.add(self.camera_list[i]._plot) self.orig_image.append(np.array([], dtype=np.ubyte)) self.hp_image.append(np.array([]))
def _create_window(self): self.model = model = Model() self.cmap = jet #self._update_model(self.cmap) # Create the plot self.plotdata = ArrayPlotData() self._update_images() # Center Plot centerplot = Plot(self.plotdata, padding=0) imgplot = centerplot.img_plot("xy", xbounds=(model.min_x, model.max_x), ybounds=(model.min_y, model.max_y), colormap=self.cmap)[0] self._add_plot_tools(imgplot, "xy") self.center = imgplot # Right Plot rightplot = Plot(self.plotdata, width=150, resizable="v", padding=0) rightplot.value_range = centerplot.value_range imgplot = rightplot.img_plot("yz", xbounds=(model.min_z, model.max_z), ybounds=(model.min_y, model.max_y), colormap=self.cmap)[0] self._add_plot_tools(imgplot, "yz") self.right = imgplot # Bottom Plot. Seismic plot axis1 (depth) down into earth # i.e. z is depth, to altitude. bottomplot = Plot(self.plotdata, height=150, resizable="h", padding=0, origin="top left") bottomplot.index_range = centerplot.index_range imgplot = bottomplot.img_plot("xz", xbounds=(model.min_x, model.max_x), ybounds=(model.min_z, model.max_z), colormap=self.cmap)[0] self._add_plot_tools(imgplot, "xz") self.bottom = imgplot # Create Container and add all Plots container = GridPlotContainer(padding=20, fill_padding=True, bgcolor="white", use_backbuffer=True, shape=(2,2), spacing=(20,20)) container.add(centerplot) container.add(rightplot) container.add(bottomplot) self.container = container return Window(self, -1, component=container)
def __init__(self,ptv=None,exp1=None): super(DemoGUI, self).__init__() self.exp1=exp1 self.ptv1=ptv self.n_camera=self.exp1.active_params.m_params.Num_Cam print self.n_camera self.orig_image=[] self.hp_image=[] if self.n_camera==1: shape=(1,1) else: shape=(2,int(self.n_camera/2)) self.container=GridPlotContainer(shape=shape) for i in range(self.n_camera): self.camera_list.append(DemoWindow()) self.container.add(self.camera_list[i]._plot) self.orig_image.append(np.array([],dtype=np.ubyte)) self.hp_image.append(np.array([]))
def activate_template(self): """ Converts all contained 'TDerived' objects to real objects using the template traits of the object. This method must be overridden in subclasses. Returns ------- None """ plots = [] i = 0 for r in range(self.rows): row = [] for c in range(self.columns): plot = self.scatter_plots[i].plot if plot is None: plot = PlotComponent() row.append(plot) i += 1 plots.append(row) self.plot = GridPlotContainer(shape=(self.rows, self.columns)) self.plot.component_grid = plots
class ImagePlot(HasTraits): #create UI interface plot = Instance(GridPlotContainer) LineScans = Instance(GridPlotContainer) value = Str saved = Bool(True) filedir = Str filename = Str path = Str xLo = Str xHi = Str yLo = Str yHi = Str Cmin = Str Cmax = Str Cmin2 = Str Cmax2 = Str loaded = False Rtrue = Bool(True) R2true = Bool(False) Fluortrue = Bool(False) #Catch variables bounds = [] xLow = [] yLow = [] xHigh = [] yHigh = [] vscale = None notes = Str #UI buttons reload_button = Button("Reload") save_plot_button = Button("Save Plots..") save_LineScans_button = Button("Save LineScans..") load_button = Button("Load") load1_button =Button("Load 1") load2_button =Button("Load 2") load3_button =Button("Load 3") load4_button =Button("Load 4") catch_bounds = Button("Catch Bounds") to_csv = Button("Generate .CSV") scale_set = Button("Set Scale") reset = Button("Reset") nextfile = Button("Next") prevfile = Button("Prev") flatten = Button("Flatten") readline = Button("LineScan") colormap = Button("ApplyColorMap") genfilelist = Button("Generate File List") out_to_mat = Button("Generate .mat") special = Button("Special") presmooth = Bool plot1button = Bool plot2button = Bool plot3button = Bool plot4button = Bool fastline = Str slowline = Str fastscanline = 0 slowscanline = 0 fastline = str(fastscanline) slowline = str(slowscanline) fastlinevar = Str fastlinemean = Str fastlinemax = Str fastlinemin = Str slowlinevar = Str slowlinemean = Str slowlinemax = Str slowlinemin = Str x_f = Bool(label = "Fast Axis x:") y_f = Bool(label = "y:") z_f = Bool(label = "z:") x_s = Bool(label = "Slow Axis x:") y_s = Bool(label = "y:") z_s = Bool(label = "z:") xbounds=None ybounds=None #wildcard patterns file_wildcard = Str("zis File (*.zis)|*.zis|All files|*") file_wildcard2 = Str("png File (*.png)|*.png|All files|*") file_wildcard3 = Str("mat File (*.mat)|*.mat|All files|*") fastlinevars = Group( Item('fastlinevar'), Item('fastlinemean'), Item('fastlinemax'), Item('fastlinemin'),show_border=True) slowlinevars = Group( Item('slowlinevar'), Item('slowlinemean'), Item('slowlinemax'), Item('slowlinemin'),show_border=True) linescangroup = HGroup(Item('LineScans', editor=ComponentEditor(),show_label=False), VGroup( Item(name="plte", style = 'simple'), HGroup( Item('slowline'), Item('fastline'),), UItem('readline'), fastlinevars, slowlinevars ),label = "LineScan") colorgroup = VGroup(HGroup( Item('Cmin',width = -50), Item('Cmax',width = -50), Item('Cmin2',width = -50), Item('Cmax2',width = -50), ), HGroup( UItem('colormap'), UItem('genfilelist'), UItem('out_to_mat'), UItem('special'), ), show_border =True) tabs = Group(Item('plot', editor=ComponentEditor(),show_label=False), linescangroup, Item('notes', style = 'custom', width=.1), layout = "tabbed") plta = Enum("R", "Phase", "R0","R/R0","Fluor", "X", "Y") pltb = Enum("R", "Phase", "R0","R/R0","Fluor", "X", "Y") pltc = Enum("R", "Phase", "R0","R/R0","Fluor", "X", "Y") pltd = Enum("R", "Phase", "R0","R/R0","Fluor", "X", "Y") plte = Enum("R", "Phase", "R0","R/R0","Fluor", "X", "Y") lefttop = Group( VGroup( HGroup( Item('value', label = "File", width = 300), Item('presmooth'), ), HGroup( UItem('save_plot_button'), UItem('save_LineScans_button'), UItem('load_button'), UItem('nextfile'), UItem('prevfile'), ), HGroup( Item(name="plta", style = 'simple'), Item(name="pltb", style = 'simple'), Item(name="pltc", style = 'simple'), Item(name="pltd", style = 'simple'), UItem('reload_button'), ), ), ) righttop = Group( VGroup( HGroup( Item('xLo',width = -50, height = 25), Item('xHi',width = -50), Item('yLo',width = -50, height = 25), Item('yHi',width = -50), ), HGroup( UItem('flatten'), UItem('catch_bounds'), UItem('scale_set'), ), HGroup( UItem("load1_button"), UItem("load2_button"), UItem("load3_button"), UItem("load4_button"), ), ), show_border = True) traits_view = View( VGroup( HGroup( lefttop, righttop, colorgroup, ), tabs, ), width=1200, height=700, resizable=True, title="Scan Image Reconstruction") #USED DICTIONARY plotA = {"plot": plta, "data" : "", "shape" : "", "range" : np.zeros((2,2))} plotB = {"plot": pltb, "data" : "", "shape" : "", "range" : np.zeros((2,2))} plotC = {"plot": pltc, "data" : "", "shape" : "", "range" : np.zeros((2,2))} plotD = {"plot": pltd, "data" : "", "shape" : "", "range" : np.zeros((2,2))} plotE = {"plot": plte, "data" : "", "shape" : "", "range" : np.zeros((2,2))} def _Rtrue_changed(self): if self.Rtrue: self.R2true = False self.Fluortrue = False def _R2true_changed(self): if self.R2true: self.Rtrue = False self.Fluortrue = False def _Fluortrue_changed(self): if self.Fluortrue: self.Rtrue = False self.R2true = False def _plot1button_changed(self): if self.plot1button: self.plot2button = False self.plot3button = False self.plot4button = False self._plot2() def _plot2button_changed(self): if self.plot2button: self.plot1button=False self.plot3button = False self.plot4button = False self._plot2() def _plot3button_changed(self): if self.plot3button: self.plot1button=False self.plot2button = False self.plot4button = False self._plot2() def _plot4button_changed(self): if self.plot4button: self.plot1button=False self.plot2button = False self.plot3button = False self._plot2() def _colormap_fired(self): self.plot1.color_mapper.range.low = float(self.Cmin) self.plot1.color_mapper.range.high = float(self.Cmax) self.plot2.color_mapper.range.low = float(self.Cmin2) self.plot2.color_mapper.range.high = float(self.Cmax2) self.plot4.color_mapper.range.low = float(self.Cmin) self.plot4.color_mapper.range.high = float(self.Cmax) if self.plot1button or self.plot3button or self.plot4button: self.plot1lines.color_mapper.range.low = float(self.Cmin) self.plot1lines.color_mapper.range.high = float(self.Cmax) if self.plot2button: self.plot1lines.color_mapper.range.low = float(self.Cmin2) self.plot1lines.color_mapper.range.high = float(self.Cmax2) #self._plot() print "Color Mapped" def _scale_set_fired(self): self.plot1.range2d.x_range.low = float(self.xLo) self.plot1.range2d.x_range.high = float(self.xHi) self.plot1.range2d.y_range.low = float(self.yLo) self.plot1.range2d.y_range.high = float(self.yHi) self.plot2.range2d.x_range.low = float(self.xLo) self.plot2.range2d.x_range.high = float(self.xHi) self.plot2.range2d.y_range.low = float(self.yLo) self.plot2.range2d.y_range.high = float(self.yHi) self.plot3.range2d.x_range.low = float(self.xLo) self.plot3.range2d.x_range.high = float(self.xHi) self.plot3.range2d.y_range.low = float(self.yLo) self.plot3.range2d.y_range.high = float(self.yHi) self.plot4.range2d.x_range.low = float(self.xLo) self.plot4.range2d.x_range.high = float(self.xHi) self.plot4.range2d.y_range.low = float(self.yLo) self.plot4.range2d.y_range.high = float(self.yHi) self.plot1lines.range2d.x_range.low = float(self.xLo)/self.plotE["range"][0][1]*self.plotE["shape"][0] self.plot1lines.range2d.x_range.high = float(self.xHi)/self.plotE["range"][0][1]*self.plotE["shape"][0] self.plot1lines.range2d.y_range.low = float(self.yLo)/self.plotE["range"][1][1]*self.plotE["shape"][1] self.plot1lines.range2d.y_range.high = float(self.yHi)/self.plotE["range"][1][1]*self.plotE["shape"][1] self.slow_plot.range2d.x_range.low = float(self.xLo) self.slow_plot.range2d.x_range.high = float(self.xHi) self.fast_plot.range2d.x_range.low = float(self.yLo) self.fast_plot.range2d.x_range.high = float(self.yHi) def _reset_fired(self): self.vscale = None self.Cmin = "" self.Cmax = "" self._refresh() def _value_changed(self): #self.saved = False self.value = self.value def _refresh(self): try: self._plot() except: print "Option will be applied when plotting" def _readline_fired(self): #select which line to scan (this should be input as int value of line number until changed) self.fastscanline = int(self.fastline)#float(self.slowline)*float(self.dataset["range"][0][1])/self.dataset["shape"][0]) self.slowscanline = int(self.slowline)#float(self.fastline)*float(self.dataset["range"][1][1])/self.dataset["shape"][1]) slowstart = int(float(self.xLo)/float(self.plotE["range"][0][1])*self.plotE["shape"][0]) slowend = int(float(self.xHi)/float(self.plotE["range"][0][1])*self.plotE["shape"][0]-1) faststart = int(float(self.yLo)/float(self.plotE["range"][1][1])*self.plotE["shape"][1]) fastend = int(float(self.yHi)/float(self.plotE["range"][1][1])*(self.plotE["shape"][1])-1) fastarray = np.array(self._image_value.data[:,int(self.slowline)]) slowarray = np.array(self._image_value.data[int(self.fastline),:]) self.pd.set_data("line_value2", self._image_value.data[:,self.fastscanline]) self.pd.set_data("line_value", self._image_value.data[self.slowscanline,:]) self.fastlinevar = str(np.std(fastarray)) self.fastlinemean = str(np.mean(fastarray)) self.fastlinemax = str(np.amax(fastarray)) self.fastlinemin = str(np.amin(fastarray)) self.slowlinevar = str(np.std(slowarray)) self.slowlinemean = str(np.mean(slowarray)) self.slowlinemax = str(np.amax(slowarray)) self.slowlinemin = str(np.amin(slowarray)) self.slow_plot.title = "Slowline : " + str(self.fastscanline) self.fast_plot.title = "Fastline : " + str(self.fastscanline) def _flatten_fired(self): self._flatten() def _out_to_mat_fired(self): dialog = FileDialog(default_filename = self.filename+"_MATLAB_Phase"+str(self.plotA["notes"]["start"][2]), action="save as", wildcard=self.file_wildcard3) dialog.open() if dialog.return_code == OK: savefiledir = dialog.directory savefilename = dialog.filename path = os.path.join(savefiledir, savefilename) dataset = {self.plotA, self.plotB, self.plotC, self.plotD} scio.savemat(path, dataset, True) def _flatten(self): y=0 x=0 for line in self.plotA['data']: x_axis = np.arange(0,int(len(line))) y_axis = np.array(line) slope,intercept,r_value,p_value,std_err = stats.linregress(x_axis,y_axis) x=0 for point in line: self.plotA['data'][y,x] = point - (slope*x + intercept) x+=1 y+=1 y=0 x=0 for line in self.plotB['data']: x_axis = np.arange(0,int(len(line))) y_axis = np.array(line) slope,intercept,r_value,p_value,std_err = stats.linregress(x_axis,y_axis) x=0 for point in line: self.plotB['data'][y,x] = point - (slope*x + intercept) x+=1 y+=1 y=0 x=0 for line in self.plotC['data']: x_axis = np.arange(0,int(len(line))) y_axis = np.array(line) slope,intercept,r_value,p_value,std_err = stats.linregress(x_axis,y_axis) x=0 for point in line: self.plotC['data'][y,x] = point - (slope*x + intercept) x+=1 y+=1 y=0 x=0 for line in self.plotD['data']: x_axis = np.arange(0,int(len(line))) y_axis = np.array(line) slope,intercept,r_value,p_value,std_err = stats.linregress(x_axis,y_axis) x=0 for point in line: self.plotD['data'][y,x] = point - (slope*x + intercept) x+=1 y+=1 self._plot() print "Flattened" def _catch_bounds_fired(self): try: self.xLow = float(self.plot1.range2d.x_range.low) self.xHigh = float(self.plot1.range2d.x_range.high) self.yLow = float(self.plot1.range2d.y_range.low) self.yHigh = float(self.plot1.range2d.y_range.high) self.xLo = str(self.xLow) self.xHi = str(self.xHigh) self.yLo = str(self.yLow) self.yHi = str(self.yHigh) except: print "Please plot first" def _save_plot_button_fired(self): dialog = FileDialog(default_filename = self.filename+"_Plots_", action="save as", wildcard=self.file_wildcard2) dialog.open() if dialog.return_code == OK: savefiledir = dialog.directory savefilename = dialog.filename path = os.path.join(savefiledir, savefilename) #self.plot.do_layout(force=True) plot_gc = PlotGraphicsContext(self.plot.outer_bounds) plot_gc.render_component(self.plot) plot_gc.save(path) def _save_LineScans_button_fired(self): dialog = FileDialog(default_filename = self.filename+"_LineScan_", action="save as", wildcard=self.file_wildcard2) dialog.open() if dialog.return_code == OK: savefiledir = dialog.directory savefilename = dialog.filename path = os.path.join(savefiledir, savefilename) self.LineScans.do_layout(force=True) plot_gc = PlotGraphicsContext(self.LineScans.outer_bounds) plot_gc.render_component(self.LineScans) plot_gc.save(path) def _load_button_fired(self): dialog = FileDialog(action="open", wildcard=self.file_wildcard) dialog.open() if dialog.return_code == OK: self.value = dialog.filename title = self.value self.path = dialog.path self.filedir = dialog.directory self.allfiles =[] for filenames in os.walk(self.filedir): for files in filenames: for afile in files: if ".zis" in str(afile): if ".png" not in str(afile)and ".mat" not in str(afile): self.allfiles.append(self.filedir+"\\"+afile) self.filename = dialog.filename self.saved = True self.loaded = True self._loader(self.path) self._plot() def _nextfile_fired(self): if self.loaded: nextone = False path2=self.path ## self.allfiles =[] ## for filenames in os.walk(self.filedir): ## for files in filenames: ## for afile in files: ## if ".zis" in str(afile): ## if ".png" not in str(afile): ## self.allfiles.append(self.filedir+"\\"+afile) for afile in self.allfiles: if nextone == True: self.path = afile junk,self.value = afile.split(self.filedir+"\\") self.filename =self.value self._loader(self.path) self._plot() nextone=False break if afile == path2: nextone = True def _prevfile_fired(self): if self.loaded: nextone = False path2=self.path for afile in self.allfiles: if afile == path2: self.path = prevfile junk,self.value = prevfile.split(self.filedir+"\\") self.filename = self.value self._loader(self.path) self._plot() break prevfile = afile def _genfilelist_fired(self): if self.loaded: event = {'trial': 0 , "settings" : "", "notes": "", "time": ""} eventlist = {"Description": "", "0" : event} i=1 for afile in self.allfiles: #grab file name junk,currentfilename = afile.split(self.filedir+"\\") print "Working on file : " + currentfilename #unpickle file and grab data try: currentfile = open(afile,'rb') data = pickle.load(currentfile) currentfile.close() foldername,time = currentfilename.split("_") time,junk = time.split(".") settings = data['settings']['scan'] strsettings = "" for key, value in settings.iteritems() : strsettings += str(key) + " " + str(value)+ "\n" newtrial = {'trial': i, "settings" : strsettings, "notes": "", "time": time} eventlist[str(i)] = newtrial i +=1 except: print "\tcorrupt file, skipping" settings = "" strsettings ="" newtrial = "" #save data to data logger compatible file a = os.getcwd() + "/eventlist_"+foldername if not os.path.isdir(a): print "made" os.makedirs(a) b = a+ "/filelist.log" f1 = open(b, "w") pickle.dump(eventlist, f1) f1.close() print "File Write Complete" else: print "Please load a folder first" def _reload_button_fired(self): self._loader(self.path) self._plot() #----------------------------------------------- # Private API #----------------------------------------------- def _plot(self): print "...plotting" self.notes = "" for key, value in self.plotA["notes"].iteritems() : self.notes += str(key) + " " + str(value)+ "\n" self.container1 = GridPlotContainer(shape = (2,4), spacing = (0,0), use_backbuffer=True, valign = 'top', bgcolor = 'white') print"\t assigning data" self.plotdata1 = ArrayPlotData(imagedata = self.plotA["data"]) self.plotdata2 = ArrayPlotData(imagedata = self.plotB["data"]) self.plotdata3 = ArrayPlotData(imagedata = self.plotC["data"]) self.plotdata4 = ArrayPlotData(imagedata = self.plotD["data"]) print"\t calling names" self.plot1 = Plot(self.plotdata1, title = self.plotA["plot"]+ str(self.plotA["notes"]["start"])) self.plot2 = Plot(self.plotdata2, title = self.plotB["plot"]) self.plot3 = Plot(self.plotdata3, title = self.plotC["plot"]) self.plot4 = Plot(self.plotdata4, title = self.plotD["plot"]) self.plot1.img_plot("imagedata", xbounds = (self.plotA["range"][0][0],self.plotA["range"][0][1]), ybounds = (self.plotA["range"][1][0],self.plotA["range"][1][1])) self.plot2.img_plot("imagedata", xbounds = (self.plotB["range"][0][0],self.plotB["range"][0][1]), ybounds = (self.plotB["range"][1][0],self.plotB["range"][1][1])) self.plot3.img_plot("imagedata", xbounds = (self.plotC["range"][0][0],self.plotC["range"][0][1]), ybounds = (self.plotC["range"][1][0],self.plotC["range"][1][1])) self.plot4.img_plot("imagedata", xbounds = (self.plotD["range"][0][0],self.plotD["range"][0][1]), ybounds = (self.plotD["range"][1][0],self.plotD["range"][1][1])) # self.scale = Str(self.plot3.color_mapper.high) # plot1.index_axis.title = str(f) + ' (um)' ##ADD TOOLS self.plot1.tools.append(PanTool(self.plot1)) zoom1 = ZoomTool(component=self.plot1, tool_mode="box", always_on=False) self.plot1.overlays.append(zoom1) self.plot2.tools.append(PanTool(self.plot2)) zoom2 = ZoomTool(component=self.plot2, tool_mode="box", always_on=False) self.plot2.overlays.append(zoom2) self.plot3.tools.append(PanTool(self.plot3)) zoom3 = ZoomTool(component=self.plot3, tool_mode="box", always_on=False) self.plot3.overlays.append(zoom3) self.plot4.tools.append(PanTool(self.plot4)) zoom4 = ZoomTool(component=self.plot4, tool_mode="box", always_on=False) self.plot4.overlays.append(zoom4) ##ADD COLORBARS self.colorbar1 = ColorBar(index_mapper=LinearMapper(range=self.plot1.color_mapper.range), color_mapper=self.plot1.color_mapper, orientation='v', resizable='v', width=20, padding=5) self.colorbar1.plot = self.plot1 self.colorbar1.padding_left = 45 self.colorbar1.padding_right= 5 self.colorbar2 = ColorBar(index_mapper=LinearMapper(range=self.plot2.color_mapper.range), color_mapper=self.plot2.color_mapper, orientation='v', resizable='v', width=20, padding=5) self.colorbar2.plot = self.plot2 self.colorbar2.padding_left = 10 self.colorbar3 = ColorBar(index_mapper=LinearMapper(range=self.plot3.color_mapper.range), color_mapper=self.plot3.color_mapper, orientation='v', resizable='v', width=20, padding=5) self.colorbar3.plot = self.plot3 self.colorbar3.padding_left = 45 self.colorbar3.padding_right= 5 self.colorbar4 = ColorBar(index_mapper=LinearMapper(range=self.plot4.color_mapper.range), color_mapper=self.plot4.color_mapper, orientation='v', resizable='v', width=20, padding=5) self.colorbar4.plot = self.plot4 self.colorbar4.padding_left = 15 self.colorbar1.tools.append(PanTool(self.colorbar1, constrain_direction="y", constrain=True)) self.zoom_overlay1 = ZoomTool(self.colorbar1, axis="index", tool_mode="range", always_on=True, drag_button="right") self.colorbar1.overlays.append(self.zoom_overlay1) self.colorbar2.tools.append(PanTool(self.colorbar2, constrain_direction="y", constrain=True)) self.zoom_overlay2 = ZoomTool(self.colorbar2, axis="index", tool_mode="range", always_on=True, drag_button="right") self.colorbar2.overlays.append(self.zoom_overlay2) self.colorbar3.tools.append(PanTool(self.colorbar3, constrain_direction="y", constrain=True)) self.zoom_overlay3 = ZoomTool(self.colorbar3, axis="index", tool_mode="range", always_on=True, drag_button="right") self.colorbar3.overlays.append(self.zoom_overlay3) self.colorbar4.tools.append(PanTool(self.colorbar4, constrain_direction="y", constrain=True)) self.zoom_overlay4 = ZoomTool(self.colorbar4, axis="index", tool_mode="range", always_on=True, drag_button="right") self.colorbar4.overlays.append(self.zoom_overlay4) self.container1.add(self.colorbar1) self.container1.add(self.plot1) self.container1.add(self.plot2) self.container1.add(self.colorbar2) self.container1.add(self.colorbar3) self.container1.add(self.plot3) self.container1.add(self.plot4) self.container1.add(self.colorbar4) self.plot1.padding_right = 5 self.plot2.padding_left = 5 self.plot1.padding_bottom = 15 self.plot2.padding_bottom = 15 self.plot3.padding_top = 15 self.plot4.padding_top = 15 self.plot1.x_axis.orientation = "top" self.plot2.x_axis.orientation = "top" self.plot2.y_axis.orientation = "right" self.plot3.padding_right = 5 self.plot4.padding_left = 5 self.plot4.y_axis.orientation = "right" self.colorbar1.padding_top = self.plot1.padding_top self.colorbar1.padding_bottom = self.plot1.padding_bottom self.colorbar2.padding_top = self.plot2.padding_top self.colorbar2.padding_bottom = self.plot2.padding_bottom self.colorbar3.padding_top = self.plot3.padding_top self.colorbar3.padding_bottom = self.plot3.padding_bottom self.colorbar4.padding_top = self.plot4.padding_top self.colorbar4.padding_bottom = self.plot4.padding_bottom imgtool = ImageInspectorTool(self.plot1) self.plot1.tools.append(imgtool) overlay = ImageInspectorOverlay(component=self.plot1, image_inspector=imgtool, bgcolor="white", border_visible=True) self.plot1.overlays.append(overlay) self.plot = self.container1 self._plot2() #######line plots############################################################################################## def _plot2(self): print"...plotting line scans" title = str(self.plotE['plot']) + str(self.plotE["notes"]["start"]) self.plotdata5 = ArrayPlotData(imagedata = self.plotE['data']) self._image_index = GridDataSource(array([]), array([]), sort_order=("ascending","ascending")) self.xs = linspace(self.plotE["range"][0][0], self.plotE["range"][0][1], self.plotE["shape"][0]) self.ys = linspace(self.plotE["range"][1][0], self.plotE["range"][1][1], self.plotE["shape"][1]) self._image_index.set_data(self.xs, self.ys) image_index_range = DataRange2D(self._image_index) self._image_value = ImageData(data=array([]), value_depth=1) self._image_value.data = self.plotE['data'] image_value_range = DataRange1D(self._image_value) s = "" f = "" if self.x_s: s = "X" if self.y_s: s = "Y" if self.z_s: s = "Z" if self.x_f: f = "X" if self.y_f: f = "Y" if self.z_f: f = "Z" self.plot1lines = Plot(self.plotdata5, title = title) self.plot1lines.img_plot("imagedata", xbounds = (self.plotE["range"][0][0],self.plotE["range"][0][1]), ybounds = (self.plotE["range"][1][0],self.plotE["range"][1][1]), colormap=jet) img_plot = self.plot1lines.img_plot("imagedata")[0] imgtool = ImageInspectorTool(img_plot) img_plot.tools.append(imgtool) overlay = ImageInspectorOverlay(component=img_plot, image_inspector=imgtool, bgcolor="white", border_visible=True) self.plot1lines.overlays.append(overlay) ##ADD TOOLS self.plot1lines.tools.append(PanTool(self.plot1lines)) zoom1 = ZoomTool(component=self.plot1lines, tool_mode="box", always_on=False) self.plot1lines.overlays.append(zoom1) self.plot1lines.overlays.append(LineInspector(component=self.plot1lines, axis='index_x', inspect_mode="indexed", write_metadata=True, is_listener=False, #constrain_key="right", color="white")) self.plot1lines.overlays.append(LineInspector(component=self.plot1lines, axis='index_y', inspect_mode="indexed", write_metadata=True, color="white", is_listener=False)) ##ADD COLORBAR self.colorbar5 = ColorBar(index_mapper=LinearMapper(range=self.plot1lines.color_mapper.range), color_mapper=self.plot1lines.color_mapper, orientation='v', resizable='v', width=20, padding=5) self.colorbar5.plot = self.plot1lines self.colorbar5.tools.append(PanTool(self.colorbar5, constrain_direction="y", constrain=True)) self.zoom_overlay5 = ZoomTool(self.colorbar5, axis="index", tool_mode="range", always_on=True, drag_button="right") self.colorbar5.overlays.append(self.zoom_overlay5) self.pd = ArrayPlotData(line_index = array([]), line_value = array([])) self.slow_plot = Plot(self.pd, title = "Slowline : " + self.slowline) self.slow_plot.plot(("line_index", "line_value"), line_style='solid') self.pd.set_data("line_index2", array([])) self.pd.set_data("line_value2", array([])) self.fast_plot = Plot(self.pd, title = "Fastline : " + self.fastline) self.fast_plot.plot(("line_index2", "line_value2"), line_style='solid') self.pd.set_data("line_index", self.xs) self.pd.set_data("line_index2", self.ys) self.pd.set_data("line_value", self._image_value.data[self.fastscanline,:]) self.pd.set_data("line_value2", self._image_value.data[:,self.slowscanline]) self.colorbar5.padding= 0 self.colorbar5.padding_left = 15 #self.colorbar5.height = 400 self.colorbar5.padding_top =50 self.colorbar5.padding_bottom = 0 self.colorbar5.padding_right = 25 self.colorbar5.padding_left = 50 self.plot1lines.width = 300 self.plot1lines.padding_top = 50 self.plot1lines.index_axis.title = 'fast axis (um)' self.plot1lines.value_axis.title = 'slow axis (um)' self.slow_plot.width = 100 self.slow_plot.padding_right = 20 self.fast_plot.width = 100 self.fast_plot.padding_right = 20 self.container2 = GridPlotContainer(shape = (1,2), spacing = ((0,0)), use_backbuffer=True, valign = 'top', halign = 'center', bgcolor = 'white') self.container3 = GridPlotContainer(shape = (2,1), spacing = (0,0), use_backbuffer=True, valign = 'top', halign = 'center', bgcolor = 'grey') self.container4 = GridPlotContainer(shape = (1,2), spacing = (0,0), use_backbuffer=True, valign = 'top', halign = 'center', bgcolor = 'grey') self.container2.add(self.colorbar5) self.container3.add(self.fast_plot) self.container3.add(self.slow_plot) self.container4.add(self.container3) self.container4.add(self.plot1lines) self.container2.add(self.container4) self.LineScans = self.container2 self._readline_fired() self._scale_set_fired() def _load_file(self,i): file = open(str(i),'rb') print "\n\n" + str(i) + " is open" self.data = pickle.load(file) file.close() print "\nfile.closed" return ######################################################### def _special_fired(self): #load stitch print "All resolutions must be the same" a,b = 2,3 #raw_input("\tset rows and cols: ") size = 512 #raw_input("\tsize:") self.stitchdataA = np.zeros((size*a, size*b)) self.stitchdataB = np.zeros((size*a, size*b)) i = 1 col = 0 while i < a*b: j = 1 row = 0 while j < b: self._load_file(self._single_load()) self.plotA['plot'] = self.plta self.plotA = self._pick_plots(self.plotA) print col*size, row*size self.stitchdataA[col*size : col*self.plotA["shape"][0], row*size : row*self.plotA["shape"][1]] = self.plotA row = row+1 j = j+1 i = i+1 col = col+1 i = 1 col = 0 while i < a*b: j = 1 row = 0 while j < b: self._load_file(self._single_load()) self.plotB['plot'] = self.pltb self.plotB = self._pick_plots(self.plotB) self.stitchdataB[col*size : col*self.plotB["shape"][0], row*size : row*self.plotB["shape"][1]] = self.plotB row = row+1 j = j+1 i = i+1 col = col+1 self.plotA["data"] = self.stitchdataA self.plotB["data"] = self.stitchdataB self.plotC["data"] = self.stitchdataA self.plotD["data"] = self.stitchdataB self.plotA["range"][0][0] = 0 self.plotA["range"][1][0] = 0 self.plotA["range"][0][1] = size*a self.plotA["range"][1][1] = size*b self.plotA["shape"] = (size*b, size*a) self._plot() gc.collect() return ######################################################## def _pick_plots(self, plotdata): #plotA = Enum("R", "Phase", "R0","R/R0","Fluor", "X", "Y") print "...loading plot" #gather shape info plotdata["notes"] = self.data['settings']['scan'] print "\t filling shapes" for x in xrange(3): if plotdata["notes"]['axes'][x] == 0: fast = plotdata["notes"]['npoints'][x] plotdata["range"][0][1] = plotdata["notes"]["fast_axis_range"] if plotdata["notes"]['axes'][x] == 1: slow = plotdata["notes"]['npoints'][x] plotdata["range"][1][1] = plotdata["notes"]['range'][x] plotdata["shape"] =(fast,slow) print "\t filling data" data =np.zeros((fast,slow)) try: if plotdata['plot']== "R": print "\t\tplotting R" data = np.sqrt(np.multiply(np.array(self.data['data']['lia_x']["0"]),np.array(self.data['data']['lia_x']["0"])) + np.multiply(np.array(self.data['data']['lia_y']["0"]),np.array(self.data['data']['lia_y']["0"]))) if plotdata['plot'] == "Phase": print "\t\tplotting Phase" data = np.arctan2(np.array(self.data['data']['lia_y']["0"]),np.array(self.data['data']['lia_x']["0"])) if plotdata['plot']== "R0": print "\t\tplotting R0" data = np.sqrt(np.multiply(np.array(self.data['data']['lia_x']["3"]),np.array(self.data['data']['lia_x']["3"])) + np.multiply(np.array(self.data['data']['lia_y']["3"]),np.array(self.data['data']['lia_y']["3"]))) if plotdata['plot']== "R/R0": print "\t\tplotting R/R0" data = np.sqrt(np.multiply(np.array(self.data['data']['lia_x']["0"]),np.array(self.data['data']['lia_x']["0"])) + np.multiply(np.array(self.data['data']['lia_y']["0"]),np.array(self.data['data']['lia_y']["0"])))/np.sqrt(np.multiply(np.array(self.data['data']['lia_x']["3"]),np.array(self.data['data']['lia_x']["3"])) + np.multiply(np.array(self.data['data']['lia_y']["3"]),np.array(self.data['data']['lia_y']["3"]))) if plotdata['plot']== "Fluor": print "\t\tplotting Fluor" data = np.array(self.data['data']['dio2']) if plotdata['plot']=="X": print "\t\tplotting X" data = np.array(self.data['data']['lia_x']["0"]) if plotdata['plot']=="Y": print "\t\tplotting Y" data = np.array(self.data['data']['lia_y']["0"]) except: print "Process failed-- check dropdown assignments" data.shape = (plotdata["shape"]) plotdata['data'] = data return plotdata def _single_load(self): dialog = FileDialog(action="open", wildcard=self.file_wildcard) dialog.open() if dialog.return_code == OK: return dialog.path def _loader(self, i): #open file with specified path unpickle and prepare to pass to dictionary self._load_file(i) #--APPLY LOGIC CONDITIONS TO DATA AND ASSIGN TO PLOTING 2D ARRAYS self.plotA['plot'] = self.plta self.plotB['plot'] = self.pltb self.plotC['plot'] = self.pltc self.plotD['plot'] = self.pltd self.plotE['plot'] = self.plte self.plotA = self._pick_plots(self.plotA) self.plotB = self._pick_plots(self.plotB) self.plotC = self._pick_plots(self.plotC) self.plotD = self._pick_plots(self.plotD) self.plotE = self._pick_plots(self.plotE) if self.xLo == "": print "...populating ranges" self.xLo = str(self.plotA["range"][0][0]) self.xHi = str(self.plotA["range"][0][1]) self.yLo = str(self.plotA["range"][1][0]) self.yHi = str(self.plotA["range"][1][1]) gc.collect() return def _load1_button_fired(self): #open file with specified path unpickle and prepare to pass to dictionary self._load_file(self._single_load()) #--APPLY LOGIC CONDITIONS TO DATA AND ASSIGN TO PLOTING 2D ARRAYS self.plotA['plot'] = self.plta self.plotA = self._pick_plots(self.plotA) gc.collect() self._plot() return def _load2_button_fired(self): #open file with specified path unpickle and prepare to pass to dictionary self._load_file(self._single_load()) #--APPLY LOGIC CONDITIONS TO DATA AND ASSIGN TO PLOTING 2D ARRAYS self.plotB['plot'] = self.pltb self.plotB = self._pick_plots(self.plotB) gc.collect() self._plot() return def _load3_button_fired(self): #open file with specified path unpickle and prepare to pass to dictionary self._load_file(self._single_load()) #--APPLY LOGIC CONDITIONS TO DATA AND ASSIGN TO PLOTING 2D ARRAYS self.plotC['plot'] = self.pltc self.plotC = self._pick_plots(self.plotC) gc.collect() self._plot() return def _load4_button_fired(self): #open file with specified path unpickle and prepare to pass to dictionary self._load_file(self._single_load()) #--APPLY LOGIC CONDITIONS TO DATA AND ASSIGN TO PLOTING 2D ARRAYS self.plotD['plot'] = self.pltd self.plotD = self._pick_plots(self.plotD) gc.collect() self._plot() return
def _plot2(self): print"...plotting line scans" title = str(self.plotE['plot']) + str(self.plotE["notes"]["start"]) self.plotdata5 = ArrayPlotData(imagedata = self.plotE['data']) self._image_index = GridDataSource(array([]), array([]), sort_order=("ascending","ascending")) self.xs = linspace(self.plotE["range"][0][0], self.plotE["range"][0][1], self.plotE["shape"][0]) self.ys = linspace(self.plotE["range"][1][0], self.plotE["range"][1][1], self.plotE["shape"][1]) self._image_index.set_data(self.xs, self.ys) image_index_range = DataRange2D(self._image_index) self._image_value = ImageData(data=array([]), value_depth=1) self._image_value.data = self.plotE['data'] image_value_range = DataRange1D(self._image_value) s = "" f = "" if self.x_s: s = "X" if self.y_s: s = "Y" if self.z_s: s = "Z" if self.x_f: f = "X" if self.y_f: f = "Y" if self.z_f: f = "Z" self.plot1lines = Plot(self.plotdata5, title = title) self.plot1lines.img_plot("imagedata", xbounds = (self.plotE["range"][0][0],self.plotE["range"][0][1]), ybounds = (self.plotE["range"][1][0],self.plotE["range"][1][1]), colormap=jet) img_plot = self.plot1lines.img_plot("imagedata")[0] imgtool = ImageInspectorTool(img_plot) img_plot.tools.append(imgtool) overlay = ImageInspectorOverlay(component=img_plot, image_inspector=imgtool, bgcolor="white", border_visible=True) self.plot1lines.overlays.append(overlay) ##ADD TOOLS self.plot1lines.tools.append(PanTool(self.plot1lines)) zoom1 = ZoomTool(component=self.plot1lines, tool_mode="box", always_on=False) self.plot1lines.overlays.append(zoom1) self.plot1lines.overlays.append(LineInspector(component=self.plot1lines, axis='index_x', inspect_mode="indexed", write_metadata=True, is_listener=False, #constrain_key="right", color="white")) self.plot1lines.overlays.append(LineInspector(component=self.plot1lines, axis='index_y', inspect_mode="indexed", write_metadata=True, color="white", is_listener=False)) ##ADD COLORBAR self.colorbar5 = ColorBar(index_mapper=LinearMapper(range=self.plot1lines.color_mapper.range), color_mapper=self.plot1lines.color_mapper, orientation='v', resizable='v', width=20, padding=5) self.colorbar5.plot = self.plot1lines self.colorbar5.tools.append(PanTool(self.colorbar5, constrain_direction="y", constrain=True)) self.zoom_overlay5 = ZoomTool(self.colorbar5, axis="index", tool_mode="range", always_on=True, drag_button="right") self.colorbar5.overlays.append(self.zoom_overlay5) self.pd = ArrayPlotData(line_index = array([]), line_value = array([])) self.slow_plot = Plot(self.pd, title = "Slowline : " + self.slowline) self.slow_plot.plot(("line_index", "line_value"), line_style='solid') self.pd.set_data("line_index2", array([])) self.pd.set_data("line_value2", array([])) self.fast_plot = Plot(self.pd, title = "Fastline : " + self.fastline) self.fast_plot.plot(("line_index2", "line_value2"), line_style='solid') self.pd.set_data("line_index", self.xs) self.pd.set_data("line_index2", self.ys) self.pd.set_data("line_value", self._image_value.data[self.fastscanline,:]) self.pd.set_data("line_value2", self._image_value.data[:,self.slowscanline]) self.colorbar5.padding= 0 self.colorbar5.padding_left = 15 #self.colorbar5.height = 400 self.colorbar5.padding_top =50 self.colorbar5.padding_bottom = 0 self.colorbar5.padding_right = 25 self.colorbar5.padding_left = 50 self.plot1lines.width = 300 self.plot1lines.padding_top = 50 self.plot1lines.index_axis.title = 'fast axis (um)' self.plot1lines.value_axis.title = 'slow axis (um)' self.slow_plot.width = 100 self.slow_plot.padding_right = 20 self.fast_plot.width = 100 self.fast_plot.padding_right = 20 self.container2 = GridPlotContainer(shape = (1,2), spacing = ((0,0)), use_backbuffer=True, valign = 'top', halign = 'center', bgcolor = 'white') self.container3 = GridPlotContainer(shape = (2,1), spacing = (0,0), use_backbuffer=True, valign = 'top', halign = 'center', bgcolor = 'grey') self.container4 = GridPlotContainer(shape = (1,2), spacing = (0,0), use_backbuffer=True, valign = 'top', halign = 'center', bgcolor = 'grey') self.container2.add(self.colorbar5) self.container3.add(self.fast_plot) self.container3.add(self.slow_plot) self.container4.add(self.container3) self.container4.add(self.plot1lines) self.container2.add(self.container4) self.LineScans = self.container2 self._readline_fired() self._scale_set_fired()
class DemoGUI(HasTraits): camera_list = List containter = Instance(GridPlotContainer) update_thread_plot = Bool(False) button_play = Button() # Defines GUI view -------------------------- traits_view = View(Item('container', editor=ComponentEditor(), show_label=False), Item('button_play', label='Play', show_label=False), width=1000, height=600, resizable=True, title="Demo") #--------------------------------------------------- # Constructor and Chaco windows initialization #--------------------------------------------------- def __init__(self, ptv=None, exp1=None): super(DemoGUI, self).__init__() self.exp1 = exp1 self.ptv1 = ptv self.n_camera = self.exp1.active_params.m_params.Num_Cam print self.n_camera self.orig_image = [] self.hp_image = [] if self.n_camera == 1: shape = (1, 1) else: shape = (2, int(self.n_camera / 2)) self.container = GridPlotContainer(shape=shape) for i in range(self.n_camera): self.camera_list.append(DemoWindow()) self.container.add(self.camera_list[i]._plot) self.orig_image.append(np.array([], dtype=np.ubyte)) self.hp_image.append(np.array([])) def _button_play_fired(self): self.tr_thread = DemoThread() self.tr_thread.seq_first = self.exp1.active_params.m_params.Seq_First self.tr_thread.seq_last = self.exp1.active_params.m_params.Seq_Last self.tr_thread.n_camera = self.n_camera self.tr_thread.temp_img = [] base_name = [] for i in range(self.n_camera): exec( "base_name.append(self.exp1.active_params.m_params.Basename_%d_Seq)" % (i + 1)) print base_name[i] self.tr_thread.base_name = base_name self.tr_thread.start() while (self.tr_thread and (self.tr_thread.isAlive() or len(self.tr_thread.temp_img) > 0)): # print len(self.tr_thread.temp_img) if len(self.tr_thread.temp_img) > 0: if len(self.tr_thread.temp_img[0]) == self.n_camera: # print len(self.tr_thread.temp_img) for i in range(self.n_camera): self.camera_list[i].update_image( self.tr_thread.temp_img[0][i], is_float=1) # self.camera_list[i]._plot.request_redraw() self.container.window.control.Update() del self.tr_thread.temp_img[0]
def create_plot_component(self): if not self.data.size: return self.pd = ArrayPlotData() self.shape = self.data.shape self.pd.set_data("imagedata", self.data) self.pd.set_data("left_line", self.data[:, self.shape[0]//2]) self.pd.set_data("top_line", self.data[self.shape[1]//2,:]) plot = Plot(self.pd) cmap = default_colormaps.color_map_name_dict[self.colormap] if self.rev_cmap: cmap = default_colormaps.reverse(cmap) drange = DataRange1D(ImageData(data=self.data, value_depth=1)) self.ccmap = cmap_constant_range(cmap, drange)(drange) #from copy import copy self.img_plot = plot.img_plot("imagedata", colormap=cmap, #xbounds=self.xbounds, #ybounds=self.ybounds, )[0] self.cmap = self.img_plot.value_mapper if not self.autoscale: self.img_plot.value_mapper = self.ccmap # Tweak some of the plot properties plot.title = self.title plot.padding = 10 # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) csr = CursorTool(self.img_plot, drag_button='right', color='white', line_width=2.0 ) self.cursor = csr csr.current_index = self.shape[0]//2, self.shape[1]//2 self.img_plot.overlays.append(csr) imgtool = ImageInspectorTool(self.img_plot) self.img_plot.tools.append(imgtool) overlay = ImageInspectorOverlay(component=self.img_plot, image_inspector=imgtool, bgcolor="white", border_visible=True) self.img_plot.overlays.append(overlay) self.plot = plot self.cross_plot = Plot(self.pd,resizable='h') self.cross_plot.height = 40 self.cross_plot.padding = 15 self.cross_plot.plot("top_line", line_style="dot") self.cross_plot.index_range = self.img_plot.index_range.x_range self.cross_plot2 = Plot(self.pd, width=40, orientation="v", padding=15, padding_bottom=10, resizable='v') self.cross_plot2.plot("left_line", line_style="dot") self.cross_plot2.index_range = self.img_plot.index_range.y_range # Create a container and add components #self.container = HPlotContainer(padding=10, fill_padding=False, # bgcolor="none", use_backbuffer=False) #inner_cont = VPlotContainer(padding=0, use_backbuffer=True, bgcolor="none") #inner_cont.add(self.plot) #inner_cont.add(self.cross_plot) self.container = GridPlotContainer(padding=20, fill_padding=False, bgcolor="none", use_backbuffer=True, shape=(2, 2), spacing=(12, 20)) #self.container.add(self.colorbar) self.container.add(self.plot) self.container.add(self.cross_plot2) self.container.add(self.cross_plot)
class ImageViewer(BaseViewer): class_name = 'ImageViewer' pd = Instance(ArrayPlotData,transient=True) title = Str('') plot = Instance(Component,transient=True) container = Instance(GridPlotContainer,transient=True) shape = Tuple() cursor = Instance(BaseCursorTool, transient=True) cursor_pos = DelegatesTo('cursor', prefix='current_position') cursor_value = Float() #cursor_idx = DelegatesTo('cursor', prefix='current_idx') xpos = Property() ypos = Property() autoscale = Bool(True) save = Button('Save') data = Array() xaxis = Enum(0, [0, 1]) yaxis = Enum(1, [0, 1]) zaxis = None start_pos = Tuple((0.,0.),cols=2, labels=['X','Y']) resolution = Tuple((1.,1.),cols=2, labels=['X','Y']) xbounds = Property(depends_on='xaxis,data, start_pos,resolution') ybounds = Property(depends_on='yaxis,data, start_pos,resolution') colormap = Enum('hot', colormaps) rev_cmap = Bool(False) view = View( VGroup(spring, HGroup(Item(name='autoscale', label='Autoscale'), spring, Item(name='cursor_value', show_label=False, style='text', enabled_when='False'), show_left=False), HGroup( spring, Item('container', editor=ComponentEditor(), #width=450,height=400, show_label=False), spring, ), spring), handler=ArraySavehandler, resizable=True, ) def __init__(self,*args,**kwargs): super(ImageViewer, self).__init__(*args, **kwargs) self.create_plot_component() def _data_default(self): return np.random.random((1280, 1024)) def _get_xpos(self): return self.cursor_pos[self.xaxis] def _get_ypos(self): return self.cursor_pos[self.yaxis] def _get_xbounds(self): if len(self.data.shape)>self.xaxis: return self.start_pos[self.xaxis], self.data.shape[self.xaxis]*self.resolution[self.xaxis] else: return (0.,1.) def _get_ybounds(self): if len(self.data.shape)>self.yaxis: return self.start_pos[self.yaxis], self.data.shape[self.yaxis]*self.resolution[self.yaxis] else: return (0.,1.) @on_trait_change('data,cursor_idx') def update_data(self): #pos = self.cursor if self.shape == self.data.shape: csr_idx = tuple(self.cursor.current_index) self.pd.set_data("imagedata", self.data) self.pd.set_data("left_line", self.data[:, csr_idx[0]]) self.pd.set_data("top_line", self.data[csr_idx[1], :]) self.cursor_value = self.data[csr_idx[1], csr_idx[0]] return else: self.create_plot_component() """ @on_trait_change('data, xaxis, yaxis, rev_colormap, colormap') def create_plot_component(self):# Create a scalar field to colormap # Create the plot if not self.data.size: return if self.shape==self.data.shape: self.pd.set_data("imagedata", self.data) return self.pd = ArrayPlotData() self.shape = self.data.shape self.pd.set_data("imagedata", self.data) plot = Plot(self.pd) cmap = default_colormaps.color_map_name_dict[self.colormap] if self.rev_cmap: cmap = default_colormaps.reverse(cmap) img_plot = plot.img_plot("imagedata", colormap=cmap, #xbounds=self.xbounds, #ybounds=self.ybounds, )[0] # Tweak some of the plot properties plot.title = self.title plot.padding = 50 # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) csr = CursorTool(img_plot, drag_button='right', color='white', line_width=2.0 ) self.cursor = csr csr.current_index = self.shape[0]//2, self.shape[1]//2 img_plot.overlays.append(csr) imgtool = ImageInspectorTool(img_plot) img_plot.tools.append(imgtool) overlay = ImageInspectorOverlay(component=img_plot, image_inspector=imgtool, bgcolor="white", border_visible=True) img_plot.overlays.append(overlay) self.plot = plot """ @on_trait_change('autoscale') def change_cmap(self): if not self.img_plot: return if self.autoscale: cmap = self.cmap else: cmap = self.ccmap self.img_plot.value_mapper = cmap @on_trait_change('xaxis,yaxis,rev_colormap,colormap') def create_plot_component(self): if not self.data.size: return self.pd = ArrayPlotData() self.shape = self.data.shape self.pd.set_data("imagedata", self.data) self.pd.set_data("left_line", self.data[:, self.shape[0]//2]) self.pd.set_data("top_line", self.data[self.shape[1]//2,:]) plot = Plot(self.pd) cmap = default_colormaps.color_map_name_dict[self.colormap] if self.rev_cmap: cmap = default_colormaps.reverse(cmap) drange = DataRange1D(ImageData(data=self.data, value_depth=1)) self.ccmap = cmap_constant_range(cmap, drange)(drange) #from copy import copy self.img_plot = plot.img_plot("imagedata", colormap=cmap, #xbounds=self.xbounds, #ybounds=self.ybounds, )[0] self.cmap = self.img_plot.value_mapper if not self.autoscale: self.img_plot.value_mapper = self.ccmap # Tweak some of the plot properties plot.title = self.title plot.padding = 10 # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) csr = CursorTool(self.img_plot, drag_button='right', color='white', line_width=2.0 ) self.cursor = csr csr.current_index = self.shape[0]//2, self.shape[1]//2 self.img_plot.overlays.append(csr) imgtool = ImageInspectorTool(self.img_plot) self.img_plot.tools.append(imgtool) overlay = ImageInspectorOverlay(component=self.img_plot, image_inspector=imgtool, bgcolor="white", border_visible=True) self.img_plot.overlays.append(overlay) self.plot = plot self.cross_plot = Plot(self.pd,resizable='h') self.cross_plot.height = 40 self.cross_plot.padding = 15 self.cross_plot.plot("top_line", line_style="dot") self.cross_plot.index_range = self.img_plot.index_range.x_range self.cross_plot2 = Plot(self.pd, width=40, orientation="v", padding=15, padding_bottom=10, resizable='v') self.cross_plot2.plot("left_line", line_style="dot") self.cross_plot2.index_range = self.img_plot.index_range.y_range # Create a container and add components #self.container = HPlotContainer(padding=10, fill_padding=False, # bgcolor="none", use_backbuffer=False) #inner_cont = VPlotContainer(padding=0, use_backbuffer=True, bgcolor="none") #inner_cont.add(self.plot) #inner_cont.add(self.cross_plot) self.container = GridPlotContainer(padding=20, fill_padding=False, bgcolor="none", use_backbuffer=True, shape=(2, 2), spacing=(12, 20)) #self.container.add(self.colorbar) self.container.add(self.plot) self.container.add(self.cross_plot2) self.container.add(self.cross_plot)
def _plot(self): print "...plotting" self.notes = "" for key, value in self.plotA["notes"].iteritems() : self.notes += str(key) + " " + str(value)+ "\n" self.container1 = GridPlotContainer(shape = (2,4), spacing = (0,0), use_backbuffer=True, valign = 'top', bgcolor = 'white') print"\t assigning data" self.plotdata1 = ArrayPlotData(imagedata = self.plotA["data"]) self.plotdata2 = ArrayPlotData(imagedata = self.plotB["data"]) self.plotdata3 = ArrayPlotData(imagedata = self.plotC["data"]) self.plotdata4 = ArrayPlotData(imagedata = self.plotD["data"]) print"\t calling names" self.plot1 = Plot(self.plotdata1, title = self.plotA["plot"]+ str(self.plotA["notes"]["start"])) self.plot2 = Plot(self.plotdata2, title = self.plotB["plot"]) self.plot3 = Plot(self.plotdata3, title = self.plotC["plot"]) self.plot4 = Plot(self.plotdata4, title = self.plotD["plot"]) self.plot1.img_plot("imagedata", xbounds = (self.plotA["range"][0][0],self.plotA["range"][0][1]), ybounds = (self.plotA["range"][1][0],self.plotA["range"][1][1])) self.plot2.img_plot("imagedata", xbounds = (self.plotB["range"][0][0],self.plotB["range"][0][1]), ybounds = (self.plotB["range"][1][0],self.plotB["range"][1][1])) self.plot3.img_plot("imagedata", xbounds = (self.plotC["range"][0][0],self.plotC["range"][0][1]), ybounds = (self.plotC["range"][1][0],self.plotC["range"][1][1])) self.plot4.img_plot("imagedata", xbounds = (self.plotD["range"][0][0],self.plotD["range"][0][1]), ybounds = (self.plotD["range"][1][0],self.plotD["range"][1][1])) # self.scale = Str(self.plot3.color_mapper.high) # plot1.index_axis.title = str(f) + ' (um)' ##ADD TOOLS self.plot1.tools.append(PanTool(self.plot1)) zoom1 = ZoomTool(component=self.plot1, tool_mode="box", always_on=False) self.plot1.overlays.append(zoom1) self.plot2.tools.append(PanTool(self.plot2)) zoom2 = ZoomTool(component=self.plot2, tool_mode="box", always_on=False) self.plot2.overlays.append(zoom2) self.plot3.tools.append(PanTool(self.plot3)) zoom3 = ZoomTool(component=self.plot3, tool_mode="box", always_on=False) self.plot3.overlays.append(zoom3) self.plot4.tools.append(PanTool(self.plot4)) zoom4 = ZoomTool(component=self.plot4, tool_mode="box", always_on=False) self.plot4.overlays.append(zoom4) ##ADD COLORBARS self.colorbar1 = ColorBar(index_mapper=LinearMapper(range=self.plot1.color_mapper.range), color_mapper=self.plot1.color_mapper, orientation='v', resizable='v', width=20, padding=5) self.colorbar1.plot = self.plot1 self.colorbar1.padding_left = 45 self.colorbar1.padding_right= 5 self.colorbar2 = ColorBar(index_mapper=LinearMapper(range=self.plot2.color_mapper.range), color_mapper=self.plot2.color_mapper, orientation='v', resizable='v', width=20, padding=5) self.colorbar2.plot = self.plot2 self.colorbar2.padding_left = 10 self.colorbar3 = ColorBar(index_mapper=LinearMapper(range=self.plot3.color_mapper.range), color_mapper=self.plot3.color_mapper, orientation='v', resizable='v', width=20, padding=5) self.colorbar3.plot = self.plot3 self.colorbar3.padding_left = 45 self.colorbar3.padding_right= 5 self.colorbar4 = ColorBar(index_mapper=LinearMapper(range=self.plot4.color_mapper.range), color_mapper=self.plot4.color_mapper, orientation='v', resizable='v', width=20, padding=5) self.colorbar4.plot = self.plot4 self.colorbar4.padding_left = 15 self.colorbar1.tools.append(PanTool(self.colorbar1, constrain_direction="y", constrain=True)) self.zoom_overlay1 = ZoomTool(self.colorbar1, axis="index", tool_mode="range", always_on=True, drag_button="right") self.colorbar1.overlays.append(self.zoom_overlay1) self.colorbar2.tools.append(PanTool(self.colorbar2, constrain_direction="y", constrain=True)) self.zoom_overlay2 = ZoomTool(self.colorbar2, axis="index", tool_mode="range", always_on=True, drag_button="right") self.colorbar2.overlays.append(self.zoom_overlay2) self.colorbar3.tools.append(PanTool(self.colorbar3, constrain_direction="y", constrain=True)) self.zoom_overlay3 = ZoomTool(self.colorbar3, axis="index", tool_mode="range", always_on=True, drag_button="right") self.colorbar3.overlays.append(self.zoom_overlay3) self.colorbar4.tools.append(PanTool(self.colorbar4, constrain_direction="y", constrain=True)) self.zoom_overlay4 = ZoomTool(self.colorbar4, axis="index", tool_mode="range", always_on=True, drag_button="right") self.colorbar4.overlays.append(self.zoom_overlay4) self.container1.add(self.colorbar1) self.container1.add(self.plot1) self.container1.add(self.plot2) self.container1.add(self.colorbar2) self.container1.add(self.colorbar3) self.container1.add(self.plot3) self.container1.add(self.plot4) self.container1.add(self.colorbar4) self.plot1.padding_right = 5 self.plot2.padding_left = 5 self.plot1.padding_bottom = 15 self.plot2.padding_bottom = 15 self.plot3.padding_top = 15 self.plot4.padding_top = 15 self.plot1.x_axis.orientation = "top" self.plot2.x_axis.orientation = "top" self.plot2.y_axis.orientation = "right" self.plot3.padding_right = 5 self.plot4.padding_left = 5 self.plot4.y_axis.orientation = "right" self.colorbar1.padding_top = self.plot1.padding_top self.colorbar1.padding_bottom = self.plot1.padding_bottom self.colorbar2.padding_top = self.plot2.padding_top self.colorbar2.padding_bottom = self.plot2.padding_bottom self.colorbar3.padding_top = self.plot3.padding_top self.colorbar3.padding_bottom = self.plot3.padding_bottom self.colorbar4.padding_top = self.plot4.padding_top self.colorbar4.padding_bottom = self.plot4.padding_bottom imgtool = ImageInspectorTool(self.plot1) self.plot1.tools.append(imgtool) overlay = ImageInspectorOverlay(component=self.plot1, image_inspector=imgtool, bgcolor="white", border_visible=True) self.plot1.overlays.append(overlay) self.plot = self.container1 self._plot2()
def make_plots(self, n_dfe_taps): """ Create the plots used by the PyBERT GUI.""" plotdata = self.plotdata # - DFE tab plot1 = Plot(plotdata) plot1.plot(("t_ns", "dfe_out"), type="line", color="blue") plot1.plot(("t_ns", "clocks"), type="line", color="green") plot1.plot(("t_ns", "lockeds"), type="line", color="red") plot1.title = "DFE Output, Recovered Clocks, & Locked" plot1.index_axis.title = "Time (ns)" plot1.tools.append(PanTool(plot1, constrain=True, constrain_key=None, constrain_direction='x')) zoom1 = ZoomTool(plot1, tool_mode="range", axis='index', always_on=False) plot1.overlays.append(zoom1) plot2 = Plot(plotdata) plot2.plot(("t_ns", "ui_ests"), type="line", color="blue") plot2.title = "CDR Adaptation" plot2.index_axis.title = "Time (ns)" plot2.value_axis.title = "UI (ps)" plot2.index_range = plot1.index_range # Zoom x-axes in tandem. plot3 = Plot(plotdata) plot3.plot(('f_MHz_dfe', 'jitter_rejection_ratio'), type="line", color="blue") plot3.title = "CDR/DFE Jitter Rejection Ratio" plot3.index_axis.title = "Frequency (MHz)" plot3.value_axis.title = "Ratio (dB)" zoom3 = ZoomTool(plot3, tool_mode="range", axis='index', always_on=False) plot3.overlays.append(zoom3) plot4 = Plot(plotdata) plot4.plot(('auto_corr'), type="line", color="blue") plot4.title = "Received to Transmitted Bits Correlation" plot4.index_axis.title = "Offset (bits)" plot4.value_axis.title = "Correlation" plot4.value_range.high_setting = 1 plot4.value_range.low_setting = 0 zoom4 = ZoomTool(plot4, tool_mode="range", axis='index', always_on=False) plot4.overlays.append(zoom4) plot9 = Plot(plotdata, auto_colors=['red', 'orange', 'yellow', 'green', 'blue', 'purple']) for i in range(n_dfe_taps): plot9.plot(("tap_weight_index", "tap%d_weights" % (i + 1)), type="line", color="auto", name="tap%d"%(i+1)) plot9.title = "DFE Adaptation" plot9.tools.append(PanTool(plot9, constrain=True, constrain_key=None, constrain_direction='x')) zoom9 = ZoomTool(plot9, tool_mode="range", axis='index', always_on=False) plot9.overlays.append(zoom9) plot9.legend.visible = True plot9.legend.align = 'ul' plot_clk_per_hist = Plot(plotdata) plot_clk_per_hist.plot(('clk_per_hist_bins', 'clk_per_hist_vals'), type="line", color="blue") plot_clk_per_hist.title = "CDR Clock Period Histogram" plot_clk_per_hist.index_axis.title = "Clock Period (ps)" plot_clk_per_hist.value_axis.title = "Bin Count" plot_clk_per_spec = Plot(plotdata) plot_clk_per_spec.plot(('clk_freqs', 'clk_spec'), type="line", color="blue") plot_clk_per_spec.title = "CDR Clock Period Spectrum" plot_clk_per_spec.index_axis.title = "Frequency (bit rate)" plot_clk_per_spec.value_axis.title = "|H(f)| (dB mean)" plot_clk_per_spec.value_range.low_setting = -10 zoom_clk_per_spec = ZoomTool(plot_clk_per_spec, tool_mode="range", axis='index', always_on=False) plot_clk_per_spec.overlays.append(zoom_clk_per_spec) container_dfe = GridPlotContainer(shape=(2,2)) container_dfe.add(plot2) container_dfe.add(plot9) container_dfe.add(plot_clk_per_hist) container_dfe.add(plot_clk_per_spec) self.plots_dfe = container_dfe # - EQ Tune tab plot_h_tune = Plot(plotdata) plot_h_tune.plot(("t_ns_chnl", "ctle_out_h_tune"), type="line", color="red", name="Cumulative") plot_h_tune.plot(("t_ns_chnl", "ctle_out_g_tune"), type="line", color="gray") plot_h_tune.title = "Channel + Tx Preemphasis + CTLE" plot_h_tune.index_axis.title = "Time (ns)" plot_h_tune.y_axis.title = "Response" zoom_tune = ZoomTool(plot_h_tune, tool_mode="range", axis='index', always_on=False) plot_h_tune.overlays.append(zoom_tune) self.plot_h_tune = plot_h_tune # - Impulse Responses tab plot_h_chnl = Plot(plotdata) plot_h_chnl.plot(("t_ns_chnl", "chnl_h"), type="line", color="blue") plot_h_chnl.title = "Channel" plot_h_chnl.index_axis.title = "Time (ns)" plot_h_chnl.y_axis.title = "Impulse Response (V/ns)" zoom_h = ZoomTool(plot_h_chnl, tool_mode="range", axis='index', always_on=False) plot_h_chnl.overlays.append(zoom_h) plot_h_tx = Plot(plotdata) plot_h_tx.plot(("t_ns_chnl", "tx_out_h"), type="line", color="red", name="Cumulative") plot_h_tx.title = "Channel + Tx Preemphasis" plot_h_tx.index_axis.title = "Time (ns)" plot_h_tx.y_axis.title = "Impulse Response (V/ns)" plot_h_tx.index_range = plot_h_chnl.index_range # Zoom x-axes in tandem. plot_h_ctle = Plot(plotdata) plot_h_ctle.plot(("t_ns_chnl", "ctle_out_h"), type="line", color="red", name="Cumulative") plot_h_ctle.title = "Channel + Tx Preemphasis + CTLE" plot_h_ctle.index_axis.title = "Time (ns)" plot_h_ctle.y_axis.title = "Impulse Response (V/ns)" plot_h_ctle.index_range = plot_h_chnl.index_range # Zoom x-axes in tandem. plot_h_dfe = Plot(plotdata) plot_h_dfe.plot(("t_ns_chnl", "dfe_out_h"), type="line", color="red", name="Cumulative") plot_h_dfe.title = "Channel + Tx Preemphasis + CTLE + DFE" plot_h_dfe.index_axis.title = "Time (ns)" plot_h_dfe.y_axis.title = "Impulse Response (V/ns)" plot_h_dfe.index_range = plot_h_chnl.index_range # Zoom x-axes in tandem. container_h = GridPlotContainer(shape=(2,2)) container_h.add(plot_h_chnl) container_h.add(plot_h_tx) container_h.add(plot_h_ctle) container_h.add(plot_h_dfe) self.plots_h = container_h # - Step Responses tab plot_s_chnl = Plot(plotdata) plot_s_chnl.plot(("t_ns_chnl", "chnl_s"), type="line", color="blue") plot_s_chnl.title = "Channel" plot_s_chnl.index_axis.title = "Time (ns)" plot_s_chnl.y_axis.title = "Step Response (V)" zoom_s = ZoomTool(plot_s_chnl, tool_mode="range", axis='index', always_on=False) plot_s_chnl.overlays.append(zoom_s) plot_s_tx = Plot(plotdata) plot_s_tx.plot(("t_ns_chnl", "tx_s"), type="line", color="blue", name="Incremental") plot_s_tx.plot(("t_ns_chnl", "tx_out_s"), type="line", color="red", name="Cumulative") plot_s_tx.title = "Channel + Tx Preemphasis" plot_s_tx.index_axis.title = "Time (ns)" plot_s_tx.y_axis.title = "Step Response (V)" plot_s_tx.legend.visible = True plot_s_tx.legend.align = 'lr' plot_s_tx.index_range = plot_s_chnl.index_range # Zoom x-axes in tandem. plot_s_ctle = Plot(plotdata) plot_s_ctle.plot(("t_ns_chnl", "ctle_s"), type="line", color="blue", name="Incremental") plot_s_ctle.plot(("t_ns_chnl", "ctle_out_s"), type="line", color="red", name="Cumulative") plot_s_ctle.title = "Channel + Tx Preemphasis + CTLE" plot_s_ctle.index_axis.title = "Time (ns)" plot_s_ctle.y_axis.title = "Step Response (V)" plot_s_ctle.legend.visible = True plot_s_ctle.legend.align = 'lr' plot_s_ctle.index_range = plot_s_chnl.index_range # Zoom x-axes in tandem. plot_s_dfe = Plot(plotdata) plot_s_dfe.plot(("t_ns_chnl", "dfe_s"), type="line", color="blue", name="Incremental") plot_s_dfe.plot(("t_ns_chnl", "dfe_out_s"), type="line", color="red", name="Cumulative") plot_s_dfe.title = "Channel + Tx Preemphasis + CTLE + DFE" plot_s_dfe.index_axis.title = "Time (ns)" plot_s_dfe.y_axis.title = "Step Response (V)" plot_s_dfe.legend.visible = True plot_s_dfe.legend.align = 'lr' plot_s_dfe.index_range = plot_s_chnl.index_range # Zoom x-axes in tandem. container_s = GridPlotContainer(shape=(2,2)) container_s.add(plot_s_chnl) container_s.add(plot_s_tx) container_s.add(plot_s_ctle) container_s.add(plot_s_dfe) self.plots_s = container_s # - Pulse Responses tab plot_p_chnl = Plot(plotdata) plot_p_chnl.plot(("t_ns_chnl", "chnl_p"), type="line", color="blue") plot_p_chnl.title = "Channel" plot_p_chnl.index_axis.title = "Time (ns)" plot_p_chnl.y_axis.title = "Pulse Response (V)" zoom_p = ZoomTool(plot_p_chnl, tool_mode="range", axis='index', always_on=False) plot_p_chnl.overlays.append(zoom_p) plot_p_tx = Plot(plotdata) plot_p_tx.plot(("t_ns_chnl", "tx_out_p"), type="line", color="red", name="Cumulative") plot_p_tx.title = "Channel + Tx Preemphasis" plot_p_tx.index_axis.title = "Time (ns)" plot_p_tx.y_axis.title = "Pulse Response (V)" plot_p_tx.legend.align = 'lr' plot_p_tx.index_range = plot_p_chnl.index_range # Zoom x-axes in tandem. plot_p_ctle = Plot(plotdata) plot_p_ctle.plot(("t_ns_chnl", "ctle_out_p"), type="line", color="red", name="Cumulative") plot_p_ctle.title = "Channel + Tx Preemphasis + CTLE" plot_p_ctle.index_axis.title = "Time (ns)" plot_p_ctle.y_axis.title = "Pulse Response (V)" plot_p_ctle.legend.align = 'lr' plot_p_ctle.index_range = plot_p_chnl.index_range # Zoom x-axes in tandem. plot_p_dfe = Plot(plotdata) plot_p_dfe.plot(("t_ns_chnl", "dfe_out_p"), type="line", color="red", name="Cumulative") plot_p_dfe.title = "Channel + Tx Preemphasis + CTLE + DFE" plot_p_dfe.index_axis.title = "Time (ns)" plot_p_dfe.y_axis.title = "Pulse Response (V)" plot_p_dfe.legend.align = 'lr' plot_p_dfe.index_range = plot_p_chnl.index_range # Zoom x-axes in tandem. container_p = GridPlotContainer(shape=(2,2)) container_p.add(plot_p_chnl) container_p.add(plot_p_tx) container_p.add(plot_p_ctle) container_p.add(plot_p_dfe) self.plots_p = container_p # - Frequency Responses tab plot_H_chnl = Plot(plotdata) plot_H_chnl.plot(("f_GHz", "chnl_H"), type="line", color="blue", index_scale='log') plot_H_chnl.title = "Channel" plot_H_chnl.index_axis.title = "Frequency (GHz)" plot_H_chnl.y_axis.title = "Frequency Response (dB)" plot_H_chnl.index_range.low_setting = 0.01 plot_H_chnl.index_range.high_setting = 40. plot_H_tx = Plot(plotdata) plot_H_tx.plot(("f_GHz", "tx_H"), type="line", color="blue", name="Incremental", index_scale='log') plot_H_tx.plot(("f_GHz", "tx_out_H"), type="line", color="red", name="Cumulative", index_scale='log') plot_H_tx.title = "Channel + Tx Preemphasis" plot_H_tx.index_axis.title = "Frequency (GHz)" plot_H_tx.y_axis.title = "Frequency Response (dB)" plot_H_tx.index_range.low_setting = 0.01 plot_H_tx.index_range.high_setting = 40. plot_H_tx.legend.visible = True plot_H_tx.legend.align = 'll' plot_H_ctle = Plot(plotdata) plot_H_ctle.plot(("f_GHz", "ctle_H"), type="line", color="blue", name="Incremental", index_scale='log') plot_H_ctle.plot(("f_GHz", "ctle_out_H"), type="line", color="red", name="Cumulative", index_scale='log') plot_H_ctle.title = "Channel + Tx Preemphasis + CTLE" plot_H_ctle.index_axis.title = "Frequency (GHz)" plot_H_ctle.y_axis.title = "Frequency Response (dB)" plot_H_ctle.index_range.low_setting = 0.01 plot_H_ctle.index_range.high_setting = 40. plot_H_ctle.value_range.low_setting = -40. plot_H_ctle.legend.visible = True plot_H_ctle.legend.align = 'll' plot_H_chnl.value_range = plot_H_ctle.value_range plot_H_tx.value_range = plot_H_ctle.value_range plot_H_dfe = Plot(plotdata) plot_H_dfe.plot(("f_GHz", "dfe_H"), type="line", color="blue", name="Incremental", index_scale='log') plot_H_dfe.plot(("f_GHz", "dfe_out_H"), type="line", color="red", name="Cumulative", index_scale='log') plot_H_dfe.title = "Channel + Tx Preemphasis + CTLE + DFE" plot_H_dfe.index_axis.title = "Frequency (GHz)" plot_H_dfe.y_axis.title = "Frequency Response (dB)" plot_H_dfe.index_range.low_setting = 0.01 plot_H_dfe.index_range.high_setting = 40. plot_H_dfe.value_range = plot_H_ctle.value_range plot_H_dfe.legend.visible = True plot_H_dfe.legend.align = 'll' container_H = GridPlotContainer(shape=(2,2)) container_H.add(plot_H_chnl) container_H.add(plot_H_tx) container_H.add(plot_H_ctle) container_H.add(plot_H_dfe) self.plots_H = container_H # - Outputs tab plot_out_chnl = Plot(plotdata) plot_out_chnl.plot(("t_ns", "ideal_signal"), type="line", color="lightgrey") plot_out_chnl.plot(("t_ns", "chnl_out"), type="line", color="blue") plot_out_chnl.title = "Channel" plot_out_chnl.index_axis.title = "Time (ns)" plot_out_chnl.y_axis.title = "Output (V)" zoom_out_chnl = ZoomTool(plot_out_chnl, tool_mode="range", axis='index', always_on=False) plot_out_chnl.overlays.append(zoom_out_chnl) plot_out_tx = Plot(plotdata) plot_out_tx.plot(("t_ns", "tx_out"), type="line", color="blue") plot_out_tx.title = "Channel + Tx Preemphasis (Noise added here.)" plot_out_tx.index_axis.title = "Time (ns)" plot_out_tx.y_axis.title = "Output (V)" plot_out_tx.index_range = plot_out_chnl.index_range # Zoom x-axes in tandem. plot_out_ctle = Plot(plotdata) plot_out_ctle.plot(("t_ns", "ctle_out"), type="line", color="blue") plot_out_ctle.title = "Channel + Tx Preemphasis + CTLE" plot_out_ctle.index_axis.title = "Time (ns)" plot_out_ctle.y_axis.title = "Output (V)" plot_out_ctle.index_range = plot_out_chnl.index_range # Zoom x-axes in tandem. plot_out_dfe = Plot(plotdata) plot_out_dfe.plot(("t_ns", "dfe_out"), type="line", color="blue") plot_out_dfe.title = "Channel + Tx Preemphasis + CTLE + DFE" plot_out_dfe.index_axis.title = "Time (ns)" plot_out_dfe.y_axis.title = "Output (V)" plot_out_dfe.index_range = plot_out_chnl.index_range # Zoom x-axes in tandem. container_out = GridPlotContainer(shape=(2,2)) container_out.add(plot_out_chnl) container_out.add(plot_out_tx) container_out.add(plot_out_ctle) container_out.add(plot_out_dfe) self.plots_out = container_out # - Eye Diagrams tab seg_map = dict( red = [ (0.00, 0.00, 0.00), # black (0.00001, 0.00, 0.00), # blue (0.15, 0.00, 0.00), # cyan (0.30, 0.00, 0.00), # green (0.45, 1.00, 1.00), # yellow (0.60, 1.00, 1.00), # orange (0.75, 1.00, 1.00), # red (0.90, 1.00, 1.00), # pink (1.00, 1.00, 1.00) # white ], green = [ (0.00, 0.00, 0.00), # black (0.00001, 0.00, 0.00), # blue (0.15, 0.50, 0.50), # cyan (0.30, 0.50, 0.50), # green (0.45, 1.00, 1.00), # yellow (0.60, 0.50, 0.50), # orange (0.75, 0.00, 0.00), # red (0.90, 0.50, 0.50), # pink (1.00, 1.00, 1.00) # white ], blue = [ (0.00, 0.00, 0.00), # black (1e-18, 0.50, 0.50), # blue (0.15, 0.50, 0.50), # cyan (0.30, 0.00, 0.00), # green (0.45, 0.00, 0.00), # yellow (0.60, 0.00, 0.00), # orange (0.75, 0.00, 0.00), # red (0.90, 0.50, 0.50), # pink (1.00, 1.00, 1.00) # white ] ) clr_map = ColorMapper.from_segment_map(seg_map) self.clr_map = clr_map plot_eye_chnl = Plot(plotdata) plot_eye_chnl.img_plot("eye_chnl", colormap=clr_map,) plot_eye_chnl.y_direction = 'normal' plot_eye_chnl.components[0].y_direction = 'normal' plot_eye_chnl.title = "Channel" plot_eye_chnl.x_axis.title = "Time (ps)" plot_eye_chnl.x_axis.orientation = "bottom" plot_eye_chnl.y_axis.title = "Signal Level (V)" plot_eye_chnl.x_grid.visible = True plot_eye_chnl.y_grid.visible = True plot_eye_chnl.x_grid.line_color = 'gray' plot_eye_chnl.y_grid.line_color = 'gray' plot_eye_tx = Plot(plotdata) plot_eye_tx.img_plot("eye_tx", colormap=clr_map,) plot_eye_tx.y_direction = 'normal' plot_eye_tx.components[0].y_direction = 'normal' plot_eye_tx.title = "Channel + Tx Preemphasis (Noise added here.)" plot_eye_tx.x_axis.title = "Time (ps)" plot_eye_tx.x_axis.orientation = "bottom" plot_eye_tx.y_axis.title = "Signal Level (V)" plot_eye_tx.x_grid.visible = True plot_eye_tx.y_grid.visible = True plot_eye_tx.x_grid.line_color = 'gray' plot_eye_tx.y_grid.line_color = 'gray' plot_eye_ctle = Plot(plotdata) plot_eye_ctle.img_plot("eye_ctle", colormap=clr_map,) plot_eye_ctle.y_direction = 'normal' plot_eye_ctle.components[0].y_direction = 'normal' plot_eye_ctle.title = "Channel + Tx Preemphasis + CTLE" plot_eye_ctle.x_axis.title = "Time (ps)" plot_eye_ctle.x_axis.orientation = "bottom" plot_eye_ctle.y_axis.title = "Signal Level (V)" plot_eye_ctle.x_grid.visible = True plot_eye_ctle.y_grid.visible = True plot_eye_ctle.x_grid.line_color = 'gray' plot_eye_ctle.y_grid.line_color = 'gray' plot_eye_dfe = Plot(plotdata) plot_eye_dfe.img_plot("eye_dfe", colormap=clr_map,) plot_eye_dfe.y_direction = 'normal' plot_eye_dfe.components[0].y_direction = 'normal' plot_eye_dfe.title = "Channel + Tx Preemphasis + CTLE + DFE" plot_eye_dfe.x_axis.title = "Time (ps)" plot_eye_dfe.x_axis.orientation = "bottom" plot_eye_dfe.y_axis.title = "Signal Level (V)" plot_eye_dfe.x_grid.visible = True plot_eye_dfe.y_grid.visible = True plot_eye_dfe.x_grid.line_color = 'gray' plot_eye_dfe.y_grid.line_color = 'gray' container_eye = GridPlotContainer(shape=(2,2)) container_eye.add(plot_eye_chnl) container_eye.add(plot_eye_tx) container_eye.add(plot_eye_ctle) container_eye.add(plot_eye_dfe) self.plots_eye = container_eye # - Jitter Distributions tab plot_jitter_dist_chnl = Plot(plotdata) plot_jitter_dist_chnl.plot(('jitter_bins', 'jitter_chnl'), type="line", color="blue", name="Measured") plot_jitter_dist_chnl.plot(('jitter_bins', 'jitter_ext_chnl'), type="line", color="red", name="Extrapolated") plot_jitter_dist_chnl.title = "Channel" plot_jitter_dist_chnl.index_axis.title = "Time (ps)" plot_jitter_dist_chnl.value_axis.title = "Count" plot_jitter_dist_chnl.legend.visible = True plot_jitter_dist_chnl.legend.align = 'ur' plot_jitter_dist_tx = Plot(plotdata) plot_jitter_dist_tx.plot(('jitter_bins', 'jitter_tx'), type="line", color="blue", name="Measured") plot_jitter_dist_tx.plot(('jitter_bins', 'jitter_ext_tx'), type="line", color="red", name="Extrapolated") plot_jitter_dist_tx.title = "Channel + Tx Preemphasis (Noise added here.)" plot_jitter_dist_tx.index_axis.title = "Time (ps)" plot_jitter_dist_tx.value_axis.title = "Count" plot_jitter_dist_tx.legend.visible = True plot_jitter_dist_tx.legend.align = 'ur' plot_jitter_dist_ctle = Plot(plotdata) plot_jitter_dist_ctle.plot(('jitter_bins', 'jitter_ctle'), type="line", color="blue", name="Measured") plot_jitter_dist_ctle.plot(('jitter_bins', 'jitter_ext_ctle'), type="line", color="red", name="Extrapolated") plot_jitter_dist_ctle.title = "Channel + Tx Preemphasis + CTLE" plot_jitter_dist_ctle.index_axis.title = "Time (ps)" plot_jitter_dist_ctle.value_axis.title = "Count" plot_jitter_dist_ctle.legend.visible = True plot_jitter_dist_ctle.legend.align = 'ur' plot_jitter_dist_dfe = Plot(plotdata) plot_jitter_dist_dfe.plot(('jitter_bins', 'jitter_dfe'), type="line", color="blue", name="Measured") plot_jitter_dist_dfe.plot(('jitter_bins', 'jitter_ext_dfe'), type="line", color="red", name="Extrapolated") plot_jitter_dist_dfe.title = "Channel + Tx Preemphasis + CTLE + DFE" plot_jitter_dist_dfe.index_axis.title = "Time (ps)" plot_jitter_dist_dfe.value_axis.title = "Count" plot_jitter_dist_dfe.legend.visible = True plot_jitter_dist_dfe.legend.align = 'ur' container_jitter_dist = GridPlotContainer(shape=(2,2)) container_jitter_dist.add(plot_jitter_dist_chnl) container_jitter_dist.add(plot_jitter_dist_tx) container_jitter_dist.add(plot_jitter_dist_ctle) container_jitter_dist.add(plot_jitter_dist_dfe) self.plots_jitter_dist = container_jitter_dist # - Jitter Spectrums tab plot_jitter_spec_chnl = Plot(plotdata) plot_jitter_spec_chnl.plot(('f_MHz', 'jitter_spectrum_chnl'), type="line", color="blue", name="Total") plot_jitter_spec_chnl.plot(('f_MHz', 'jitter_ind_spectrum_chnl'), type="line", color="red", name="Data Independent") plot_jitter_spec_chnl.plot(('f_MHz', 'thresh_chnl'), type="line", color="magenta", name="Pj Threshold") plot_jitter_spec_chnl.title = "Channel" plot_jitter_spec_chnl.index_axis.title = "Frequency (MHz)" plot_jitter_spec_chnl.value_axis.title = "|FFT(TIE)| (dBui)" plot_jitter_spec_chnl.tools.append(PanTool(plot_jitter_spec_chnl, constrain=True, constrain_key=None, constrain_direction='x')) zoom_jitter_spec_chnl = ZoomTool(plot_jitter_spec_chnl, tool_mode="range", axis='index', always_on=False) plot_jitter_spec_chnl.overlays.append(zoom_jitter_spec_chnl) plot_jitter_spec_chnl.legend.visible = True plot_jitter_spec_chnl.legend.align = 'lr' plot_jitter_spec_tx = Plot(plotdata) plot_jitter_spec_tx.plot(('f_MHz', 'jitter_spectrum_tx'), type="line", color="blue", name="Total") plot_jitter_spec_tx.plot(('f_MHz', 'jitter_ind_spectrum_tx'), type="line", color="red", name="Data Independent") plot_jitter_spec_tx.plot(('f_MHz', 'thresh_tx'), type="line", color="magenta", name="Pj Threshold") plot_jitter_spec_tx.title = "Channel + Tx Preemphasis (Noise added here.)" plot_jitter_spec_tx.index_axis.title = "Frequency (MHz)" plot_jitter_spec_tx.value_axis.title = "|FFT(TIE)| (dBui)" plot_jitter_spec_tx.value_range.low_setting = -40. plot_jitter_spec_tx.tools.append(PanTool(plot_jitter_spec_tx, constrain=True, constrain_key=None, constrain_direction='x')) zoom_jitter_spec_tx = ZoomTool(plot_jitter_spec_tx, tool_mode="range", axis='index', always_on=False) plot_jitter_spec_tx.overlays.append(zoom_jitter_spec_tx) plot_jitter_spec_tx.legend.visible = True plot_jitter_spec_tx.legend.align = 'lr' plot_jitter_spec_chnl.value_range = plot_jitter_spec_tx.value_range plot_jitter_spec_ctle = Plot(plotdata) plot_jitter_spec_ctle.plot(('f_MHz', 'jitter_spectrum_ctle'), type="line", color="blue", name="Total") plot_jitter_spec_ctle.plot(('f_MHz', 'jitter_ind_spectrum_ctle'), type="line", color="red", name="Data Independent") plot_jitter_spec_ctle.plot(('f_MHz', 'thresh_ctle'), type="line", color="magenta", name="Pj Threshold") plot_jitter_spec_ctle.title = "Channel + Tx Preemphasis + CTLE" plot_jitter_spec_ctle.index_axis.title = "Frequency (MHz)" plot_jitter_spec_ctle.value_axis.title = "|FFT(TIE)| (dBui)" plot_jitter_spec_ctle.tools.append(PanTool(plot_jitter_spec_ctle, constrain=True, constrain_key=None, constrain_direction='x')) zoom_jitter_spec_ctle = ZoomTool(plot_jitter_spec_ctle, tool_mode="range", axis='index', always_on=False) plot_jitter_spec_ctle.overlays.append(zoom_jitter_spec_ctle) plot_jitter_spec_ctle.legend.visible = True plot_jitter_spec_ctle.legend.align = 'lr' plot_jitter_spec_ctle.value_range = plot_jitter_spec_tx.value_range plot_jitter_spec_dfe = Plot(plotdata) plot_jitter_spec_dfe.plot(('f_MHz_dfe', 'jitter_spectrum_dfe'), type="line", color="blue", name="Total") plot_jitter_spec_dfe.plot(('f_MHz_dfe', 'jitter_ind_spectrum_dfe'), type="line", color="red", name="Data Independent") plot_jitter_spec_dfe.plot(('f_MHz_dfe', 'thresh_dfe'), type="line", color="magenta", name="Pj Threshold") plot_jitter_spec_dfe.title = "Channel + Tx Preemphasis + CTLE + DFE" plot_jitter_spec_dfe.index_axis.title = "Frequency (MHz)" plot_jitter_spec_dfe.value_axis.title = "|FFT(TIE)| (dBui)" plot_jitter_spec_dfe.tools.append(PanTool(plot_jitter_spec_dfe, constrain=True, constrain_key=None, constrain_direction='x')) zoom_jitter_spec_dfe = ZoomTool(plot_jitter_spec_dfe, tool_mode="range", axis='index', always_on=False) plot_jitter_spec_dfe.overlays.append(zoom_jitter_spec_dfe) plot_jitter_spec_dfe.legend.visible = True plot_jitter_spec_dfe.legend.align = 'lr' plot_jitter_spec_dfe.value_range = plot_jitter_spec_tx.value_range container_jitter_spec = GridPlotContainer(shape=(2,2)) container_jitter_spec.add(plot_jitter_spec_chnl) container_jitter_spec.add(plot_jitter_spec_tx) container_jitter_spec.add(plot_jitter_spec_ctle) container_jitter_spec.add(plot_jitter_spec_dfe) self.plots_jitter_spec = container_jitter_spec # - Bathtub Curves tab plot_bathtub_chnl = Plot(plotdata) plot_bathtub_chnl.plot(("jitter_bins", "bathtub_chnl"), type="line", color="blue") plot_bathtub_chnl.value_range.high_setting = 0 plot_bathtub_chnl.value_range.low_setting = -18 plot_bathtub_chnl.value_axis.tick_interval = 3 plot_bathtub_chnl.title = "Channel" plot_bathtub_chnl.index_axis.title = "Time (ps)" plot_bathtub_chnl.value_axis.title = "Log10(P(Transition occurs inside.))" plot_bathtub_tx = Plot(plotdata) plot_bathtub_tx.plot(("jitter_bins", "bathtub_tx"), type="line", color="blue") plot_bathtub_tx.value_range.high_setting = 0 plot_bathtub_tx.value_range.low_setting = -18 plot_bathtub_tx.value_axis.tick_interval = 3 plot_bathtub_tx.title = "Channel + Tx Preemphasis (Noise added here.)" plot_bathtub_tx.index_axis.title = "Time (ps)" plot_bathtub_tx.value_axis.title = "Log10(P(Transition occurs inside.))" plot_bathtub_ctle = Plot(plotdata) plot_bathtub_ctle.plot(("jitter_bins", "bathtub_ctle"), type="line", color="blue") plot_bathtub_ctle.value_range.high_setting = 0 plot_bathtub_ctle.value_range.low_setting = -18 plot_bathtub_ctle.value_axis.tick_interval = 3 plot_bathtub_ctle.title = "Channel + Tx Preemphasis + CTLE" plot_bathtub_ctle.index_axis.title = "Time (ps)" plot_bathtub_ctle.value_axis.title = "Log10(P(Transition occurs inside.))" plot_bathtub_dfe = Plot(plotdata) plot_bathtub_dfe.plot(("jitter_bins", "bathtub_dfe"), type="line", color="blue") plot_bathtub_dfe.value_range.high_setting = 0 plot_bathtub_dfe.value_range.low_setting = -18 plot_bathtub_dfe.value_axis.tick_interval = 3 plot_bathtub_dfe.title = "Channel + Tx Preemphasis + CTLE + DFE" plot_bathtub_dfe.index_axis.title = "Time (ps)" plot_bathtub_dfe.value_axis.title = "Log10(P(Transition occurs inside.))" container_bathtub = GridPlotContainer(shape=(2,2)) container_bathtub.add(plot_bathtub_chnl) container_bathtub.add(plot_bathtub_tx) container_bathtub.add(plot_bathtub_ctle) container_bathtub.add(plot_bathtub_dfe) self.plots_bathtub = container_bathtub update_eyes(self) return
def make_plots(self, n_dfe_taps): """ Create the plots used by the PyBERT GUI.""" post_chnl_str = "Channel" post_tx_str = "Channel + Tx Preemphasis" post_ctle_str = "Channel + Tx Preemphasis + CTLE (+ AMI DFE)" post_dfe_str = "Channel + Tx Preemphasis + CTLE (+ AMI DFE) + PyBERT DFE" plotdata = self.plotdata # - DFE tab plot2 = Plot(plotdata, padding_left=75) plot2.plot(("t_ns", "ui_ests"), type="line", color="blue") plot2.title = "CDR Adaptation" plot2.index_axis.title = "Time (ns)" plot2.value_axis.title = "UI (ps)" plot9 = Plot( plotdata, auto_colors=["red", "orange", "yellow", "green", "blue", "purple"], padding_left=75, ) for i in range(n_dfe_taps): plot9.plot( ("tap_weight_index", "tap%d_weights" % (i + 1)), type="line", color="auto", name="tap%d" % (i + 1), ) plot9.title = "DFE Adaptation" plot9.tools.append( PanTool(plot9, constrain=True, constrain_key=None, constrain_direction="x")) zoom9 = ZoomTool(plot9, tool_mode="range", axis="index", always_on=False) plot9.overlays.append(zoom9) plot9.legend.visible = True plot9.legend.align = "ul" plot_clk_per_hist = Plot(plotdata, padding_left=75) plot_clk_per_hist.plot(("clk_per_hist_bins", "clk_per_hist_vals"), type="line", color="blue") plot_clk_per_hist.title = "CDR Clock Period Histogram" plot_clk_per_hist.index_axis.title = "Clock Period (ps)" plot_clk_per_hist.value_axis.title = "Bin Count" plot_clk_per_spec = Plot(plotdata, padding_left=75) plot_clk_per_spec.plot(("clk_freqs", "clk_spec"), type="line", color="blue") plot_clk_per_spec.title = "CDR Clock Period Spectrum" plot_clk_per_spec.index_axis.title = "Frequency (bit rate)" plot_clk_per_spec.value_axis.title = "|H(f)| (dB mean)" plot_clk_per_spec.value_range.low_setting = -10 zoom_clk_per_spec = ZoomTool(plot_clk_per_spec, tool_mode="range", axis="index", always_on=False) plot_clk_per_spec.overlays.append(zoom_clk_per_spec) container_dfe = GridPlotContainer(shape=(2, 2), spacing=(PLOT_SPACING, PLOT_SPACING)) container_dfe.add(plot2) container_dfe.add(plot9) container_dfe.add(plot_clk_per_hist) container_dfe.add(plot_clk_per_spec) self.plots_dfe = container_dfe self._dfe_plot = plot9 # - EQ Tune tab # plot_h_tune = Plot(plotdata, padding_left=75) plot_h_tune = Plot(plotdata, padding_bottom=75) plot_h_tune.plot(("t_ns_chnl", "ctle_out_h_tune"), type="line", color="blue") plot_h_tune.plot(("t_ns_chnl", "clocks_tune"), type="line", color="gray") plot_h_tune.title = "Channel + Tx Preemphasis + CTLE (+ AMI DFE) + Ideal DFE" plot_h_tune.index_axis.title = "Time (ns)" plot_h_tune.y_axis.title = "Pulse Response (V)" zoom_tune = ZoomTool(plot_h_tune, tool_mode="range", axis="index", always_on=False) plot_h_tune.overlays.append(zoom_tune) self.plot_h_tune = plot_h_tune # - Impulse Responses tab plot_h_chnl = Plot(plotdata, padding_left=75) plot_h_chnl.plot(("t_ns_chnl", "chnl_h"), type="line", color="blue", name="Incremental") plot_h_chnl.title = post_chnl_str plot_h_chnl.index_axis.title = "Time (ns)" plot_h_chnl.y_axis.title = "Impulse Response (V/ns)" plot_h_chnl.legend.visible = True plot_h_chnl.legend.align = "ur" zoom_h = ZoomTool(plot_h_chnl, tool_mode="range", axis="index", always_on=False) plot_h_chnl.overlays.append(zoom_h) plot_h_tx = Plot(plotdata, padding_left=75) plot_h_tx.plot(("t_ns_chnl", "tx_out_h"), type="line", color="red", name="Cumulative") plot_h_tx.title = post_tx_str plot_h_tx.index_axis.title = "Time (ns)" plot_h_tx.y_axis.title = "Impulse Response (V/ns)" plot_h_tx.legend.visible = True plot_h_tx.legend.align = "ur" plot_h_tx.index_range = plot_h_chnl.index_range # Zoom x-axes in tandem. plot_h_ctle = Plot(plotdata, padding_left=75) plot_h_ctle.plot(("t_ns_chnl", "ctle_out_h"), type="line", color="red", name="Cumulative") plot_h_ctle.title = post_ctle_str plot_h_ctle.index_axis.title = "Time (ns)" plot_h_ctle.y_axis.title = "Impulse Response (V/ns)" plot_h_ctle.legend.visible = True plot_h_ctle.legend.align = "ur" plot_h_ctle.index_range = plot_h_chnl.index_range # Zoom x-axes in tandem. plot_h_dfe = Plot(plotdata, padding_left=75) plot_h_dfe.plot(("t_ns_chnl", "dfe_out_h"), type="line", color="red", name="Cumulative") plot_h_dfe.title = post_dfe_str plot_h_dfe.index_axis.title = "Time (ns)" plot_h_dfe.y_axis.title = "Impulse Response (V/ns)" plot_h_dfe.legend.visible = True plot_h_dfe.legend.align = "ur" plot_h_dfe.index_range = plot_h_chnl.index_range # Zoom x-axes in tandem. container_h = GridPlotContainer(shape=(2, 2), spacing=(PLOT_SPACING, PLOT_SPACING)) container_h.add(plot_h_chnl) container_h.add(plot_h_tx) container_h.add(plot_h_ctle) container_h.add(plot_h_dfe) self.plots_h = container_h # - Step Responses tab plot_s_chnl = Plot(plotdata, padding_left=75) plot_s_chnl.plot(("t_ns_chnl", "chnl_s"), type="line", color="blue", name="Incremental") plot_s_chnl.title = post_chnl_str plot_s_chnl.index_axis.title = "Time (ns)" plot_s_chnl.y_axis.title = "Step Response (V)" plot_s_chnl.legend.visible = True plot_s_chnl.legend.align = "lr" zoom_s = ZoomTool(plot_s_chnl, tool_mode="range", axis="index", always_on=False) plot_s_chnl.overlays.append(zoom_s) plot_s_tx = Plot(plotdata, padding_left=75) plot_s_tx.plot(("t_ns_chnl", "tx_s"), type="line", color="blue", name="Incremental") plot_s_tx.plot(("t_ns_chnl", "tx_out_s"), type="line", color="red", name="Cumulative") plot_s_tx.title = post_tx_str plot_s_tx.index_axis.title = "Time (ns)" plot_s_tx.y_axis.title = "Step Response (V)" plot_s_tx.legend.visible = True plot_s_tx.legend.align = "lr" plot_s_tx.index_range = plot_s_chnl.index_range # Zoom x-axes in tandem. plot_s_ctle = Plot(plotdata, padding_left=75) plot_s_ctle.plot(("t_ns_chnl", "ctle_s"), type="line", color="blue", name="Incremental") plot_s_ctle.plot(("t_ns_chnl", "ctle_out_s"), type="line", color="red", name="Cumulative") plot_s_ctle.title = post_ctle_str plot_s_ctle.index_axis.title = "Time (ns)" plot_s_ctle.y_axis.title = "Step Response (V)" plot_s_ctle.legend.visible = True plot_s_ctle.legend.align = "lr" plot_s_ctle.index_range = plot_s_chnl.index_range # Zoom x-axes in tandem. plot_s_dfe = Plot(plotdata, padding_left=75) plot_s_dfe.plot(("t_ns_chnl", "dfe_s"), type="line", color="blue", name="Incremental") plot_s_dfe.plot(("t_ns_chnl", "dfe_out_s"), type="line", color="red", name="Cumulative") plot_s_dfe.title = post_dfe_str plot_s_dfe.index_axis.title = "Time (ns)" plot_s_dfe.y_axis.title = "Step Response (V)" plot_s_dfe.legend.visible = True plot_s_dfe.legend.align = "lr" plot_s_dfe.index_range = plot_s_chnl.index_range # Zoom x-axes in tandem. container_s = GridPlotContainer(shape=(2, 2), spacing=(PLOT_SPACING, PLOT_SPACING)) container_s.add(plot_s_chnl) container_s.add(plot_s_tx) container_s.add(plot_s_ctle) container_s.add(plot_s_dfe) self.plots_s = container_s # - Pulse Responses tab plot_p_chnl = Plot(plotdata, padding_left=75) plot_p_chnl.plot(("t_ns_chnl", "chnl_p"), type="line", color="blue", name="Incremental") plot_p_chnl.title = post_chnl_str plot_p_chnl.index_axis.title = "Time (ns)" plot_p_chnl.y_axis.title = "Pulse Response (V)" plot_p_chnl.legend.visible = True plot_p_chnl.legend.align = "ur" zoom_p = ZoomTool(plot_p_chnl, tool_mode="range", axis="index", always_on=False) plot_p_chnl.overlays.append(zoom_p) plot_p_tx = Plot(plotdata, padding_left=75) plot_p_tx.plot(("t_ns_chnl", "tx_out_p"), type="line", color="red", name="Cumulative") plot_p_tx.title = post_tx_str plot_p_tx.index_axis.title = "Time (ns)" plot_p_tx.y_axis.title = "Pulse Response (V)" plot_p_tx.legend.visible = True plot_p_tx.legend.align = "ur" plot_p_tx.index_range = plot_p_chnl.index_range # Zoom x-axes in tandem. plot_p_ctle = Plot(plotdata, padding_left=75) plot_p_ctle.plot(("t_ns_chnl", "ctle_out_p"), type="line", color="red", name="Cumulative") plot_p_ctle.title = post_ctle_str plot_p_ctle.index_axis.title = "Time (ns)" plot_p_ctle.y_axis.title = "Pulse Response (V)" plot_p_ctle.legend.visible = True plot_p_ctle.legend.align = "ur" plot_p_ctle.index_range = plot_p_chnl.index_range # Zoom x-axes in tandem. plot_p_dfe = Plot(plotdata, padding_left=75) plot_p_dfe.plot(("t_ns_chnl", "dfe_out_p"), type="line", color="red", name="Cumulative") plot_p_dfe.title = post_dfe_str plot_p_dfe.index_axis.title = "Time (ns)" plot_p_dfe.y_axis.title = "Pulse Response (V)" plot_p_dfe.legend.visible = True plot_p_dfe.legend.align = "ur" plot_p_dfe.index_range = plot_p_chnl.index_range # Zoom x-axes in tandem. container_p = GridPlotContainer(shape=(2, 2), spacing=(PLOT_SPACING, PLOT_SPACING)) container_p.add(plot_p_chnl) container_p.add(plot_p_tx) container_p.add(plot_p_ctle) container_p.add(plot_p_dfe) self.plots_p = container_p # - Frequency Responses tab plot_H_chnl = Plot(plotdata, padding_left=75) plot_H_chnl.plot(("f_GHz", "chnl_H"), type="line", color="blue", name="Original Impulse", index_scale="log") plot_H_chnl.plot(("f_GHz", "chnl_trimmed_H"), type="line", color="red", name="Trimmed Impulse", index_scale="log") plot_H_chnl.title = post_chnl_str plot_H_chnl.index_axis.title = "Frequency (GHz)" plot_H_chnl.y_axis.title = "Frequency Response (dB)" plot_H_chnl.index_range.low_setting = 0.01 plot_H_chnl.index_range.high_setting = 40.0 plot_H_chnl.legend.visible = True plot_H_chnl.legend.align = "ll" plot_H_tx = Plot(plotdata, padding_left=75) plot_H_tx.plot(("f_GHz", "tx_H"), type="line", color="blue", name="Incremental", index_scale="log") plot_H_tx.plot(("f_GHz", "tx_out_H"), type="line", color="red", name="Cumulative", index_scale="log") plot_H_tx.title = post_tx_str plot_H_tx.index_axis.title = "Frequency (GHz)" plot_H_tx.y_axis.title = "Frequency Response (dB)" plot_H_tx.index_range.low_setting = 0.01 plot_H_tx.index_range.high_setting = 40.0 plot_H_tx.legend.visible = True plot_H_tx.legend.align = "ll" plot_H_ctle = Plot(plotdata, padding_left=75) plot_H_ctle.plot(("f_GHz", "ctle_H"), type="line", color="blue", name="Incremental", index_scale="log") plot_H_ctle.plot(("f_GHz", "ctle_out_H"), type="line", color="red", name="Cumulative", index_scale="log") plot_H_ctle.title = post_ctle_str plot_H_ctle.index_axis.title = "Frequency (GHz)" plot_H_ctle.y_axis.title = "Frequency Response (dB)" plot_H_ctle.index_range.low_setting = 0.01 plot_H_ctle.index_range.high_setting = 40.0 plot_H_ctle.value_range.low_setting = -40.0 plot_H_ctle.legend.visible = True plot_H_ctle.legend.align = "ll" plot_H_chnl.value_range = plot_H_ctle.value_range plot_H_tx.value_range = plot_H_ctle.value_range plot_H_dfe = Plot(plotdata, padding_left=75) plot_H_dfe.plot(("f_GHz", "dfe_H"), type="line", color="blue", name="Incremental", index_scale="log") plot_H_dfe.plot(("f_GHz", "dfe_out_H"), type="line", color="red", name="Cumulative", index_scale="log") plot_H_dfe.title = post_dfe_str plot_H_dfe.index_axis.title = "Frequency (GHz)" plot_H_dfe.y_axis.title = "Frequency Response (dB)" plot_H_dfe.index_range.low_setting = 0.01 plot_H_dfe.index_range.high_setting = 40.0 plot_H_dfe.value_range = plot_H_ctle.value_range plot_H_dfe.legend.visible = True plot_H_dfe.legend.align = "ll" container_H = GridPlotContainer(shape=(2, 2), spacing=(PLOT_SPACING, PLOT_SPACING)) container_H.add(plot_H_chnl) container_H.add(plot_H_tx) container_H.add(plot_H_ctle) container_H.add(plot_H_dfe) self.plots_H = container_H # - Outputs tab plot_out_chnl = Plot(plotdata, padding_left=75) # plot_out_chnl.plot(("t_ns", "ideal_signal"), type="line", color="lightgrey") plot_out_chnl.plot(("t_ns", "chnl_out"), type="line", color="blue") plot_out_chnl.title = post_chnl_str plot_out_chnl.index_axis.title = "Time (ns)" plot_out_chnl.y_axis.title = "Output (V)" plot_out_chnl.tools.append( PanTool(plot_out_chnl, constrain=True, constrain_key=None, constrain_direction="x")) zoom_out_chnl = ZoomTool(plot_out_chnl, tool_mode="range", axis="index", always_on=False) plot_out_chnl.overlays.append(zoom_out_chnl) plot_out_tx = Plot(plotdata, padding_left=75) plot_out_tx.plot(("t_ns", "tx_out"), type="line", color="blue") plot_out_tx.title = post_tx_str plot_out_tx.index_axis.title = "Time (ns)" plot_out_tx.y_axis.title = "Output (V)" plot_out_tx.index_range = plot_out_chnl.index_range # Zoom x-axes in tandem. plot_out_ctle = Plot(plotdata, padding_left=75) plot_out_ctle.plot(("t_ns", "ctle_out"), type="line", color="blue") plot_out_ctle.title = post_ctle_str plot_out_ctle.index_axis.title = "Time (ns)" plot_out_ctle.y_axis.title = "Output (V)" plot_out_ctle.index_range = plot_out_chnl.index_range # Zoom x-axes in tandem. plot_out_dfe = Plot(plotdata, padding_left=75) plot_out_dfe.plot(("t_ns", "dfe_out"), type="line", color="blue") plot_out_dfe.title = post_dfe_str plot_out_dfe.index_axis.title = "Time (ns)" plot_out_dfe.y_axis.title = "Output (V)" plot_out_dfe.index_range = plot_out_chnl.index_range # Zoom x-axes in tandem. container_out = GridPlotContainer(shape=(2, 2), spacing=(PLOT_SPACING, PLOT_SPACING)) container_out.add(plot_out_chnl) container_out.add(plot_out_tx) container_out.add(plot_out_ctle) container_out.add(plot_out_dfe) self.plots_out = container_out # - Eye Diagrams tab seg_map = dict( red=[ (0.00, 0.00, 0.00), # black (0.00001, 0.00, 0.00), # blue (0.15, 0.00, 0.00), # cyan (0.30, 0.00, 0.00), # green (0.45, 1.00, 1.00), # yellow (0.60, 1.00, 1.00), # orange (0.75, 1.00, 1.00), # red (0.90, 1.00, 1.00), # pink (1.00, 1.00, 1.00), # white ], green=[ (0.00, 0.00, 0.00), # black (0.00001, 0.00, 0.00), # blue (0.15, 0.50, 0.50), # cyan (0.30, 0.50, 0.50), # green (0.45, 1.00, 1.00), # yellow (0.60, 0.50, 0.50), # orange (0.75, 0.00, 0.00), # red (0.90, 0.50, 0.50), # pink (1.00, 1.00, 1.00), # white ], blue=[ (0.00, 0.00, 0.00), # black (1e-18, 0.50, 0.50), # blue (0.15, 0.50, 0.50), # cyan (0.30, 0.00, 0.00), # green (0.45, 0.00, 0.00), # yellow (0.60, 0.00, 0.00), # orange (0.75, 0.00, 0.00), # red (0.90, 0.50, 0.50), # pink (1.00, 1.00, 1.00), # white ], ) clr_map = ColorMapper.from_segment_map(seg_map) self.clr_map = clr_map plot_eye_chnl = Plot(plotdata, padding_left=75) plot_eye_chnl.img_plot("eye_chnl", colormap=clr_map) plot_eye_chnl.y_direction = "normal" plot_eye_chnl.components[0].y_direction = "normal" plot_eye_chnl.title = post_chnl_str plot_eye_chnl.x_axis.title = "Time (ps)" plot_eye_chnl.x_axis.orientation = "bottom" plot_eye_chnl.y_axis.title = "Signal Level (V)" plot_eye_chnl.x_grid.visible = True plot_eye_chnl.y_grid.visible = True plot_eye_chnl.x_grid.line_color = "gray" plot_eye_chnl.y_grid.line_color = "gray" plot_eye_tx = Plot(plotdata, padding_left=75) plot_eye_tx.img_plot("eye_tx", colormap=clr_map) plot_eye_tx.y_direction = "normal" plot_eye_tx.components[0].y_direction = "normal" plot_eye_tx.title = post_tx_str plot_eye_tx.x_axis.title = "Time (ps)" plot_eye_tx.x_axis.orientation = "bottom" plot_eye_tx.y_axis.title = "Signal Level (V)" plot_eye_tx.x_grid.visible = True plot_eye_tx.y_grid.visible = True plot_eye_tx.x_grid.line_color = "gray" plot_eye_tx.y_grid.line_color = "gray" plot_eye_ctle = Plot(plotdata, padding_left=75) plot_eye_ctle.img_plot("eye_ctle", colormap=clr_map) plot_eye_ctle.y_direction = "normal" plot_eye_ctle.components[0].y_direction = "normal" plot_eye_ctle.title = post_ctle_str plot_eye_ctle.x_axis.title = "Time (ps)" plot_eye_ctle.x_axis.orientation = "bottom" plot_eye_ctle.y_axis.title = "Signal Level (V)" plot_eye_ctle.x_grid.visible = True plot_eye_ctle.y_grid.visible = True plot_eye_ctle.x_grid.line_color = "gray" plot_eye_ctle.y_grid.line_color = "gray" plot_eye_dfe = Plot(plotdata, padding_left=75) plot_eye_dfe.img_plot("eye_dfe", colormap=clr_map) plot_eye_dfe.y_direction = "normal" plot_eye_dfe.components[0].y_direction = "normal" plot_eye_dfe.title = post_dfe_str plot_eye_dfe.x_axis.title = "Time (ps)" plot_eye_dfe.x_axis.orientation = "bottom" plot_eye_dfe.y_axis.title = "Signal Level (V)" plot_eye_dfe.x_grid.visible = True plot_eye_dfe.y_grid.visible = True plot_eye_dfe.x_grid.line_color = "gray" plot_eye_dfe.y_grid.line_color = "gray" container_eye = GridPlotContainer(shape=(2, 2), spacing=(PLOT_SPACING, PLOT_SPACING)) container_eye.add(plot_eye_chnl) container_eye.add(plot_eye_tx) container_eye.add(plot_eye_ctle) container_eye.add(plot_eye_dfe) self.plots_eye = container_eye # - Jitter Distributions tab plot_jitter_dist_chnl = Plot(plotdata, padding_left=75) plot_jitter_dist_chnl.plot(("jitter_bins", "jitter_chnl"), type="line", color="blue", name="Measured") plot_jitter_dist_chnl.plot(("jitter_bins", "jitter_ext_chnl"), type="line", color="red", name="Extrapolated") plot_jitter_dist_chnl.title = post_chnl_str plot_jitter_dist_chnl.index_axis.title = "Time (ps)" plot_jitter_dist_chnl.value_axis.title = "Count" plot_jitter_dist_chnl.legend.visible = True plot_jitter_dist_chnl.legend.align = "ur" plot_jitter_dist_tx = Plot(plotdata, padding_left=75) plot_jitter_dist_tx.plot(("jitter_bins", "jitter_tx"), type="line", color="blue", name="Measured") plot_jitter_dist_tx.plot(("jitter_bins", "jitter_ext_tx"), type="line", color="red", name="Extrapolated") plot_jitter_dist_tx.title = post_tx_str plot_jitter_dist_tx.index_axis.title = "Time (ps)" plot_jitter_dist_tx.value_axis.title = "Count" plot_jitter_dist_tx.legend.visible = True plot_jitter_dist_tx.legend.align = "ur" plot_jitter_dist_ctle = Plot(plotdata, padding_left=75) plot_jitter_dist_ctle.plot(("jitter_bins", "jitter_ctle"), type="line", color="blue", name="Measured") plot_jitter_dist_ctle.plot(("jitter_bins", "jitter_ext_ctle"), type="line", color="red", name="Extrapolated") plot_jitter_dist_ctle.title = post_ctle_str plot_jitter_dist_ctle.index_axis.title = "Time (ps)" plot_jitter_dist_ctle.value_axis.title = "Count" plot_jitter_dist_ctle.legend.visible = True plot_jitter_dist_ctle.legend.align = "ur" plot_jitter_dist_dfe = Plot(plotdata, padding_left=75) plot_jitter_dist_dfe.plot(("jitter_bins", "jitter_dfe"), type="line", color="blue", name="Measured") plot_jitter_dist_dfe.plot(("jitter_bins", "jitter_ext_dfe"), type="line", color="red", name="Extrapolated") plot_jitter_dist_dfe.title = post_dfe_str plot_jitter_dist_dfe.index_axis.title = "Time (ps)" plot_jitter_dist_dfe.value_axis.title = "Count" plot_jitter_dist_dfe.legend.visible = True plot_jitter_dist_dfe.legend.align = "ur" container_jitter_dist = GridPlotContainer(shape=(2, 2), spacing=(PLOT_SPACING, PLOT_SPACING)) container_jitter_dist.add(plot_jitter_dist_chnl) container_jitter_dist.add(plot_jitter_dist_tx) container_jitter_dist.add(plot_jitter_dist_ctle) container_jitter_dist.add(plot_jitter_dist_dfe) self.plots_jitter_dist = container_jitter_dist # - Jitter Spectrums tab plot_jitter_spec_chnl = Plot(plotdata) plot_jitter_spec_chnl.plot(("f_MHz", "jitter_spectrum_chnl"), type="line", color="blue", name="Total") plot_jitter_spec_chnl.plot(("f_MHz", "jitter_ind_spectrum_chnl"), type="line", color="red", name="Data Independent") plot_jitter_spec_chnl.plot(("f_MHz", "thresh_chnl"), type="line", color="magenta", name="Pj Threshold") plot_jitter_spec_chnl.title = post_chnl_str plot_jitter_spec_chnl.index_axis.title = "Frequency (MHz)" plot_jitter_spec_chnl.value_axis.title = "|FFT(TIE)| (dBui)" plot_jitter_spec_chnl.tools.append( PanTool(plot_jitter_spec_chnl, constrain=True, constrain_key=None, constrain_direction="x")) zoom_jitter_spec_chnl = ZoomTool(plot_jitter_spec_chnl, tool_mode="range", axis="index", always_on=False) plot_jitter_spec_chnl.overlays.append(zoom_jitter_spec_chnl) plot_jitter_spec_chnl.legend.visible = True plot_jitter_spec_chnl.legend.align = "lr" plot_jitter_spec_tx = Plot(plotdata) plot_jitter_spec_tx.plot(("f_MHz", "jitter_spectrum_tx"), type="line", color="blue", name="Total") plot_jitter_spec_tx.plot(("f_MHz", "jitter_ind_spectrum_tx"), type="line", color="red", name="Data Independent") plot_jitter_spec_tx.plot(("f_MHz", "thresh_tx"), type="line", color="magenta", name="Pj Threshold") plot_jitter_spec_tx.title = post_tx_str plot_jitter_spec_tx.index_axis.title = "Frequency (MHz)" plot_jitter_spec_tx.value_axis.title = "|FFT(TIE)| (dBui)" plot_jitter_spec_tx.value_range.low_setting = -40.0 plot_jitter_spec_tx.index_range = plot_jitter_spec_chnl.index_range # Zoom x-axes in tandem. plot_jitter_spec_tx.legend.visible = True plot_jitter_spec_tx.legend.align = "lr" plot_jitter_spec_chnl.value_range = plot_jitter_spec_tx.value_range plot_jitter_spec_ctle = Plot(plotdata) plot_jitter_spec_ctle.plot(("f_MHz", "jitter_spectrum_ctle"), type="line", color="blue", name="Total") plot_jitter_spec_ctle.plot(("f_MHz", "jitter_ind_spectrum_ctle"), type="line", color="red", name="Data Independent") plot_jitter_spec_ctle.plot(("f_MHz", "thresh_ctle"), type="line", color="magenta", name="Pj Threshold") plot_jitter_spec_ctle.title = post_ctle_str plot_jitter_spec_ctle.index_axis.title = "Frequency (MHz)" plot_jitter_spec_ctle.value_axis.title = "|FFT(TIE)| (dBui)" plot_jitter_spec_ctle.index_range = plot_jitter_spec_chnl.index_range # Zoom x-axes in tandem. plot_jitter_spec_ctle.legend.visible = True plot_jitter_spec_ctle.legend.align = "lr" plot_jitter_spec_ctle.value_range = plot_jitter_spec_tx.value_range plot_jitter_spec_dfe = Plot(plotdata) plot_jitter_spec_dfe.plot(("f_MHz_dfe", "jitter_spectrum_dfe"), type="line", color="blue", name="Total") plot_jitter_spec_dfe.plot(("f_MHz_dfe", "jitter_ind_spectrum_dfe"), type="line", color="red", name="Data Independent") plot_jitter_spec_dfe.plot(("f_MHz_dfe", "thresh_dfe"), type="line", color="magenta", name="Pj Threshold") plot_jitter_spec_dfe.title = post_dfe_str plot_jitter_spec_dfe.index_axis.title = "Frequency (MHz)" plot_jitter_spec_dfe.value_axis.title = "|FFT(TIE)| (dBui)" plot_jitter_spec_dfe.index_range = plot_jitter_spec_chnl.index_range # Zoom x-axes in tandem. plot_jitter_spec_dfe.legend.visible = True plot_jitter_spec_dfe.legend.align = "lr" plot_jitter_spec_dfe.value_range = plot_jitter_spec_tx.value_range container_jitter_spec = GridPlotContainer(shape=(2, 2), spacing=(PLOT_SPACING, PLOT_SPACING)) container_jitter_spec.add(plot_jitter_spec_chnl) container_jitter_spec.add(plot_jitter_spec_tx) container_jitter_spec.add(plot_jitter_spec_ctle) container_jitter_spec.add(plot_jitter_spec_dfe) self.plots_jitter_spec = container_jitter_spec # - Bathtub Curves tab plot_bathtub_chnl = Plot(plotdata) plot_bathtub_chnl.plot(("jitter_bins", "bathtub_chnl"), type="line", color="blue") plot_bathtub_chnl.value_range.high_setting = 0 plot_bathtub_chnl.value_range.low_setting = -18 plot_bathtub_chnl.value_axis.tick_interval = 3 plot_bathtub_chnl.title = post_chnl_str plot_bathtub_chnl.index_axis.title = "Time (ps)" plot_bathtub_chnl.value_axis.title = "Log10(P(Transition occurs inside.))" plot_bathtub_tx = Plot(plotdata) plot_bathtub_tx.plot(("jitter_bins", "bathtub_tx"), type="line", color="blue") plot_bathtub_tx.value_range.high_setting = 0 plot_bathtub_tx.value_range.low_setting = -18 plot_bathtub_tx.value_axis.tick_interval = 3 plot_bathtub_tx.title = post_tx_str plot_bathtub_tx.index_axis.title = "Time (ps)" plot_bathtub_tx.value_axis.title = "Log10(P(Transition occurs inside.))" plot_bathtub_ctle = Plot(plotdata) plot_bathtub_ctle.plot(("jitter_bins", "bathtub_ctle"), type="line", color="blue") plot_bathtub_ctle.value_range.high_setting = 0 plot_bathtub_ctle.value_range.low_setting = -18 plot_bathtub_ctle.value_axis.tick_interval = 3 plot_bathtub_ctle.title = post_ctle_str plot_bathtub_ctle.index_axis.title = "Time (ps)" plot_bathtub_ctle.value_axis.title = "Log10(P(Transition occurs inside.))" plot_bathtub_dfe = Plot(plotdata) plot_bathtub_dfe.plot(("jitter_bins", "bathtub_dfe"), type="line", color="blue") plot_bathtub_dfe.value_range.high_setting = 0 plot_bathtub_dfe.value_range.low_setting = -18 plot_bathtub_dfe.value_axis.tick_interval = 3 plot_bathtub_dfe.title = post_dfe_str plot_bathtub_dfe.index_axis.title = "Time (ps)" plot_bathtub_dfe.value_axis.title = "Log10(P(Transition occurs inside.))" container_bathtub = GridPlotContainer(shape=(2, 2), spacing=(PLOT_SPACING, PLOT_SPACING)) container_bathtub.add(plot_bathtub_chnl) container_bathtub.add(plot_bathtub_tx) container_bathtub.add(plot_bathtub_ctle) container_bathtub.add(plot_bathtub_dfe) self.plots_bathtub = container_bathtub update_eyes(self)
def setup_plots(self): self.screen = Plot(self.data, resizable="hv", padding=0, bgcolor="lightgray", border_visible=False) self.screen.index_grid.visible = False self.screen.value_grid.visible = False px = self.process.capture.pixelsize w, h = self.process.capture.width, self.process.capture.height # value_range last, see set_range() self.screen.index_range.low_setting = -w/2*px self.screen.index_range.high_setting = w/2*px self.screen.value_range.low_setting = -h/2*px self.screen.value_range.high_setting = h/2*px self.horiz = Plot(self.data, resizable="h", padding=0, height=100, bgcolor="lightgray", border_visible=False) self.horiz.value_mapper.range.low_setting = \ -.1*self.process.capture.maxval self.horiz.index_range = self.screen.index_range self.vert = Plot(self.data, orientation="v", resizable="v", padding=0, width=100, bgcolor="lightgray", border_visible=False) for p in self.horiz, self.vert: p.index_axis.visible = False p.value_axis.visible = False p.index_grid.visible = True p.value_grid.visible = False self.vert.value_mapper.range.low_setting = \ -.1*self.process.capture.maxval self.vert.index_range = self.screen.value_range #self.vert.value_range = self.horiz.value_range self.mini = Plot(self.data, width=100, height=100, resizable="", padding=0, bgcolor="lightgray", border_visible=False) self.mini.index_axis.visible = False self.mini.value_axis.visible = False self.label = PlotLabel(component=self.mini, overlay_position="inside left", font="modern 10", text=self.process.text) self.mini.overlays.append(self.label) self.plots = GridPlotContainer(shape=(2, 2), padding=0, spacing=(5, 5), use_backbuffer=True, bgcolor="lightgray") self.plots.component_grid = [[self.vert, self.screen], [self.mini, self.horiz ]] self.screen.overlays.append(ZoomTool(self.screen, x_max_zoom_factor=1e2, y_max_zoom_factor=1e2, x_min_zoom_factor=0.5, y_min_zoom_factor=0.5, zoom_factor=1.2)) self.screen.tools.append(PanTool(self.screen)) self.plots.tools.append(SaveTool(self.plots, filename="bullseye.pdf")) self.asum = Plot(self.data, padding=0, height=100, bgcolor="lightgray", title="major axis", border_visible=False) self.bsum = Plot(self.data, padding=0, height=100, bgcolor="lightgray", title="minor axis", border_visible=False) for p in self.asum, self.bsum: p.value_axis.visible = False p.value_grid.visible = False p.title_font = "modern 10" p.title_position = "left" p.title_angle = 90 # lock scales #self.bsum.value_range = self.asum.value_range #self.bsum.index_range = self.asum.index_range self.abplots = VPlotContainer(padding=20, spacing=20, use_backbuffer=True,bgcolor="lightgray", fill_padding=True) self.abplots.add(self.bsum, self.asum)