def setplot(plotdata): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot from numpy import linspace plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' #plotdata.format = 'ascii' # Load data from output clawdata = clawutil.ClawInputData(2) clawdata.read(os.path.join(plotdata.outdir, 'claw.data')) ocean_xlimits = [clawdata.lower[0], clawdata.upper[0]] ocean_ylimits = [clawdata.lower[1], clawdata.upper[1]] amrdata = amrclaw.AmrclawInputData(clawdata) amrdata.read(os.path.join(plotdata.outdir, 'amr.data')) physics = geodata.GeoClawData() physics.read(os.path.join(plotdata.outdir, 'geoclaw.data')) surge_data = geodata.SurgeData() surge_data.read(os.path.join(plotdata.outdir, 'surge.data')) probdata = clawutil.ClawData() #probdata.read('setprob.data', force=True) #theta_island = probdata.theta_island # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from clawpack.visclaw import gaugetools gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos='all', format_string='ko', add_labels=True) def mynewafteraxes(current_data): addgauges(current_data) bigfont(current_data) #----------------------------------------- # Some global KML settings #----------------------------------------- #plotdata.kml_publish = 'http://math.boisestate.edu/~calhoun/visclaw/GoogleEarth/kmz/' #public html plotdata.kml_publish = None plotdata.kml_name = "NYC Asteroid" # name appears in Google Earth display only plotdata.kml_index_fname = "NYC_Asteroid" # name for .kmz and .kml files ["_GoogleEarth"] # specify beginning of slider time. if not used, assumes Jan. 1 1970 plotdata.kml_starttime = [2115, 4, 29, 7, 32, 0] # Asteroid hits at 1:32AM, 4/29/2115 (UTC) plotdata.kml_tz_offset = 6 # off set to UTC # for todays date as the default use kml_cmin = -0.005 #colorbar min and max kml_cmax = 0.005 kml_dpi = 400 # only used if individual figures dpi not set kml_cmap = geoplot.googleearth_lightblue # kml_cmap = geoplot.googleearth_darkblue # kml_cmap = geoplot.googleearth_transparent # kml_cmap = geoplot.googleearth_white def kml_colorbar(filename): #cmin = -0.01 #cmax = 0.01 geoplot.kml_build_colorbar(filename, kml_cmap, kml_cmin, kml_cmax) #----------------------------------------- # Figure for pcolor plot for surface #----------------------------------------- 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.show = True #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth #plotitem.plot_var = 0/1/2 or plot that entry into q instead of a function plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -.8 plotitem.pcolor_cmax = .8 plotitem.add_colorbar = True plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [0, 0, 0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.show = True # plotitem.pcolor_cmap = colormaps.all_white # to print better in B&W plotitem.pcolor_cmap = geoplot.land_colors #plotitem.pcolor_cmap = geoplot.googleearth_transparent plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0, 0, 0, 0, 0] #plotitem.patchedges_show = 1 plotitem.amr_patchedges_show = [0, 0, 0] #plotaxes.xlimits = [-85,-55] #plotaxes.ylimits = [25,45] plotaxes.xlimits = ocean_xlimits plotaxes.ylimits = ocean_ylimits #plotaxes.xlimits = [-75,-70] #plotaxes.ylimits = [38,43] # add contour lines of bathy if desired: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.show = True plotitem.plot_var = geoplot.topo #plotitem.contour_levels = [-500,-250,-100, -50, 0, 50] plotitem.contour_levels = linspace(-1000, -400, 3) plotitem.amr_contour_colors = ['g'] # color on each level #plotitem.kwargs = {'linestyles':'dashed','linewidths':2,'colors' : 'red' } plotitem.kwargs = { 'linestyles': 'dashed', 'linewidths': 1, 'colors': 'magenta' } plotitem.amr_contour_show = [1, 1, 1] plotitem.celledges_show = 0 plotitem.patchedges_show = 0 #----------------------------------------------------------- # Figure for KML files - Sea Surface Height #---------------------------------------------------------- #plotfigure = plotdata.new_plotfigure(name='Sea Surface',figno=1) #plotfigure.show = True #plotfigure.use_for_kml = True #plotfigure.kml_use_for_initial_view = True # These overide any values set in the plotitems below #plotfigure.kml_xlimits = [-80,-55] #plotfigure.kml_ylimits = [25, 45] # Resolution #plotfigure.kml_dpi = 300 #plotfigure.kml_tile_images = False def kml_colorbar_transparent(filename): #cmin = -0.01 #cmax = 0.01 geoplot.kml_build_colorbar(filename, geoplot.googleearth_transparent, kml_cmin, kml_cmax) #plotfigure.kml_colorbar = kml_colorbar_transparent # Set up for axes in this figure: #plotaxes = plotfigure.new_plotaxes('kml') #plotaxes.scaled = True # Water #plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.show = True #plotitem.plot_var = geoplot.surface_or_depth #plotitem.pcolor_cmap = geoplot.googleearth_transparent #plotitem.pcolor_cmin = kml_cmin #plotitem.pcolor_cmax = kml_cmax #plotitem.amr_celledges_show = [0,0,0] #plotitem.patchedges_show = 0 #plotfigure.kml_colorbar = kml_colorbar #----------------------------------------- # Figure for speeds #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Speeds', figno=10) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Speed' plotaxes.scaled = True #def fixup(current_data): # import pylab # addgauges(current_data) # t = current_data.t # t = t / 3600. # hours # pylab.title('Speed at %4.2f hours' % t, fontsize=20) # pylab.xticks(fontsize=15) # pylab.yticks(fontsize=15) #plotaxes.afteraxes = fixup def speed(current_data): from pylab import where, sqrt q = current_data.q h = q[0, :] dry_tol = 0.001 u = q[1, :] # this is just to initialize v = q[2, :] # to correct size s = 0 * q[2, :] # to correct size nq = len(q[1, :]) [n, m] = h.shape for ii in range(0, n): for jj in range(0, m): if h[ii, jj] > dry_tol: u[ii, jj] = q[1, ii, jj] / h[ii, jj] v[ii, jj] = q[2, ii, jj] / h[ii, jj] s[ii, jj] = sqrt(u[ii, jj] * u[ii, jj] + v[ii, jj] * v[ii, jj]) else: u[ii, jj] = 0. v[ii, jj] = 0. s[ii, jj] = 0 #print("max of u = " + str(max(u))) #u = where(h>dry_tol, q[1,:]/h, 0.) #v = where(h>dry_tol, q[2,:]/h, 0.) #s = sqrt(u**2 + v**2) #s = sqrt(u*2+v*v) #try not dividing or using where return s # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.show = False plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.tsunami_colormap #plotitem.pcolor_cmap = \ # colormaps.make_colormap({0:[1,1,1],0.5:[0.5,0.5,1],1:[1,0.3,0.3]}) plotitem.pcolor_cmin = 0. plotitem.pcolor_cmax = .10 plotitem.add_colorbar = True plotitem.amr_celledges_show = [0, 0, 0] #plotitem.patchedges_show = 1 plotitem.amr_patchedges_show = [0, 0, 0] # 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 = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 plotaxes.xlimits = ocean_xlimits plotaxes.ylimits = ocean_ylimits #----------------------------------------- # Figure for zoom around NYC #----------------------------------------- zoomWanted = True if zoomWanted: plotfigure = plotdata.new_plotfigure(name='Zoom1', figno=7) # add another figure #plotfigure.use_for_kml = True #plotfigure.kml_use_for_initial_view = False # These overide any values set in the plotitems below #plotfigure.kml_xlimits = [-74.5, -73.5] #plotfigure.kml_ylimits = [40.4,40.9] # Resolution #plotfigure.kml_dpi = 300 #plotfigure.kml_tile_images = True #plotfigure.kml_colorbar = kml_colorbar # defined above # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('zoom on nyc') plotaxes.title = 'Surface elevation' plotaxes.scaled = True manhattan_island = -73.5 xisland, yisland = latlong(1600e3, manhattan_island, 40., Rearth) #plotaxes.xlimits = [xisland-0.6, xisland+0.6] #plotaxes.xlimits = [manhattan_island-1, manhattan_island+1] #plotaxes.ylimits = [40.15,41.5] plotaxes.xlimits = [-74.5, -72.5] # really zoom in on lower manhattan] plotaxes.ylimits = [40.25, 41.5] 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 #plotaxes.afteraxes = mynewafteraxes # after axes functions mess with GE plots # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.show = False #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth #plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmap = kml_cmap #plotitem.pcolor_cmin = kml_cmin # same as above #plotitem.pcolor_cmax = kml_cmax plotitem.pcolor_cmin = -.2 plotitem.pcolor_cmax = .2 plotitem.add_colorbar = True plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.show = False 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_celledges_show = [0, 0, 0, 0, 0] plotitem.patchedges_show = 0 # contour lines: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.show = False 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': 1} plotitem.amr_contour_show = [0, 0, 0, 1, 1] plotitem.celledges_show = 0 plotitem.patchedges_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(-30, -10, 3) plotitem.amr_contour_colors = ['m'] # color on each level plotitem.kwargs = {'linestyles': 'dashed', 'linewidths': 1} plotitem.amr_contour_show = [1, 1, 1] plotitem.celledges_show = 0 plotitem.patchedges_show = 0 #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() #plotaxes.xlimits = [0000, 6500] #plotaxes.ylimits = [-.10, .15] plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' 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 def gaugedpress(current_data): q = current_data.q #dpress = (q[4,:] - 101300)/101300 dpress = q[4, :] # already output as relative: dp/amb_pr return dpress def gs(current_data): q = current_data.q # different than speed function because q is function of time, not # x,y at the gauges. from numpy import where, sqrt h = q[0, :] #print('shape of h ' + str(h.shape)) dry_tol = 0.001 u = where(h > dry_tol, q[1, :] / h, 0.) v = where(h > dry_tol, q[2, :] / h, 0.) ssq = sqrt(u * u + v * v) #s = sqrt(u**2 + v**2) s = sqrt(ssq) return ssq #plotitem.plot_var = gaugetopo #plotitem.plotstyle = 'g-' # Plot relative delta pressure as red curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = gaugedpress plotitem.plotstyle = 'r-' # add speed to this plot since cant get new one going plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = gs plotitem.plotstyle = 'g-' def add_zeroline(current_data): from pylab import plot, legend t = current_data.t # legend(('surface','topography','dp'),loc='lower left') legend(('surface', 'dp', 'speed'), loc='upper right') #plot(t, 0*t, 'k') plotaxes.afteraxes = add_zeroline # ------------------------------- # Figure for speed at gauges #-------------------------------- # plotfigure = plotdata.new_plotfigure(name='Speed at gauges', figno=310, \ # type='each_gauge') # # # # Set up for axes in this figure: # plotaxes = plotfigure.new_plotaxes() # plotaxes.xlimits = 'auto' # plotaxes.ylimits = 'auto' # #plotaxes.xlimits = [0000, 7000] # #plotaxes.ylimits = 'auto' # plotaxes.title = 'Speed' # # # Plot surface as blue curve: # plotitem = plotaxes.new_plotitem(plot_type='1d_plot') # #plotitem.plot_var = speed # plotitem.plot_var = gs #gauge_speed # plotitem.plotstyle = 'b-' # # plotfigure.show = True # #----------------------------------------- # Figure for bathy alone #----------------------------------------- def bathy(current_data): return current_data.aux[0, :, :] plotfigure = plotdata.new_plotfigure(name='bathymetry', figno=3) plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Bathymetry' plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = bathy plotitem.pcolor_cmin = -3000.00 plotitem.pcolor_cmax = 500 plotitem.add_colorbar = True plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.show = False plotitem.plot_var = geoplot.topo plotitem.contour_levels = linspace(-2000, 2000, 21) plotitem.amr_contour_colors = ['k'] # color on each level #plotitem.contour_levels = [-1000 -500,-250,-100, -5, 5] #----------------------------------------- # 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_patch') #plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] #plotitem.amr_celledges_show = [0,0,0] #plotitem.amr_patchedges_show = [0,0,0] def normalized_pressure(current_data): pressure_index = 6 #7 in fortran, but python is 0 based return current_data.aux[ pressure_index, :, :] / surge_data.ambient_pressure # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure', figno=33) plotfigure.show = True plotaxes = plotfigure.new_plotaxes('normalized_pressure') plotaxes.xlimits = ocean_xlimits plotaxes.ylimits = ocean_ylimits plotaxes.title = 'Pressure Field' plotaxes.scaled = True plotaxes.afteraxes = addgauges pressure_limits = [.99, 1.10] #pressure_limits = [.999*surge_data.ambient_pressure / 100.0, # 1.001 * surge_data.ambient_pressure / 100.0] #pressure_limits = [-.000001*surge_data.ambient_pressure, # .000001 * surge_data.ambient_pressure] surgeplot.add_pressure(plotaxes, bounds=pressure_limits) surgeplot.add_land(plotaxes) #plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem = plotaxes.plotitem_dict['pressure'] plotitem.show = False plotitem.plot_var = normalized_pressure plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [0, 0, 0] plotaxes.plotitem_dict['land'].amr_celledges_show = [0, 0, 0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0, 0, 0] #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print #plotdata.print_framenos = [30,50,70] # list of frames to print #plotdata.print_framenos = [1] # list of frames to print plotdata.print_gaugenos = 'all' # list of gauges to print #plotdata.print_fignos = [0,7,10,33,300] # list of figures to print #plotdata.print_fignos = [0,7,10,300] # list of figures to print plotdata.print_fignos = [0, 300] # 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? plotdata.kml = False return plotdata
def setplot(plotdata): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot from numpy import linspace plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' #plotdata.format = 'ascii' # Load data from output clawdata = clawutil.ClawInputData(2) clawdata.read(os.path.join(plotdata.outdir,'claw.data')) ocean_xlimits = [clawdata.lower[0],clawdata.upper[0]] ocean_ylimits = [clawdata.lower[1],clawdata.upper[1]] amrdata = amrclaw.AmrclawInputData(clawdata) amrdata.read(os.path.join(plotdata.outdir,'amr.data')) physics = geodata.GeoClawData() physics.read(os.path.join(plotdata.outdir,'geoclaw.data')) surge_data = geodata.SurgeData() surge_data.read(os.path.join(plotdata.outdir,'surge.data')) probdata = clawutil.ClawData() #probdata.read('setprob.data', force=True) #theta_island = probdata.theta_island # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from clawpack.visclaw import gaugetools gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos='all', format_string='ko', add_labels=True) def mynewafteraxes(current_data): addgauges(current_data) bigfont(current_data) #----------------------------------------- # Some global KML settings #----------------------------------------- #plotdata.kml_publish = 'http://math.boisestate.edu/~calhoun/visclaw/GoogleEarth/kmz/' #public html plotdata.kml_publish = None plotdata.kml_name = "NYC Asteroid" # name appears in Google Earth display only plotdata.kml_index_fname = "NYC_Asteroid" # name for .kmz and .kml files ["_GoogleEarth"] # specify beginning of slider time. if not used, assumes Jan. 1 1970 plotdata.kml_starttime = [2115,4,29,7,32,0] # Asteroid hits at 1:32AM, 4/29/2115 (UTC) plotdata.kml_tz_offset = 6 # off set to UTC # for todays date as the default use kml_cmin = -0.005 #colorbar min and max kml_cmax = 0.005 kml_dpi = 400 # only used if individual figures dpi not set kml_cmap = geoplot.googleearth_lightblue # kml_cmap = geoplot.googleearth_darkblue # kml_cmap = geoplot.googleearth_transparent # kml_cmap = geoplot.googleearth_white def kml_colorbar(filename): #cmin = -0.01 #cmax = 0.01 geoplot.kml_build_colorbar(filename, kml_cmap, kml_cmin,kml_cmax) #----------------------------------------- # Figure for pcolor plot for surface #----------------------------------------- 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.show = True #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth #plotitem.plot_var = 0/1/2 or plot that entry into q instead of a function plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -.08 plotitem.pcolor_cmax = .08 plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [0,0,0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.show = True # plotitem.pcolor_cmap = colormaps.all_white # to print better in B&W plotitem.pcolor_cmap = geoplot.land_colors #plotitem.pcolor_cmap = geoplot.googleearth_transparent plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0,0,0,0,0] #plotitem.patchedges_show = 1 plotitem.amr_patchedges_show = [0,0,0] #plotaxes.xlimits = [-85,-55] #plotaxes.ylimits = [25,45] plotaxes.xlimits = ocean_xlimits plotaxes.ylimits = ocean_ylimits #plotaxes.xlimits = [-75,-70] #plotaxes.ylimits = [38,43] # add contour lines of bathy if desired: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.show = True plotitem.plot_var = geoplot.topo #plotitem.contour_levels = [-500,-250,-100, -50, 0, 50] plotitem.contour_levels = linspace(-1000,-200,4) plotitem.amr_contour_colors = ['g'] # color on each level #plotitem.kwargs = {'linestyles':'dashed','linewidths':2,'colors' : 'red' } plotitem.kwargs = {'linestyles':'dashed','linewidths':1,'colors' : 'magenta' } plotitem.amr_contour_show = [1,1,1] plotitem.celledges_show = 0 plotitem.patchedges_show = 0 #----------------------------------------------------------- # Figure for KML files - Sea Surface Height #---------------------------------------------------------- #plotfigure = plotdata.new_plotfigure(name='Sea Surface',figno=1) #plotfigure.show = True #plotfigure.use_for_kml = True #plotfigure.kml_use_for_initial_view = True # These overide any values set in the plotitems below #plotfigure.kml_xlimits = [-80,-55] #plotfigure.kml_ylimits = [25, 45] # Resolution #plotfigure.kml_dpi = 300 #plotfigure.kml_tile_images = False def kml_colorbar_transparent(filename): #cmin = -0.01 #cmax = 0.01 geoplot.kml_build_colorbar(filename, geoplot.googleearth_transparent, kml_cmin,kml_cmax) #plotfigure.kml_colorbar = kml_colorbar_transparent # Set up for axes in this figure: #plotaxes = plotfigure.new_plotaxes('kml') #plotaxes.scaled = True # Water #plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.show = True #plotitem.plot_var = geoplot.surface_or_depth #plotitem.pcolor_cmap = geoplot.googleearth_transparent #plotitem.pcolor_cmin = kml_cmin #plotitem.pcolor_cmax = kml_cmax #plotitem.amr_celledges_show = [0,0,0] #plotitem.patchedges_show = 0 #plotfigure.kml_colorbar = kml_colorbar #----------------------------------------- # Figure for speeds #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Speeds', figno=10) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Speed' plotaxes.scaled = True #def fixup(current_data): # import pylab # addgauges(current_data) # t = current_data.t # t = t / 3600. # hours # pylab.title('Speed at %4.2f hours' % t, fontsize=20) # pylab.xticks(fontsize=15) # pylab.yticks(fontsize=15) #plotaxes.afteraxes = fixup def speed(current_data): from pylab import where,sqrt q = current_data.q h = q[0,:] dry_tol = 0.001 u = q[1,:] # this is just to initialize v = q[2,:] # to correct size s = 0*q[2,:] # to correct size nq = len(q[1,:]) [n,m] = h.shape for ii in range(0,n): for jj in range(0,m): if h[ii,jj] > dry_tol: u[ii,jj] = q[1,ii,jj]/h[ii,jj] v[ii,jj] = q[2,ii,jj]/h[ii,jj] s[ii,jj] = sqrt(u[ii,jj]* u[ii,jj] + v[ii,jj]*v[ii,jj]) else: u[ii,jj] = 0. v[ii,jj] = 0. s[ii,jj] = 0 #print("max of u = " + str(max(u))) #u = where(h>dry_tol, q[1,:]/h, 0.) #v = where(h>dry_tol, q[2,:]/h, 0.) #s = sqrt(u**2 + v**2) #s = sqrt(u*2+v*v) #try not dividing or using where return s # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.tsunami_colormap #plotitem.pcolor_cmap = \ # colormaps.make_colormap({0:[1,1,1],0.5:[0.5,0.5,1],1:[1,0.3,0.3]}) plotitem.pcolor_cmin = 0. plotitem.pcolor_cmax = .02 plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] #plotitem.patchedges_show = 1 plotitem.amr_patchedges_show = [0,0,0] # 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 = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0,0,0] plotitem.patchedges_show = 0 plotaxes.xlimits = ocean_xlimits plotaxes.ylimits = ocean_ylimits #----------------------------------------- # Figure for zoom around NYC #----------------------------------------- zoomWanted = True if zoomWanted: plotfigure = plotdata.new_plotfigure(name='Zoom1', figno=7) # add another figure #plotfigure.use_for_kml = True #plotfigure.kml_use_for_initial_view = False # These overide any values set in the plotitems below #plotfigure.kml_xlimits = [-74.5, -73.5] #plotfigure.kml_ylimits = [40.4,40.9] # Resolution #plotfigure.kml_dpi = 300 #plotfigure.kml_tile_images = True #plotfigure.kml_colorbar = kml_colorbar # defined above # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('zoom on nyc') plotaxes.title = 'Surface elevation' plotaxes.scaled = True manhattan_island = -73.5 xisland,yisland = latlong(1600e3, manhattan_island, 40., Rearth) #plotaxes.xlimits = [xisland-0.6, xisland+0.6] #plotaxes.xlimits = [manhattan_island-1, manhattan_island+1] #plotaxes.ylimits = [40.15,41.5] plotaxes.xlimits = [-74.5, -72.5] # really zoom in on lower manhattan] plotaxes.ylimits = [40.25,41.5] 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 #plotaxes.afteraxes = mynewafteraxes # after axes functions mess with GE plots # 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_cmap = kml_cmap plotitem.pcolor_cmin = kml_cmin # same as above plotitem.pcolor_cmax = kml_cmax plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.patchedges_show = 0 # 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_celledges_show = [0,0,0,0,0] plotitem.patchedges_show = 0 # 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':1} plotitem.amr_contour_show = [0,0,0,1,1] plotitem.celledges_show = 0 plotitem.patchedges_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(-30, -10,3) plotitem.amr_contour_colors = ['m'] # color on each level plotitem.kwargs = {'linestyles':'dashed','linewidths':1} plotitem.amr_contour_show = [1,1,1] plotitem.celledges_show = 0 plotitem.patchedges_show = 0 #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0000, 6100] plotaxes.ylimits = [-.10, .15] #plotaxes.xlimits = 'auto' #plotaxes.ylimits = 'auto' 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 def gaugedpress(current_data): q = current_data.q #dpress = (q[4,:] - 101300)/101300 dpress = q[4,:] # already output as relative: dp/amb_pr return dpress def gs(current_data): q = current_data.q # different than speed function because q is function of time, not # x,y at the gauges. from numpy import where, sqrt h = q[0,:] #print('shape of h ' + str(h.shape)) dry_tol = 0.001 u = where(h>dry_tol, q[1,:]/h, 0.) v = where(h>dry_tol, q[2,:]/h, 0.) ssq = sqrt(u*u+v*v) #s = sqrt(u**2 + v**2) s = sqrt(ssq) return ssq #plotitem.plot_var = gaugetopo #plotitem.plotstyle = 'g-' # Plot relative delta pressure as red curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = gaugedpress plotitem.plotstyle = 'r-' # add speed to this plot since cant get new one going plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = gs plotitem.plotstyle = 'g-' def add_zeroline(current_data): from pylab import plot, legend t = current_data.t # legend(('surface','topography','dp'),loc='lower left') legend(('surface','dp','speed'),loc='upper right') #plot(t, 0*t, 'k') plotaxes.afteraxes = add_zeroline # ------------------------------- # Figure for speed at gauges #-------------------------------- # plotfigure = plotdata.new_plotfigure(name='Speed at gauges', figno=310, \ # type='each_gauge') # # # # Set up for axes in this figure: # plotaxes = plotfigure.new_plotaxes() # plotaxes.xlimits = 'auto' # plotaxes.ylimits = 'auto' # #plotaxes.xlimits = [0000, 7000] # #plotaxes.ylimits = 'auto' # plotaxes.title = 'Speed' # # # Plot surface as blue curve: # plotitem = plotaxes.new_plotitem(plot_type='1d_plot') # #plotitem.plot_var = speed # plotitem.plot_var = gs #gauge_speed # plotitem.plotstyle = 'b-' # # plotfigure.show = True # #----------------------------------------- # Figure for bathy alone #----------------------------------------- def bathy(current_data): return current_data.aux[0,:,:] plotfigure = plotdata.new_plotfigure(name='bathymetry', figno=3) plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Bathymetry' plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = bathy plotitem.pcolor_cmin = -3000.00 plotitem.pcolor_cmax = 500 plotitem.add_colorbar = True plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.show = False plotitem.plot_var = geoplot.topo plotitem.contour_levels = linspace(-2000,2000,21) plotitem.amr_contour_colors = ['k'] # color on each level #plotitem.contour_levels = [-1000 -500,-250,-100, -5, 5] #----------------------------------------- # 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_patch') #plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] #plotitem.amr_celledges_show = [0,0,0] #plotitem.amr_patchedges_show = [0,0,0] def normalized_pressure(current_data): pressure_index = 6 #7 in fortran, but python is 0 based return current_data.aux[pressure_index,:,:]/surge_data.ambient_pressure # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure',figno=33) plotfigure.show = False plotaxes = plotfigure.new_plotaxes('normalized_pressure') plotaxes.xlimits = ocean_xlimits plotaxes.ylimits = ocean_ylimits plotaxes.title = 'Pressure Field' plotaxes.scaled = True plotaxes.afteraxes = addgauges pressure_limits = [.995,1.005] #pressure_limits = [.999*surge_data.ambient_pressure / 100.0, # 1.001 * surge_data.ambient_pressure / 100.0] #pressure_limits = [-.000001*surge_data.ambient_pressure, # .000001 * surge_data.ambient_pressure] surgeplot.add_pressure(plotaxes, bounds=pressure_limits) surgeplot.add_land(plotaxes) #plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem = plotaxes.plotitem_dict['pressure'] plotitem.show = True plotitem.plot_var = normalized_pressure plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [0,0,0] plotaxes.plotitem_dict['land'].amr_celledges_show=[0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show=[0,0,0] #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.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 = [0,7,10,33,300] # list of figures to print #plotdata.print_fignos = [0,7,10,300] # list of figures to print plotdata.print_fignos = [7] # 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? plotdata.kml = False return plotdata
def setrun(claw_pkg='geoclaw'): #------------------------------ """ Define the parameters used for running Clawpack. INPUT: claw_pkg expected to be "geoclaw" for this setrun. OUTPUT: rundata - object of class ClawRunData """ from clawpack.clawutil import data assert claw_pkg.lower() == 'geoclaw', "Expected claw_pkg = 'geoclaw'" num_dim = 2 rundata = data.ClawRunData(claw_pkg, num_dim) #------------------------------------------------------------------ # Problem-specific parameters to be written to setprob.data: #------------------------------------------------------------------ # theta_island locates the island: 220 or 260 in the paper (x axis is latter) # to get rid of island altogether, change make topo file to not include routine that # adds island to topography # if changed here need to do make data then make topo # then make .output as usual, or make .plots theta_island = 260. probdata = rundata.new_UserData(name='probdata',fname='setprob.data') probdata.add_param('theta_island', theta_island, 'angle to island') #------------------------------------------------------------------ # GeoClaw specific parameters: #------------------------------------------------------------------ rundata = setgeo(rundata) #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: #------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated # Set single grid parameters first. # See below for AMR parameters. # --------------- # Spatial domain: # --------------- # Number of space dimensions: clawdata.num_dim = num_dim # Lower and upper edge of computational domain: clawdata.lower[0] = -20.0 # xlower clawdata.upper[0] = 20.0 # xupper clawdata.lower[1] = 20.0 # ylower clawdata.upper[1] = 60.0 # yupper #clawdata.lower[0] = -5.0 # xlower #clawdata.upper[0] = 5.0 # xupper #clawdata.lower[1] = 35.0 # ylower #clawdata.upper[1] = 45.0 # yupper # Number of grid cells: #clawdata.num_cells[0] = 40 # mx #clawdata.num_cells[1] = 40 # my clawdata.num_cells[0] = 100 # mx clawdata.num_cells[1] = 100 # my # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 3 # Number of auxiliary variables in the aux array (initialized in setaux) clawdata.num_aux = 3 + 1 + 3 # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 2 # ------------- # Initial time: # ------------- clawdata.t0 = 0.0 # Restart from checkpoint file of a previous run? # Note: If restarting, you must also change the Makefile to set: # RESTART = True # If restarting, t0 above should be from original run, and the # restart_file 'fort.chkNNNNN' specified below should be in # the OUTDIR indicated in Makefile. clawdata.restart = False # True to restart from prior results clawdata.restart_file = 'fort.chk00021' # File to use for restart data # ------------- # Output times: #-------------- # Specify at what times the results should be written to fort.q files. # Note that the time integration stops after the final output time. clawdata.output_style = 3 if clawdata.output_style==1: # Output ntimes frames at equally spaced times up to tfinal: # Can specify num_output_times = 0 for no output clawdata.num_output_times = 14 #clawdata.tfinal = 14000.0 clawdata.tfinal = 7000.0 clawdata.output_t0 = True # output at initial (or restart) time? elif clawdata.output_style == 2: # Specify a list or numpy array of output times: # Include t0 if you want output at the initial time. clawdata.output_times = [0., 0.1] elif clawdata.output_style == 3: # Output every step_interval timesteps over total_steps timesteps: clawdata.output_step_interval = 100 clawdata.total_steps = 4000/1 # final time 6000 sec / dtinit of 2 sec clawdata.output_t0 = True # output at initial (or restart) time? #clawdata.output_format = 'binary' # 'ascii', 'binary' clawdata.output_format = 'ascii' # 'ascii', 'binary' clawdata.output_q_components = 'all' # could be list such as [True,True] clawdata.output_aux_components = 'all' # could be list clawdata.output_aux_onlyonce = False # output aux arrays only at t0 # --------------------------------------------------- # Verbosity of messages to screen during integration: # --------------------------------------------------- # The current t, dt, and cfl will be printed every time step # at AMR levels <= verbosity. Set verbosity = 0 for no printing. # (E.g. verbosity == 2 means print only on levels 1 and 2.) clawdata.verbosity = 1 # -------------- # Time stepping: # -------------- # if dt_variable==True: variable time steps used based on cfl_desired, # if dt_variable==Falseixed time steps dt = dt_initial always used. #clawdata.dt_variable = True clawdata.dt_variable = False # Initial time step for variable dt. # (If dt_variable==0 then dt=dt_initial for all steps) #clawdata.dt_initial = 16.0 clawdata.dt_initial = 1.0 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1e+99 # Desired Courant number if variable dt used clawdata.cfl_desired = 0.75 # max Courant number to allow without retaking step with a smaller dt: clawdata.cfl_max = 1.0 # Maximum number of time steps to allow between output times: clawdata.steps_max = 5000 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 2 # Use dimensional splitting? (not yet available for AMR) clawdata.dimensional_split = 'unsplit' # For unsplit method, transverse_waves can be # 0 or 'none' ==> donor cell (only normal solver used) # 1 or 'increment' ==> corner transport of waves # 2 or 'all' ==> corner transport of 2nd order corrections too clawdata.transverse_waves = 2 # Number of waves in the Riemann solution: clawdata.num_waves = 3 # List of limiters to use for each wave family: # Required: len(limiter) == num_waves # Some options: # 0 or 'none' ==> no limiter (Lax-Wendroff) # 1 or 'minmod' ==> minmod # 2 or 'superbee' ==> superbee # 3 or 'vanleer' ==> van Leer # 4 or 'mc' ==> MC limiter clawdata.limiter = ['vanleer', 'vanleer', 'vanleer'] clawdata.use_fwaves = True # True ==> use f-wave version of algorithms # Source terms splitting: # src_split == 0 or 'none' ==> no source term (src routine never called) # src_split == 1 or 'godunov' ==> Godunov (1st order) splitting used, # src_split == 2 or 'strang' ==> Strang (2nd order) splitting used, not recommended. clawdata.source_split = 1 # -------------------- # Boundary conditions: # -------------------- # Number of ghost cells (usually 2) clawdata.num_ghost = 2 # Choice of BCs at xlower and xupper: # 0 or 'user' => user specified (must modify bcNamr.f to use this option) # 1 or 'extrap' => extrapolation (non-reflecting outflow) # 2 or 'periodic' => periodic (must specify this at both boundaries) # 3 or 'wall' => solid wall for systems where q(2) is normal velocity clawdata.bc_lower[0] = 'extrap' # at xlower clawdata.bc_upper[0] = 'extrap' # at xupper clawdata.bc_lower[1] = 'extrap' # at ylower clawdata.bc_upper[1] = 'extrap' # at yupper # --------------- # Gauges: # --------------- gauges = rundata.gaugedata.gauges # for gauges append lines of the form [gaugeno, x, y, t1, t2] gaugeno = 0 for d in [1570e3, 1590e3, 1610e3, 1630e3]: gaugeno = gaugeno+1 x,y = latlong(d, theta_island, 40., Rearth) gauges.append([gaugeno, x, y, 0., 1e10]) # for radially symmetric traveling wave test #gauges.append([1, 0.01, 40.01, 0, 1e10]) #gauges.append([2, 1.01, 40.01, 0, 1e10]) #gauges.append([3, 2.01, 40.01, 0, 1e10]) #gauges.append([4, 3.01, 40.01, 0, 1e10]) #for 1d test problem i use these gauges #gauges.append([1, -17.50, 40, 0, 1e10]) #gauges.append([2, -15.5, 40, 0, 1e10]) #gauges.append([3, -13.5, 40, 0, 1e10]) #gauges.append([4, -11.5, 40, 0, 1e10]) # -------------- # Checkpointing: # -------------- # Specify when checkpoint files should be created that can be # used to restart a computation. clawdata.checkpt_style = 1 if clawdata.checkpt_style == 0: # Do not checkpoint at all pass elif clawdata.checkpt_style == 1: # Checkpoint only at tfinal. pass elif clawdata.checkpt_style == 2: # Specify a list of checkpoint times. clawdata.checkpt_times = [0.1,0.15] elif clawdata.checkpt_style == 3: # Checkpoint every checkpt_interval timesteps (on Level 1) # and at the final time. clawdata.checkpt_interval = 5 # --------------- # AMR parameters: (written to amr.data) # --------------- amrdata = rundata.amrdata # max number of refinement levels: #amrdata.amr_levels_max = 5 amrdata.amr_levels_max = 4 # List of refinement ratios at each level (length at least amr_level_max-1) amrdata.refinement_ratios_x = [4, 4, 4, 4] amrdata.refinement_ratios_y = [4, 4, 4, 4] amrdata.refinement_ratios_t = [4, 4, 4, 1] # Specify type of each aux variable in amrdata.auxtype. # This must be a list of length num_aux, each element of which is one of: # 'center', 'capacity', 'xleft', or 'yleft' (see documentation). amrdata.aux_type = ['center', 'capacity', 'yleft', 'center', 'center', 'center', 'center'] # Flag for refinement based on Richardson error estimater: amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 1.0 # Richardson tolerance # Flag for refinement using routine flag2refine: amrdata.flag2refine = True # use this? amrdata.flag2refine_tol = 0.5 # tolerance used in this routine # Note: in geoclaw the refinement tolerance is set as wave_tolerance below # and flag2refine_tol is unused! # steps to take on each level L between regriddings of level L+1: amrdata.regrid_interval = 3 # width of buffer zone around flagged points: # (typically the same as regrid_interval so waves don't escape): amrdata.regrid_buffer_width = 2 # clustering alg. cutoff for (# flagged pts) / (total # of cells refined) # (closer to 1.0 => more small grids may be needed to cover flagged cells) amrdata.clustering_cutoff = 0.7 # print info about each regridding up to this level: amrdata.verbosity_regrid = 5 # --------------- # Regions: # --------------- regions = rundata.regiondata.regions # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] #regions.append([1, 3, 0., 5000., -5., 20., 35., 45.]) #regions.append([1, 2, 5000., 6900., 10., 20., 35., 45.]) #regions.append([1, 3, 5000., 6900., 12., 20., 39., 43.]) regions.append([1, 2, 0., 100000000., -20., 20., 20., 60.]) # Force refinement near the island as the wave approaches: (xisland,yisland) = latlong(1600.e3, theta_island, 40., Rearth) x1 = xisland - 1. x2 = xisland + 1. y1 = yisland - 1. y2 = yisland + 1. regions.append([4, 4, 2500., 1.e10, x1,x2,y1,y2]) x1 = xisland - 0.2 x2 = xisland + 0.2 y1 = yisland - 0.2 y2 = yisland + 0.2 regions.append([4, 5, 3000., 1.e10, x1,x2,y1,y2]) # ----- For developers ----- # Toggle debugging print statements: amrdata.dprint = False # print domain flags amrdata.eprint = False # print err est flags amrdata.edebug = False # even more err est flags amrdata.gprint = False # grid bisection/clustering amrdata.nprint = False # proper nesting output amrdata.pprint = False # proj. of tagged points amrdata.rprint = True # print regridding summary amrdata.sprint = False # space/memory output amrdata.tprint = False # time step reporting each level amrdata.uprint = False # update/upbnd reporting return rundata
from clawpack.geoclaw.data import Rearth # radius of earth from clawpack.clawutil.data import ClawData from mapper import latlong import maketopo probdata = ClawData() probdata.read('setprob.data', force=True) theta_island = probdata.theta_island print "theta_island = ", theta_island #close(1) #figure(1, figsize=(10,6)) #axes([.1,.1,.5,.8]) clf() s = linspace(0, 360., 1001) xshore, yshore = latlong(1645.e3, s, 40., Rearth) plot(xshore, yshore, 'k', linewidth=2) xshelf, yshelf = latlong(1560.e3, s, 40., Rearth) plot(xshelf, yshelf, 'k--', linewidth=2) theta_island = 220. (xi, yi) = latlong(1600.e3, theta_island, 40., Rearth) xb = [xi - 1, xi + 1, xi + 1, xi - 1, xi - 1] yb = [yi - 1, yi - 1, yi + 1, yi + 1, yi - 1] plot(xb, yb, 'b', linewidth=1.5) text(5, 49, 'Test 1', fontsize=20) theta_island = 260. (xi, yi) = latlong(1600.e3, theta_island, 40., Rearth) xb = [xi - 1, xi + 1, xi + 1, xi - 1, xi - 1]
""" from clawpack.geoclaw import topotools from clawpack.geoclaw.data import Rearth # radius of earth from interp import pwcubic from clawpack.clawutil.data import ClawData from numpy import * from mapper import latlong, gcdist probdata = ClawData() probdata.read('setprob.data', force=True) theta_island = probdata.theta_island print "theta_island = ", theta_island (xisland, yisland) = latlong(1600.e3, theta_island, 40., Rearth) def maketopo(): """ Output topography file for the entire domain and near-shore in one location. """ nxpoints = 400 nypoints = 400 xlower = -30.e0 xupper = 30.e0 ylower = 20.e0 yupper = 60.e0 outfile = "ocean.topotype2" topotools.topo2writer(outfile, topo, xlower, xupper, ylower, yupper,
from clawpack.clawutil.data import ClawData from mapper import latlong import maketopo probdata = ClawData() probdata.read('setprob.data', force=True) theta_island = probdata.theta_island print "theta_island = ",theta_island #close(1) #figure(1, figsize=(10,6)) #axes([.1,.1,.5,.8]) clf() s = linspace(0, 360., 1001) xshore,yshore = latlong(1645.e3, s, 40., Rearth) plot(xshore,yshore,'k',linewidth=2) xshelf,yshelf = latlong(1560.e3, s, 40., Rearth) plot(xshelf,yshelf,'k--',linewidth=2) theta_island = 220. (xi,yi) = latlong(1600.e3, theta_island, 40., Rearth) xb = [xi-1, xi+1, xi+1, xi-1, xi-1] yb = [yi-1, yi-1, yi+1, yi+1, yi-1] plot(xb,yb,'b',linewidth=1.5) text(5,49,'Test 1', fontsize=20) theta_island = 260. (xi,yi) = latlong(1600.e3, theta_island, 40., Rearth) xb = [xi-1, xi+1, xi+1, xi-1, xi-1]
def setplot(plotdata): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot from numpy import linspace plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from clawpack.visclaw 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 def fixup(current_data): import pylab t = current_data.t #addgauges(current_data) pylab.title("Surface at t = %8.1f" % t, fontsize=20) #pylab.xticks(fontsize=15) #pylab.yticks(fontsize=15) pylab.gca().set_aspect(1. / pylab.cos(40 * pylab.pi / 180.)) plotaxes.afteraxes = fixup # 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_celledges_show = [0, 0, 0] plotitem.patchedges_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_celledges_show = [1, 0] plotitem.patchedges_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.celledges_show = 0 plotitem.patchedges_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' xisland, yisland = latlong(1600e3, theta_island, 40., Rearth) plotaxes.xlimits = [xisland - 0.6, xisland + 0.8] plotaxes.ylimits = [yisland - 0.6, yisland + 0.8] def fixup(current_data): import pylab t = current_data.t addgauges(current_data) pylab.title("Surface at t = %8.1f" % t, fontsize=20) #pylab.xticks(fontsize=15) #pylab.yticks(fontsize=15) pylab.gca().set_aspect(1. / pylab.cos(50 * pylab.pi / 180.)) plotaxes.afteraxes = fixup # 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_celledges_show = [0] plotitem.patchedges_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_celledges_show = [1, 0, 0, 0, 0] plotitem.patchedges_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.celledges_show = 0 plotitem.patchedges_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.celledges_show = 0 plotitem.patchedges_show = 0 #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # 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_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = [1, 1, 0] plotitem.amr_patchedges_show = [1] #----------------------------------------- # Figures for fgmax plots #----------------------------------------- # Note: You need to move fgmax png files into _plots/fgmax_plots after # creating them, e.g., by running the process_fgmax notebook or script. # The lines below just create links to these figures from _PlotIndex.html otherfigure = plotdata.new_otherfigure( name='max depth on fgmax grid 1', fname='fgmax_plots/fgmax0001_h_onshore.png') otherfigure = plotdata.new_otherfigure( name='max speed on fgmax grid 1', fname='fgmax_plots/fgmax0001_speed.png') otherfigure = plotdata.new_otherfigure( name='max elevation on fgmax grid 2', fname='fgmax_plots/fgmax0002_surface.png') otherfigure = plotdata.new_otherfigure( name='max depth on fgmax grid 3', fname='fgmax_plots/fgmax0003_h_onshore.png') otherfigure = plotdata.new_otherfigure( name='max speed on fgmax grid 3', fname='fgmax_plots/fgmax0003_speed.png') # add additional lines for any other figures you want added to the index. #----------------------------------------- # Plots of timing (CPU and wall time): def make_timing_plots(plotdata): import os from clawpack.visclaw import plot_timing_stats try: timing_plotdir = plotdata.plotdir + '/timing_figures' os.system('mkdir -p %s' % timing_plotdir) units = { 'comptime': 'seconds', 'simtime': 'hours', 'cell': 'billions' } plot_timing_stats.make_plots(outdir=plotdata.outdir, make_pngs=True, plotdir=timing_plotdir, units=units) os.system('cp %s/timing.* %s' % (plotdata.outdir, timing_plotdir)) except: print('*** Error making timing plots') # create a link to this webpage from _PlotIndex.html: otherfigure = plotdata.new_otherfigure(name='timing', fname='timing_figures/timing.html') otherfigure.makefig = make_timing_plots #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.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
def setrun(claw_pkg='geoclaw'): #------------------------------ """ Define the parameters used for running Clawpack. INPUT: claw_pkg expected to be "geoclaw" for this setrun. OUTPUT: rundata - object of class ClawRunData """ from clawpack.clawutil import data assert claw_pkg.lower() == 'geoclaw', "Expected claw_pkg = 'geoclaw'" num_dim = 2 rundata = data.ClawRunData(claw_pkg, num_dim) #------------------------------------------------------------------ # Problem-specific parameters to be written to setprob.data: #------------------------------------------------------------------ theta_island = 220. probdata = rundata.new_UserData(name='probdata', fname='setprob.data') probdata.add_param('theta_island', theta_island, 'angle to island') #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: #------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated # Set single grid parameters first. # See below for AMR parameters. # --------------- # Spatial domain: # --------------- # Number of space dimensions: clawdata.num_dim = num_dim # Lower and upper edge of computational domain: clawdata.lower[0] = -20.0 # xlower clawdata.upper[0] = 20.0 # xupper clawdata.lower[1] = 20.0 # ylower clawdata.upper[1] = 60.0 # yupper # Number of grid cells: clawdata.num_cells[0] = 40 # mx clawdata.num_cells[1] = 40 # my # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 3 # Number of auxiliary variables in the aux array (initialized in setaux) clawdata.num_aux = 3 # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 2 # ------------- # Initial time: # ------------- clawdata.t0 = 0.0 # Restart from checkpoint file of a previous run? # Note: If restarting, you must also change the Makefile to set: # RESTART = True # If restarting, t0 above should be from original run, and the # restart_file 'fort.chkNNNNN' specified below should be in # the OUTDIR indicated in Makefile. clawdata.restart = False # True to restart from prior results clawdata.restart_file = 'fort.chk00006' # File to use for restart data # ------------- # Output times: #-------------- # Specify at what times the results should be written to fort.q files. # Note that the time integration stops after the final output time. clawdata.output_style = 1 if clawdata.output_style == 1: # Output ntimes frames at equally spaced times up to tfinal: # Can specify num_output_times = 0 for no output clawdata.num_output_times = 7 clawdata.tfinal = 14000. clawdata.output_t0 = True # output at initial (or restart) time? elif clawdata.output_style == 2: # Specify a list or numpy array of output times: # Include t0 if you want output at the initial time. clawdata.output_times = [0., 0.1] elif clawdata.output_style == 3: # Output every step_interval timesteps over total_steps timesteps: clawdata.output_step_interval = 2 clawdata.total_steps = 4 clawdata.output_t0 = True # output at initial (or restart) time? clawdata.output_format = 'binary' # 'ascii', 'binary' clawdata.output_q_components = 'all' # could be list such as [True,True] clawdata.output_aux_components = 'none' # could be list clawdata.output_aux_onlyonce = True # output aux arrays only at t0 # --------------------------------------------------- # Verbosity of messages to screen during integration: # --------------------------------------------------- # The current t, dt, and cfl will be printed every time step # at AMR levels <= verbosity. Set verbosity = 0 for no printing. # (E.g. verbosity == 2 means print only on levels 1 and 2.) clawdata.verbosity = 1 # -------------- # Time stepping: # -------------- # if dt_variable==True: variable time steps used based on cfl_desired, # if dt_variable==Falseixed time steps dt = dt_initial always used. clawdata.dt_variable = True # Initial time step for variable dt. # (If dt_variable==0 then dt=dt_initial for all steps) clawdata.dt_initial = 16.0 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1e+99 # Desired Courant number if variable dt used clawdata.cfl_desired = 0.75 # max Courant number to allow without retaking step with a smaller dt: clawdata.cfl_max = 1.0 # Maximum number of time steps to allow between output times: clawdata.steps_max = 5000 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 2 # Use dimensional splitting? (not yet available for AMR) clawdata.dimensional_split = 'unsplit' # For unsplit method, transverse_waves can be # 0 or 'none' ==> donor cell (only normal solver used) # 1 or 'increment' ==> corner transport of waves # 2 or 'all' ==> corner transport of 2nd order corrections too clawdata.transverse_waves = 2 # Number of waves in the Riemann solution: clawdata.num_waves = 3 # List of limiters to use for each wave family: # Required: len(limiter) == num_waves # Some options: # 0 or 'none' ==> no limiter (Lax-Wendroff) # 1 or 'minmod' ==> minmod # 2 or 'superbee' ==> superbee # 3 or 'vanleer' ==> van Leer # 4 or 'mc' ==> MC limiter clawdata.limiter = ['vanleer', 'vanleer', 'vanleer'] clawdata.use_fwaves = True # True ==> use f-wave version of algorithms # Source terms splitting: # src_split == 0 or 'none' ==> no source term (src routine never called) # src_split == 1 or 'godunov' ==> Godunov (1st order) splitting used, # src_split == 2 or 'strang' ==> Strang (2nd order) splitting used, not recommended. clawdata.source_split = 1 # -------------------- # Boundary conditions: # -------------------- # Number of ghost cells (usually 2) clawdata.num_ghost = 2 # Choice of BCs at xlower and xupper: # 0 or 'user' => user specified (must modify bcNamr.f to use this option) # 1 or 'extrap' => extrapolation (non-reflecting outflow) # 2 or 'periodic' => periodic (must specify this at both boundaries) # 3 or 'wall' => solid wall for systems where q(2) is normal velocity clawdata.bc_lower[0] = 'extrap' # at xlower clawdata.bc_upper[0] = 'extrap' # at xupper clawdata.bc_lower[1] = 'extrap' # at ylower clawdata.bc_upper[1] = 'extrap' # at yupper # --------------- # Gauges: # --------------- gauges = rundata.gaugedata.gauges # for gauges append lines of the form [gaugeno, x, y, t1, t2] gaugeno = 0 for d in [1570e3, 1590e3, 1610e3, 1630e3]: gaugeno = gaugeno + 1 x, y = latlong(d, theta_island, 40., Rearth) gauges.append([gaugeno, x, y, 0., 1e10]) # -------------- # Checkpointing: # -------------- # Specify when checkpoint files should be created that can be # used to restart a computation. clawdata.checkpt_style = 1 if clawdata.checkpt_style == 0: # Do not checkpoint at all pass elif clawdata.checkpt_style == 1: # Checkpoint only at tfinal. pass elif clawdata.checkpt_style == 2: # Specify a list of checkpoint times. clawdata.checkpt_times = [0.1, 0.15] elif clawdata.checkpt_style == 3: # Checkpoint every checkpt_interval timesteps (on Level 1) # and at the final time. clawdata.checkpt_interval = 5 # --------------- # AMR parameters: (written to amr.data) # --------------- amrdata = rundata.amrdata # max number of refinement levels: amrdata.amr_levels_max = 5 # List of refinement ratios at each level (length at least amr_level_max-1) amrdata.refinement_ratios_x = [4, 3, 5, 4] amrdata.refinement_ratios_y = [4, 3, 5, 4] amrdata.refinement_ratios_t = [1, 1, 1, 1] # Specify type of each aux variable in amrdata.auxtype. # This must be a list of length num_aux, each element of which is one of: # 'center', 'capacity', 'xleft', or 'yleft' (see documentation). amrdata.aux_type = ['center', 'capacity', 'yleft'] # Flag for refinement based on Richardson error estimater: amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 1.0 # Richardson tolerance # Flag for refinement using routine flag2refine: amrdata.flag2refine = True # use this? amrdata.flag2refine_tol = 0.5 # tolerance used in this routine # Note: in geoclaw the refinement tolerance is set as wave_tolerance below # and flag2refine_tol is unused! # steps to take on each level L between regriddings of level L+1: amrdata.regrid_interval = 3 # width of buffer zone around flagged points: # (typically the same as regrid_interval so waves don't escape): amrdata.regrid_buffer_width = 2 # clustering alg. cutoff for (# flagged pts) / (total # of cells refined) # (closer to 1.0 => more small grids may be needed to cover flagged cells) amrdata.clustering_cutoff = 0.7 # print info about each regridding up to this level: amrdata.verbosity_regrid = 0 # --------------- # Regions: # --------------- regions = rundata.regiondata.regions # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] regions.append([1, 3, 0., 5000., -5., 20., 35., 55.]) regions.append([1, 2, 5000., 6900., -5., 20., 35., 55.]) regions.append([1, 3, 5000., 6900., 10., 20., 45., 55.]) regions.append([1, 2, 6900., 9000., 10., 20., 47., 52.]) # Force refinement near the island as the wave approaches: (xisland, yisland) = latlong(1600.e3, theta_island, 40., Rearth) x1 = xisland - 1. x2 = xisland + 1. y1 = yisland - 1. y2 = yisland + 1. regions.append([4, 4, 7000., 1.e10, x1, x2, y1, y2]) x1 = xisland - 0.2 x2 = xisland + 0.2 y1 = yisland - 0.2 y2 = yisland + 0.2 regions.append([4, 5, 8000., 1.e10, x1, x2, y1, y2]) # ----------------------------------------------- # GeoClaw specific parameters: try: geo_data = rundata.geo_data except: print("*** Error, this rundata has no geo_data attribute") raise AttributeError("Missing geo_data attribute") # == Physics == geo_data.gravity = 9.81 geo_data.coordinate_system = 2 geo_data.earth_radius = 6367500.0 # == Forcing Options geo_data.coriolis_forcing = False # == Algorithm and Initial Conditions == geo_data.sea_level = 0.0 geo_data.dry_tolerance = 0.001 geo_data.friction_forcing = True geo_data.manning_coefficient = 0.025 geo_data.friction_depth = 1000000.0 # Refinement settings refinement_data = rundata.refinement_data refinement_data.variable_dt_refinement_ratios = True refinement_data.wave_tolerance = 0.01 refinement_data.deep_depth = 100.0 refinement_data.max_level_deep = 3 # == settopo.data values == topofiles = rundata.topo_data.topofiles # for topography, append lines of the form # [topotype, minlevel, maxlevel, t1, t2, fname] topofiles.append([3, 1, 1, 0.0, 10000000000.0, 'ocean.tt3']) topofiles.append([3, 1, 1, 0.0, 10000000000.0, 'island.tt3']) # == setdtopo.data values == rundata.dtopo_data.dtopofiles = [] dtopofiles = rundata.dtopo_data.dtopofiles # for moving topography, append lines of the form : # [topotype, minlevel,maxlevel,fname] # == setqinit.data values == rundata.qinit_data.qinit_type = 4 qinitfiles = rundata.qinit_data.qinitfiles # for qinit perturbations, append lines of the form: (<= 1 allowed for now!) # [minlev, maxlev, fname] rundata.qinit_data.qinitfiles = [[1, 2, 'hump.xyz']] # == fgmax_grids.data values == # NEW STYLE STARTING IN v5.7.0 # set num_fgmax_val = 1 to save only max depth, # 2 to also save max speed, # 5 to also save max hs,hss,hmin rundata.fgmax_data.num_fgmax_val = 2 # Save depth and speed fgmax_grids = rundata.fgmax_data.fgmax_grids # empty list to start # Now append to this list objects of class fgmax_tools.FGmaxGrid # specifying any fgmax grids. # Here several different ones are specified to illustrate: tstart_max = 8000. # when to start monitoring fgmax grids # Points on a uniform 2d grid: fg = fgmax_tools.FGmaxGrid() fg.point_style = 2 # uniform rectangular x-y grid fg.x1 = 14.25 fg.x2 = 14.65 fg.y1 = 50.10 fg.y2 = 50.35 fg.dx = 15 / 3600. # desired resolution of fgmax grid fg.min_level_check = amrdata.amr_levels_max # which levels to monitor max on fg.tstart_max = tstart_max # just before wave arrives fg.tend_max = 1.e10 # when to stop monitoring max values fg.dt_check = 20. # how often to update max values fg.interp_method = 0 # 0 ==> pw const in cells, recommended fgmax_grids.append(fg) # written to fgmax_grids.data # Points on a 1d transect from (x1,y1) to (x2,y2): fg = fgmax_tools.FGmaxGrid() fg.point_style = 1 # equally spaced points on a transect fg.x1 = 14.25 fg.x2 = 14.65 fg.y1 = 50.10 fg.y2 = 50.35 fg.npts = 50 fg.min_level_check = amrdata.amr_levels_max # which levels to monitor max on fg.tstart_max = tstart_max # just before wave arrives fg.tend_max = 1.e10 # when to stop monitoring max values fg.dt_check = 20. # how often to update max values fg.interp_method = 0 # 0 ==> pw const in cells, recommended fgmax_grids.append(fg) # written to fgmax_grids.data # fgmax grid point_style==4 means grid specified as topo_type==3 file: fg = fgmax_tools.FGmaxGrid() fg.point_style = 4 fg.min_level_check = amrdata.amr_levels_max # which levels to monitor max on fg.tstart_max = tstart_max # just before wave arrives fg.tend_max = 1.e10 # when to stop monitoring max values fg.dt_check = 20. # how often to update max values fg.interp_method = 0 # 0 ==> pw const in cells, recommended fg.xy_fname = 'fgmax_pts_island.data' # file of 0/1 values in tt3 format fgmax_grids.append(fg) # written to fgmax_grids.data # fgmax grid point_style==0 means list of points: fg = fgmax_tools.FGmaxGrid() fg.point_style = 0 fg.min_level_check = amrdata.amr_levels_max # which levels to monitor max on fg.tstart_max = tstart_max # just before wave arrives fg.tend_max = 1.e10 # when to stop monitoring max values fg.dt_check = 20. # how often to update max values fg.interp_method = 0 # 0 ==> pw const in cells, recommended # can set list of points here: fg.npts = 2 fg.X = np.array([14.4, 14.5]) fg.Y = np.array([50.13, 50.13]) fgmax_grids.append(fg) # written to fgmax_grids.data # fgmax grid point_style==0 means list of points: fg = fgmax_tools.FGmaxGrid() fg.point_style = 0 fg.min_level_check = amrdata.amr_levels_max # which levels to monitor max on fg.tstart_max = tstart_max # just before wave arrives fg.tend_max = 1.e10 # when to stop monitoring max values fg.dt_check = 20. # how often to update max values fg.interp_method = 0 # 0 ==> pw const in cells, recommended # can specify that list of points is in a different file: fg.npts = 0 fg.xy_fname = 'fgmax_ps0.txt' fgmax_grids.append(fg) # written to fgmax_grids.data # ----- For developers ----- # Toggle debugging print statements: amrdata.dprint = False # print domain flags amrdata.eprint = False # print err est flags amrdata.edebug = False # even more err est flags amrdata.gprint = False # grid bisection/clustering amrdata.nprint = False # proper nesting output amrdata.pprint = False # proj. of tagged points amrdata.rprint = False # print regridding summary amrdata.sprint = False # space/memory output amrdata.tprint = False # time step reporting each level amrdata.uprint = False # update/upbnd reporting return rundata
from clawpack.geoclaw.data import Rearth # radius of earth from interp import pwcubic from clawpack.clawutil.data import ClawData import numpy as np from matplotlib import pylab as plt from mapper import latlong import maketopo probdata = ClawData() probdata.read('setprob.data', force=True) theta_island = probdata.theta_island print "theta_island = ",theta_island (xisland,yisland) = latlong(1600.e3, theta_island, 40., Rearth) def ocean(): dmax = 1650.e3 dp = np.linspace(0., dmax, 3301) zp = maketopo.shelf1(dp) plt.clf() plt.plot(dp*1e-3,zp,'k-',linewidth=3) plt.fill_between(dp*1e-3,zp,0.,where=(zp<0.), color=[0,0.5,1]) plt.xlim([0.,1650]) plt.ylim([-4500.,500]) plt.title("Topography as function of radius",fontsize=18) plt.xlabel("kilometers from center",fontsize=15) plt.ylabel("meters",fontsize=15) plt.xticks(fontsize=15)
def setplot(plotdata): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot from numpy import linspace plotdata.clearfigures() # clear any old figures,axes,items data #plotdata.format = 'binary' plotdata.format = 'ascii' # Load data from output clawdata = clawutil.ClawInputData(2) clawdata.read(os.path.join(plotdata.outdir,'claw.data')) amrdata = amrclaw.AmrclawInputData(clawdata) amrdata.read(os.path.join(plotdata.outdir,'amr.data')) physics = geodata.GeoClawData() physics.read(os.path.join(plotdata.outdir,'geoclaw.data')) surge_data = surgedata.SurgeData() surge_data.read(os.path.join(plotdata.outdir,'surge.data')) probdata = clawutil.ClawData() probdata.read('setprob.data', force=True) theta_island = probdata.theta_island # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from clawpack.visclaw import gaugetools gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos='all', format_string='ko', add_labels=True) #----------------------------------------- # Figure for pcolor plot for surface #----------------------------------------- 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.plot_var = 0/1/2 or plot that entry into q instead of a function plotitem.pcolor_cmap = geoplot.tsunami_colormap #plotitem.pcolor_cmin = -1.0 #plotitem.pcolor_cmax = 1.0 plotitem.pcolor_cmin = -.005 plotitem.pcolor_cmax = .005 plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.patchedges_show = 1 #plotitem.patchedges_show = 0 # 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_celledges_show = [0,0] #plotitem.patchedges_show = 1 plotitem.patchedges_show = 0 plotaxes.xlimits = [-20,20] plotaxes.ylimits = [20,60] #plotaxes.xlimits = [-5,5] #plotaxes.ylimits = [35,45] # add contour lines of bathy if desired: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.show = True #False plotitem.plot_var = geoplot.topo plotitem.contour_levels = [-3500,-2500,-1500, -500, 0, 500] plotitem.amr_contour_colors = ['g'] # color on each level plotitem.kwargs = {'linestyles':'dashed','linewidths':2,'colors' : 'red' } plotitem.amr_contour_show = [0,0,0] plotitem.celledges_show = 0 plotitem.patchedges_show = 0 #----------------------------------------- # Figure for speeds #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Speeds', figno=10) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Speed' plotaxes.scaled = True #def fixup(current_data): # import pylab # addgauges(current_data) # t = current_data.t # t = t / 3600. # hours # pylab.title('Speed at %4.2f hours' % t, fontsize=20) # pylab.xticks(fontsize=15) # pylab.yticks(fontsize=15) #plotaxes.afteraxes = fixup def speed(current_data): from pylab import where,sqrt q = current_data.q h = q[0,:] dry_tol = 0.001 u = q[1,:] # this is just to initialize v = q[2,:] # to correct size s = 0*q[2,:] # to correct size nq = len(q[1,:]) [n,m] = h.shape for ii in range(0,n): for jj in range(0,m): if h[ii,jj] > dry_tol: u[ii,jj] = q[1,ii,jj]/h[ii,jj] v[ii,jj] = q[2,ii,jj]/h[ii,jj] s[ii,jj] = sqrt(u[ii,jj]* u[ii,jj] + v[ii,jj]*v[ii,jj]) else: u[ii,jj] = 0. v[ii,jj] = 0. s[ii,jj] = 0 #print("max of u = " + str(max(u))) #u = where(h>dry_tol, q[1,:]/h, 0.) #v = where(h>dry_tol, q[2,:]/h, 0.) #s = sqrt(u**2 + v**2) #s = sqrt(u*2+v*v) #try not dividing or using where return s # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmap = \ colormaps.make_colormap({0:[1,1,1],0.5:[0.5,0.5,1],1:[1,0.3,0.3]}) plotitem.pcolor_cmin = 0. plotitem.pcolor_cmax = .01 plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.patchedges_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 = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0,0,0] plotitem.patchedges_show = 1 plotaxes.xlimits = [-20,20] plotaxes.ylimits = [20,60] #----------------------------------------- # Figure for zoom at island #----------------------------------------- zoomWanted = True if zoomWanted: 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 plotaxes.afteraxes = addgauges # 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_celledges_show = [0] plotitem.patchedges_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_celledges_show = [1,0,0,0,0] plotitem.patchedges_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.celledges_show = 0 plotitem.patchedges_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.celledges_show = 0 plotitem.patchedges_show = 0 #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0000, 5000] plotaxes.ylimits = [-.10, .10] #plotaxes.xlimits = 'auto' #plotaxes.ylimits = 'auto' 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 def gaugedpress(current_data): q = current_data.q #dpress = (q[4,:] - 101300)/101300 dpress = q[4,:] # already output as relative: dp/amb_pr return dpress def gs(current_data): q = current_data.q # different than speed function because q is function of time, not # x,y at the gauges. from numpy import where, sqrt h = q[0,:] #print('shape of h ' + str(h.shape)) dry_tol = 0.001 u = where(h>dry_tol, q[1,:]/h, 0.) v = where(h>dry_tol, q[2,:]/h, 0.) ssq = sqrt(u*u+v*v) #s = sqrt(u**2 + v**2) s = sqrt(ssq) return ssq #plotitem.plot_var = gaugetopo #plotitem.plotstyle = 'g-' # Plot relative delta pressure as red curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = gaugedpress plotitem.plotstyle = 'r-' # add speed to this plot since cant get new one going plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = gs plotitem.plotstyle = 'g-' def add_zeroline(current_data): from pylab import plot, legend t = current_data.t # legend(('surface','topography','dp'),loc='lower left') legend(('surface','dp','speed'),loc='upper right') plot(t, 0*t, 'k') plotaxes.afteraxes = add_zeroline # ------------------------------- # Figure for speed at gauges #-------------------------------- # plotfigure = plotdata.new_plotfigure(name='Speed at gauges', figno=310, \ # type='each_gauge') # # # # Set up for axes in this figure: # plotaxes = plotfigure.new_plotaxes() # plotaxes.xlimits = 'auto' # plotaxes.ylimits = 'auto' # #plotaxes.xlimits = [0000, 7000] # #plotaxes.ylimits = 'auto' # plotaxes.title = 'Speed' # # # Plot surface as blue curve: # plotitem = plotaxes.new_plotitem(plot_type='1d_plot') # #plotitem.plot_var = speed # plotitem.plot_var = gs #gauge_speed # plotitem.plotstyle = 'b-' # # plotfigure.show = True # #----------------------------------------- # Figure for bathy alone #----------------------------------------- def bathy(current_data): return current_data.aux[0,:,:] plotfigure = plotdata.new_plotfigure(name='bathymetry', figno=3) plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Bathymetry' plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = bathy plotitem.pcolor_cmin = -4000.00 plotitem.pcolor_cmax = 100 plotitem.add_colorbar = True #----------------------------------------- # 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_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = [1,1,0] #plotitem.amr_patchedges_show = [1] plotitem.amr_patchedges_show = [0] # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure') plotfigure.show = True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-20,20] plotaxes.ylimits = [20,60] #plotaxes.xlimits = [-5,5] #plotaxes.ylimits = [35,45] plotaxes.title = "Pressure Field" # plotaxes.afteraxes = gulf_after_axes plotaxes.scaled = True #pressure_limits = [surge_data.ambient_pressure / 100.0, # 2.0 * surge_data.ambient_pressure / 100.0] pressure_limits = [.999*surge_data.ambient_pressure / 100.0, 1.001 * surge_data.ambient_pressure / 100.0] #pressure_limits = [-.000001*surge_data.ambient_pressure, # .000001 * surge_data.ambient_pressure] surgeplot.add_pressure(plotaxes, bounds=pressure_limits) surgeplot.add_land(plotaxes) #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.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