def get_histview( self, histogram, min, max,set_ymin=None,set_ymax=None ): # Prepare histogram plot data = [] bucket_width = (max - min) / 256.0 for bucket_index in range(256): data.append( (min + bucket_width * bucket_index, histogram[bucket_index]) ) # Generate histogram graph import gvplot xpm_file = gvutils.tempnam(extension='xpm') if ((set_ymin is not None) and (set_ymax is not None)): # Allows you to explicitly set ymin/ymax at startup # to avoid the gnuplot 0 y-range warning. gvplot.plot( data, xaxis = 'Pixel Value', yaxis = 'Count', xmin = min, xmax = max, ymin = set_ymin, ymax = set_ymax, output = xpm_file, title = 'Histogram', terminal = 'xpm' ) else: gvplot.plot( data, xaxis = 'Pixel Value', yaxis = 'Count', xmin = min, xmax = max, output = xpm_file, title = 'Histogram', terminal = 'xpm' ) # apply it to display. pixbuf = gtk.gdk.pixbuf_new_from_file(xpm_file) os.unlink( xpm_file ) return pixbuf
def get_histview( self, histogram, min, max,set_ymin=None,set_ymax=None ): # Prepare histogram plot data = [] bucket_width = (max - min) / 256.0 for bucket_index in range(256): data.append( (min + bucket_width * bucket_index, histogram[bucket_index]) ) # Generate histogram graph import gvplot xpm_file = gvutils.tempnam(extension='xpm') if ((set_ymin is not None) and (set_ymax is not None)): # Allows you to explicitly set ymin/ymax at startup # to avoid the gnuplot 0 y-range warning. gvplot.plot( data, xaxis = 'Pixel Value', yaxis = 'Count', xmin = min, xmax = max, ymin = set_ymin, ymax = set_ymax, output = xpm_file, title = 'Histogram', terminal = 'xpm' ) else: gvplot.plot( data, xaxis = 'Pixel Value', yaxis = 'Count', xmin = min, xmax = max, output = xpm_file, title = 'Histogram', terminal = 'xpm' ) # apply it to display. gdk_pixmap, gdk_mask = \ gtk.create_pixmap_from_xpm(self,None,xpm_file) os.unlink( xpm_file ) return (gdk_pixmap, gdk_mask)
def graph_rgb(view_xy): view = gview.app.view_manager.get_active_view_window() layers = view.viewarea.list_layers() to_plot = [] for layer in layers: lclass = ev_mosaic_viewer.layer_class(layer) raster = layer.get_data(0) date = get_dataset_date(raster.get_dataset()) if date is None: continue pixel_xy = layer.view_to_pixel(view_xy[0], view_xy[1]) data_point = [date] for comp in range(3): raster = layer.get_data(comp) data_point.append(raster.get_sample(pixel_xy[0], pixel_xy[1])) print raster.get_dataset().GetDescription(), data_point to_plot.append(data_point) to_plot = Numeric.array(to_plot) return gvplot.plot(to_plot, xaxis = 'Days', yaxis = 'Value', ymin = 6500.0, ymax = 11000.0, terminal='openev', multiplot=True)
def graph_rgb(view_xy): view = gview.app.view_manager.get_active_view_window() layers = view.viewarea.list_layers() to_plot = [] for layer in layers: lclass = ev_mosaic_viewer.layer_class(layer) raster = layer.get_data(0) date = get_dataset_date(raster.get_dataset()) if date is None: continue pixel_xy = layer.view_to_pixel(view_xy[0], view_xy[1]) data_point = [date] for comp in range(3): raster = layer.get_data(comp) data_point.append(raster.get_sample(pixel_xy[0], pixel_xy[1])) print raster.get_dataset().GetDescription(), data_point to_plot.append(data_point) to_plot = Numeric.array(to_plot) return gvplot.plot(to_plot, xaxis='Days', yaxis='Value', ymin=6500.0, ymax=11000.0, terminal='openev', multiplot=True)
def graph_darkness(view_xy): view = gview.app.view_manager.get_active_view_window() layers = view.viewarea.list_layers() to_plot = [] for layer in layers: lclass = ev_mosaic_viewer.layer_class(layer) if lclass != ev_mosaic_viewer.LYR_LANDSAT8: continue raster = layer.get_data(0) # ignore rasters that aren't source scenes with a date. date = get_dataset_date(raster.get_dataset()) if date is None: continue pixel_xy = layer.view_to_pixel(view_xy[0], view_xy[1]) data_point = [date] for xoff in range(-2,4,2): for yoff in range(-2,4,2): rgb_sum = 0 for comp in range(3): raster = layer.get_data(comp) rgb_sum += raster.get_sample(pixel_xy[0] + xoff, pixel_xy[1] + yoff) rgb_sum *= 0.3333 to_plot.append(rgb_sum) to_plot.sort() return gvplot.plot(to_plot, xaxis = 'Sample', yaxis = 'Brightness', ymin = 6500.0, ymax = 11000.0, terminal='openev')
def graph_darkness(view_xy): view = gview.app.view_manager.get_active_view_window() layers = view.viewarea.list_layers() to_plot = [] for layer in layers: lclass = ev_mosaic_viewer.layer_class(layer) if lclass != ev_mosaic_viewer.LYR_LANDSAT8: continue raster = layer.get_data(0) # ignore rasters that aren't source scenes with a date. date = get_dataset_date(raster.get_dataset()) if date is None: continue pixel_xy = layer.view_to_pixel(view_xy[0], view_xy[1]) data_point = [date] for xoff in range(-2, 4, 2): for yoff in range(-2, 4, 2): rgb_sum = 0 for comp in range(3): raster = layer.get_data(comp) rgb_sum += raster.get_sample(pixel_xy[0] + xoff, pixel_xy[1] + yoff) rgb_sum *= 0.3333 to_plot.append(rgb_sum) to_plot.sort() return gvplot.plot(to_plot, xaxis='Sample', yaxis='Brightness', ymin=6500.0, ymax=11000.0, terminal='openev')