Esempio n. 1
0
    def plotHistogram(self, image, plot=None):
        if plot == None:
            pd = ArrayPlotData(y=np.array([0]), x=np.array([0]))
            plot = Plot(pd, padding=(70, 10, 0, 0))
            plot.plot(('x', 'y'), name='Histogram', type='bar', bar_width=5.0, color='auto')
            #plot.title = 'Histogram'
            plot.line_color = 'black'
            plot.bgcolor = "white"
            plot.fixed_preferred_size = (100, 30)
            add_default_grids(plot)
            plot.value_axis.title = "Histogram"
            self._appendHistogramTools(plot)
            '''
            plot.overlays.append(PlotAxis(plot, orientation='left'))
            plot.overlays.append(PlotAxis(plot, orientation='bottom'))
            '''
        else:
            data = np.histogram(image.data, bins=10000)
            index = np.delete(data[1], data[1].size-1)
            values = data[0]
            
            plot.index_range.low= np.min(index)
            plot.index_range.high = np.max(index)
            plot.value_range.low = 0
            plot.value_range.high = np.max(values)

            plot.data.set_data('x', index)
            plot.data.set_data('y', values)
        plot.request_redraw()
        return plot
Esempio n. 2
0
    def plotImage(self, image, plot=None):
        '''plot one image
        image:     Image object
        plot:      plot instance to be update, if None, a plot instance will be created
        return:    plot instance'''
        if plot == None:
            pd = ArrayPlotData()
            pd.set_data('imagedata', image.data)
            plot = Plot(pd, default_origin = "bottom left", padding=0)
            #plot.title = image.name
            plot.bgcolor = 'white'
            plot.fixed_preferred_size = (100, 100)
            plot.x_axis.visible = False
            plot.y_axis.visible = False
            self.imageplot = plot

            # TODO: mess with color maps on else block    
            imgPlot = plot.img_plot("imagedata", colormap=jet, name='image')[0]
            self.imgPlot = imgPlot
            self._appendImageTools(imgPlot)
            #plot.overlays.append(MyLineDrawer(plot))
        else:
            plot.data.set_data('imagedata', image.data)
            imgPlot = plot.plots['image'][0]
            #plot.title = image.name
        plot.aspect_ratio = float(image.data.shape[1]) / image.data.shape[0]
        plot.invalidate_draw()
        return plot
Esempio n. 3
0
    def plotImage(self, image, plot=None):
        '''Plots a tiff image.

        |  image -- Image object
        |  plot  -- plot instance to be updated 
        |           if None, a plot instance will be created

        Returns the plot instance.
        '''
        if plot == None:
            pd = ArrayPlotData()
            pd.set_data('imagedata', image.data)
            plot = Plot(pd, default_origin = "bottom left", padding=0)
            plot.bgcolor = 'white'
            plot.fixed_preferred_size = (100, 100)
            plot.x_axis.visible = False
            plot.y_axis.visible = False
            self.imageplot = plot

            imgPlot = plot.img_plot("imagedata", colormap=self.cmap, 
                                                    name='image')[0]
            self.imgPlot = imgPlot
            self.appendImageTools(imgPlot)
        else:
            plot.data.set_data('imagedata', image.data)
        plot.aspect_ratio = float(image.data.shape[1]) / image.data.shape[0]
        plot.invalidate_and_redraw()
        return plot
Esempio n. 4
0
    def plot1DCut(self, image, plot=None):
        '''Plots a 1D cut of the image.

        Currently, the 1D cut is a plot of mean intensity vs column #.

        |  image -- Image object
        |  plot  -- plot instance to be updated 
        |           if None, a plot instance will be created

        Returns the plot instance.
        '''
        if plot == None:
            pd = ArrayPlotData(y=np.array([0]), x=np.array([0]))
            plot = Plot(pd, padding=(70, 10, 0, 5))
            plot.plot(('x', 'y'), name='1D Cut', type='line', color='blue')
            plot.value_axis.title = '1D Cut'
            plot.x_axis.visible = False
            plot.bgcolor = "white"
            plot.fixed_preferred_size = (100, 30)
            plot.value_range.low = 'auto'
            plot.value_range.high = 'auto'
            plot.index_range.low = 'auto'
            plot.index_range.high = 'auto'
            self.append1DCutTools(plot)
        else:
            index = range(image.data.shape[1])
            values = image.data.mean(axis=0)
            self.setData(values, index, plot)
        plot.invalidate_and_redraw()
        return plot
Esempio n. 5
0
    def plotHistogram(self, image, plot=None):
        '''Plots a histogram.

        |  image -- Image object
        |  plot  -- plot instance to be updated 
        |           if None, a plot instance will be created

        Returns the plot instance.
        '''
        if plot == None:
            pd = ArrayPlotData(y=np.array([0]), x=np.array([0]))
            plot = Plot(pd, padding=(70, 10, 0, 0))
            plot.plot(('x', 'y'), name='Histogram', type='bar', bar_width=1.0)
            plot.line_color = 'black'
            plot.bgcolor = "white"
            plot.fixed_preferred_size = (100, 30)
            add_default_grids(plot)
            plot.value_range.low = 'auto'
            plot.value_range.high = 'auto'
            plot.index_range.low = 'auto'
            plot.index_range.high = 'auto'
            plot.value_axis.title = "Histogram"
            self.appendHistogramTools(plot)
            
        else:
            data = np.histogram(image.data, bins=10000)
            index = np.delete(data[1], data[1].size-1)
            values = data[0]
            self.setData(values, index, plot)
        plot.invalidate_and_redraw()
        return plot
Esempio n. 6
0
    def plotRRMap(self, ydata, title, plot=None):
        '''Plots an RR map.

        |  ydata -- y-data to be plotted
        |  title -- RR type, to be displayed on y-axis
        |  plot  -- plot instance to be updated 
        |           if None, a plot instance will be created

        Returns the plot instance.
        '''
        if plot == None:
            pd = ArrayPlotData()
            plot = Plot(pd, padding=(79, 5, 0, 0))
            self.setData(ydata, None, plot)
            plot.plot(('x', 'y'), name='rrplot', type="scatter", color='green',
                      marker="circle", marker_size=6)
            plot.value_axis.title = title
            plot.bgcolor = 'white'
            plot.aspect_ratio = 2.5
            plot.fixed_preferred_size = (100, 50)
            plot.y_axis.tick_label_formatter = lambda val:('%.2E'%val)
            plot.x_axis.visible = False
            hgrid, vgrid = add_default_grids(plot)
            self.appendRRTools(plot)
        else:
            self.setData(ydata, None, plot)
        plot.invalidate_and_redraw()
        return plot
Esempio n. 7
0
 def plotRRMap(self, rr, rrchoice, plot=None):
     if plot == None:
         pd = ArrayPlotData(y=np.array([0]), x=np.array([0]))
         plot = Plot(pd, padding=(70, 5, 0, 0))
         self._setData(rr, plot)
         plot.plot(('x', 'y'), name='rrplot', type="scatter", color='green',
                   marker="circle", marker_size=6)
         #plot.title = 'rrplot'
         plot.value_axis.title = rrchoice
         #plot.y_axis.visible = False
         plot.bgcolor = 'white'
         plot.aspect_ratio = 2.5
         plot.fixed_preferred_size = (100, 50)
         #left, bottom = add_default_axes(plot)
         hgrid, vgrid = add_default_grids(plot)
         self._appendCMapTools(plot)
     else:
         self._setData(rr, plot)
     plot.request_redraw()
     return plot