def show_swath_pycoast(self, start, period=None): """ A helper method that displays the orbital swath starting at datetime start, for a period number of minutes. If, start is iterable, then the method assumes it is an iterable of datetimes, plotting a number of swaths at those times. """ # test if start is iterable, EAFP style: try: for e in start: pass except TypeError: start = [start] start.sort() from PIL import Image from pycoast import ContourWriterAGG from pydecorate import DecoratorAGG img = Image.new('RGB', (650, 650)) proj4_string = "" for x in self.working_projection: proj4_string += "+%s=%s "%(x,self.working_projection[x]) area_extent = (-6700000.0, -6700000.0, 6700000.0, 6700000.0) area_def = (proj4_string, area_extent) cw = ContourWriterAGG() cw.add_grid(img, area_def, (10.0,10.0),(2.0,2.0), fill='blue', outline='gray', outline_opacity=130, minor_outline=None, write_text=False) # Plot granules for t in start: # fetch the coordinates xys_segs = self.swath_working_projection(t, period) for xys in xys_segs: lls = self.proj(xys[0],xys[1],inverse=True) cw.add_polygon(img, area_def, zip(lls[0], lls[1]), outline="blue", fill="blue", fill_opacity=70, width=1) cw.add_coastlines(img, area_def, resolution='l') aoi_coords = zip(*self.aoi) ## TODO: Handle single point case properly if len(aoi_coords) == 1: x, y = aoi_coords[0] d = 0.5 line_coords = [(x-d,y),(x+d,y)] cw.add_line(img, area_def, line_coords, outline="red", fill="red", fill_opacity=100, width=2) elif len(aoi_coords) == 2: cw.add_line(img, area_def, aoi_coords, outline="red", fill="red", fill_opacity=100, width=10) else: cw.add_polygon(img, area_def, aoi_coords, outline="red", fill="red", fill_opacity=100, width=2) # Decorate dc = DecoratorAGG(img) text = "Granules from time: %s + %.2f min."%(start[0].strftime('%Y.%m.%d %H:%M:%S'), (start[-1]-start[0]).total_seconds()/60.0) dc.align_bottom() dc.add_text(text,height=0) img.show()
def plot(data, text, minmax=None, transpose=False, filename=None, position=(-16.743860721,64.915348712,712.4), tilt=None, target_position=None, target_name="", vfov=18.5, tick_distance=50.0): if transpose: data = data.transpose() if minmax is None: rainbow.set_range(data.min(),data.max()) else: rainbow.set_range(minmax[0],minmax[1]) img = Image(data, mode="L") img.colorize(rainbow) img = img.pil_image() # Decoration dc = DecoratorAGG(img) dc.align_bottom() #dc.add_logo("/home/sat/dev/pydecorate/logos/VI_Logo_Transp.png") #dc.add_logo("Nicarnica-Aviation-22-oct-300x102.png") try: dc.add_logo("/home/master/bin/futurevolc_logo.png", height=47) dc.add_logo("/home/master/bin/nicarnica_logo.png") dc.add_logo("/home/master/bin/vi_logo.png") except IOError: dc.add_logo("bin/futurevolc_logo.png", height=47) dc.add_logo("bin/nicarnica_logo.png") dc.add_logo("bin/vi_logo.png") dc.add_text(text, font=font) tick_space = 5.0 #dc.add_scale(rainbow, extend=True, unit='°C', tick_marks=tick_space, minor_tick_marks=tick_space) # target distance and km/px ny = data.shape[0] nx = data.shape[1] distance = distance_longlat(target_position,position) # plot grid lines, texts = prepare_graticule(nx, ny, distance=distance, vfov=vfov, tilt=tilt, tick_distance=tick_distance, height=position[2],target_height=target_position[2], target_name=target_name) draw_lines(img, lines) draw_texts(img, texts) if filename == None: img.show() else: img.save(filename, "JPEG", quality=90)
dc.add_scale(rdbu, extend=True, tick_marks=5.0, line_opacity=100, unit='K') #dc.align_left() #dc.add_scale(rdbu, extend=True, font=font_scale, tick_marks=2.0, minor_tick_marks=1.0, line_opacity=100, width=60, unit='K') img.show() #img.save("style_retention.png") exit() #dc.align_right() #dc.align_bottom() #dc.add_logo("logos/pytroll_light_big.png") #dc.add_logo("logos/NASA_Logo.gif") #dc.add_text("This is manually\nplaced text\nover here.",cursor=[400,480]) dc.new_line() dc.add_text("This here is\na new line\nof features") dc.add_logo("logos/pytroll_light_big.png") dc.align_right() dc.write_vertically() dc.add_text("Now writing\nvertically", height=0) dc.add_logo("logos/pytroll_light_big.png") dc.add_logo("logos/NASA_Logo.gif") img.show() exit() #dc.toggle_direction() dc.add_logo("logos/pytroll_light_big.png", height=60) dc.add_logo("logos/NASA_Logo.gif")
def show_swath_pycoast(self, start, period=None): """ A helper method that displays the orbital swath starting at datetime start, for a period number of minutes. If, start is iterable, then the method assumes it is an iterable of datetimes, plotting a number of swaths at those times. """ # test if start is iterable, EAFP style: try: for e in start: pass except TypeError: start = [start] start.sort() from PIL import Image from pycoast import ContourWriterAGG from pydecorate import DecoratorAGG img = Image.new('RGB', (650, 650)) proj4_string = "" for x in self.working_projection: proj4_string += "+%s=%s " % (x, self.working_projection[x]) area_extent = (-6700000.0, -6700000.0, 6700000.0, 6700000.0) area_def = (proj4_string, area_extent) cw = ContourWriterAGG() cw.add_grid(img, area_def, (10.0, 10.0), (2.0, 2.0), fill='blue', outline='gray', outline_opacity=130, minor_outline=None, write_text=False) # Plot granules for t in start: # fetch the coordinates xys_segs = self.swath_working_projection(t, period) for xys in xys_segs: lls = self.proj(xys[0], xys[1], inverse=True) cw.add_polygon(img, area_def, zip(lls[0], lls[1]), outline="blue", fill="blue", fill_opacity=70, width=1) cw.add_coastlines(img, area_def, resolution='l') aoi_coords = zip(*self.aoi) ## TODO: Handle single point case properly if len(aoi_coords) == 1: x, y = aoi_coords[0] d = 0.5 line_coords = [(x - d, y), (x + d, y)] cw.add_line(img, area_def, line_coords, outline="red", fill="red", fill_opacity=100, width=2) elif len(aoi_coords) == 2: cw.add_line(img, area_def, aoi_coords, outline="red", fill="red", fill_opacity=100, width=10) else: cw.add_polygon(img, area_def, aoi_coords, outline="red", fill="red", fill_opacity=100, width=2) # Decorate dc = DecoratorAGG(img) text = "Granules from time: %s + %.2f min." % ( start[0].strftime('%Y.%m.%d %H:%M:%S'), (start[-1] - start[0]).total_seconds() / 60.0) dc.align_bottom() dc.add_text(text, height=0) img.show()
#dc.align_right() #dc.align_bottom() #dc.add_logo("logos/pytroll_light_big.png") #dc.add_logo("logos/NASA_Logo.gif") #dc.add_text("This is manually\nplaced text\nover here.",cursor=[400,480]) dc.new_line() dc.add_text("This here is\na new line\nof features") dc.add_logo("logos/pytroll_light_big.png") dc.align_right() dc.write_vertically() dc.add_text("Now writing\nvertically",height=0) dc.add_logo("logos/pytroll_light_big.png") dc.add_logo("logos/NASA_Logo.gif") img.show() exit() #dc.toggle_direction()