setplot.py.html | |
Source file: setplot.py | |
Directory: /var/www/html/clawpack/links/awr10/radial-ocean-island | |
Converted: Thu Jul 29 2010 at 13:49:18 using clawcode2html | |
This documentation file will not reflect any later changes in the source file. |
""" Set up the plot figures, axes, and items to be done for each frame. This module is imported by the plotting routines and then the function setplot is called to set the plot parameters. """ from pyclaw.geotools import topotools from mapper import latlong from pyclaw.data import Data probdata = Data('setprob.data') theta_island = probdata.theta_island geodata = Data('setgeo.data') Rearth = geodata.Rearth #-------------------------- def setplot(plotdata): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ from pyclaw.plotters import colormaps, geoplot from numpy import linspace plotdata.clearfigures() # clear any old figures,axes,items data # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from pyclaw.plotters import gaugetools gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos='all', format_string='ko', add_labels=True) #----------------------------------------- # Figure for pcolor plot #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='pcolor', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Surface' plotaxes.scaled = True #plotaxes.afteraxes = addgauges # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -1.0 plotitem.pcolor_cmax = 1.0 plotitem.add_colorbar = True plotitem.amr_gridlines_show = [0,0,0] plotitem.gridedges_show = 1 # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = colormaps.all_white # to print better in B&W #plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_gridlines_show = [1,1,0,0,0] plotitem.gridedges_show = 1 plotaxes.xlimits = [-20,20] plotaxes.ylimits = [20,60] # add contour lines of bathy if desired: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.show = False plotitem.plot_var = geoplot.topo plotitem.contour_levels = linspace(-1000,-1000,1) plotitem.amr_contour_colors = ['g'] # color on each level plotitem.kwargs = {'linestyles':'dashed','linewidths':2} plotitem.amr_contour_show = [1,0,0] plotitem.gridlines_show = 0 plotitem.gridedges_show = 0 #----------------------------------------- # Figure for zoom #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Zoom1', figno=7) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('zoom on island') plotaxes.title = 'Surface elevation' plotaxes.scaled = True xisland,yisland = latlong(1600e3, theta_island, 40., Rearth) plotaxes.xlimits = [xisland-0.6, xisland+0.6] plotaxes.ylimits = [yisland-0.6, yisland+0.6] #plotaxes.afteraxes = addgauges def bigfont(current_data): import pylab t = current_data.t pylab.title("Surface at t = %8.1f" % t, fontsize=20) pylab.xticks(fontsize=15) pylab.yticks(fontsize=15) plotaxes.afteraxes = bigfont # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.show = True #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -1.0 plotitem.pcolor_cmax = 1.0 plotitem.add_colorbar = False plotitem.amr_gridlines_show = [0] plotitem.gridedges_show = 1 # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.show = True plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = colormaps.all_white # to print better in B&W #plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_gridlines_show = [0,0,0,1,0] plotitem.gridedges_show = 1 # contour lines: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.show = True plotitem.plot_var = geoplot.surface plotitem.contour_levels = [-0.8, -0.4, 0.4, 0.8] plotitem.amr_contour_colors = ['k'] # color on each level plotitem.kwargs = {'linewidths':2} plotitem.amr_contour_show = [0,0,0,1,1] plotitem.gridlines_show = 0 plotitem.gridedges_show = 0 # add contour lines of bathy if desired: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.show = False plotitem.plot_var = geoplot.topo plotitem.contour_levels = linspace(-1000,-1000,1) plotitem.amr_contour_colors = ['g'] # color on each level plotitem.kwargs = {'linestyles':'dashed','linewidths':2} plotitem.amr_contour_show = [0,0,1] plotitem.gridlines_show = 0 plotitem.gridedges_show = 0 #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = False # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [6000, 14000] plotaxes.ylimits = [-2.0, 3.0] plotaxes.title = 'Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # Plot topo as green curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') def gaugetopo(current_data): q = current_data.q h = q[:,0] eta = q[:,3] topo = eta - h return topo plotitem.plot_var = gaugetopo plotitem.plotstyle = 'g-' def add_zeroline(current_data): from pylab import plot, legend t = current_data.t #legend(('surface','topography'),loc='lower left') plot(t, 0*t, 'k') plotaxes.afteraxes = add_zeroline #----------------------------------------- # Figure for grids alone #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='grids', figno=2) plotfigure.show = False # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0,1] plotaxes.ylimits = [0,1] plotaxes.title = 'grids' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_grid') plotitem.amr_grid_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_gridlines_show = [1,1,0] plotitem.amr_gridedges_show = [1] #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via pyclaw.plotters.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_gaugenos = 'all' # list of gauges to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' # pointer for top of index plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? return plotdata