def setplot(plotdata): r"""Setplot function for surge plotting""" plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' fig_num_counter = surgeplot.figure_counter() # 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')) friction_data = surgedata.FrictionData() friction_data.read(os.path.join(plotdata.outdir,'friction.data')) # Load storm track track = surgeplot.track_data(os.path.join(plotdata.outdir,'fort.track')) # Calculate landfall time, off by a day, maybe leap year issue? landfall_dt = datetime.datetime(2008,9,13,7) - datetime.datetime(2008,1,1,0) landfall = (landfall_dt.days - 1.0) * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function surge_afteraxes = lambda cd: surgeplot.surge_afteraxes(cd, track, landfall, plot_direction=False) # Color limits surface_range = 5.0 speed_range = 3.0 eta = physics.sea_level if not isinstance(eta,list): eta = [eta] surface_limits = [eta[0]-surface_range,eta[0]+surface_range] # surface_contours = numpy.linspace(-surface_range, surface_range,11) surface_contours = [-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5] surface_ticks = [-5,-4,-3,-2,-1,0,1,2,3,4,5] surface_labels = [str(value) for value in surface_ticks] speed_limits = [0.0,speed_range] speed_contours = numpy.linspace(0.0,speed_range,13) speed_ticks = [0,1,2,3] speed_labels = [str(value) for value in speed_ticks] wind_limits = [0,64] # wind_limits = [-0.002,0.002] pressure_limits = [935,1013] friction_bounds = [0.01,0.04] # vorticity_limits = [-1.e-2,1.e-2] # def pcolor_afteraxes(current_data): # surge_afteraxes(current_data) # surge.plot.gauge_locations(current_data,gaugenos=[6]) def contour_afteraxes(current_data): surge_afteraxes(current_data) def add_custom_colorbar_ticks_to_axes(axes, item_name, ticks, tick_labels=None): axes.plotitem_dict[item_name].colorbar_ticks = ticks axes.plotitem_dict[item_name].colorbar_tick_labels = tick_labels # ========================================================================== # ========================================================================== # Plot specifications # ========================================================================== # ========================================================================== # ======================================================================== # Entire Gulf # ======================================================================== gulf_xlimits = [clawdata.lower[0],clawdata.upper[0]] gulf_ylimits = [clawdata.lower[1],clawdata.upper[1]] gulf_shrink = 0.9 def gulf_after_axes(cd): plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) surge_afteraxes(cd) # # Surface # plotfigure = plotdata.new_plotfigure(name='Surface - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes surgeplot.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=gulf_shrink) surgeplot.add_land(plotaxes,topo_min=-10.0,topo_max=5.0) # surge.plot.add_bathy_contours(plotaxes) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [1,1,1,1,1,1,1,1] # # Water Speed # plotfigure = plotdata.new_plotfigure(name='Currents - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes # Speed surgeplot.add_speed(plotaxes, plot_type='contourf', contours=speed_contours, shrink=gulf_shrink) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) # Land surgeplot.add_land(plotaxes) surgeplot.add_bathy_contours(plotaxes) # # Friction field # plotfigure = plotdata.new_plotfigure(name='Friction', figno=fig_num_counter.get_counter()) plotfigure.show = friction_data.variable_friction and True def friction_after_axes(cd): plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) plt.title(r"Manning's $n$ Coefficient") # surge_afteraxes(cd) plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits # plotaxes.title = "Manning's N Coefficient" plotaxes.afteraxes = friction_after_axes plotaxes.scaled = True surgeplot.add_friction(plotaxes,bounds=friction_bounds,shrink=0.9) plotaxes.plotitem_dict['friction'].amr_patchedges_show = [0,0,0,0,0,0,0] plotaxes.plotitem_dict['friction'].colorbar_label = "$n$" # ======================================================================== # LaTex Shelf # ======================================================================== latex_xlimits = [-97.5,-88.5] latex_ylimits = [27.5,30.5] latex_shrink = 1.0 def latex_after_axes(cd): if article: plt.subplots_adjust(left=0.07, bottom=0.14, right=1.0, top=0.86) else: plt.subplots_adjust(right=1.0) surge_afteraxes(cd) # # Surface # plotfigure = plotdata.new_plotfigure(name='Surface - LaTex Shelf', figno=fig_num_counter.get_counter()) plotfigure.show = True if article: plotfigure.kwargs = {'figsize':(8,2.7), 'facecolor':'none'} else: plotfigure.kwargs = {'figsize':(9,2.7), 'facecolor':'none'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = latex_xlimits plotaxes.ylimits = latex_ylimits plotaxes.afteraxes = latex_after_axes surgeplot.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=latex_shrink) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False # plotaxes.afteraxes = lambda cd: article_latex_after_axes(cd, landfall) else: add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', [-5,-2.5,0,2.5,5.0], ["-5.0","-2.5"," 0"," 2.5"," 5.0"]) # plotaxes.plotitem_dict['surface'].contour_cmap = plt.get_cmap('OrRd') # surge.plot.add_surface_elevation(plotaxes,plot_type='contour') surgeplot.add_land(plotaxes) # plotaxes.plotitem_dict['surface'].amr_patchedges_show = [1,1,1,0,0,0,0] plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0,0,0,0,0,0,0] # plotaxes.plotitem_dict['land'].amr_patchedges_show = [1,1,1,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0,0,0,0,0,0,0] # Plot using jet and 0.0 to 5.0 to match figgen generated ADCIRC results # plotaxes.plotitem_dict['surface'].pcolor_cmin = 0.0 # plotaxes.plotitem_dict['surface'].pcolor_cmax = 5.0 # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('jet') # # Water Speed # plotfigure = plotdata.new_plotfigure(name='Currents - LaTex Shelf', figno=fig_num_counter.get_counter()) plotfigure.show = True if article: plotfigure.kwargs = {'figsize':(8,2.7), 'facecolor':'none'} else: plotfigure.kwargs = {'figsize':(9,2.7), 'facecolor':'none'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = latex_xlimits plotaxes.ylimits = latex_ylimits plotaxes.afteraxes = latex_after_axes surgeplot.add_speed(plotaxes, plot_type='contourf', contours=speed_contours, shrink=latex_shrink) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) # surge.plot.add_surface_elevation(plotaxes,plot_type='contour') surgeplot.add_land(plotaxes) # plotaxes.plotitem_dict['speed'].amr_patchedges_show = [1,1,0,0,0,0,0] # plotaxes.plotitem_dict['land'].amr_patchedges_show = [1,1,1,0,0,0,0] plotaxes.plotitem_dict['speed'].amr_patchedges_show = [0,0,0,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0,0,0,0,0,0,0] # ======================================================================== # Houston/Galveston # ======================================================================== houston_xlimits = [-(95.0 + 26.0 / 60.0), -(94.0 + 25.0 / 60.0)] houston_ylimits = [29.1, 29.0 + 55.0 / 60.0] houston_shrink = 0.9 def houston_after_axes(cd): if article: plt.subplots_adjust(left=0.05, bottom=0.07, right=0.99, top=0.92) else: plt.subplots_adjust(left=0.12, bottom=0.06, right=0.97, top=0.97) surge_afteraxes(cd) # surge.plot.gauge_locations(cd) # # Surface Elevations # plotfigure = plotdata.new_plotfigure(name='Surface - Houston/Galveston', figno=fig_num_counter.get_counter()) plotfigure.show = True # if article: # plotfigure.kwargs['figsize'] = # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = houston_xlimits plotaxes.ylimits = houston_ylimits plotaxes.afteraxes = houston_after_axes surgeplot.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=houston_shrink) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0,0,0,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0,0,0,0,0,0,0] # surge.plot.add_bathy_contours(plotaxes) # Plot using jet and 0.0 to 5.0 to match figgen generated ADCIRC results # plotaxes.plotitem_dict['surface'].pcolor_cmin = 0.0 # plotaxes.plotitem_dict['surface'].pcolor_cmax = 5.0 # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('jet') # # Water Speed # plotfigure = plotdata.new_plotfigure(name='Currents - Houston/Galveston', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = houston_xlimits plotaxes.ylimits = houston_ylimits plotaxes.afteraxes = houston_after_axes surgeplot.add_speed(plotaxes, plot_type='contourf', contours=speed_contours, shrink=houston_shrink) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) surgeplot.add_land(plotaxes) # surge.plot.add_bathy_contours(plotaxes) # plotaxes.plotitem_dict['speed'].amr_patchedges_show = [1,1,1,1,1,1,1,1] # plotaxes.plotitem_dict['land'].amr_patchedges_show = [1,1,1,1,1,1,1,1] plotaxes.plotitem_dict['speed'].amr_patchedges_show = [0,0,0,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0,0,0,0,0,0,0] # ========================== # Hurricane Forcing fields # ========================== # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.title = "Pressure Field" plotaxes.afteraxes = gulf_after_axes plotaxes.scaled = True surgeplot.add_pressure(plotaxes, bounds=pressure_limits, shrink=gulf_shrink) surgeplot.add_land(plotaxes) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.title = "Wind Field" plotaxes.afteraxes = gulf_after_axes plotaxes.scaled = True surgeplot.add_wind(plotaxes, bounds=wind_limits, plot_type='pcolor', shrink=gulf_shrink) surgeplot.add_land(plotaxes) # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True # plotfigure.kwargs['figsize'] = (16,10) def gauge_after_axes(cd): if cd.gaugeno in [1,2,3,4]: axes = plt.gca() # # Add Kennedy gauge data # kennedy_gauge = kennedy_gauges[gauge_name_trans[cd.gaugeno]] # axes.plot(kennedy_gauge['t'] - seconds2days(date2seconds(gauge_landfall[0])), # kennedy_gauge['mean_water'] + kennedy_gauge['depth'], 'k-', # label='Gauge Data') # Add GeoClaw gauge data geoclaw_gauge = cd.gaugesoln axes.plot(seconds2days(geoclaw_gauge.t - date2seconds(gauge_landfall[1])), geoclaw_gauge.q[3,:] + gauge_surface_offset[0], 'b--', label="GeoClaw") # Add ADCIRC gauge data # ADCIRC_gauge = ADCIRC_gauges[kennedy_gauge['gauge_no']] # axes.plot(seconds2days(ADCIRC_gauge[:,0] - gauge_landfall[2]), # ADCIRC_gauge[:,1] + gauge_surface_offset[1], 'r-.', label="ADCIRC") # Fix up plot axes.set_title('Station %s' % cd.gaugeno) axes.set_xlabel('Days relative to landfall') axes.set_ylabel('Surface (m)') axes.set_xlim([-2,1]) axes.set_ylim([-1,5]) axes.set_xticks([-2,-1,0,1]) axes.set_xticklabels([r"$-2$",r"$-1$",r"$0$",r"$1$"]) axes.grid(True) axes.legend() plt.hold(False) # surge.plot.gauge_afteraxes(cd) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-2,1] # plotaxes.xlabel = "Days from landfall" # plotaxes.ylabel = "Surface (m)" plotaxes.ylimits = [-1,5] plotaxes.title = 'Surface' plotaxes.afteraxes = gauge_after_axes # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # ===================== # Gauge Location Plot # ===================== gauge_xlimits = [-95.5, -94] gauge_ylimits = [29.0, 30.0] gauge_location_shrink = 0.75 def gauge_after_axes(cd): plt.subplots_adjust(left=0.12, bottom=0.06, right=0.97, top=0.97) surge_afteraxes(cd) surgeplot.gauge_locations(cd, gaugenos=[1, 2, 3, 4]) plt.title("Gauge Locations") plotfigure = plotdata.new_plotfigure(name='Gauge Locations', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = gauge_xlimits plotaxes.ylimits = gauge_ylimits plotaxes.afteraxes = gauge_after_axes surgeplot.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=gauge_location_shrink) # surge.plot.add_surface_elevation(plotaxes, plot_type="contourf") add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) surgeplot.add_land(plotaxes) # plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0,0,0,0,0,0,0] # plotaxes.plotitem_dict['surface'].add_colorbar = False # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('jet') # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('gist_yarg') # plotaxes.plotitem_dict['surface'].pcolor_cmin = 0.0 # plotaxes.plotitem_dict['surface'].pcolor_cmax = 5.0 plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0,0,0,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0,0,0,0,0,0,0] # ============================================================== # Debugging Plots, only really work if using interactive plots # ============================================================== # # Water Velocity Components # plotfigure = plotdata.new_plotfigure(name='Velocity Components - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = False # X-Component plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = "subplot(121)" plotaxes.title = 'Velocity, X-Component' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surgeplot.water_u plotitem.pcolor_cmap = colormaps.make_colormap({1.0:'r',0.5:'w',0.0:'b'}) plotitem.pcolor_cmin = -speed_limits[1] plotitem.pcolor_cmax = speed_limits[1] plotitem.colorbar_shrink = gulf_shrink plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1] surgeplot.add_land(plotaxes) # Y-Component plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = "subplot(122)" plotaxes.title = 'Velocity, Y-Component' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surgeplot.water_v plotitem.pcolor_cmap = colormaps.make_colormap({1.0:'r',0.5:'w',0.0:'b'}) plotitem.pcolor_cmin = -speed_limits[1] plotitem.pcolor_cmax = speed_limits[1] plotitem.colorbar_shrink = gulf_shrink plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1] surgeplot.add_land(plotaxes) # # Depth # plotfigure = plotdata.new_plotfigure(name='Depth - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = False # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'depth' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes plotitem = plotaxes.new_plotitem(plot_type='2d_imshow') plotitem.plot_var = 0 plotitem.imshow_cmap = colormaps.make_colormap({1.0:'r',0.5:'w',0.0:'b'}) plotitem.imshow_cmin = 0 plotitem.imshow_cmax = 100 plotitem.colorbar_shrink = gulf_shrink plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1,1,1,1,1,1,1] # Surge field plotfigure = plotdata.new_plotfigure(name='Surge Field', figno=fig_num_counter.get_counter()) plotfigure.show = ((surge_data.wind_forcing or surge_data.pressure_forcing) and False) plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.title = "Storm Surge Source Term S" plotaxes.afteraxes = gulf_after_axes plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surgeplot.pressure_field + 1 plotitem.pcolor_cmap = plt.get_cmap('PuBu') plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 1e-3 plotitem.add_colorbar = True plotitem.colorbar_shrink = gulf_shrink plotitem.colorbar_label = "Source Strength" plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1,1,1,0,0] surgeplot.add_land(plotaxes) plotfigure = plotdata.new_plotfigure(name='Friction/Coriolis Source', figno=fig_num_counter.get_counter()) plotfigure.show = False plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.title = "Friction/Coriolis Source" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surgeplot.pressure_field + 2 plotitem.pcolor_cmap = plt.get_cmap('PuBu') plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 1e-3 plotitem.add_colorbar = True plotitem.colorbar_shrink = gulf_shrink plotitem.colorbar_label = "Source Strength" plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1,1,1,0,0] surgeplot.add_land(plotaxes) #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via pyclaw.plotters.frametools.printframes: if article: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = [54,60,66,72,78,84] # list of frames to print plotdata.print_gaugenos = [1,2,3,4] # list of gauges to print plotdata.print_fignos = [4,5,6,7,10,3,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 = False # 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? else: 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,4] # 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 setplot(plotdata): r"""Setplot function for surge plotting""" plotdata.clearfigures() # clear any old figures,axes,items data fig_num_counter = surge.plot.figure_counter() # Load data from output physics = clawpack.geoclaw.data.GeoClawData() physics.read(os.path.join(plotdata.outdir, 'geoclaw.data')) surge_data = clawpack.geoclaw.surge.data.SurgeData() surge_data.read(os.path.join(plotdata.outdir, 'surge.data')) friction_data = clawpack.geoclaw.surge.data.FrictionData() friction_data.read(os.path.join(plotdata.outdir, 'friction.data')) # Load storm track track = surge.track_data(os.path.join(plotdata.outdir, 'fort.track')) # Calculate landfall time, off by a day, maybe leap year issue? landfall_dt = datetime.datetime(2005, 8, 29, 6) - datetime.datetime( 2005, 1, 1, 0) landfall = (landfall_dt.days - 1.0) * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function surge_afteraxes = lambda cd: surge.surge_afteraxes( cd, track, landfall, plot_direction=False) # Limits for plots full_xlimits = [-99.0, -50.0] full_ylimits = [8.0, 32.0] full_shrink = 0.5 # Color limits surface_range = 5.0 speed_range = 3.0 xlimits = full_xlimits ylimits = full_ylimits eta = physics.sea_level if not isinstance(eta, list): eta = [eta] surface_limits = [eta[0] - surface_range, eta[0] + surface_range] speed_limits = [0.0, speed_range] wind_limits = [0, 40] # wind_limits = [-0.002,0.002] pressure_limits = [966, 1013] friction_bounds = [0.01, 0.04] # vorticity_limits = [-1.e-2,1.e-2] def pcolor_afteraxes(current_data): surge_afteraxes(current_data) surge.gauge_locations(current_data, gaugenos=[6]) def contour_afteraxes(current_data): surge_afteraxes(current_data) # ========================================================================== # ========================================================================== # Plot specifications # ========================================================================== # ========================================================================== # ======================================================================== # Surface Elevations - Entire Gulf # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = surge_afteraxes surge.add_surface_elevation(plotaxes, bounds=surface_limits, shrink=full_shrink) surge.add_land(plotaxes, topo_min=-10.0, topo_max=5.0) surge.add_bathy_contours(plotaxes) # ======================================================================== # Water Speed - Entire Gulf # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Currents - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = surge_afteraxes # Speed surge.add_speed(plotaxes, bounds=speed_limits, shrink=full_shrink) # Land surge.add_land(plotaxes) surge.add_bathy_contours(plotaxes) # ======================================================================== # Hurricane forcing - Entire gulf # ======================================================================== # Friction field plotfigure = plotdata.new_plotfigure(name='Friction', figno=fig_num_counter.get_counter()) plotfigure.show = friction_data.variable_friction and False plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Manning's N Coefficients" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surge.add_friction(plotaxes, bounds=friction_bounds) # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Pressure Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surge.add_pressure(plotaxes, bounds=pressure_limits) # add_pressure(plotaxes) surge.add_land(plotaxes) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Wind Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surge.add_wind(plotaxes, bounds=wind_limits, plot_type='imshow') # add_wind(plotaxes,bounds=wind_limits,plot_type='contour') # add_wind(plotaxes,bounds=wind_limits,plot_type='quiver') surge.add_land(plotaxes) # Surge field plotfigure = plotdata.new_plotfigure(name='Surge Field', figno=fig_num_counter.get_counter()) plotfigure.show = ((surge_data.wind_forcing or surge_data.pressure_forcing) and True) plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Storm Surge Source Term S" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surge.pressure_field + 1 plotitem.pcolor_cmap = plt.get_cmap('PuBu') plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 1e-3 plotitem.add_colorbar = True plotitem.colorbar_shrink = 0.5 plotitem.colorbar_label = "Source Strength" plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [1, 1, 1, 1, 1, 0, 0] surge.add_land(plotaxes) plotfigure = plotdata.new_plotfigure(name='Friction/Coriolis Source', figno=fig_num_counter.get_counter()) plotfigure.show = True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Friction/Coriolis Source" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surge.pressure_field + 2 plotitem.pcolor_cmap = plt.get_cmap('PuBu') plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 1e-3 plotitem.add_colorbar = True plotitem.colorbar_shrink = 0.5 plotitem.colorbar_label = "Source Strength" plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [1, 1, 1, 1, 1, 0, 0] surge.add_land(plotaxes) # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() # try: # plotaxes.xlimits = [amrdata.t0,amrdata.tfinal] # except: # pass # plotaxes.ylimits = [0,150.0] plotaxes.ylimits = 'auto' plotaxes.title = 'Surface' plotaxes.afteraxes = surge.gauge_afteraxes # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # ======================================================================== # Water Velocity Components - Entire Gulf # ======================================================================== plotfigure = plotdata.new_plotfigure( name='Velocity Components - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = False # X-Component plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = "subplot(121)" plotaxes.title = 'Velocity, X-Component' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = surge_afteraxes plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surge.water_u plotitem.pcolor_cmap = colormaps.make_colormap({ 1.0: 'r', 0.5: 'w', 0.0: 'b' }) plotitem.pcolor_cmin = -speed_limits[1] plotitem.pcolor_cmax = speed_limits[1] plotitem.add_colorbar = True plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [1, 1, 1] surge.add_land(plotaxes) # Y-Component plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = "subplot(122)" plotaxes.title = 'Velocity, Y-Component' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = surge_afteraxes plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surge.water_v plotitem.pcolor_cmap = colormaps.make_colormap({ 1.0: 'r', 0.5: 'w', 0.0: 'b' }) plotitem.pcolor_cmin = -speed_limits[1] plotitem.pcolor_cmax = speed_limits[1] plotitem.add_colorbar = True plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [1, 1, 1] surge.add_land(plotaxes) # ========================================================================== # Depth # ========================================================================== plotfigure = plotdata.new_plotfigure(name='Depth - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = False # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'depth' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = surge_afteraxes plotitem = plotaxes.new_plotitem(plot_type='2d_imshow') plotitem.plot_var = 0 plotitem.imshow_cmap = colormaps.make_colormap({ 1.0: 'r', 0.5: 'w', 0.0: 'b' }) plotitem.imshow_cmin = 0 plotitem.imshow_cmax = 100 plotitem.add_colorbar = True plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [1, 1, 1, 1, 1, 1, 1, 1, 1] #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via pyclaw.plotters.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_gaugenos = 'all' # list of gauges to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' # pointer for top of index plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? return plotdata
def setplot(plotdata): r"""Setplot function for surge plotting""" plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' fig_num_counter = surge.figure_counter() # 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 = geodata.SurgeData() surge_data.read(os.path.join(plotdata.outdir, 'surge.data')) friction_data = geodata.FrictionData() friction_data.read(os.path.join(plotdata.outdir, 'friction.data')) # Load storm track track = surge.track_data(os.path.join(plotdata.outdir, 'fort.track')) # Calculate landfall time, off by a day, maybe leap year issue? landfall_dt = datetime.datetime(2008, 9, 13, 7) - datetime.datetime( 2008, 1, 1, 0) landfall = (landfall_dt.days - 1.0) * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function surge_afteraxes = lambda cd: surge.surge_afteraxes( cd, track, landfall, plot_direction=False) # Color limits surface_range = 5.0 speed_range = 3.0 eta = physics.sea_level if not isinstance(eta, list): eta = [eta] surface_limits = [eta[0] - surface_range, eta[0] + surface_range] # surface_contours = numpy.linspace(-surface_range, surface_range,11) surface_contours = [ -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5 ] surface_ticks = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] surface_labels = [str(value) for value in surface_ticks] speed_limits = [0.0, speed_range] speed_contours = numpy.linspace(0.0, speed_range, 13) speed_ticks = [0, 1, 2, 3] speed_labels = [str(value) for value in speed_ticks] wind_limits = [0, 64] # wind_limits = [-0.002,0.002] pressure_limits = [935, 1013] friction_bounds = [0.01, 0.04] # vorticity_limits = [-1.e-2,1.e-2] # def pcolor_afteraxes(current_data): # surge_afteraxes(current_data) # surge.gauge_locations(current_data,gaugenos=[6]) def contour_afteraxes(current_data): surge_afteraxes(current_data) def add_custom_colorbar_ticks_to_axes(axes, item_name, ticks, tick_labels=None): axes.plotitem_dict[item_name].colorbar_ticks = ticks axes.plotitem_dict[item_name].colorbar_tick_labels = tick_labels # ========================================================================== # ========================================================================== # Plot specifications # ========================================================================== # ========================================================================== # ======================================================================== # Entire Gulf # ======================================================================== gulf_xlimits = [clawdata.lower[0], clawdata.upper[0]] gulf_ylimits = [clawdata.lower[1], clawdata.upper[1]] gulf_shrink = 0.9 def gulf_after_axes(cd): if article: plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) else: plt.subplots_adjust(left=0.05, bottom=0.07, right=1.00, top=0.93) surge_afteraxes(cd) # # Surface # plotfigure = plotdata.new_plotfigure(name='Surface - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes surge.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=gulf_shrink) surge.add_land(plotaxes, topo_min=-10.0, topo_max=5.0) # surge.add_bathy_contours(plotaxes) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [ 1, 1, 1, 1, 1, 1, 1, 1 ] # # Water Speed # plotfigure = plotdata.new_plotfigure(name='Currents - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes # Speed surge.add_speed(plotaxes, plot_type='contourf', contours=speed_contours, shrink=gulf_shrink) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) # Land surge.add_land(plotaxes) surge.add_bathy_contours(plotaxes) # # Friction field # plotfigure = plotdata.new_plotfigure(name='Friction', figno=fig_num_counter.get_counter()) plotfigure.show = friction_data.variable_friction and True def friction_after_axes(cd): plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) plt.title(r"Manning's $n$ Coefficient") # surge_afteraxes(cd) plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits # plotaxes.title = "Manning's N Coefficient" plotaxes.afteraxes = friction_after_axes plotaxes.scaled = True surge.add_friction(plotaxes, bounds=friction_bounds, shrink=0.9) plotaxes.plotitem_dict['friction'].amr_patchedges_show = [ 0, 0, 0, 0, 0, 0, 0 ] plotaxes.plotitem_dict['friction'].colorbar_label = "$n$" # ======================================================================== # LaTex Shelf # ======================================================================== latex_xlimits = [-97.5, -88.5] latex_ylimits = [27.5, 30.5] latex_shrink = 1.0 def latex_after_axes(cd): if article: plt.subplots_adjust(left=0.07, bottom=0.14, right=1.0, top=0.86) # else: # plt.subplots_adjust(right=1.0) surge_afteraxes(cd) # # Surface # plotfigure = plotdata.new_plotfigure(name='Surface - LaTex Shelf', figno=fig_num_counter.get_counter()) plotfigure.show = True if article: plotfigure.kwargs = {'figsize': (8, 2.7)} #, 'facecolor':'none'} else: plotfigure.kwargs = {'figsize': (9, 2.7)} #, 'facecolor':'none'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = latex_xlimits plotaxes.ylimits = latex_ylimits plotaxes.afteraxes = latex_after_axes surge.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=latex_shrink) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False # plotaxes.afteraxes = lambda cd: article_latex_after_axes(cd, landfall) else: add_custom_colorbar_ticks_to_axes( plotaxes, 'surface', [-5, -2.5, 0, 2.5, 5.0], ["-5.0", "-2.5", " 0", " 2.5", " 5.0"]) # plotaxes.plotitem_dict['surface'].contour_cmap = plt.get_cmap('OrRd') # surge.add_surface_elevation(plotaxes,plot_type='contour') surge.add_land(plotaxes) # plotaxes.plotitem_dict['surface'].amr_patchedges_show = [1,1,1,0,0,0,0] plotaxes.plotitem_dict['surface'].amr_patchedges_show = [ 0, 0, 0, 0, 0, 0, 0 ] # plotaxes.plotitem_dict['land'].amr_patchedges_show = [1,1,1,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0, 0, 0, 0, 0, 0, 0] # Plot using jet and 0.0 to 5.0 to match figgen generated ADCIRC results # plotaxes.plotitem_dict['surface'].pcolor_cmin = 0.0 # plotaxes.plotitem_dict['surface'].pcolor_cmax = 5.0 # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('jet') # # Water Speed # plotfigure = plotdata.new_plotfigure(name='Currents - LaTex Shelf', figno=fig_num_counter.get_counter()) plotfigure.show = True if article: plotfigure.kwargs = {'figsize': (8, 2.7)} #, 'facecolor':'none'} else: plotfigure.kwargs = {'figsize': (9, 2.7)} #, 'facecolor':'none'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = latex_xlimits plotaxes.ylimits = latex_ylimits plotaxes.afteraxes = latex_after_axes surge.add_speed(plotaxes, plot_type='contourf', contours=speed_contours, shrink=latex_shrink) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) # surge.add_surface_elevation(plotaxes,plot_type='contour') surge.add_land(plotaxes) # plotaxes.plotitem_dict['speed'].amr_patchedges_show = [1,1,0,0,0,0,0] # plotaxes.plotitem_dict['land'].amr_patchedges_show = [1,1,1,0,0,0,0] plotaxes.plotitem_dict['speed'].amr_patchedges_show = [0, 0, 0, 0, 0, 0, 0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0, 0, 0, 0, 0, 0, 0] # ======================================================================== # Houston/Galveston # ======================================================================== houston_xlimits = [-(95.0 + 26.0 / 60.0), -(94.0 + 25.0 / 60.0)] houston_ylimits = [29.1, 29.0 + 55.0 / 60.0] houston_shrink = 0.9 def houston_after_axes(cd): if article: plt.subplots_adjust(left=0.05, bottom=0.07, right=0.99, top=0.92) else: plt.subplots_adjust(left=0.12, bottom=0.06, right=0.97, top=0.97) surge_afteraxes(cd) # surge.gauge_locations(cd) # # Surface Elevations # plotfigure = plotdata.new_plotfigure(name='Surface - Houston/Galveston', figno=fig_num_counter.get_counter()) plotfigure.show = True # if article: # plotfigure.kwargs['figsize'] = # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = houston_xlimits plotaxes.ylimits = houston_ylimits plotaxes.afteraxes = houston_after_axes surge.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=houston_shrink) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) surge.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [ 0, 0, 0, 0, 0, 0, 0 ] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0, 0, 0, 0, 0, 0, 0] # surge.add_bathy_contours(plotaxes) # Plot using jet and 0.0 to 5.0 to match figgen generated ADCIRC results # plotaxes.plotitem_dict['surface'].pcolor_cmin = 0.0 # plotaxes.plotitem_dict['surface'].pcolor_cmax = 5.0 # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('jet') # # Water Speed # plotfigure = plotdata.new_plotfigure(name='Currents - Houston/Galveston', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = houston_xlimits plotaxes.ylimits = houston_ylimits plotaxes.afteraxes = houston_after_axes surge.add_speed(plotaxes, plot_type='contourf', contours=speed_contours, shrink=houston_shrink) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) surge.add_land(plotaxes) # surge.add_bathy_contours(plotaxes) # plotaxes.plotitem_dict['speed'].amr_patchedges_show = [1,1,1,1,1,1,1,1] # plotaxes.plotitem_dict['land'].amr_patchedges_show = [1,1,1,1,1,1,1,1] plotaxes.plotitem_dict['speed'].amr_patchedges_show = [0, 0, 0, 0, 0, 0, 0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0, 0, 0, 0, 0, 0, 0] # ========================== # Hurricane Forcing fields # ========================== # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.title = "Pressure Field" plotaxes.afteraxes = gulf_after_axes plotaxes.scaled = True surge.add_pressure(plotaxes, bounds=pressure_limits, shrink=gulf_shrink) surge.add_land(plotaxes) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.title = "Wind Field" plotaxes.afteraxes = gulf_after_axes plotaxes.scaled = True surge.add_wind(plotaxes, bounds=wind_limits, plot_type='pcolor', shrink=gulf_shrink) surge.add_land(plotaxes) # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True # plotfigure.kwargs['figsize'] = (16,10) def gauge_after_axes(cd): if cd.gaugeno in [1, 2, 3, 4]: axes = plt.gca() # Add Kennedy gauge data kennedy_gauge = kennedy_gauges[gauge_name_trans[cd.gaugeno]] axes.plot(kennedy_gauge['t'] - seconds2days(date2seconds(gauge_landfall[0])), kennedy_gauge['mean_water'] + kennedy_gauge['depth'], 'k-', label='Gauge Data') # Add GeoClaw gauge data geoclaw_gauge = cd.gaugesoln axes.plot(seconds2days(geoclaw_gauge.t - date2seconds(gauge_landfall[1])), geoclaw_gauge.q[3, :] + gauge_surface_offset[0], 'b--', label="GeoClaw") # Add ADCIRC gauge data ADCIRC_gauge = ADCIRC_gauges[kennedy_gauge['gauge_no']] axes.plot(seconds2days(ADCIRC_gauge[:, 0] - gauge_landfall[2]), ADCIRC_gauge[:, 1] + gauge_surface_offset[1], 'r-.', label="ADCIRC") # Fix up plot axes.set_title('Station %s' % cd.gaugeno) axes.set_xlabel('Days relative to landfall') axes.set_ylabel('Surface (m)') axes.set_xlim([-2, 1]) axes.set_ylim([-1, 5]) axes.set_xticks([-2, -1, 0, 1]) axes.set_xticklabels([r"$-2$", r"$-1$", r"$0$", r"$1$"]) axes.grid(True) axes.legend() plt.hold(False) # surge.gauge_afteraxes(cd) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-2, 1] # plotaxes.xlabel = "Days from landfall" # plotaxes.ylabel = "Surface (m)" plotaxes.ylimits = [-1, 5] plotaxes.title = 'Surface' plotaxes.afteraxes = gauge_after_axes # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # ===================== # Gauge Location Plot # ===================== gauge_xlimits = [-95.5, -94] gauge_ylimits = [29.0, 30.0] gauge_location_shrink = 0.75 def gauge_after_axes(cd): plt.subplots_adjust(left=0.12, bottom=0.06, right=0.97, top=0.97) surge_afteraxes(cd) surge.gauge_locations(cd, gaugenos=[1, 2, 3, 4]) plt.title("Gauge Locations") plotfigure = plotdata.new_plotfigure(name='Gauge Locations', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = gauge_xlimits plotaxes.ylimits = gauge_ylimits plotaxes.afteraxes = gauge_after_axes surge.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=gauge_location_shrink) # surge.add_surface_elevation(plotaxes, plot_type="contourf") add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) surge.add_land(plotaxes) # plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0,0,0,0,0,0,0] # plotaxes.plotitem_dict['surface'].add_colorbar = False # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('jet') # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('gist_yarg') # plotaxes.plotitem_dict['surface'].pcolor_cmin = 0.0 # plotaxes.plotitem_dict['surface'].pcolor_cmax = 5.0 plotaxes.plotitem_dict['surface'].amr_patchedges_show = [ 0, 0, 0, 0, 0, 0, 0 ] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0, 0, 0, 0, 0, 0, 0] # ============================================================== # Debugging Plots, only really work if using interactive plots # ============================================================== # # Water Velocity Components # plotfigure = plotdata.new_plotfigure( name='Velocity Components - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = False # X-Component plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = "subplot(121)" plotaxes.title = 'Velocity, X-Component' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surge.water_u plotitem.pcolor_cmap = colormaps.make_colormap({ 1.0: 'r', 0.5: 'w', 0.0: 'b' }) plotitem.pcolor_cmin = -speed_limits[1] plotitem.pcolor_cmax = speed_limits[1] plotitem.colorbar_shrink = gulf_shrink plotitem.add_colorbar = True plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [1, 1, 1] surge.add_land(plotaxes) # Y-Component plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = "subplot(122)" plotaxes.title = 'Velocity, Y-Component' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surge.water_v plotitem.pcolor_cmap = colormaps.make_colormap({ 1.0: 'r', 0.5: 'w', 0.0: 'b' }) plotitem.pcolor_cmin = -speed_limits[1] plotitem.pcolor_cmax = speed_limits[1] plotitem.colorbar_shrink = gulf_shrink plotitem.add_colorbar = True plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [1, 1, 1] surge.add_land(plotaxes) # # Depth # plotfigure = plotdata.new_plotfigure(name='Depth - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = False # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'depth' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes plotitem = plotaxes.new_plotitem(plot_type='2d_imshow') plotitem.plot_var = 0 plotitem.imshow_cmap = colormaps.make_colormap({ 1.0: 'r', 0.5: 'w', 0.0: 'b' }) plotitem.imshow_cmin = 0 plotitem.imshow_cmax = 100 plotitem.colorbar_shrink = gulf_shrink plotitem.add_colorbar = True plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [1, 1, 1, 1, 1, 1, 1, 1, 1] # Surge field plotfigure = plotdata.new_plotfigure(name='Surge Field', figno=fig_num_counter.get_counter()) plotfigure.show = ((surge_data.wind_forcing or surge_data.pressure_forcing) and False) plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.title = "Storm Surge Source Term S" plotaxes.afteraxes = gulf_after_axes plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surge.pressure_field + 1 plotitem.pcolor_cmap = plt.get_cmap('PuBu') plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 1e-3 plotitem.add_colorbar = True plotitem.colorbar_shrink = gulf_shrink plotitem.colorbar_label = "Source Strength" plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [1, 1, 1, 1, 1, 0, 0] surge.add_land(plotaxes) plotfigure = plotdata.new_plotfigure(name='Friction/Coriolis Source', figno=fig_num_counter.get_counter()) plotfigure.show = False plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.title = "Friction/Coriolis Source" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surge.pressure_field + 2 plotitem.pcolor_cmap = plt.get_cmap('PuBu') plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 1e-3 plotitem.add_colorbar = True plotitem.colorbar_shrink = gulf_shrink plotitem.colorbar_label = "Source Strength" plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [1, 1, 1, 1, 1, 0, 0] surge.add_land(plotaxes) #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via pyclaw.plotters.frametools.printframes: if article: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = [54, 60, 66, 72, 78, 84] # list of frames to print plotdata.print_gaugenos = [1, 2, 3, 4] # list of gauges to print plotdata.print_fignos = [4, 5, 6, 7, 10, 3, 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 = False # 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? else: 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, 4] # 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 setplot(plotdata): r"""Setplot function for surge plotting""" plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' fig_num_counter = surge.figure_counter() # 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 = geodata.SurgeData() surge_data.read(os.path.join(plotdata.outdir,'surge.data')) friction_data = geodata.FrictionData() friction_data.read(os.path.join(plotdata.outdir,'friction.data')) # Load storm track track = surge.track_data(os.path.join(plotdata.outdir,'fort.track')) # Calculate landfall time, off by a day, maybe leap year issue? if storm_num == 1: # Storm 1 landfall_dt = datetime.datetime(1997, 11, 15, 3) - datetime.datetime(1997, 1, 1, 0) elif storm_num == 2: # Storm 2 landfall_dt = datetime.datetime(2008, 12, 17, 0) - datetime.datetime(2008, 1, 1, 0) landfall = (landfall_dt.days) * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function surge_afteraxes = lambda cd: surge.surge_afteraxes(cd, track, landfall, plot_direction=False) # Color limits surface_range = 5.0 speed_range = 3.0 eta = physics.sea_level if not isinstance(eta,list): eta = [eta] surface_limits = [-5.0, 5.0] # surface_contours = numpy.linspace(-surface_range, surface_range,11) surface_contours = [-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5] surface_ticks = [-5,-4,-3,-2,-1,0,1,2,3,4,5] surface_labels = [str(value) for value in surface_ticks] speed_limits = [0.0,speed_range] speed_contours = numpy.linspace(0.0,speed_range,13) speed_ticks = [0,1,2,3] speed_labels = [str(value) for value in speed_ticks] # wind_limits = [0,64] wind_limits = [0,50] # wind_limits = [-0.002,0.002] pressure_limits = [935,1013] friction_bounds = [0.01,0.04] # vorticity_limits = [-1.e-2,1.e-2] # def pcolor_afteraxes(current_data): # surge_afteraxes(current_data) # surge.gauge_locations(current_data,gaugenos=[6]) def afteraxes(current_data): surge_afteraxes(current_data) def add_custom_colorbar_ticks_to_axes(axes, item_name, ticks, tick_labels=None): axes.plotitem_dict[item_name].colorbar_ticks = ticks axes.plotitem_dict[item_name].colorbar_tick_labels = tick_labels # ========================================================================== # ========================================================================== # Plot specifications # ========================================================================== # ========================================================================== regions = {"Full Domain (Grids)": [[clawdata.lower[0], clawdata.upper[0]], [clawdata.lower[1], clawdata.upper[1]], [1, 1, 1, 1, 1, 1, 1]], "Mumbai Regio (Grids)": [[70, 75], [17, 22], [1, 1, 1, 1, 1, 1, 1]], "Mumbai (Grids)": [[72.6, 73.15], [18.80, 19.25], [1, 1, 1, 1, 1, 1, 1]], "Full Domain (No Grids)": [[clawdata.lower[0], clawdata.upper[0]], [clawdata.lower[1], clawdata.upper[1]], [0, 0, 0, 0, 0, 0, 0]], "Mumbai Region (No Grids)": [[70, 75], [17, 22], [0, 0, 0, 0, 0, 0, 0]], "Mumbai (No Grids)": [[72.6, 73.15], [18.80, 19.25], [0, 0, 0, 0, 0, 0, 0]]} full_xlimits = regions['Full Domain (Grids)'][0] full_ylimits = regions['Full Domain (Grids)'][1] for (name, region_data) in regions.iteritems(): # # Surface # plotfigure = plotdata.new_plotfigure(name='Surface - %s' % name, figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = region_data[0] plotaxes.ylimits = region_data[1] plotaxes.afteraxes = afteraxes surge.add_surface_elevation(plotaxes, plot_type='pcolor', bounds=surface_limits) # surge.add_surface_elevation(plotaxes, plot_type='contourf', # contours=surface_contours) surge.add_land(plotaxes,topo_min=-10.0,topo_max=5.0) surge.add_bathy_contours(plotaxes) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) plotaxes.plotitem_dict['land'].amr_patchedges_show = region_data[2] plotaxes.plotitem_dict['surface'].amr_patchedges_show = region_data[2] # # Water Speed # plotfigure = plotdata.new_plotfigure(name='Currents - %s' % name, figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = region_data[0] plotaxes.ylimits = region_data[1] plotaxes.afteraxes = afteraxes # Speed surge.add_speed(plotaxes, plot_type='pcolor', bounds=speed_limits) # surge.add_speed(plotaxes, plot_type='contourf', contours=speed_contours) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) # Land surge.add_land(plotaxes,topo_min=-10.0,topo_max=5.0) plotaxes.plotitem_dict['speed'].amr_patchedges_show = region_data[2] plotaxes.plotitem_dict['land'].amr_patchedges_show = region_data[2] # # Friction field # plotfigure = plotdata.new_plotfigure(name='Friction', figno=fig_num_counter.get_counter()) plotfigure.show = friction_data.variable_friction and False def friction_after_axes(cd): plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) plt.title(r"Manning's $n$ Coefficient") # surge_afteraxes(cd) plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits # plotaxes.title = "Manning's N Coefficient" plotaxes.afteraxes = friction_after_axes plotaxes.scaled = True surge.add_friction(plotaxes, bounds=friction_bounds) plotaxes.plotitem_dict['friction'].amr_patchedges_show = [0,0,0,0,0,0,0] plotaxes.plotitem_dict['friction'].colorbar_label = "$n$" # ========================== # Hurricane Forcing fields # ========================== grids = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]] label = ["(No Grids)", "(Grids)"] for i in xrange(2): # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure %s' % label[i], figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Pressure Field" plotaxes.afteraxes = afteraxes plotaxes.scaled = True surge.add_pressure(plotaxes, bounds=pressure_limits) surge.add_land(plotaxes) plotaxes.plotitem_dict['pressure'].amr_patchedges_show = grids[i] plotaxes.plotitem_dict['land'].amr_patchedges_show = grids[i] # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed %s' % label[i], figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Wind Field" plotaxes.afteraxes = afteraxes plotaxes.scaled = True surge.add_wind(plotaxes, bounds=wind_limits, plot_type='pcolor') surge.add_land(plotaxes) plotaxes.plotitem_dict['wind'].amr_patchedges_show = grids[i] plotaxes.plotitem_dict['land'].amr_patchedges_show = grids[i] # ===================== # Gauge Location Plot # ===================== gauge_xlimits = regions["Mumbai (Grids)"][0] gauge_ylimits = regions["Mumbai (Grids)"][1] # gauge_location_shrink = 0.75 def gauge_after_axes(cd): # plt.subplots_adjust(left=0.12, bottom=0.06, right=0.97, top=0.97) surge_afteraxes(cd) # import pdb; pdb.set_trace() surge.gauge_locations(cd, gaugenos=[1, 2, 3]) plt.title("Gauge Locations") plotfigure = plotdata.new_plotfigure(name='Gauge Locations', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = gauge_xlimits plotaxes.ylimits = gauge_ylimits plotaxes.afteraxes = gauge_after_axes surge.add_surface_elevation(plotaxes, plot_type='pcolor', bounds=surface_limits) # surge.plot.add_surface_elevation(plotaxes, plot_type="contourf") add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) surge.add_land(plotaxes) # plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0,0,0,0,0,0,0] # plotaxes.plotitem_dict['surface'].add_colorbar = False # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('jet') # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('gist_yarg') # plotaxes.plotitem_dict['surface'].pcolor_cmin = 0.0 # plotaxes.plotitem_dict['surface'].pcolor_cmax = 5.0 plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0,0,0,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0,0,0,0,0,0,0] # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True # plotfigure.kwargs['figsize'] = (16,10) def gauge_after_axes(cd): if cd.gaugeno in [1, 2, 3]: axes = plt.gca() # Add GeoClaw gauge data geoclaw_gauge = cd.gaugesoln axes.plot(seconds2days(geoclaw_gauge.t - date2seconds(gauge_landfall[1])), geoclaw_gauge.q[3,:], 'b--') # Fix up plot axes.set_title('Station %s' % cd.gaugeno) axes.set_xlabel('Days relative to landfall') axes.set_ylabel('Surface (m)') axes.set_xlim([-2,1]) axes.set_ylim([-1,5]) axes.set_xticks([-2,-1,0,1]) axes.set_xticklabels([r"$-2$",r"$-1$",r"$0$",r"$1$"]) axes.grid(True) axes.legend() plt.hold(False) # surge.gauge_afteraxes(cd) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-2,1] # plotaxes.xlabel = "Days from landfall" # plotaxes.ylabel = "Surface (m)" plotaxes.ylimits = [-1,5] plotaxes.title = 'Surface' plotaxes.afteraxes = gauge_after_axes # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via pyclaw.plotters.frametools.printframes: if article: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = [54,60,66,72,78,84] # list of frames to print plotdata.print_gaugenos = [1,2,3] # list of gauges to print plotdata.print_fignos = [4,5,6,7,10,3,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 = False # 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? else: 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] # 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 setplot(plotdata): r"""Setplot function for surge plotting""" plotdata.clearfigures() # clear any old figures,axes,items data fig_num_counter = surge.plot.figure_counter() # Load data from output physics = clawpack.geoclaw.data.GeoClawData() physics.read(os.path.join(plotdata.outdir,'geoclaw.data')) surge_data = clawpack.geoclaw.surge.data.SurgeData() surge_data.read(os.path.join(plotdata.outdir,'surge.data')) friction_data = clawpack.geoclaw.surge.data.FrictionData() friction_data.read(os.path.join(plotdata.outdir,'friction.data')) # Load storm track track = surge.track_data(os.path.join(plotdata.outdir,'fort.track')) # Calculate landfall time, off by a day, maybe leap year issue? landfall_dt = datetime.datetime(2005,8,29,6) - datetime.datetime(2005,1,1,0) landfall = (landfall_dt.days - 1.0) * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function surge_afteraxes = lambda cd: surge.surge_afteraxes(cd, track, landfall, plot_direction=False) # Limits for plots full_xlimits = [-99.0,-50.0] full_ylimits = [8.0,32.0] full_shrink = 0.5 # Color limits surface_range = 5.0 speed_range = 3.0 xlimits = full_xlimits ylimits = full_ylimits eta = physics.sea_level if not isinstance(eta,list): eta = [eta] surface_limits = [eta[0]-surface_range,eta[0]+surface_range] speed_limits = [0.0,speed_range] wind_limits = [0,40] # wind_limits = [-0.002,0.002] pressure_limits = [966,1013] friction_bounds = [0.01,0.04] # vorticity_limits = [-1.e-2,1.e-2] def pcolor_afteraxes(current_data): surge_afteraxes(current_data) surge.gauge_locations(current_data,gaugenos=[6]) def contour_afteraxes(current_data): surge_afteraxes(current_data) # ========================================================================== # ========================================================================== # Plot specifications # ========================================================================== # ========================================================================== # ======================================================================== # Surface Elevations - Entire Gulf # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = surge_afteraxes surge.add_surface_elevation(plotaxes,bounds=surface_limits,shrink=full_shrink) surge.add_land(plotaxes,topo_min=-10.0,topo_max=5.0) surge.add_bathy_contours(plotaxes) # ======================================================================== # Water Speed - Entire Gulf # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Currents - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = surge_afteraxes # Speed surge.add_speed(plotaxes,bounds=speed_limits,shrink=full_shrink) # Land surge.add_land(plotaxes) surge.add_bathy_contours(plotaxes) # ======================================================================== # Hurricane forcing - Entire gulf # ======================================================================== # Friction field plotfigure = plotdata.new_plotfigure(name='Friction', figno=fig_num_counter.get_counter()) plotfigure.show = friction_data.variable_friction and False plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Manning's N Coefficients" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surge.add_friction(plotaxes,bounds=friction_bounds) # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Pressure Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surge.add_pressure(plotaxes,bounds=pressure_limits) # add_pressure(plotaxes) surge.add_land(plotaxes) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Wind Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surge.add_wind(plotaxes,bounds=wind_limits,plot_type='imshow') # add_wind(plotaxes,bounds=wind_limits,plot_type='contour') # add_wind(plotaxes,bounds=wind_limits,plot_type='quiver') surge.add_land(plotaxes) # Surge field plotfigure = plotdata.new_plotfigure(name='Surge Field', figno=fig_num_counter.get_counter()) plotfigure.show = ((surge_data.wind_forcing or surge_data.pressure_forcing) and True) plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Storm Surge Source Term S" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surge.pressure_field + 1 plotitem.pcolor_cmap = plt.get_cmap('PuBu') plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 1e-3 plotitem.add_colorbar = True plotitem.colorbar_shrink = 0.5 plotitem.colorbar_label = "Source Strength" plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1,1,1,0,0] surge.add_land(plotaxes) plotfigure = plotdata.new_plotfigure(name='Friction/Coriolis Source', figno=fig_num_counter.get_counter()) plotfigure.show = True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Friction/Coriolis Source" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surge.pressure_field + 2 plotitem.pcolor_cmap = plt.get_cmap('PuBu') plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 1e-3 plotitem.add_colorbar = True plotitem.colorbar_shrink = 0.5 plotitem.colorbar_label = "Source Strength" plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1,1,1,0,0] surge.add_land(plotaxes) # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() # try: # plotaxes.xlimits = [amrdata.t0,amrdata.tfinal] # except: # pass # plotaxes.ylimits = [0,150.0] plotaxes.ylimits = 'auto' plotaxes.title = 'Surface' plotaxes.afteraxes = surge.gauge_afteraxes # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # ======================================================================== # Water Velocity Components - Entire Gulf # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Velocity Components - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = False # X-Component plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = "subplot(121)" plotaxes.title = 'Velocity, X-Component' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = surge_afteraxes plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surge.water_u plotitem.pcolor_cmap = colormaps.make_colormap({1.0:'r',0.5:'w',0.0:'b'}) plotitem.pcolor_cmin = -speed_limits[1] plotitem.pcolor_cmax = speed_limits[1] plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1] surge.add_land(plotaxes) # Y-Component plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = "subplot(122)" plotaxes.title = 'Velocity, Y-Component' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = surge_afteraxes plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = surge.water_v plotitem.pcolor_cmap = colormaps.make_colormap({1.0:'r',0.5:'w',0.0:'b'}) plotitem.pcolor_cmin = -speed_limits[1] plotitem.pcolor_cmax = speed_limits[1] plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1] surge.add_land(plotaxes) # ========================================================================== # Depth # ========================================================================== plotfigure = plotdata.new_plotfigure(name='Depth - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = False # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'depth' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = surge_afteraxes plotitem = plotaxes.new_plotitem(plot_type='2d_imshow') plotitem.plot_var = 0 plotitem.imshow_cmap = colormaps.make_colormap({1.0:'r',0.5:'w',0.0:'b'}) plotitem.imshow_cmin = 0 plotitem.imshow_cmax = 100 plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1,1,1,1,1,1,1] #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via pyclaw.plotters.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_gaugenos = 'all' # list of gauges to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' # pointer for top of index plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? return plotdata
def setplot(plotdata): r"""Setplot function for surge plotting""" plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' fig_num_counter = surge.figure_counter() # 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 = geodata.SurgeData() surge_data.read(os.path.join(plotdata.outdir,'surge.data')) # Load storm track track = surge.track_data(os.path.join(plotdata.outdir,'fort.track')) # Calculate landfall time, off by a day, maybe leap year issue? landfall_dt = datetime.datetime(2016,6,20-1,0) - datetime.datetime(2016,1,1,0) landfall = (landfall_dt.days - 1.0) * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function surge_afteraxes = lambda cd: surge.surge_afteraxes(cd, track, landfall, plot_direction=False) # Color limits surface_range = 5.0 speed_range = 3.0 eta = physics.sea_level if not isinstance(eta,list): eta = [eta] surface_limits = [eta[0]-surface_range,eta[0]+surface_range] # surface_contours = numpy.linspace(-surface_range, surface_range,11) surface_contours = [-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5] surface_ticks = [-5,-4,-3,-2,-1,0,1,2,3,4,5] surface_labels = [str(value) for value in surface_ticks] speed_limits = [0.0,speed_range] speed_contours = numpy.linspace(0.0,speed_range,13) speed_ticks = [0,1,2,3] speed_labels = [str(value) for value in speed_ticks] wind_limits = [0,64] # wind_limits = [-0.002,0.002] pressure_limits = [935,1013] # vorticity_limits = [-1.e-2,1.e-2] # def pcolor_afteraxes(current_data): # surge_afteraxes(current_data) # surge.gauge_locations(current_data,gaugenos=[6]) def contour_afteraxes(current_data): surge_afteraxes(current_data) def add_custom_colorbar_ticks_to_axes(axes, item_name, ticks, tick_labels=None): axes.plotitem_dict[item_name].colorbar_ticks = ticks axes.plotitem_dict[item_name].colorbar_tick_labels = tick_labels # ========================================================================== # ========================================================================== # Plot specifications # ========================================================================== # ========================================================================== # ======================================================================== # Entire Domain # ======================================================================== entire_domain_xlimits = [clawdata.lower[0],clawdata.upper[0]] entire_domain_ylimits = [clawdata.lower[1],clawdata.upper[1]] entire_domain_shrink = 0.9 def entire_domain_after_axes(cd): plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) surge_afteraxes(cd) # # Surface # plotfigure = plotdata.new_plotfigure(name='Surface - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = entire_domain_xlimits plotaxes.ylimits = entire_domain_ylimits plotaxes.afteraxes = entire_domain_after_axes surge.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=entire_domain_shrink) surge.add_land(plotaxes,topo_min=-10.0,topo_max=5.0) # surge.add_bathy_contours(plotaxes) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [1,1,1,1,1,1,1,1] # # Water Speed # plotfigure = plotdata.new_plotfigure(name='Currents - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = entire_domain_xlimits plotaxes.ylimits = entire_domain_ylimits plotaxes.afteraxes = entire_domain_after_axes # Speed surge.add_speed(plotaxes, plot_type='contourf', contours=speed_contours, shrink=entire_domain_shrink) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) # Land surge.add_land(plotaxes) surge.add_bathy_contours(plotaxes) # ========================== # Hurricane Forcing fields # ========================== # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = entire_domain_xlimits plotaxes.ylimits = entire_domain_ylimits plotaxes.title = "Pressure Field" plotaxes.afteraxes = entire_domain_after_axes plotaxes.scaled = True surge.add_pressure(plotaxes, bounds=pressure_limits, shrink=entire_domain_shrink) surge.add_land(plotaxes) plotaxes.plotitem_dict['pressure'].amr_patchedges_show = [0,0,0,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0,0,0,0,0,0,0] # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = entire_domain_xlimits plotaxes.ylimits = entire_domain_ylimits plotaxes.title = "Wind Field" plotaxes.afteraxes = entire_domain_after_axes plotaxes.scaled = True surge.add_wind(plotaxes, bounds=wind_limits, plot_type='pcolor', shrink=entire_domain_shrink) surge.add_land(plotaxes) # plotaxes.plotitem_dict['wind'].amr_patchedges_show = [0,0,0,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0,0,0,0,0,0,0] #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via pyclaw.plotters.frametools.printframes: if article: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = [54,60,66,72,78,84] # list of frames to print plotdata.print_gaugenos = [] # list of gauges to print plotdata.print_fignos = [4,5,6,7,10,3,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 = False # 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? else: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_gaugenos = [] # 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 setplot(plotdata): r"""Setplot function for surge plotting""" plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' fig_num_counter = surge.figure_counter() # 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 = geodata.SurgeData() surge_data.read(os.path.join(plotdata.outdir, 'surge.data')) friction_data = geodata.FrictionData() friction_data.read(os.path.join(plotdata.outdir, 'friction.data')) # Load storm track track = surge.track_data(os.path.join(plotdata.outdir, 'fort.track')) # Calculate landfall time, off by a day, maybe leap year issue? if storm_num == 1: # Storm 1 landfall_dt = datetime.datetime(1997, 11, 15, 3) - datetime.datetime( 1997, 1, 1, 0) elif storm_num == 2: # Storm 2 landfall_dt = datetime.datetime(2008, 12, 17, 0) - datetime.datetime( 2008, 1, 1, 0) landfall = (landfall_dt.days) * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function surge_afteraxes = lambda cd: surge.surge_afteraxes( cd, track, landfall, plot_direction=False) # Color limits surface_range = 5.0 speed_range = 3.0 eta = physics.sea_level if not isinstance(eta, list): eta = [eta] surface_limits = [-5.0, 5.0] # surface_contours = numpy.linspace(-surface_range, surface_range,11) surface_contours = [ -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5 ] surface_ticks = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] surface_labels = [str(value) for value in surface_ticks] speed_limits = [0.0, speed_range] speed_contours = numpy.linspace(0.0, speed_range, 13) speed_ticks = [0, 1, 2, 3] speed_labels = [str(value) for value in speed_ticks] # wind_limits = [0,64] wind_limits = [0, 50] # wind_limits = [-0.002,0.002] pressure_limits = [935, 1013] friction_bounds = [0.01, 0.04] # vorticity_limits = [-1.e-2,1.e-2] # def pcolor_afteraxes(current_data): # surge_afteraxes(current_data) # surge.gauge_locations(current_data,gaugenos=[6]) def afteraxes(current_data): surge_afteraxes(current_data) def add_custom_colorbar_ticks_to_axes(axes, item_name, ticks, tick_labels=None): axes.plotitem_dict[item_name].colorbar_ticks = ticks axes.plotitem_dict[item_name].colorbar_tick_labels = tick_labels # ========================================================================== # ========================================================================== # Plot specifications # ========================================================================== # ========================================================================== regions = { "Full Domain (Grids)": [[clawdata.lower[0], clawdata.upper[0]], [clawdata.lower[1], clawdata.upper[1]], [1, 1, 1, 1, 1, 1, 1]], "Mumbai Regio (Grids)": [[70, 75], [17, 22], [1, 1, 1, 1, 1, 1, 1]], "Mumbai (Grids)": [[72.6, 73.15], [18.80, 19.25], [1, 1, 1, 1, 1, 1, 1]], "Full Domain (No Grids)": [[clawdata.lower[0], clawdata.upper[0]], [clawdata.lower[1], clawdata.upper[1]], [0, 0, 0, 0, 0, 0, 0]], "Mumbai Region (No Grids)": [[70, 75], [17, 22], [0, 0, 0, 0, 0, 0, 0]], "Mumbai (No Grids)": [[72.6, 73.15], [18.80, 19.25], [0, 0, 0, 0, 0, 0, 0]] } full_xlimits = regions['Full Domain (Grids)'][0] full_ylimits = regions['Full Domain (Grids)'][1] for (name, region_data) in regions.iteritems(): # # Surface # plotfigure = plotdata.new_plotfigure( name='Surface - %s' % name, figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = region_data[0] plotaxes.ylimits = region_data[1] plotaxes.afteraxes = afteraxes surge.add_surface_elevation(plotaxes, plot_type='pcolor', bounds=surface_limits) # surge.add_surface_elevation(plotaxes, plot_type='contourf', # contours=surface_contours) surge.add_land(plotaxes, topo_min=-10.0, topo_max=5.0) surge.add_bathy_contours(plotaxes) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) plotaxes.plotitem_dict['land'].amr_patchedges_show = region_data[2] plotaxes.plotitem_dict['surface'].amr_patchedges_show = region_data[2] # # Water Speed # plotfigure = plotdata.new_plotfigure( name='Currents - %s' % name, figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = region_data[0] plotaxes.ylimits = region_data[1] plotaxes.afteraxes = afteraxes # Speed surge.add_speed(plotaxes, plot_type='pcolor', bounds=speed_limits) # surge.add_speed(plotaxes, plot_type='contourf', contours=speed_contours) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) # Land surge.add_land(plotaxes, topo_min=-10.0, topo_max=5.0) plotaxes.plotitem_dict['speed'].amr_patchedges_show = region_data[2] plotaxes.plotitem_dict['land'].amr_patchedges_show = region_data[2] # # Friction field # plotfigure = plotdata.new_plotfigure(name='Friction', figno=fig_num_counter.get_counter()) plotfigure.show = friction_data.variable_friction and False def friction_after_axes(cd): plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) plt.title(r"Manning's $n$ Coefficient") # surge_afteraxes(cd) plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits # plotaxes.title = "Manning's N Coefficient" plotaxes.afteraxes = friction_after_axes plotaxes.scaled = True surge.add_friction(plotaxes, bounds=friction_bounds) plotaxes.plotitem_dict['friction'].amr_patchedges_show = [ 0, 0, 0, 0, 0, 0, 0 ] plotaxes.plotitem_dict['friction'].colorbar_label = "$n$" # ========================== # Hurricane Forcing fields # ========================== grids = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]] label = ["(No Grids)", "(Grids)"] for i in xrange(2): # Pressure field plotfigure = plotdata.new_plotfigure( name='Pressure %s' % label[i], figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Pressure Field" plotaxes.afteraxes = afteraxes plotaxes.scaled = True surge.add_pressure(plotaxes, bounds=pressure_limits) surge.add_land(plotaxes) plotaxes.plotitem_dict['pressure'].amr_patchedges_show = grids[i] plotaxes.plotitem_dict['land'].amr_patchedges_show = grids[i] # Wind field plotfigure = plotdata.new_plotfigure( name='Wind Speed %s' % label[i], figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Wind Field" plotaxes.afteraxes = afteraxes plotaxes.scaled = True surge.add_wind(plotaxes, bounds=wind_limits, plot_type='pcolor') surge.add_land(plotaxes) plotaxes.plotitem_dict['wind'].amr_patchedges_show = grids[i] plotaxes.plotitem_dict['land'].amr_patchedges_show = grids[i] # ===================== # Gauge Location Plot # ===================== gauge_xlimits = regions["Mumbai (Grids)"][0] gauge_ylimits = regions["Mumbai (Grids)"][1] # gauge_location_shrink = 0.75 def gauge_after_axes(cd): # plt.subplots_adjust(left=0.12, bottom=0.06, right=0.97, top=0.97) surge_afteraxes(cd) # import pdb; pdb.set_trace() surge.gauge_locations(cd, gaugenos=[1, 2, 3]) plt.title("Gauge Locations") plotfigure = plotdata.new_plotfigure(name='Gauge Locations', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = gauge_xlimits plotaxes.ylimits = gauge_ylimits plotaxes.afteraxes = gauge_after_axes surge.add_surface_elevation(plotaxes, plot_type='pcolor', bounds=surface_limits) # surge.plot.add_surface_elevation(plotaxes, plot_type="contourf") add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) surge.add_land(plotaxes) # plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0,0,0,0,0,0,0] # plotaxes.plotitem_dict['surface'].add_colorbar = False # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('jet') # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('gist_yarg') # plotaxes.plotitem_dict['surface'].pcolor_cmin = 0.0 # plotaxes.plotitem_dict['surface'].pcolor_cmax = 5.0 plotaxes.plotitem_dict['surface'].amr_patchedges_show = [ 0, 0, 0, 0, 0, 0, 0 ] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0, 0, 0, 0, 0, 0, 0] # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True # plotfigure.kwargs['figsize'] = (16,10) def gauge_after_axes(cd): if cd.gaugeno in [1, 2, 3]: axes = plt.gca() # Add GeoClaw gauge data geoclaw_gauge = cd.gaugesoln axes.plot( seconds2days(geoclaw_gauge.t - date2seconds(gauge_landfall[1])), geoclaw_gauge.q[3, :], 'b--') # Fix up plot axes.set_title('Station %s' % cd.gaugeno) axes.set_xlabel('Days relative to landfall') axes.set_ylabel('Surface (m)') axes.set_xlim([-2, 1]) axes.set_ylim([-1, 5]) axes.set_xticks([-2, -1, 0, 1]) axes.set_xticklabels([r"$-2$", r"$-1$", r"$0$", r"$1$"]) axes.grid(True) axes.legend() plt.hold(False) # surge.gauge_afteraxes(cd) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-2, 1] # plotaxes.xlabel = "Days from landfall" # plotaxes.ylabel = "Surface (m)" plotaxes.ylimits = [-1, 5] plotaxes.title = 'Surface' plotaxes.afteraxes = gauge_after_axes # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via pyclaw.plotters.frametools.printframes: if article: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = [54, 60, 66, 72, 78, 84] # list of frames to print plotdata.print_gaugenos = [1, 2, 3] # list of gauges to print plotdata.print_fignos = [4, 5, 6, 7, 10, 3, 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 = False # 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? else: 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] # 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 setplot(plotdata): r"""Setplot function for surge plotting""" plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' fig_num_counter = surge.figure_counter() # 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 = geodata.SurgeData() surge_data.read(os.path.join(plotdata.outdir,'surge.data')) friction_data = geodata.FrictionData() friction_data.read(os.path.join(plotdata.outdir,'friction.data')) # Load storm track track = surge.track_data(os.path.join(plotdata.outdir,'fort.track')) # Calculate landfall time, off by a day, maybe leap year issue? landfall_dt = datetime.datetime(2013,10,5,0) - datetime.datetime(2013,1,1,0) landfall = (landfall_dt.days - 1.0) * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function surge_afteraxes = lambda cd: surge.surge_afteraxes(cd, track, landfall, plot_direction=False) # Color limits surface_range = 5.0 speed_range = 3.0 eta = physics.sea_level if not isinstance(eta,list): eta = [eta] surface_limits = [eta[0]-surface_range,eta[0]+surface_range] # surface_contours = numpy.linspace(-surface_range, surface_range,11) surface_contours = [-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5] surface_ticks = [-5,-4,-3,-2,-1,0,1,2,3,4,5] surface_labels = [str(value) for value in surface_ticks] speed_limits = [0.0,speed_range] speed_contours = numpy.linspace(0.0,speed_range,13) speed_ticks = [0,1,2,3] speed_labels = [str(value) for value in speed_ticks] wind_limits = [0,64] # wind_limits = [-0.002,0.002] pressure_limits = [935,1013] friction_bounds = [0.01,0.04] # vorticity_limits = [-1.e-2,1.e-2] # def pcolor_afteraxes(current_data): # surge_afteraxes(current_data) # surge.gauge_locations(current_data,gaugenos=[6]) def contour_afteraxes(current_data): surge_afteraxes(current_data) def add_custom_colorbar_ticks_to_axes(axes, item_name, ticks, tick_labels=None): axes.plotitem_dict[item_name].colorbar_ticks = ticks axes.plotitem_dict[item_name].colorbar_tick_labels = tick_labels # ========================================================================== # ========================================================================== # Plot specifications # ========================================================================== # ========================================================================== # ======================================================================== # Entire Gulf # ======================================================================== gulf_xlimits = [clawdata.lower[0],clawdata.upper[0]] gulf_ylimits = [clawdata.lower[1],clawdata.upper[1]] gulf_shrink = 0.9 def gulf_after_axes(cd): plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) surge_afteraxes(cd) # # Surface # plotfigure = plotdata.new_plotfigure(name='Surface - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes surge.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=gulf_shrink) surge.add_land(plotaxes,topo_min=-10.0,topo_max=5.0) # surge.add_bathy_contours(plotaxes) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [1,1,1,1,1,1,1,1] # # Water Speed # plotfigure = plotdata.new_plotfigure(name='Currents - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes # Speed surge.add_speed(plotaxes, plot_type='contourf', contours=speed_contours, shrink=gulf_shrink) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) # Land surge.add_land(plotaxes) surge.add_bathy_contours(plotaxes) # # Friction field # plotfigure = plotdata.new_plotfigure(name='Friction', figno=fig_num_counter.get_counter()) plotfigure.show = friction_data.variable_friction and True def friction_after_axes(cd): plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) plt.title(r"Manning's $n$ Coefficient") # surge_afteraxes(cd) plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits # plotaxes.title = "Manning's N Coefficient" plotaxes.afteraxes = friction_after_axes plotaxes.scaled = True surge.add_friction(plotaxes,bounds=friction_bounds,shrink=0.9) plotaxes.plotitem_dict['friction'].amr_patchedges_show = [0,0,0,0,0,0,0] plotaxes.plotitem_dict['friction'].colorbar_label = "$n$" # ======================================================================== # LaTex Shelf # ======================================================================== latex_xlimits = [-97.5,-88.5] latex_ylimits = [27.5,30.5] latex_shrink = 1.0 def latex_after_axes(cd): if article: plt.subplots_adjust(left=0.07, bottom=0.14, right=1.0, top=0.86) else: plt.subplots_adjust(right=1.0) surge_afteraxes(cd) # # Surface # plotfigure = plotdata.new_plotfigure(name='Surface - LaTex Shelf', figno=fig_num_counter.get_counter()) plotfigure.show = True if article: plotfigure.kwargs = {'figsize':(8,2.7), 'facecolor':'none'} else: plotfigure.kwargs = {'figsize':(9,2.7), 'facecolor':'none'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = latex_xlimits plotaxes.ylimits = latex_ylimits plotaxes.afteraxes = latex_after_axes surge.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=latex_shrink) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False # plotaxes.afteraxes = lambda cd: article_latex_after_axes(cd, landfall) else: add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', [-5,-2.5,0,2.5,5.0], ["-5.0","-2.5"," 0"," 2.5"," 5.0"]) # plotaxes.plotitem_dict['surface'].contour_cmap = plt.get_cmap('OrRd') # surge.add_surface_elevation(plotaxes,plot_type='contour') surge.add_land(plotaxes) # plotaxes.plotitem_dict['surface'].amr_patchedges_show = [1,1,1,0,0,0,0] plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0,0,0,0,0,0,0] # plotaxes.plotitem_dict['land'].amr_patchedges_show = [1,1,1,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0,0,0,0,0,0,0] # Plot using jet and 0.0 to 5.0 to match figgen generated ADCIRC results # plotaxes.plotitem_dict['surface'].pcolor_cmin = 0.0 # plotaxes.plotitem_dict['surface'].pcolor_cmax = 5.0 # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('jet') # # Water Speed # plotfigure = plotdata.new_plotfigure(name='Currents - LaTex Shelf', figno=fig_num_counter.get_counter()) plotfigure.show = True if article: plotfigure.kwargs = {'figsize':(8,2.7), 'facecolor':'none'} else: plotfigure.kwargs = {'figsize':(9,2.7), 'facecolor':'none'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = latex_xlimits plotaxes.ylimits = latex_ylimits plotaxes.afteraxes = latex_after_axes surge.add_speed(plotaxes, plot_type='contourf', contours=speed_contours, shrink=latex_shrink) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) # surge.add_surface_elevation(plotaxes,plot_type='contour') surge.add_land(plotaxes) # plotaxes.plotitem_dict['speed'].amr_patchedges_show = [1,1,0,0,0,0,0] # plotaxes.plotitem_dict['land'].amr_patchedges_show = [1,1,1,0,0,0,0] plotaxes.plotitem_dict['speed'].amr_patchedges_show = [0,0,0,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0,0,0,0,0,0,0] # ========================== # Hurricane Forcing fields # ========================== # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.title = "Pressure Field" plotaxes.afteraxes = gulf_after_axes plotaxes.scaled = True surge.add_pressure(plotaxes, bounds=pressure_limits, shrink=gulf_shrink) surge.add_land(plotaxes) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.title = "Wind Field" plotaxes.afteraxes = gulf_after_axes plotaxes.scaled = True surge.add_wind(plotaxes, bounds=wind_limits, plot_type='pcolor', shrink=gulf_shrink) surge.add_land(plotaxes) # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True plotfigure.kwargs['figsize'] = (16,10) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-2,1] # plotaxes.xlabel = "Days from landfall" # plotaxes.ylabel = "Surface (m)" plotaxes.ylimits = [-1,5] plotaxes.title = 'Surface' # plotaxes.afteraxes = gauge_after_axes # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # ===================== # Gauge Location Plot # ===================== gauge_xlimits = [-95.5, -94] gauge_ylimits = [29.0, 30.0] gauge_location_shrink = 0.75 def gauge_after_axes(cd): # plt.subplots_adjust(left=0.12, bottom=0.06, right=0.97, top=0.97) surge_afteraxes(cd) surge.gauge_locations(cd, gaugenos=[1, 2, 3, 4]) plt.title("Gauge Locations") plotfigure = plotdata.new_plotfigure(name='Gauge Locations', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = gauge_xlimits plotaxes.ylimits = gauge_ylimits plotaxes.afteraxes = gauge_after_axes surge.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=gauge_location_shrink) # surge.add_surface_elevation(plotaxes, plot_type="contourf") add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) surge.add_land(plotaxes) # plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0,0,0,0,0,0,0] # plotaxes.plotitem_dict['surface'].add_colorbar = False # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('jet') # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('gist_yarg') # plotaxes.plotitem_dict['surface'].pcolor_cmin = 0.0 # plotaxes.plotitem_dict['surface'].pcolor_cmax = 5.0 plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0,0,0,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0,0,0,0,0,0,0] #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via pyclaw.plotters.frametools.printframes: if article: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = [54,60,66,72,78,84] # list of frames to print plotdata.print_gaugenos = [1,2,3,4] # list of gauges to print plotdata.print_fignos = [4,5,6,7,10,3,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 = False # 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? else: 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,4] # 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 setplot(plotdata): r"""Setplot function for surge plotting""" plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' # Load data from output clawdata = clawpack.clawutil.data.ClawInputData(2) clawdata.read(os.path.join(plotdata.outdir, 'claw.data')) physics = clawpack.geoclaw.data.GeoClawData() physics.read(os.path.join(plotdata.outdir, 'geoclaw.data')) surge_data = clawpack.geoclaw.data.SurgeData() surge_data.read(os.path.join(plotdata.outdir, 'surge.data')) friction_data = clawpack.geoclaw.data.FrictionData() friction_data.read(os.path.join(plotdata.outdir, 'friction.data')) # Load storm track32 track = surge.track_data(os.path.join(plotdata.outdir, 'fort.track')) # Calculate landfall time landfall_dt = datetime.datetime(2005, 8, 29, 11, 10) \ - datetime.datetime(2005, 1, 1, 0, 0) landfall = landfall_dt.days * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function surge_afteraxes = lambda cd: surge.surge_afteraxes( cd, track, landfall, plot_direction=False) # Limits for plots regions = [{ "name": "Full Domain", "limits": [[clawdata.lower[0], clawdata.upper[0]], [clawdata.lower[1], clawdata.upper[1]]] }, { "name": "New Orleans", "limits": [[-92.5, -87.5], [27.5, 31.5]] }] full_xlimits = regions[0]['limits'][0] full_ylimits = regions[0]['limits'][1] # Color limits surface_limits = [physics.sea_level - 5.0, physics.sea_level + 5.0] surface_ticks = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] surface_labels = [str(value) for value in surface_ticks] speed_limits = [0.0, 3.0] speed_ticks = [0, 1, 2, 3] speed_labels = [str(value) for value in speed_ticks] wind_limits = [0, 40] pressure_limits = [966, 1013] friction_bounds = [0.01, 0.04] # ========================================================================== # ========================================================================== # Plot specifications # ========================================================================== # ========================================================================== # Loop over region specifications ploting both surface and speeds for region in regions: name = region['name'] xlimits = region['limits'][0] ylimits = region['limits'][1] # ====================================================================== # Surface Elevations # ====================================================================== plotfigure = plotdata.new_plotfigure(name='Surface - %s' % name) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = surge_afteraxes surge.add_bathy_contours(plotaxes) surge.add_surface_elevation(plotaxes, bounds=surface_limits) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 # ====================================================================== # Water Speed # ====================================================================== plotfigure = plotdata.new_plotfigure(name='Currents - %s' % name) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = surge_afteraxes surge.add_bathy_contours(plotaxes) surge.add_speed(plotaxes, bounds=speed_limits) plotaxes.plotitem_dict['speed'].amr_patchedges_show = [0] * 10 # ======================================================================== # Hurricane forcing - Entire gulf # ======================================================================== # Friction field plotfigure = plotdata.new_plotfigure(name='Friction') plotfigure.show = friction_data.variable_friction and False plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Manning's N Coefficients" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surge.add_friction(plotaxes, bounds=friction_bounds) # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure') plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Pressure Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surge.add_bathy_contours(plotaxes) surge.add_pressure(plotaxes, bounds=pressure_limits) plotaxes.plotitem_dict['pressure'].amr_patchedges_show = [0] * 10 # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed') plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Wind Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surge.add_bathy_contours(plotaxes) surge.add_wind(plotaxes, bounds=wind_limits, plot_type='imshow') plotaxes.plotitem_dict['wind'].amr_patchedges_show = [0] * 10 # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True stations = [('8761724', 'Grand Isle, LA'), ('8760922', 'Pilots Station East, SW Pass, LA'), ('8735180', 'Dauphin Island, AL')] landfall_time = np.datetime64('2005-08-29T11:10') begin_date = datetime.datetime(2005, 8, 26) end_date = datetime.datetime(2005, 8, 31) def get_actual_water_levels(station_id): # Fetch water levels and tide predictions for given station date_time, water_level, tide = fetch_noaa_tide_data( station_id, begin_date, end_date) # Calculate times relative to landfall days_rel_landfall = (date_time - landfall_time) / np.timedelta64( 1, 'D') # Subtract tide predictions from measured water levels water_level -= tide return days_rel_landfall, water_level def gauge_afteraxes(cd): station_id, station_name = stations[cd.gaugeno - 1] days_rel_landfall, actual_level = get_actual_water_levels(station_id) axes = plt.gca() surge.plot_landfall_gauge(cd.gaugesoln, axes, landfall=landfall) axes.plot(days_rel_landfall, actual_level, 'g') # Fix up plot - in particular fix time labels axes.set_title(station_name) axes.set_xlabel('Days relative to landfall') axes.set_ylabel('Surface (m)') axes.set_xlim([-3, 1]) axes.set_ylim([-0.5, 2.5]) axes.set_xticks([-3, -2, -1, 0, 1]) axes.set_xticklabels([r"$-3$", r"$-2$", r"$-1$", r"$0$", r"$1$"]) axes.grid(True) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.afteraxes = gauge_afteraxes # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # # Gauge Location Plot # def gauge_location_afteraxes(cd): plt.subplots_adjust(left=0.12, bottom=0.06, right=0.97, top=0.97) surge_afteraxes(cd) gaugetools.plot_gauge_locations(cd.plotdata, gaugenos='all', format_string='ko', add_labels=True) plotfigure = plotdata.new_plotfigure(name="Gauge Locations") plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Gauge Locations' plotaxes.scaled = True plotaxes.xlimits = [-91.5, -87.5] plotaxes.ylimits = [28.0, 31.0] plotaxes.afteraxes = gauge_location_afteraxes surge.add_bathy_contours(plotaxes) surge.add_surface_elevation(plotaxes, bounds=surface_limits) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via pyclaw.plotters.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_gaugenos = 'all' # list of gauges to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' # pointer for top of index plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? return plotdata
def setplot(plotdata): r"""Setplot function for surge plotting""" plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' fig_num_counter = surge.figure_counter() # 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 = geodata.SurgeData() surge_data.read(os.path.join(plotdata.outdir, 'surge.data')) friction_data = geodata.FrictionData() friction_data.read(os.path.join(plotdata.outdir, 'friction.data')) # Load storm track track = surge.track_data(os.path.join(plotdata.outdir, 'fort.track')) # Calculate landfall time, off by a day, maybe leap year issue? landfall_dt = datetime.datetime(2013, 10, 5, 0) - datetime.datetime( 2013, 1, 1, 0) landfall = (landfall_dt.days - 1.0) * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function surge_afteraxes = lambda cd: surge.surge_afteraxes( cd, track, landfall, plot_direction=False) # Color limits surface_range = 5.0 speed_range = 3.0 eta = physics.sea_level if not isinstance(eta, list): eta = [eta] surface_limits = [eta[0] - surface_range, eta[0] + surface_range] # surface_contours = numpy.linspace(-surface_range, surface_range,11) surface_contours = [ -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5 ] surface_ticks = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] surface_labels = [str(value) for value in surface_ticks] speed_limits = [0.0, speed_range] speed_contours = numpy.linspace(0.0, speed_range, 13) speed_ticks = [0, 1, 2, 3] speed_labels = [str(value) for value in speed_ticks] wind_limits = [0, 64] # wind_limits = [-0.002,0.002] pressure_limits = [935, 1013] friction_bounds = [0.01, 0.04] # vorticity_limits = [-1.e-2,1.e-2] # def pcolor_afteraxes(current_data): # surge_afteraxes(current_data) # surge.gauge_locations(current_data,gaugenos=[6]) def contour_afteraxes(current_data): surge_afteraxes(current_data) def add_custom_colorbar_ticks_to_axes(axes, item_name, ticks, tick_labels=None): axes.plotitem_dict[item_name].colorbar_ticks = ticks axes.plotitem_dict[item_name].colorbar_tick_labels = tick_labels # ========================================================================== # ========================================================================== # Plot specifications # ========================================================================== # ========================================================================== # ======================================================================== # Entire Gulf # ======================================================================== gulf_xlimits = [clawdata.lower[0], clawdata.upper[0]] gulf_ylimits = [clawdata.lower[1], clawdata.upper[1]] gulf_shrink = 0.9 def gulf_after_axes(cd): plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) surge_afteraxes(cd) # # Surface # plotfigure = plotdata.new_plotfigure(name='Surface - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes surge.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=gulf_shrink) surge.add_land(plotaxes, topo_min=-10.0, topo_max=5.0) # surge.add_bathy_contours(plotaxes) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [ 1, 1, 1, 1, 1, 1, 1, 1 ] # # Water Speed # plotfigure = plotdata.new_plotfigure(name='Currents - Entire Domain', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.afteraxes = gulf_after_axes # Speed surge.add_speed(plotaxes, plot_type='contourf', contours=speed_contours, shrink=gulf_shrink) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) # Land surge.add_land(plotaxes) surge.add_bathy_contours(plotaxes) # # Friction field # plotfigure = plotdata.new_plotfigure(name='Friction', figno=fig_num_counter.get_counter()) plotfigure.show = friction_data.variable_friction and True def friction_after_axes(cd): plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) plt.title(r"Manning's $n$ Coefficient") # surge_afteraxes(cd) plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits # plotaxes.title = "Manning's N Coefficient" plotaxes.afteraxes = friction_after_axes plotaxes.scaled = True surge.add_friction(plotaxes, bounds=friction_bounds, shrink=0.9) plotaxes.plotitem_dict['friction'].amr_patchedges_show = [ 0, 0, 0, 0, 0, 0, 0 ] plotaxes.plotitem_dict['friction'].colorbar_label = "$n$" # ======================================================================== # LaTex Shelf # ======================================================================== latex_xlimits = [-97.5, -88.5] latex_ylimits = [27.5, 30.5] latex_shrink = 1.0 def latex_after_axes(cd): if article: plt.subplots_adjust(left=0.07, bottom=0.14, right=1.0, top=0.86) else: plt.subplots_adjust(right=1.0) surge_afteraxes(cd) # # Surface # plotfigure = plotdata.new_plotfigure(name='Surface - LaTex Shelf', figno=fig_num_counter.get_counter()) plotfigure.show = True if article: plotfigure.kwargs = {'figsize': (8, 2.7), 'facecolor': 'none'} else: plotfigure.kwargs = {'figsize': (9, 2.7), 'facecolor': 'none'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = latex_xlimits plotaxes.ylimits = latex_ylimits plotaxes.afteraxes = latex_after_axes surge.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=latex_shrink) if article: plotaxes.plotitem_dict['surface'].add_colorbar = False # plotaxes.afteraxes = lambda cd: article_latex_after_axes(cd, landfall) else: add_custom_colorbar_ticks_to_axes( plotaxes, 'surface', [-5, -2.5, 0, 2.5, 5.0], ["-5.0", "-2.5", " 0", " 2.5", " 5.0"]) # plotaxes.plotitem_dict['surface'].contour_cmap = plt.get_cmap('OrRd') # surge.add_surface_elevation(plotaxes,plot_type='contour') surge.add_land(plotaxes) # plotaxes.plotitem_dict['surface'].amr_patchedges_show = [1,1,1,0,0,0,0] plotaxes.plotitem_dict['surface'].amr_patchedges_show = [ 0, 0, 0, 0, 0, 0, 0 ] # plotaxes.plotitem_dict['land'].amr_patchedges_show = [1,1,1,0,0,0,0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0, 0, 0, 0, 0, 0, 0] # Plot using jet and 0.0 to 5.0 to match figgen generated ADCIRC results # plotaxes.plotitem_dict['surface'].pcolor_cmin = 0.0 # plotaxes.plotitem_dict['surface'].pcolor_cmax = 5.0 # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('jet') # # Water Speed # plotfigure = plotdata.new_plotfigure(name='Currents - LaTex Shelf', figno=fig_num_counter.get_counter()) plotfigure.show = True if article: plotfigure.kwargs = {'figsize': (8, 2.7), 'facecolor': 'none'} else: plotfigure.kwargs = {'figsize': (9, 2.7), 'facecolor': 'none'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents' plotaxes.scaled = True plotaxes.xlimits = latex_xlimits plotaxes.ylimits = latex_ylimits plotaxes.afteraxes = latex_after_axes surge.add_speed(plotaxes, plot_type='contourf', contours=speed_contours, shrink=latex_shrink) if article: plotaxes.plotitem_dict['speed'].add_colorbar = False else: add_custom_colorbar_ticks_to_axes(plotaxes, 'speed', speed_ticks, speed_labels) # surge.add_surface_elevation(plotaxes,plot_type='contour') surge.add_land(plotaxes) # plotaxes.plotitem_dict['speed'].amr_patchedges_show = [1,1,0,0,0,0,0] # plotaxes.plotitem_dict['land'].amr_patchedges_show = [1,1,1,0,0,0,0] plotaxes.plotitem_dict['speed'].amr_patchedges_show = [0, 0, 0, 0, 0, 0, 0] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0, 0, 0, 0, 0, 0, 0] # ========================== # Hurricane Forcing fields # ========================== # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.title = "Pressure Field" plotaxes.afteraxes = gulf_after_axes plotaxes.scaled = True surge.add_pressure(plotaxes, bounds=pressure_limits, shrink=gulf_shrink) surge.add_land(plotaxes) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed', figno=fig_num_counter.get_counter()) plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = gulf_xlimits plotaxes.ylimits = gulf_ylimits plotaxes.title = "Wind Field" plotaxes.afteraxes = gulf_after_axes plotaxes.scaled = True surge.add_wind(plotaxes, bounds=wind_limits, plot_type='pcolor', shrink=gulf_shrink) surge.add_land(plotaxes) # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True plotfigure.kwargs['figsize'] = (16, 10) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-2, 1] # plotaxes.xlabel = "Days from landfall" # plotaxes.ylabel = "Surface (m)" plotaxes.ylimits = [-1, 5] plotaxes.title = 'Surface' # plotaxes.afteraxes = gauge_after_axes # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # ===================== # Gauge Location Plot # ===================== gauge_xlimits = [-95.5, -94] gauge_ylimits = [29.0, 30.0] gauge_location_shrink = 0.75 def gauge_after_axes(cd): # plt.subplots_adjust(left=0.12, bottom=0.06, right=0.97, top=0.97) surge_afteraxes(cd) surge.gauge_locations(cd, gaugenos=[1, 2, 3, 4]) plt.title("Gauge Locations") plotfigure = plotdata.new_plotfigure(name='Gauge Locations', figno=fig_num_counter.get_counter()) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = gauge_xlimits plotaxes.ylimits = gauge_ylimits plotaxes.afteraxes = gauge_after_axes surge.add_surface_elevation(plotaxes, plot_type='contourf', contours=surface_contours, shrink=gauge_location_shrink) # surge.add_surface_elevation(plotaxes, plot_type="contourf") add_custom_colorbar_ticks_to_axes(plotaxes, 'surface', surface_ticks, surface_labels) surge.add_land(plotaxes) # plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0,0,0,0,0,0,0] # plotaxes.plotitem_dict['surface'].add_colorbar = False # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('jet') # plotaxes.plotitem_dict['surface'].pcolor_cmap = plt.get_cmap('gist_yarg') # plotaxes.plotitem_dict['surface'].pcolor_cmin = 0.0 # plotaxes.plotitem_dict['surface'].pcolor_cmax = 5.0 plotaxes.plotitem_dict['surface'].amr_patchedges_show = [ 0, 0, 0, 0, 0, 0, 0 ] plotaxes.plotitem_dict['land'].amr_patchedges_show = [0, 0, 0, 0, 0, 0, 0] #----------------------------------------- # Parameters used only when creating html and/or latex hardcopy # e.g., via pyclaw.plotters.frametools.printframes: if article: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = [54, 60, 66, 72, 78, 84] # list of frames to print plotdata.print_gaugenos = [1, 2, 3, 4] # list of gauges to print plotdata.print_fignos = [4, 5, 6, 7, 10, 3, 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 = False # 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? else: 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, 4] # 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