setplot.py.html | |
Source file: setplot.py | |
Directory: /var/www/html/clawpack/links/noaa-tsunami-benchmarks/monai-valley/monai3 | |
Converted: Mon Jan 24 2011 at 13:13:05 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. """ #-------------------------- 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 plotdata.clearfigures() # clear any old figures,axes,items data def set_drytol(current_data): # The drytol parameter is used in masking land and water and # affects what color map is used for cells with small water depth h. # The cell will be plotted as dry if h < drytol. # The best value to use often depends on the application and can # be set here (measured in meters): current_data.user.drytol = 1.e-4 plotdata.beforeframe = set_drytol # 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) plotfigure.show = False # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Surface' plotaxes.scaled = True # 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 = -0.02 plotitem.pcolor_cmax = 0.02 plotitem.add_colorbar = True plotitem.amr_gridlines_show = [0,0,0] plotitem.amr_gridedges_show = [1] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 0.05 plotitem.add_colorbar = False plotitem.amr_gridlines_show = [0,0,0] plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' #----------------------------------------- # Figure for imshow plot #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface and Gauge 1', figno=20) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('imshow') plotaxes.axescmd = "axes([.1,.5,.8,.4])" plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.afteraxes = addgauges # Water plotitem = plotaxes.new_plotitem(plot_type='2d_imshow') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.imshow_cmap = geoplot.tsunami_colormap plotitem.imshow_cmin = -0.03 plotitem.imshow_cmax = 0.03 plotitem.add_colorbar = True plotitem.amr_gridlines_show = [0,0,0] plotitem.amr_gridedges_show = [1] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_imshow') plotitem.plot_var = geoplot.land plotitem.imshow_cmap = geoplot.land_colors plotitem.imshow_cmin = 0.0 plotitem.imshow_cmax = 0.05 plotitem.add_colorbar = False plotitem.amr_gridlines_show = [0,0,0] plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' # Gauge trace: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = "axes([.1,.1,.8,.3])" plotaxes.xlimits = 'auto' plotaxes.ylimits = [-0.02, 0.05] plotaxes.title = 'Gauge 1' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_gauge_trace') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' plotitem.gaugeno = 1 #----------------------------------------- # Figure for zoom #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Zoom', figno=10) #plotfigure.show = False plotfigure.kwargs = {'figsize':[12,7]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('monai') #plotaxes.axescmd = 'axes([0.0,0.1,0.6,0.6])' plotaxes.title = 'Zoom near Monai Valley' plotaxes.scaled = True plotaxes.xlimits = [4.0, 5.2] plotaxes.ylimits = [1.3, 2.5] # 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 = -0.02 plotitem.pcolor_cmax = 0.02 plotitem.add_colorbar = True plotitem.amr_gridlines_show = [0] plotitem.amr_gridedges_show = [1] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 0.05 plotitem.add_colorbar = False plotitem.amr_gridlines_show = [0] # Add contour lines of bathymetry: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = arange(-0.02, 0., .0025) plotitem.amr_contour_colors = ['k'] # color on each level plotitem.kwargs = {'linestyles':'solid'} plotitem.amr_contour_show = [1] # show contours only on finest level plotitem.gridlines_show = 0 plotitem.gridedges_show = 0 plotitem.show = True # Add contour lines of topography: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = arange(0., .2, .01) plotitem.amr_contour_colors = ['w'] # color on each level plotitem.kwargs = {'linestyles':'solid'} plotitem.amr_contour_show = [1] # show contours only on finest level plotitem.gridlines_show = 0 plotitem.gridedges_show = 0 plotitem.show = True # Add dashed contour line for shoreline plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.topo plotitem.contour_levels = [0.] plotitem.amr_contour_colors = ['k'] # color on each level plotitem.kwargs = {'linestyles':'dashed'} plotitem.amr_contour_show = [1] # show contours only on finest level plotitem.gridlines_show = 0 plotitem.gridedges_show = 0 plotitem.show = True #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0,60] plotaxes.ylimits = [-0.02, 0.05] 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.clf_each_gauge = False plotitem.plotstyle = 'g-' def afteraxes(current_data): from pylab import plot, legend, loadtxt t = current_data.t plot(t, 0*t, 'k') try: labgage = loadtxt('WaveGages.txt',skiprows=1) except: print "*** Did not find WaveGages.txt from benchmark" gaugeno = current_data.gaugeno if gaugeno in [1,2,3]: plot(labgage[:,0],0.01*labgage[:,gaugeno],'r') legend(('GeoClaw','topography','sea level','lab data'),loc='upper right') else: legend(('GeoClaw','topography','sea level'),loc='upper right') plotaxes.afteraxes = afteraxes #----------------------------------------- # 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 = [1,2,3,12] # 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