def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # Figure for q[0] plotfigure = plotdata.new_plotfigure(name='Pressure and Velocity', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = [-.5,1.3] plotaxes.title = 'q' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = '-o' plotitem.color = 'b' # Plot true solution for comparison: def plot_qtrue(current_data): from pylab import plot, legend x = current_data.x t = current_data.t q = qtrue(x,t) plot(x,q,'r',label='true solution') legend() plotaxes.afteraxes = plot_qtrue # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data print("**** Python plotting tools not yet implemented in 3d") print("**** No frame plots will be generated.") #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='q', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'q' # Plot q as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = 'b-' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = False # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = [] # list of frames to print plotdata.print_fignos = [] # list of figures to print plotdata.html = False # create html files of plots? plotdata.html_homelink = '../README.html' # pointer for top of index plotdata.html_movie = 'JSAnimation' # new style, or "4.x" for old style 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # Figures corresponding to Figure 9.5 of LeVeque, "Finite Volume # Methods for Hyperbolic Problems," 2002 (though more of them) # Tuples of (variable name, variable number) figdata = [('Pressure', 0), ('Velocity', 1)] # Afteraxes function: draw a vertical dashed line at the interface # between different media def draw_interface(current_data): import pylab pylab.plot([0., 0.], [-1000., 1000.], 'k--') for varname, varid in figdata: plotfigure = plotdata.new_plotfigure(name=varname, figno=varid) plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-5., 5.] plotaxes.ylimits = [-0.5, 1.5] # Good for both vars because of near-unit impedance plotaxes.title = varname plotaxes.afteraxes = draw_interface plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = varid plotitem.color = 'b' plotdata.printfigs = True # Whether to output figures plotdata.print_format = 'png' # What type of output format plotdata.print_framenos = 'all' # Which frames to output plotdata.print_fignos = 'all' # Which figures to print plotdata.html = True # Whether to create HTML files plotdata.latex = False # Whether to make LaTeX output return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data print("**** Python plotting tools not yet implemented in 3d") print("**** No plots will be generated.") # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = False # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = [] # list of frames to print plotdata.print_fignos = [] # list of figures to print plotdata.html = False # create html files of plots? plotdata.html_homelink = '../README.html' # pointer for top of index plotdata.html_movie = 'JSAnimation' # new style, or "4.x" for old style 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data gamma = 1.4 def pressure(current_data): q = current_data.q rho = q[0,:] u = q[1,:]/rho p = (gamma-1)*(q[2,:] - 0.5*rho*u**2) return p level_labels = ['Level 1','Level 2', 'Level 3', 'Level 4'] level_colors = ['k','g','b','r'] level_styles = '-' level_markers = '' def add_legend(current_data): try: from clawpack.visclaw import legend_tools legend_tools.add_legend(labels=level_labels, colors=level_colors, markers=level_markers, linestyles=level_styles, loc='upper right') except: print('legend_tools error') pass # Density and pressure plots # -------------------------- plotfigure = plotdata.new_plotfigure(name='Density and Pressure', figno=1) plotfigure.kwargs = {'figsize':(10,5)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1,2,1)' # left figure plotaxes.xlimits = [0,1] plotaxes.ylimits = [0,7] plotaxes.title = 'Density' #plotaxes.afteraxes = add_legend # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_pwconst') plotitem.plot_var = 0 plotitem.amr_color = level_colors plotitem.amr_plotstyle = level_styles plotitem.amr_data_show = [1] # all levels # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1,2,2)' # right plotaxes.xlimits = [0,1] plotaxes.ylimits = [-10,1100] plotaxes.title = 'Pressure' plotaxes.afteraxes = add_legend # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_pwconst') plotitem.plot_var = pressure plotitem.amr_color = level_colors plotitem.amr_plotstyle = level_styles plotitem.amr_data_show = [1] # all levels # Density and pressure plots, zoomed at final time # ------------------------------------------------- plotfigure = plotdata.new_plotfigure(name='zoom view', figno=2) plotfigure.kwargs = {'figsize':(10,5)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1,2,1)' # left figure plotaxes.xlimits = [0.5,0.9] plotaxes.ylimits = [0,7] plotaxes.title = 'Density' #plotaxes.afteraxes = add_legend # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_pwconst') plotitem.plot_var = 0 plotitem.amr_color = level_colors plotitem.amr_plotstyle = level_styles plotitem.amr_data_show = [1] # all levels # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1,2,2)' # right plotaxes.xlimits = [0.5,0.9] plotaxes.ylimits = [-10,450] plotaxes.title = 'Pressure' plotaxes.afteraxes = add_legend # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_pwconst') plotitem.plot_var = pressure plotitem.amr_color = level_colors plotitem.amr_plotstyle = level_styles plotitem.amr_data_show = [1] # all levels #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='q', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = [-1,30] plotaxes.title = 'Density' plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = 'b-' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # Figure for q[0] plotfigure = plotdata.new_plotfigure(name='q[0]', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0, 1.5] plotaxes.ylimits = [-2., 4.] plotaxes.title = 'q[0]' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d') plotitem.plot_var = 0 plotitem.plotstyle = '-' plotitem.color = 'b' plotitem.show = True # show on plot? # Figure for q[1] plotfigure = plotdata.new_plotfigure(name='q[1]', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'q[1]' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d') plotitem.plot_var = 1 plotitem.plotstyle = '-' plotitem.color = 'b' plotitem.show = True # show on plot? # 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_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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): # -------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() from clawpack.visclaw import colormaps, geoplot plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = "ascii" # Format of output # plotdata.format = 'netcdf' def set_drytol(current_data): # The drytol parameter is used in masking land and water and # affects what color map is used for cells with small water depth h. # The cell will be plotted as dry if h < drytol. # The best value to use often depends on the application and can # be set here (measured in meters): current_data.user["drytol"] = 1.0e-2 plotdata.beforeframe = set_drytol # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from clawpack.visclaw import gaugetools gaugetools.plot_gauge_locations(current_data.plotdata, gaugenos="all", format_string="ko", add_labels=True) # ----------------------------------------- # Figure for pcolor plot # ----------------------------------------- plotfigure = plotdata.new_plotfigure(name="pcolor", figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes("pcolor") plotaxes.title = "Surface" plotaxes.scaled = True # Water plotitem = plotaxes.new_plotitem(plot_type="2d_pcolor") # plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.9 plotitem.pcolor_cmax = 0.9 plotitem.add_colorbar = True plotitem.amr_celledges_show = [1, 1, 0] plotitem.amr_patchedges_show = [1] # Land plotitem = plotaxes.new_plotitem(plot_type="2d_pcolor") plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [1, 1, 0] plotaxes.xlimits = [-100, 100] plotaxes.ylimits = [-100, 100] # ----------------------------------------- # Figure for zoom # ----------------------------------------- plotfigure = plotdata.new_plotfigure(name="Zoom", figno=10) # plotfigure.show = False plotfigure.kwargs = {"figsize": [12, 7]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes("diag zoom") plotaxes.axescmd = "axes([0.0,0.1,0.6,0.6])" plotaxes.title = "On diagonal" plotaxes.scaled = True plotaxes.xlimits = [55, 66] plotaxes.ylimits = [55, 66] plotaxes.afteraxes = addgauges # Water plotitem = plotaxes.new_plotitem(plot_type="2d_pcolor") # plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.9 plotitem.pcolor_cmax = 0.9 plotitem.add_colorbar = True plotitem.amr_celledges_show = [1, 1, 0] plotitem.amr_patchedges_show = [1] # Land plotitem = plotaxes.new_plotitem(plot_type="2d_pcolor") plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [1, 1, 0] # Add contour lines of bathymetry: plotitem = plotaxes.new_plotitem(plot_type="2d_contour") plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = arange(-10.0, 0.0, 1.0) plotitem.amr_contour_colors = ["k"] # color on each level plotitem.kwargs = {"linestyles": "solid"} plotitem.amr_contour_show = [0, 0, 1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True # Add contour lines of topography: plotitem = plotaxes.new_plotitem(plot_type="2d_contour") plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = arange(0.0, 11.0, 1.0) plotitem.amr_contour_colors = ["g"] # color on each level plotitem.kwargs = {"linestyles": "solid"} plotitem.amr_contour_show = [0, 0, 1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True # Add dashed contour line for shoreline plotitem = plotaxes.new_plotitem(plot_type="2d_contour") plotitem.plot_var = geoplot.topo plotitem.contour_levels = [0.0] plotitem.amr_contour_colors = ["k"] # color on each level plotitem.kwargs = {"linestyles": "dashed"} plotitem.amr_contour_show = [0, 0, 1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True # ----------------------------------------- # Figure for zoom near axis # ----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Zoom2', figno=11) # now included in same figure as zoom on diagonal # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes("x zoom") plotaxes.show = True plotaxes.axescmd = "axes([0.5,0.1,0.6,0.6])" plotaxes.title = "On x-axis" plotaxes.scaled = True plotaxes.xlimits = [82, 93] plotaxes.ylimits = [-5, 6] plotaxes.afteraxes = addgauges # Water plotitem = plotaxes.new_plotitem(plot_type="2d_pcolor") # plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.9 plotitem.pcolor_cmax = 0.9 plotitem.add_colorbar = True plotitem.amr_celledges_show = [1, 1, 0] plotitem.amr_patchedges_show = [1] # Land plotitem = plotaxes.new_plotitem(plot_type="2d_pcolor") plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [1, 1, 0] # Add contour lines of bathymetry: plotitem = plotaxes.new_plotitem(plot_type="2d_contour") plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = arange(-10.0, 0.0, 1.0) plotitem.amr_contour_colors = ["k"] # color on each level plotitem.kwargs = {"linestyles": "solid"} plotitem.amr_contour_show = [0, 0, 1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True # Add contour lines of topography: plotitem = plotaxes.new_plotitem(plot_type="2d_contour") plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = arange(0.0, 11.0, 1.0) plotitem.amr_contour_colors = ["g"] # color on each level plotitem.kwargs = {"linestyles": "solid"} plotitem.amr_contour_show = [0, 0, 1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True # Add dashed contour line for shoreline plotitem = plotaxes.new_plotitem(plot_type="2d_contour") plotitem.plot_var = geoplot.topo plotitem.contour_levels = [0.0] plotitem.amr_contour_colors = ["k"] # color on each level plotitem.kwargs = {"linestyles": "dashed"} plotitem.amr_contour_show = [0, 0, 1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True # ----------------------------------------- # Figures for gauges # ----------------------------------------- plotfigure = plotdata.new_plotfigure(name="Surface & topo", figno=300, type="each_gauge") plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = "auto" plotaxes.ylimits = [-2.0, 2.0] plotaxes.title = "Surface" # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type="1d_plot") plotitem.plot_var = 3 plotitem.plotstyle = "b-" # Plot topo as green curve: plotitem = plotaxes.new_plotitem(plot_type="1d_plot") def gaugetopo(current_data): q = current_data.q h = q[0, :] eta = q[3, :] topo = eta - h return topo plotitem.plot_var = gaugetopo plotitem.plotstyle = "g-" def add_zeroline(current_data): from pylab import plot, legend t = current_data.t legend(("surface", "topography"), loc="lower left") plot(t, 0 * t, "k") plotaxes.afteraxes = add_zeroline # ----------------------------------------- # Figure for patches alone # ----------------------------------------- plotfigure = plotdata.new_plotfigure(name="patches", figno=2) plotfigure.show = False # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0, 1] plotaxes.ylimits = [0, 1] plotaxes.title = "patches" plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type="2d_patch") plotitem.amr_patch_bgcolor = ["#ffeeee", "#eeeeff", "#eeffee"] plotitem.amr_celledges_show = [1, 1, 0] plotitem.amr_patchedges_show = [1] # ----------------------------------------- # Scatter plot of surface for radially symmetric # ----------------------------------------- plotfigure = plotdata.new_plotfigure(name="Scatter", figno=200) plotfigure.show = False # Note: will not look very good unless more of domain is refined # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0.0, 100.0] plotaxes.ylimits = [-1.5, 2.0] plotaxes.title = "Scatter plot of surface" # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type="1d_from_2d_data") plotitem.plot_var = geoplot.surface def q_vs_radius(current_data): from numpy import sqrt x = current_data.x y = current_data.y r = sqrt(x ** 2 + y ** 2) q = current_data.var return r, q plotitem.map_2d_to_1d = q_vs_radius plotitem.plotstyle = "o" plotitem.amr_color = ["b", "r", "g"] plotaxes.afteraxes = "import pylab; pylab.legend(['Level 1','Level 2'])" # ----------------------------------------- # 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 = [4, 5, 104, 105] # 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data gamma = 1.4 def pressure(current_data): q = current_data.q rho = q[0,:] u = q[1,:]/rho p = (gamma-1)*(q[2,:] - 0.5*rho*u**2) return p plotfigure = plotdata.new_plotfigure(name='Density and Pressure', figno=1) plotfigure.kwargs = {'figsize':(10,5)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1,2,1)' # left figure plotaxes.xlimits = [0,1] plotaxes.ylimits = [0,7] plotaxes.title = 'Density' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = '-' plotitem.color = 'b' # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1,2,2)' # right plotaxes.xlimits = [0,1] plotaxes.ylimits = [0,1450] plotaxes.title = 'Pressure' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = pressure plotitem.plotstyle = '-' plotitem.color = 'b' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data def set_drytol(current_data): # The drytol parameter is used in masking land and water and # affects what color map is used for cells with small water depth h. # The cell will be plotted as dry if h < drytol. # The best value to use often depends on the application and can # be set here (measured in meters): current_data.user["drytol"] = 1.e-10 plotdata.beforeframe = set_drytol #----------------------------------------- # Figure for pcolor plot #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='pcolor', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Depth' plotaxes.scaled = False def max_cmap(current_data): q = current_data.q return ((q[1, :, :].max()) * 1.1) # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = cmax1 plotitem.add_colorbar = True plotitem.colorbar_label = 'm' plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 plotaxes.xlimits = [0.0, domain_x] plotaxes.ylimits = [-domain_y / 2.0, domain_y / 2.0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = cmax1 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 plotaxes.xlimits = [0.0, domain_x] plotaxes.ylimits = [-domain_y / 2.0, domain_y / 2.0] # # Add contour lines of bathymetry: # plotitem = plotaxes.new_plotitem(plot_type='2d_contour') # plotitem.plot_var = geoplot.topo # from numpy import arange, linspace # plotitem.contour_levels = linspace(-.1, 0.5, 20) # plotitem.amr_contour_colors = ['k'] # color on each level # plotitem.kwargs = {'linestyles':'solid'} # plotitem.amr_contour_show = [1] # plotitem.celledges_show = 0 # plotitem.patchedges_show = 0 # plotitem.show = True #----------------------------------------- # Figure for zoomed area pcolor plot #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='zoomed_pcolor', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Depth for Zoomed area' plotaxes.scaled = True def max_cmap(current_data): q = current_data.q return ((q[1, :, :].max()) * 1.1) # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = cmax1 plotitem.add_colorbar = True plotitem.colorbar_label = 'm' plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 plotaxes.xlimits = [39.6, 42.0] plotaxes.ylimits = [-domain_y / 2.0, domain_y / 2.0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = cmax1 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 plotaxes.xlimits = [39.6, 42.0] plotaxes.ylimits = [-domain_y / 2.0, domain_y / 2.0] #----------------------------------------- # Figure for centerline slice #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Centerline_slice', figno=2) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0.0, domain_x] plotaxes.ylimits = [0.0, hn * 2.0] plotaxes.title = 'Centerline slice' #def depth_plot(current_data): #from pylab import plot, cos,sin,where,legend,nan #t = current_data.t #q = current_data.q #q1 = q[1,:,centerline_index] #x = numpy.linspace(0,domain_x,len(q1)) #plot(x, q1, 'k.', label="true solution", linewidth=2) plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = 'ko' ## need to be able to set amr_plotstyle #plotitem.kwargs = {'markersize':3} #plotitem.amr_show = [1] # plot on all levels #plotaxes.afteraxes = depth_plot #----------------------------------------- # Figure for grids alone #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='grids', figno=3) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0.0, domain_x] plotaxes.ylimits = [-domain_y / 2.0, domain_y / 2.0] plotaxes.title = 'grids' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = [1, 1, 0] plotitem.amr_patchedges_show = [1] #----------------------------------------- # 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 = [] # 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() from clawpack.visclaw import colormaps, geoplot plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'ascii' # Format of output # plotdata.format = 'netcdf' def set_drytol(current_data): # The drytol parameter is used in masking land and water and # affects what color map is used for cells with small water depth h. # The cell will be plotted as dry if h < drytol. # The best value to use often depends on the application and can # be set here (measured in meters): current_data.user['drytol'] = 1.e-2 plotdata.beforeframe = set_drytol # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from clawpack.visclaw import gaugetools gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos='all', format_string='ko', add_labels=True) #----------------------------------------- # Figure for pcolor plot #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='pcolor', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Surface' plotaxes.scaled = True # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.9 plotitem.pcolor_cmax = 0.9 plotitem.add_colorbar = True plotitem.amr_celledges_show = [1, 1, 0] plotitem.amr_patchedges_show = [1] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [1, 1, 0] plotaxes.xlimits = [-100, 100] plotaxes.ylimits = [-100, 100] #----------------------------------------- # Figure for zoom #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Zoom', figno=10) #plotfigure.show = False plotfigure.kwargs = {'figsize': [12, 7]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('diag zoom') plotaxes.axescmd = 'axes([0.0,0.1,0.6,0.6])' plotaxes.title = 'On diagonal' plotaxes.scaled = True plotaxes.xlimits = [55, 66] plotaxes.ylimits = [55, 66] plotaxes.afteraxes = addgauges # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.9 plotitem.pcolor_cmax = 0.9 plotitem.add_colorbar = True plotitem.amr_celledges_show = [1, 1, 0] plotitem.amr_patchedges_show = [1] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [1, 1, 0] # Add contour lines of bathymetry: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = arange(-10., 0., 1.) plotitem.amr_contour_colors = ['k'] # color on each level plotitem.kwargs = {'linestyles': 'solid'} plotitem.amr_contour_show = [0, 0, 1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True # Add contour lines of topography: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = arange(0., 11., 1.) plotitem.amr_contour_colors = ['g'] # color on each level plotitem.kwargs = {'linestyles': 'solid'} plotitem.amr_contour_show = [0, 0, 1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True # Add dashed contour line for shoreline plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.topo plotitem.contour_levels = [0.] plotitem.amr_contour_colors = ['k'] # color on each level plotitem.kwargs = {'linestyles': 'dashed'} plotitem.amr_contour_show = [0, 0, 1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True #----------------------------------------- # Figure for zoom near axis #----------------------------------------- #plotfigure = plotdata.new_plotfigure(name='Zoom2', figno=11) # now included in same figure as zoom on diagonal # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('x zoom') plotaxes.show = True plotaxes.axescmd = 'axes([0.5,0.1,0.6,0.6])' plotaxes.title = 'On x-axis' plotaxes.scaled = True plotaxes.xlimits = [82, 93] plotaxes.ylimits = [-5, 6] plotaxes.afteraxes = addgauges # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.9 plotitem.pcolor_cmax = 0.9 plotitem.add_colorbar = True plotitem.amr_celledges_show = [1, 1, 0] plotitem.amr_patchedges_show = [1] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [1, 1, 0] # Add contour lines of bathymetry: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = arange(-10., 0., 1.) plotitem.amr_contour_colors = ['k'] # color on each level plotitem.kwargs = {'linestyles': 'solid'} plotitem.amr_contour_show = [0, 0, 1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True # Add contour lines of topography: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = arange(0., 11., 1.) plotitem.amr_contour_colors = ['g'] # color on each level plotitem.kwargs = {'linestyles': 'solid'} plotitem.amr_contour_show = [0, 0, 1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True # Add dashed contour line for shoreline plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.topo plotitem.contour_levels = [0.] plotitem.amr_contour_colors = ['k'] # color on each level plotitem.kwargs = {'linestyles': 'dashed'} plotitem.amr_contour_show = [0, 0, 1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = [-2.0, 2.0] plotaxes.title = 'Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # Plot topo as green curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') def gaugetopo(current_data): q = current_data.q h = q[0, :] eta = q[3, :] topo = eta - h return topo plotitem.plot_var = gaugetopo plotitem.plotstyle = 'g-' def add_zeroline(current_data): from pylab import plot, legend t = current_data.t legend(('surface', 'topography'), loc='lower left') plot(t, 0 * t, 'k') plotaxes.afteraxes = add_zeroline #----------------------------------------- # Figure for patches alone #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='patches', figno=2) plotfigure.show = False # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0, 1] plotaxes.ylimits = [0, 1] plotaxes.title = 'patches' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = [1, 1, 0] plotitem.amr_patchedges_show = [1] #----------------------------------------- # Scatter plot of surface for radially symmetric #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Scatter', figno=200) plotfigure.show = False # Note: will not look very good unless more of domain is refined # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0., 100.] plotaxes.ylimits = [-1.5, 2.] plotaxes.title = 'Scatter plot of surface' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') plotitem.plot_var = geoplot.surface def q_vs_radius(current_data): from numpy import sqrt x = current_data.x y = current_data.y r = sqrt(x**2 + y**2) q = current_data.var return r, q plotitem.map_2d_to_1d = q_vs_radius plotitem.plotstyle = 'o' plotitem.amr_color = ['b', 'r', 'g'] plotaxes.afteraxes = "import pylab; pylab.legend(['Level 1','Level 2'])" #----------------------------------------- # 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 = [4, 5, 104, 105] # 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() from clawpack.visclaw import colormaps plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = "ascii" # Figure for pcolor plot plotfigure = plotdata.new_plotfigure(name='q[0]', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'q[0]' plotaxes.scaled = True plotaxes.afteraxes = addgauges # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = 0 plotitem.pcolor_cmap = colormaps.red_yellow_blue plotitem.pcolor_cmin = -1. plotitem.pcolor_cmax = 1. plotitem.add_colorbar = True plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotitem.show = True # show on plot? # Figure for contour plot plotfigure = plotdata.new_plotfigure(name='contour', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'q[0]' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = 0 plotitem.contour_levels = np.linspace(-0.9, 0.9, 10) plotitem.amr_contour_colors = ['k','b'] plotitem.patchedges_show = 1 plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotitem.show = True # show on plot? # Figure for grids plotfigure = plotdata.new_plotfigure(name='grids', figno=2) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'grids' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotitem.amr_celledges_show = [1,1,0] plotitem.amr_patchedges_show = [1] #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='q', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'q' # Plot q as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = 'b-' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_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.html_movie = 'JSAnimation' # new style, or "4.x" for old style plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): # -------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() def change_fonts(current_data): pylab.xticks(fontsize=21, fontname="Tex Gyre Pagella") pylab.yticks(fontsize=21, fontname="Tex Gyre Pagella") # "Fill the step area with a black rectangle." import matplotlib.pyplot as plt rectangle = plt.Rectangle((x1, y1), 0.4, 0.4, color="k", fill=True) plt.gca().add_patch(rectangle) def change_fonts2(current_data): pylab.xticks(fontsize=17, fontname="Tex Gyre Pagella") pylab.yticks(fontsize=17, fontname="Tex Gyre Pagella") # "Fill the step area with a black rectangle." import matplotlib.pyplot as plt rectangle = plt.Rectangle((x1,y1),0.4,0.4,color="k",fill=True) plt.gca().add_patch(rectangle) plotdata.clearfigures() # clear any old figures,axes,items data def set_drytol(current_data): # The drytol parameter is used in masking land and water and # affects what color map is used for cells with small water depth h. # The cell will be plotted as dry if h < drytol. # The best value to use often depends on the application and can # be set here (measured in meters): current_data.user["drytol"] = 1.e-20 plotdata.beforeframe = set_drytol # ----------------------------------------- # Figure for pcolor plot # ----------------------------------------- plotfigure = plotdata.new_plotfigure(name='pcolor', figno=0) plotfigure.kwargs = {'figsize':[10,10],'facecolor':'white'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Depth' plotaxes.scaled = False # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = cmax1 plotitem.add_colorbar = True plotitem.colorbar_label = 'm' plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 plotaxes.xlimits = [0.0, domain_x] plotaxes.ylimits = [-domain_y/2.0, domain_y/2.0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = cmax1 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 plotaxes.xlimits = [0.0, domain_x] plotaxes.ylimits = [-domain_y/2.0, domain_y/2.0] # # Add contour lines of bathymetry: # plotitem = plotaxes.new_plotitem(plot_type='2d_contour') # plotitem.plot_var = geoplot.topo # from numpy import arange, linspace # plotitem.contour_levels = linspace(-.1, 0.5, 20) # plotitem.amr_contour_colors = ['k'] # color on each level # plotitem.kwargs = {'linestyles':'solid'} # plotitem.amr_contour_show = [1] # plotitem.celledges_show = 0 # plotitem.patchedges_show = 0 # plotitem.show = True plotaxes.afteraxes = change_fonts # ----------------------------------------- # Figure for zoomed area pcolor plot # ----------------------------------------- plotfigure = plotdata.new_plotfigure(name='zoomed_pcolor', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Depth for Zoomed area' plotaxes.scaled = False # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = cmax1 plotitem.add_colorbar = True plotitem.colorbar_label = 'm' plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 plotaxes.xlimits = [39.4, 42.0] plotaxes.ylimits = [-domain_y/2.0, domain_y/2.0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = cmax1 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 plotaxes.xlimits = [39.5, 42.0] plotaxes.ylimits = [-domain_y/2.0, domain_y/2.0] plotaxes.afteraxes = change_fonts2 # ----------------------------------------- # Figure for centerline slice # ----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Centerline_slice', figno=2) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0.0, domain_x] plotaxes.ylimits = [0.0, hn*2.0] plotaxes.title = 'Centerline slice' # def depth_plot(current_data): #from pylab import plot, cos,sin,where,legend,nan #t = current_data.t #q = current_data.q #q1 = q[1,:,centerline_index] #x = numpy.linspace(0,domain_x,len(q1)) #plot(x, q1, 'k.', label="true solution", linewidth=2) plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = 'ko' # need to be able to set amr_plotstyle #plotitem.kwargs = {'markersize':3} # plotitem.amr_show = [1] # plot on all levels #plotaxes.afteraxes = depth_plot # ----------------------------------------- # Figure for grids alone # ----------------------------------------- plotfigure = plotdata.new_plotfigure(name='grids', figno=3) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0.0, domain_x] plotaxes.ylimits = [-domain_y/2.0, domain_y/2.0] plotaxes.title = 'grids' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = [1, 1, 0] plotitem.amr_patchedges_show = [1] # ----------------------------------------- # Figure for cross section at y=0 # ----------------------------------------- plotfigure = plotdata.new_plotfigure(name='cross-section', figno=4) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0.0, domain_x] plotaxes.ylimits = [0.0, cmax1*1.80] plotaxes.title = 'Cross section at y=0' def plot_topo_xsec(current_data): from pylab import plot, cos, sin, where, legend, nan t = current_data.t x = numpy.linspace(0.0, domain_x, 201) #y = 0. B = where(x > 40.0, where(x < 40.50, 7.0, 0.0), 0.0) plot(x, B, 'g', label="bathymetry") legend() pylab.xticks(fontsize=21, fontname="Tex Gyre Pagella") pylab.yticks(fontsize=21, fontname="Tex Gyre Pagella") plotaxes.afteraxes = plot_topo_xsec plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') def xsec(current_data): # Return x value and surface depth at this point, along y=0 from pylab import where, ravel x = current_data.x y = ravel(current_data.y) dy = current_data.dy q = current_data.q ij = where((y <= dy/2.) & (y > -dy/2.)) x_slice = ravel(x)[ij] ij1 = where((x_slice > 40.50) | (x_slice < 40.0)) x_slice = x_slice[ij1] depth_slice = ravel(q[0, :, :])[ij] depth_slice = depth_slice[ij1] return x_slice, depth_slice plotitem.map_2d_to_1d = xsec plotitem.plotstyle = 'k-x' # need to be able to set amr_plotstyle plotitem.kwargs = {'markersize': 4} plotitem.amr_show = [1] # plot on all levels # ----------------------------------------- # 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 = [] # 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata): r"""Setplot function for surge plotting""" if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # plotdata.format = 'binary' plotdata.format = 'ascii' # Load data from output claw_data = clawdata.ClawInputData(2) claw_data.read(os.path.join(plotdata.outdir, 'claw.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 = surgeplot.track_data(os.path.join(plotdata.outdir, 'fort.track')) # Set afteraxes function surge_afteraxes = lambda cd: surgeplot.surge_afteraxes( cd, track, plot_direction=False) # Color limits surface_range = 4.5 speed_range = 1.0 # speed_range = 1.e-2 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, 55] pressure_limits = [966, 1013] friction_bounds = [0.01, 0.04] vorticity_limits = [-1.e-2, 1.e-2] land_bounds = [-10, 50] # ========================================================================== # Plot specifications # ========================================================================== # Limits for plots regions = { 'Full Domain': { "xlimits": [claw_data.lower[0], claw_data.upper[0]], "ylimits": [claw_data.lower[1], claw_data.upper[1]], "shrink": 1.0, "figsize": [6.4, 4.8] }, 'Mumbai Region': { "xlimits": [70, 75], "ylimits": [17, 22], "shrink": 1.0, "figsize": [6.4, 4.8] }, 'Mumbai': { "xlimits": [72.6, 73.15], "ylimits": [18.80, 19.25], "shrink": 1.0, "figsize": [6.4, 4.8] } } 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) for (name, region_dict) in regions.items(): # ======================================================================== # Surface Elevations # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface - %s' % name) plotfigure.show = True #plotfigure = plotdata.new_plotfigure(name="Gauge Locations") #plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.xlimits = region_dict['xlimits'] plotaxes.ylimits = region_dict['ylimits'] plotaxes.afteraxes = surge_afteraxes plotaxes.afteraxes = gauge_location_afteraxes surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits, shrink=region_dict['shrink']) surgeplot.add_land(plotaxes, bounds=land_bounds) plotaxes.plotitem_dict['land'].amr_patchedges_show = [1, 0, 0] plotaxes.plotitem_dict['surface'].amr_patchedges_show = [1, 0, 0] # ======================================================================== # 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 = region_dict['xlimits'] plotaxes.ylimits = region_dict['ylimits'] plotaxes.afteraxes = surge_afteraxes surgeplot.add_speed(plotaxes, bounds=speed_limits, shrink=region_dict['shrink']) surgeplot.add_land(plotaxes, bounds=land_bounds) # ======================================================================== # Hurricane forcing - Entire Atlantic # ======================================================================== # Friction field plotfigure = plotdata.new_plotfigure(name='Friction') plotfigure.show = False plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Full Domain']['xlimits'] plotaxes.ylimits = regions['Full Domain']['ylimits'] plotaxes.title = "Manning's N Coefficients" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_friction(plotaxes, bounds=friction_bounds) # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure') plotfigure.show = True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Full Domain']['xlimits'] plotaxes.ylimits = regions['Full Domain']['ylimits'] plotaxes.title = "Pressure Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_pressure(plotaxes, bounds=pressure_limits) surgeplot.add_land(plotaxes, bounds=[-10, 500]) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed') plotfigure.show = True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Full Domain']['xlimits'] plotaxes.ylimits = regions['Full Domain']['ylimits'] plotaxes.title = "Wind Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_wind(plotaxes, bounds=wind_limits, plot_type='imshow') surgeplot.add_land(plotaxes, bounds=[-10, 500]) # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True def gauge_afteraxes(cd): axes = plt.gca() surgeplot.plot_landfall_gauge(cd.gaugesoln, axes) # Fix up plot - in particular fix time labels axes.set_title('Station %s' % cd.gaugeno) axes.set_xlabel('Days relative to landfall') axes.set_ylabel('Surface (m)') axes.set_xlim([0, 6]) axes.set_xticks([0, 1, 2, 3, 4, 5, 6]) axes.set_xticklabels( [r"$0$", r"$1$", r"$2$", r"$3$", r"$4$", r"$5$", r"$6$"]) #axes.set_ylim([-1, 5]) axes.grid(True) # def gauge_afteraxes(cd): # station_id, station_name = stations[cd.gaugeno-1] # seconds_rel_landfall, actual_level = get_actual_water_levels(station_id) # # axes = plt.gca() # #surgeplot.plot_landfall_gauge(cd.gaugesoln, axes, landfall=landfall) # axes.plot(seconds_rel_landfall, actual_level, 'g') # # # Fix up plot - in particular fix time labels # axes.set_title(station_name) # axes.set_xlabel('Seconds relative to landfall') # axes.set_ylabel('Surface (m)') # axes.set_xlim([days2seconds(-2), days2seconds(1)]) # axes.set_ylim([0, 4]) # axes.set_xticks([ days2seconds(-2), days2seconds(-1), 0, #days2seconds(1)]) #axes.set_xticklabels([r"$-3$", r"$-2$", r"$-1$", r"$0$", r"$1$"]) #axes.grid(True) # def current_afterxes(cd): # station_id, station_name = stations[cd.gaugeno-1] # if len(station_id)==6: # seconds_rel_landfall, currents = get_actual_currents(station_id) # # axes = plt.gca() # #surgeplot.plot_landfall_gauge(cd.gaugesoln, axes, # landfall=landfall) # axes.plot(seconds_rel_landfall, currents, 'g') # # # Fix up plot - in particular fix time labels # axes.set_title(station_name) # axes.set_xlabel('Seconds relative to landfall') # axes.set_ylabel('Surface (m)') # axes.set_xlim([days2seconds(-2), days2seconds(1)]) # axes.set_xticks([ days2seconds(-2), days2seconds(-1), 0, # days2seconds(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-' # Speeds # plotfigure = plotdata.new_plotfigure(name='Currents', figno=400, \ # type='each_gauge') # plotfigure.show = True # plotfigure.clf_each_gauge = True # plotaxes = plotfigure.new_plotaxes() #plotaxes.afteraxes = current_afterxes # plotaxes.axescmd = 'subplot(122)' # try: # plotaxes.xlimits = [amrdata.t0, amrdata.tfinal] # except: # pass # plotaxes.ylimits = surface_limits #plotaxes.title = 'Momenta' # plotaxes.afteraxes = surge.gauge_afteraxes # plotitem = plotaxes.new_plotitem(plot_type='1d_plot') # plotitem.plot_var = calc_currents # plotitem.plotstyle = 'r-.' #plotitem = plotaxes.new_plotitem(plot_type='1d_plot') #plotitem.plot_var = 2 #plotitem.plotstyle = 'b-' #----------------------------------------- # 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # Figure for q[0] plotfigure = plotdata.new_plotfigure(name='Solution', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0, 1] plotaxes.ylimits = [-.6, 1.2] plotaxes.title = 'q' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.amr_color = ['g', 'b', 'r'] plotitem.amr_plotstyle = ['^-', 's-', 'o-'] plotitem.amr_data_show = [1, 1, 1] plotitem.amr_kwargs = [{ 'markersize': 8 }, { 'markersize': 6 }, { 'markersize': 5 }] # Plot true solution for comparison: def plot_qtrue(current_data): from pylab import plot, legend x = linspace(0, 1, 1000) t = current_data.t q = qtrue(x, t) plot(x, q, 'k', label='true solution') def plot_qtrue_with_legend(current_data): from pylab import plot, legend x = linspace(0, 1, 1000) t = current_data.t q = qtrue(x, t) plot(x, q, 'k', label='true solution') try: from clawpack.visclaw import legend_tools labels = ['Level 1', 'Level 2', 'Level 3', 'True solution'] legend_tools.add_legend(labels, colors=['g', 'b', 'r', 'k'], markers=['^', 's', 'o', ''], linestyles=['', '', '', '-'], loc='lower right') except: legend(loc='lower right') plotaxes.afteraxes = plot_qtrue_with_legend # ------------------------------------------ # Figure with each level plotted separately: plotfigure = plotdata.new_plotfigure(name='By AMR Level', figno=2) plotfigure.kwargs = {'figsize': (8, 10)} for level in range(1, 4): # Set up plot for this level: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(3,1,%i)' % level plotaxes.xlimits = [0, 1] plotaxes.ylimits = [-.5, 1.3] plotaxes.title = 'Level %s' % level plotaxes.afteraxes = plot_qtrue plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.amr_color = ['g', 'b', 'r'] plotitem.amr_plotstyle = ['^-', 's-', 'o-'] plotitem.amr_data_show = [0, 0, 0] plotitem.amr_data_show[level - 1] = 1 # show only one level #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='q', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Solution' plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = 'b-' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot from numpy import linspace if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data def speed(current_data): from numpy import ma, where, sqrt, log10 drytol = 1e-3 q = current_data.q h = q[0, :, :] hu = q[1, :, :] hv = q[2, :, :] u = where(h > 0.0, hu / h, 0.) v = where(h > 0.0, hv / h, 0.) speed = sqrt(u**2 + v**2) return speed def stress(current_data): from numpy import ma, where, sqrt, log10 q = current_data.q h = q[0, :, :] hu = q[1, :, :] hv = q[2, :, :] u = where(h > 0.0, hu / h, 0.) v = where(h > 0.0, hv / h, 0.) speed = np.sqrt(u**2 + v**2) #Speed calc, same as above n = 0.06 #Manning's n g = 9.8 #gravity cf = where( h > 0.0, (g * n**2) / (h**(1. / 3)), 0. ) #calculate friction coefficient, DONT FORGET THE F*****G PERIOD YOU IDIOT (mike) stress = 1000 * cf * (speed**2) return stress # def erodibilityratio(current_data): # ratio of impelling forces (dimensionless shear stress T) to resisting forces (critical shear stress Tc) # from numpy import ma, where, sqrt, log10 # q=current_data.q # h=q[0,:,:] # hu=q[1,:,:] # hv=q[2,:,:] # u = where(h>0.0, hu/h, 0.) # v = where(h>0.0, hv/h, 0.) # speed = sqrt(u**2 +v**2) #Speed calc, same as above # n = 0.06 #Manning's n # g = 9.8 #gravity # def dsp(current_data): # dsp = depth slope product # from numpy import ma, where, sqrt, log10 # q = current_data.q # h=q[0,:,:] # g = 9.8 # gravity # dsp = 1000*g*h*0.02 # using a bulk channel gradient of 0.02-- will need to figure out how to make a localized measurement of this # return dsp # def froude(current_data): # from numpy import ma, where, sqrt, log10 # drytol = 1e-3 # q = current_data.q # h=q[0,:,:] # hu=q[1,:,:] # hv=q[2,:,:] # u = where(h>0.0, hu/h, 0.) # v = where(h>0.0, hv/h, 0.) # g = 9.8 # speed = np.sqrt(u**2 +v**2) # froude = speed/((g*h)**(1.2)) # return froude # def blocksize(current_data): # from numpy import ma, where, sqrt, log10 # q = current_data.q # h=q[0,:,:] # hu=q[1,:,:] # hv=q[2,:,:] # u = where(h>0.0, hu/h, 0.) # v = where(h>0.0, hv/h, 0.) # speed = np.sqrt(u**2 +v**2) #Speed calc, same as above # n = 0.04 #Manning's n # g = 9.8 #gravity idiot # cf = where(h>0.0, (g*n**2)/(h**(1./3)), 0.) # stress = 1000*cf*(speed**2) # tc = 0.15*((0.02)**(1./4)) #need to choose a slope here, sooooo 0.02 # blocksize = stress/(tc*g*1700) # return blocksize #####----------------------------------------- # Lake (depth) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='lake_depth', figno=1) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Depth') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [93.0, 95.6] plotaxes.ylimits = [28.0, 30.0] # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.depth #variable to plot plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 200 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Lake (speed) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='lake_speed', figno=2) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Speed') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [93, 94.96] plotaxes.ylimits = [28.96, 29.77] # speed plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 80 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Lake (stress) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='lake_stress', figno=3) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Stress') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [93, 94.96] plotaxes.ylimits = [28.96, 29.77] # stress plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = stress plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 2500 #make this reasonable max stress plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #####----------------------------------------- # Outburst (depth) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Outburst_depth', figno=11) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Depth') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.8, 95.2] plotaxes.ylimits = [29.5, 29.9] # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.depth #variable to plot plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 300 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Outburst (speed) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Outburst_speed', figno=12) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Speed') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.8, 95.2] plotaxes.ylimits = [29.5, 29.9] # speed plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 80 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Outburst (stress) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Outburst_stress', figno=13) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Stress') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.8, 95.2] plotaxes.ylimits = [29.5, 29.9] # stress plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = stress plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 40000 #make this reasonable max stress plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Gorge depth #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Gorgetesting_depth', figno=21) plotfigure.show = True plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Depth') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [95.0, 95.45] plotaxes.ylimits = [29.5, 30.0] # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.depth #variable to plot plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 300 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Gorge speed #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Gorgetesting_speed', figno=22) plotfigure.show = True plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Speed') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [95.0, 95.45] plotaxes.ylimits = [29.5, 30.0] # speed plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 60 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Gorge stress #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Gorgetesting_stress', figno=23) plotfigure.show = True plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Stress') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [95.0, 95.45] plotaxes.ylimits = [29.5, 30.0] # stress plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = stress plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 10000 #make this reasonable max stress plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #####----------------------------------------- # Gorge-Tuting depth #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='gorge_tuting_depth', figno=24) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Depth') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [95.25, 95.5] plotaxes.ylimits = [29.25, 29.7] # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.depth #variable to plot plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 300 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Gorge-Tuting speed #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='gorge_tuting_speed', figno=25) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Speed') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [95.25, 95.5] plotaxes.ylimits = [29.25, 29.7] # speed plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 60 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Gorge-Tuting stress #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='gorge_tuting_stress', figno=26) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Stress') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [95.25, 95.5] plotaxes.ylimits = [29.25, 29.7] # stress plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = stress plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 16000 #make this reasonable max stress plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 5000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Gorge-Tuting2 depth - arrives here at Frame 12, t = 1.08e04 #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Gorge-Tuting2_depth', figno=27) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Depth') plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.85, 95.35] plotaxes.ylimits = [28.9, 29.35] # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.depth #variable to plot plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 250 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Gorge-Tuting2 speed #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Gorge-Tuting2_speed', figno=28) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Speed') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.85, 95.35] plotaxes.ylimits = [28.9, 29.35] # speed plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 60 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Gorge-Tuting2 stress #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Gorge-Tuting2_stress', figno=29) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Stress') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.85, 95.35] plotaxes.ylimits = [28.9, 29.35] # stress plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = stress plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 16000 #make this reasonable max stress plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 5000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #####----------------------------------------- # Tuting-ish(depth) arrives here in Frame 16, t = 1.44e04 #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Tuting_depth', figno=30) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Depth') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.65, 95.0] plotaxes.ylimits = [28.6, 29.05] # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.depth #variable to plot plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 250 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Tuting-ish (speed) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Tuting_speed', figno=31) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Speed') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.65, 95.0] plotaxes.ylimits = [28.6, 29.05] # speed plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 60 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Tuting-ish (stress) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Tuting_stress', figno=32) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Stress') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.65, 95.0] plotaxes.ylimits = [28.6, 29.05] # stress plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = stress plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 234.0 plotitem.pcolor_cmax = 61555.0 #make this reasonable max stress plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Downstream 1 (depth) arrives here at Frame 26, t = 2.34e04 #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='downstream1_depth', figno=33) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Depth') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.8, 95.15] plotaxes.ylimits = [28.15, 28.7] # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.depth #variable to plot plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 300 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Downstream 1 (speed) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='downstream1_speed', figno=34) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Speed') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.8, 95.15] plotaxes.ylimits = [28.15, 28.7] # speed plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 80 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Downstream 1 (stress) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='downstream1_stress', figno=35) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Stress') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.8, 95.15] plotaxes.ylimits = [28.15, 28.7] # stress plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = stress plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 10000 #make this reasonable max stress plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #####----------------------------------------- # Downstream 2 (depth) - arrives at Frame 36, t = 3.24e04 #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='downstream2_depth', figno=36) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Depth') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.8, 95.4] plotaxes.ylimits = [28.0, 28.5] # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.depth #variable to plot plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 150 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Downstream 2 (speed) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='downstream2_speed', figno=37) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Speed') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.9, 95.1] plotaxes.ylimits = [28.15, 28.3] # speed plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 80 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 2000.0 plotitem.pcolor_cmax = 6000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Downstream 2 (stress) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='downstream2_stress', figno=38) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 15]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Stress') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.9, 95.1] plotaxes.ylimits = [28.15, 28.3] # stress plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = stress plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 234.0 plotitem.pcolor_cmax = 61555.0 #make this reasonable max stress plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 100.0 plotitem.pcolor_cmax = 2000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #####----------------------------------------- # Backflow up the Siyom (depth) - arrives at Frame 35 #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='backflow_depth', figno=39) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 10]} # # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Depth') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.6, 95.1] plotaxes.ylimits = [28.00, 28.35] # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.depth #variable to plot plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 200.0 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 100.0 plotitem.pcolor_cmax = 2000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #####----------------------------------------- # Backflow up the Siyom (speed) #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='backflow_speed', figno=40) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 10]} # # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Speed') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.6, 95.1] plotaxes.ylimits = [28.00, 28.35] # speed plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 60 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 100.0 plotitem.pcolor_cmax = 2000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #####----------------------------------------- # Backflow up the Siyom (stress) #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='backflow_stress', figno=41) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 10]} # # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Stress') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.6, 95.1] plotaxes.ylimits = [28.00, 28.35] # stress plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = stress plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 20000 #make this reasonable max stress plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 100.0 plotitem.pcolor_cmax = 2000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges # #####----------------------------------------- # # Backflow up the Siyom (blocksize) # #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='blocksize_stress', figno=42) # plotfigure.show = False # plotfigure.kwargs = {'figsize':[15,10]} # # # # Set up for axes in this figure: # plotaxes = plotfigure.new_plotaxes('Maximum grain size capable of being moved') # #plotaxes.title = 'Water Surface' # plotaxes.scaled = True # plotaxes.xlimits = [94.65,95.0] # plotaxes.ylimits = [28.15,28.35] # # stress # plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') # #plotitem.plot_var = geoplot.surface # plotitem.plot_var = blocksize # plotitem.pcolor_cmap = geoplot.custom_river # plotitem.pcolor_cmin = 0.0 # plotitem.pcolor_cmax = 32.8 #make this reasonable max stress # plotitem.add_colorbar = True #turn off for making movies # plotitem.amr_celledges_show = [0] # plotitem.amr_patchedges_show = [0] # # Land # plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') # plotitem.plot_var = geoplot.land # #plotitem.pcolor_cmap = geoplot.blank # plotitem.pcolor_cmap = geoplot.bw_colormap # plotitem.pcolor_cmin = 100.0 # plotitem.pcolor_cmax = 2000.0 # #plotitem.add_colorbar = True #turn off for making movies # plotitem.amr_celledges_show = [0] # #plotaxes.afteraxes = addgauges #####----------------------------------------- # Tuting zoom (depth) arrives here in Frame 16, t = 1.44e04 #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Tutingzoom_depth', figno=43) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 10]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Depth') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.8, 94.95] plotaxes.ylimits = [28.93, 29.07] # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.depth #variable to plot plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 250 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 800.0 plotitem.pcolor_cmax = 3000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Tuting zoom (speed) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Tutingzoom_speed', figno=44) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 10]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Speed') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.8, 94.95] plotaxes.ylimits = [28.93, 29.07] # speed plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 60 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 800.0 plotitem.pcolor_cmax = 3000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges #####----------------------------------------- # Tuting zoom (stress) #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Tutingzoom_stress', figno=45) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 10]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Stress') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.8, 94.95] plotaxes.ylimits = [28.93, 29.07] # stress plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = stress plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0 plotitem.pcolor_cmax = 30824.0 #make this reasonable max stress plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 800.0 plotitem.pcolor_cmax = 3000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] ############# FOR MIKE #### --> Boulder Bar upstream of Tuting # stress plotfigure = plotdata.new_plotfigure(name='BB_stress', figno=50) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 10]} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Stress') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.9, 94.921] plotaxes.ylimits = [29.04, 29.056] # stress plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = stress plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 30824.0 #make this reasonable max stress plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 450.0 plotitem.pcolor_cmax = 800.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] # # block size # plotfigure = plotdata.new_plotfigure(name='BB_blocksize', figno=51) # plotfigure.show = False # plotfigure.kwargs = {'figsize':[15,10]} # # Set up for axes in this figure: # plotaxes = plotfigure.new_plotaxes('Grain Size capable of being moved') # #plotaxes.title = 'Water Surface' # plotaxes.scaled = True # plotaxes.xlimits = [94.9,94.921] # plotaxes.ylimits = [29.04,29.056] # # stress # plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') # #plotitem.plot_var = geoplot.surface # plotitem.plot_var = blocksize # plotitem.pcolor_cmap = geoplot.custom_river # plotitem.pcolor_cmin = 0.0 # plotitem.pcolor_cmax = 4.1 #make this reasonable max stress # plotitem.add_colorbar = True #turn off for making movies # plotitem.amr_celledges_show = [0] # plotitem.amr_patchedges_show = [0] # # Land # plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') # plotitem.plot_var = geoplot.land # #plotitem.pcolor_cmap = geoplot.blank # plotitem.pcolor_cmap = geoplot.bw_colormap # plotitem.pcolor_cmin = 450.0 # plotitem.pcolor_cmax = 800.0 # #plotitem.add_colorbar = True #turn off for making movies # plotitem.amr_celledges_show = [0] # #plotaxes.afteraxes = addgauges #----------------------------------------- # Figures for gauges #----------------------------------------- #plotfigure = plotdata.new_plotfigure(name='Surface at gauges', figno=300, \ # type='each_gauge') #plotfigure.clf_each_gauge = False # Set up for axes in this figure: #plotaxes = plotfigure.new_plotaxes() #plotaxes.xlimits = 'auto' #plotaxes.ylimits = 'auto' #plotaxes.title = 'Surface' # Plot surface as blue curve: #plotitem = plotaxes.new_plotitem(plot_type='1d_plot') #plotitem.plot_var = 0 #plotitem.plotstyle = 'b-' # Plot topo as green curve: #plotitem = plotaxes.new_plotitem(plot_type='1d_plot') #plotitem.show = False #----------------------------------------- # 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 = np.arange(0,5,1) # list of frames to print #plotdata.print_framenos = [9] #frame is a timestep, so this is the way #plotdata.print_gaugenos = [1,2,3,4] # list of gauges to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = False # 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None, bathy_location=0.15, bathy_angle=0.0, bathy_left=-1.0, bathy_right=-0.2): """Setup the plotting data objects. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. returns plotdata object """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() # Load data from output clawdata = clawutil.ClawInputData(2) clawdata.read(os.path.join(plotdata.outdir, 'claw.data')) multilayer_data = clawpack.geoclaw.data.MultilayerData() multilayer_data.read(os.path.join(plotdata.outdir, 'multilayer.data')) def transform_c2p(x, y, x0, y0, theta): return ((x + x0) * np.cos(theta) - (y + y0) * np.sin(theta), (x + x0) * np.sin(theta) + (y + y0) * np.cos(theta)) def transform_p2c(x, y, x0, y0, theta): return (x * np.cos(theta) + y * np.sin(theta) - x0, -x * np.sin(theta) + y * np.cos(theta) - y0) # Setup bathymetry reference lines with open(os.path.join(plotdata.outdir, "bathy_geometry.data"), 'r') \ as bathy_geometry_file: bathy_location = float(bathy_geometry_file.readline()) bathy_angle = float(bathy_geometry_file.readline()) x = [0.0, 0.0] y = [0.0, 1.0] x1, y1 = transform_c2p(x[0], y[0], bathy_location, 0.0, bathy_angle) x2, y2 = transform_c2p(x[1], y[1], bathy_location, 0.0, bathy_angle) if abs(x1 - x2) < 10**-3: x = [x1, x1] y = [clawdata.lower[1], clawdata.upper[1]] else: m = (y1 - y2) / (x1 - x2) x[0] = (clawdata.lower[1] - y1) / m + x1 y[0] = clawdata.lower[1] x[1] = (clawdata.upper[1] - y1) / m + x1 y[1] = clawdata.upper[1] ref_lines = [((x[0], y[0]), (x[1], y[1]))] plotdata.clearfigures() plotdata.save_frames = False # ======================================================================== # Generic helper functions def pcolor_afteraxes(current_data): bathy_ref_lines(current_data) def contour_afteraxes(current_data): axes = plt.gca() pos = -80.0 * (23e3 / 180) + 500e3 - 5e3 axes.plot([pos, pos], [-300e3, 300e3], 'b', [pos - 5e3, pos - 5e3], [-300e3, 300e3], 'y') wind_contours(current_data) bathy_ref_lines(current_data) def profile_afteraxes(current_data): pass def bathy_ref_lines(current_data): axes = plt.gca() for ref_line in ref_lines: x1 = ref_line[0][0] y1 = ref_line[0][1] x2 = ref_line[1][0] y2 = ref_line[1][1] axes.plot([x1, x2], [y1, y2], 'y--', linewidth=1) # ======================================================================== # Axis limits xlimits = [-0.5, 0.5] ylimits = [-0.5, 0.5] eta = [multilayer_data.eta[0], multilayer_data.eta[1]] top_surface_limits = [eta[0] - 0.03, eta[0] + 0.03] internal_surface_limits = [eta[1] - 0.015, eta[1] + 0.015] top_speed_limits = [0.0, 0.1] internal_speed_limits = [0.0, 0.03] # ======================================================================== # Surface Elevations plotfigure = plotdata.new_plotfigure(name='Surface') plotfigure.show = True plotfigure.kwargs = {'figsize': (14, 4)} # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Surface' plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_surface_elevation(plotaxes, 1, bounds=top_surface_limits) ml_plot.add_land(plotaxes) # Bottom surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Internal Surface' plotaxes.axescmd = 'subplot(1, 2, 2)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_surface_elevation(plotaxes, 2, bounds=internal_surface_limits) ml_plot.add_land(plotaxes) # ======================================================================== # Water Speed plotfigure = plotdata.new_plotfigure(name='speed') plotfigure.show = True plotfigure.kwargs = {'figsize': (14, 4)} # Top layer speed plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents - Top Layer' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_speed(plotaxes, 1, bounds=top_speed_limits) ml_plot.add_land(plotaxes) # Bottom layer speed plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents - Bottom Layer' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(1, 2, 2)' plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_speed(plotaxes, 2, bounds=internal_speed_limits) ml_plot.add_land(plotaxes) # ======================================================================== # Profile Plots # Note that these are not currently plotted by default - set # `plotfigure.show = True` is you want this to be plotted plotfigure = plotdata.new_plotfigure(name='profile') plotfigure.show = False # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = [-1.1, 0.1] plotaxes.title = "Profile of depth" plotaxes.afteraxes = profile_afteraxes slice_index = 30 # Internal surface def bathy_profile(current_data): return current_data.x[:, slice_index], b(current_data)[:, slice_index] def lower_surface(current_data): if multilayer_data.init_type == 2: return current_data.x[:, slice_index], \ eta2(current_data)[:, slice_index] elif multilayer_data.init_type == 6: return current_data.y[slice_index, :], \ eta2(current_data)[slice_index, :] def upper_surface(current_data): if multilayer_data.init_type == 2: return current_data.x[:, slice_index], \ eta1(current_data)[:, slice_index] elif multilayer_data.init_type == 6: return current_data.y[slice_index, :], \ eta1(current_data)[slice_index, :] def top_speed(current_data): if multilayer_data.init_type == 2: return current_data.x[:, slice_index], \ water_u1(current_data)[:, slice_index] elif multilayer_data.init_type == 6: return current_data.y[slice_index, :], \ water_u1(current_data)[slice_index, :] def bottom_speed(current_data): if multilayer_data.init_type == 2: return current_data.x[:, slice_index], \ water_u2(current_data)[:, slice_index] elif multilayer_data.init_type == 6: return current_data.y[slice_index, :], \ water_u2(current_data)[slice_index, :] # Bathy plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') plotitem.map_2d_to_1d = bathy_profile plotitem.plot_var = 0 plotitem.amr_plotstyle = ['-', '+', 'x'] plotitem.color = 'k' plotitem.show = True # Internal Interface plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') plotitem.map_2d_to_1d = lower_surface plotitem.plot_var = 7 plotitem.amr_plotstyle = ['-', '+', 'x'] plotitem.color = 'b' plotitem.show = True # Upper Interface plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') plotitem.map_2d_to_1d = upper_surface plotitem.plot_var = 6 plotitem.amr_plotstyle = ['-', '+', 'x'] plotitem.color = (0.2, 0.8, 1.0) plotitem.show = True # ======================================================================== # Figures for gauges # Top plotfigure = plotdata.new_plotfigure(name='Surface & topo', type='each_gauge', figno=301) plotfigure.show = True plotfigure.clf_each_gauge = True plotfigure.kwargs = {'figsize': (14, 4)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.xlimits = [0.0, 1.0] plotaxes.ylimits = top_surface_limits plotaxes.title = 'Top Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 6 plotitem.plotstyle = 'b-' # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1, 2, 2)' plotaxes.xlimits = [0.0, 1.0] plotaxes.ylimits = internal_surface_limits plotaxes.title = 'Bottom Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 7 plotitem.plotstyle = 'b-' # ========================================================================= # Other plots # Gauge Locations - Enable to see where gauges are located def locations_afteraxes(current_data, gaugenos='all'): gaugetools.plot_gauge_locations(current_data.plotdata, gaugenos=gaugenos, format_string='kx', add_labels=True) pcolor_afteraxes(current_data) plotfigure = plotdata.new_plotfigure(name='Gauge Locations') plotfigure.show = False plotfigure.kwargs = {'figsize': (14, 4)} # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Surface' plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = locations_afteraxes ml_plot.add_surface_elevation(plotaxes, 1, bounds=top_surface_limits) ml_plot.add_land(plotaxes) # Bottom surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Internal Surface' plotaxes.axescmd = 'subplot(1, 2, 2)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = locations_afteraxes ml_plot.add_surface_elevation(plotaxes, 2, bounds=internal_surface_limits) ml_plot.add_land(plotaxes) # ----------------------------------------- # 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_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # Figure with both components plotfigure = plotdata.new_plotfigure(name='h and hu', figno=0) plotfigure.kwargs = {'figsize':(6,8)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(2,1,1)' plotaxes.xlimits = 'auto' plotaxes.ylimits = [0., 4.5] plotaxes.title = 'depth h' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d') plotitem.plot_var = 0 plotitem.plotstyle = '-' plotitem.color = 'b' plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(2,1,2)' plotaxes.xlimits = 'auto' plotaxes.ylimits = [-2., 6.] plotaxes.title = 'momentum hu' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d') plotitem.plot_var = 1 plotitem.plotstyle = '-' plotitem.color = 'b' plotitem.show = True # show on plot? # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot from clawpack.visclaw.data import ClawPlotData from numpy import linspace if plotdata is None: plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from clawpack.visclaw import gaugetools gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos='all', format_string='ko', add_labels=True) def fixup(current_data): import pylab #addgauges(current_data) t = current_data.t t = t / 3600. # hours pylab.title('Surface at %4.2f hours' % t, fontsize=20) pylab.xticks(fontsize=15) pylab.yticks(fontsize=15) #----------------------------------------- # Figure for surface #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.afteraxes = fixup # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.2 plotitem.pcolor_cmax = 0.2 plotitem.add_colorbar = True plotitem.amr_celledges_show = [1,1,0] plotitem.patchedges_show = 1 # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [1,1,0] plotitem.patchedges_show = 1 plotaxes.xlimits = [-120,-60] plotaxes.ylimits = [-60,0] #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface at gauges', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' def add_zeroline(current_data): from pylab import plot, legend, xticks, floor, axis, xlabel t = current_data.t gaugeno = current_data.gaugeno plot(t, 0*t, 'k') n = int(floor(t.max()/3600.) + 2) xticks([3600*i for i in range(n)], ['%i' % i for i in range(n)]) xlabel('time (hours)') plotaxes.afteraxes = add_zeroline #----------------------------------------- # 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot from numpy import linspace if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'ascii' # 'ascii', 'binary', 'netcdf' # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from clawpack.visclaw import gaugetools gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos='all', format_string='ko', add_labels=True) # To add title with time format hours:minutes:seconds... def title_hours(current_data): from pylab import title, mod t = current_data.t hours = int(t / 3600.) tmin = mod(t, 3600.) min = int(tmin / 60.) tsec = mod(tmin, 60.) sec = int(mod(tmin, 60.)) timestr = '%s:%s:%s' % (hours, str(min).zfill(2), str(sec).zfill(2)) title('%s after earthquake' % timestr) #----------------------------------------- # Figure for surface #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface', figno=0) plotfigure.kwargs = {'figsize': (12, 6)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.axescmd = 'subplot(121)' plotaxes.title = 'Surface' plotaxes.scaled = True def fixup(current_data): addgauges(current_data) title_hours(current_data) plotaxes.afteraxes = fixup # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.2 plotitem.pcolor_cmax = 0.2 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 1 # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 plotaxes.xlimits = [-120, -60] plotaxes.ylimits = [-60, 0] # add contour lines of bathy if desired: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.show = False plotitem.plot_var = geoplot.topo plotitem.contour_levels = linspace(-3000, -3000, 1) plotitem.amr_contour_colors = ['y'] # color on each level plotitem.kwargs = {'linestyles': 'solid', 'linewidths': 2} plotitem.amr_contour_show = [1, 0, 0] plotitem.celledges_show = 0 plotitem.patchedges_show = 0 #----------------------------------------- # Figure for adjoint flagging #----------------------------------------- # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('adjoint') plotaxes.axescmd = 'subplot(122)' plotaxes.scaled = True plotaxes.title = 'Adjoint flag' def fixup(current_data): addgauges(current_data) plotaxes.afteraxes = fixup def masked_inner_product(current_data): from numpy import ma aux = current_data.aux tol = 1e-15 soln = ma.masked_where(aux[3, :, :] < tol, aux[3, :, :]) return soln plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = masked_inner_product plotitem.pcolor_cmap = colormaps.white_red plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 0.005 #plotitem.pcolor_cmax = 0.00001 # use for adjoint-error flagging plotitem.add_colorbar = False # doesn't work when adjoint all masked plotitem.colorbar_shrink = 0.75 plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_data_show = [1, 1, 0] # inner product not computed on finest level plotitem.patchedges_show = 0 # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 plotaxes.xlimits = [-120, -60] plotaxes.ylimits = [-60, 0] #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface at gauges', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # Plot topo as green curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.show = False def gaugetopo(current_data): q = current_data.q h = q[0, :] eta = q[3, :] topo = eta - h return topo plotitem.plot_var = gaugetopo plotitem.plotstyle = 'g-' def add_zeroline(current_data): from pylab import plot, legend, xticks, floor, axis, xlabel t = current_data.t gaugeno = current_data.gaugeno if gaugeno == 32412: try: plot(TG32412[:, 0], TG32412[:, 1], 'r') legend(['GeoClaw', 'Obs'], loc='lower right') except: pass axis((0, t.max(), -0.3, 0.3)) plot(t, 0 * t, 'k') n = int(floor(t.max() / 3600.) + 2) xticks([3600 * i for i in range(n)], ['%i' % i for i in range(n)]) xlabel('time (hours)') plotaxes.afteraxes = add_zeroline #----------------------------------------- # 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data def fix_plot(current_data): from pylab import plot from pylab import xticks,yticks,xlabel,ylabel,savefig,ylim,title t = current_data.t plot([0., 0.], [-1000., 1000.], 'k--') title('Pressure at t = %5.3f seconds' % t, fontsize=26) yticks(fontsize=23) xticks(fontsize=23) def fix_plot_innerprod(current_data): from pylab import plot from pylab import xticks,yticks,xlabel,ylabel,savefig,ylim,title t = current_data.t plot([0., 0.], [-1000., 1000.], 'k--') title('Pressure at t = %5.3f seconds' % t, fontsize=26) yticks(fontsize=23) xticks(fontsize=23) # Figure for q[0] plotfigure = plotdata.new_plotfigure(name='Pressure', figno=1) plotfigure.kwargs = {'figsize': (10,3.5)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-12,12] plotaxes.ylimits = [-1.1,1.1] plotaxes.title = 'Pressure' plotaxes.afteraxes = fix_plot # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.amr_color = 'b' plotitem.amr_plotstyle = 'o' plotitem.amr_kwargs = [{'linewidth':2}] plotitem.amr_kwargs = [{'markersize':4}] # Figure for inner product, q[2] plotfigure = plotdata.new_plotfigure(name='Inner Product', figno=10) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' #plotaxes.ylimits = [-.5,1.1] # use when taking inner product with forward solution plotaxes.ylimits = [0,0.02] # use when taking inner product with Richardson error plotaxes.title = 'Inner Product' plotaxes.afteraxes = fix_plot_innerprod # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d') plotitem.plot_var = 2 plotitem.amr_color = 'b' plotitem.amr_plotstyle = 'o' plotitem.amr_kwargs = [{'linewidth':2}] plotitem.amr_data_show = [1,1,1,0] plotitem.show = True # show on plot? # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data print("**** Python plotting tools not yet implemented in 3d") print("**** No frames will be generated.") #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = False # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'density' # Plot q as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = 'b-' plotfigure = plotdata.new_plotfigure(figno=301, \ type='each_gauge') plotfigure.clf_each_gauge = False # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'energy' # Plot q as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 4 plotitem.plotstyle = 'b-' plotfigure = plotdata.new_plotfigure(figno=302, \ type='each_gauge') plotfigure.clf_each_gauge = False # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'speed' def speed(current_data): from numpy import sqrt q = current_data.q s = sqrt(q[1, :]**2 + q[2, :]**2 + q[3, :]**2) / q[0, :] return s # Plot q as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = speed plotitem.plotstyle = 'b-' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = False # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = [] # list of frames to print plotdata.print_fignos = [] # list of figures to print plotdata.html = False # create html files of plots? plotdata.html_homelink = '../README.html' # pointer for top of index plotdata.html_movie = 'JSAnimation' # new style, or "4.x" for old style 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() from clawpack.visclaw import colormaps, geoplot plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'ascii' # Format of output print('Reading all gauges...') gauge_solutions = particle_tools.read_gauges(gaugenos='all', outdir=plotdata.outdir) gaugenos_lagrangian = [k for k in gauge_solutions.keys() \ if gauge_solutions[k].gtype=='lagrangian'] gaugenos_stationary = [k for k in gauge_solutions.keys() \ if gauge_solutions[k].gtype=='stationary'] print('+++ gaugenos_lagrangian: ',gaugenos_lagrangian) def add_particles(current_data): t = current_data.t # plot recent path: t_path_length = 0.5 # length of path trailing particle kwargs_plot_path = {'linewidth':1, 'color':'k'} particle_tools.plot_paths(gauge_solutions, t1=t-t_path_length, t2=t, gaugenos=gaugenos_lagrangian, kwargs_plot=kwargs_plot_path) # plot current location: kwargs_plot_point = {'marker':'o','markersize':3,'color':'k'} particle_tools.plot_particles(gauge_solutions, t, gaugenos=gaugenos_lagrangian, kwargs_plot=kwargs_plot_point) # plot any stationary gauges: gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos=gaugenos_stationary, format_string='kx', add_labels=False) kwargs={'loc':'upper left'} legend_tools.add_legend(['Lagrangian particle','Stationary gauge'], linestyles=['',''], markers=['o','x'], loc='lower right', framealpha=0.5, fontsize=10) def speed(current_data): from pylab import sqrt, where, zeros from numpy.ma import masked_where, allequal q = current_data.q h = q[0,:,:] hs = sqrt(q[1,:,:]**2 + q[2,:,:]**2) s = where(h>1e-3, hs/h, 0.) s = masked_where(h<1e-3, s) #s = s * 1.94384 # convert to knots return s speed_cmap = colormaps.make_colormap({0:[0,1,1], 0.5:[1,1,0], 1:[1,0,0]}) #----------------------------------------- # Figure for pcolor plot #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='pcolor', figno=0) plotfigure.kwargs = {'figsize': (9,4)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Speed' plotaxes.scaled = True plotaxes.xlimits = [0,80] plotaxes.ylimits = [0,50] plotaxes.afteraxes = add_particles # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = speed plotitem.pcolor_cmap = speed_cmap plotitem.pcolor_cmin = 0. plotitem.pcolor_cmax = 10 plotitem.add_colorbar = True plotitem.colorbar_label = 'm/s' plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1] plotitem.amr_patchedges_color = ['m','g','w'] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.show = False plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0,0,0] # Add contour lines of topography: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.show = False plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = arange(-75,75,10) #plotitem.contour_nlevels = 10 plotitem.amr_contour_colors = ['g'] # color on each level plotitem.kwargs = {'linestyles':'solid'} plotitem.amr_contour_show = [1,1,1] # show contours only on finest level plotitem.celledges_show = 0 plotitem.patchedges_show = 0 #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = [-25,50] plotaxes.title = 'Surface' # reset in fix_gauge # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' def fix_gauge(current_data): from pylab import plot, title t = current_data.t plot(t, 0*t, 'k') gaugeno = current_data.gaugeno if gaugeno in gaugenos_stationary: title('Surface elevation at stationary gauge %s' % gaugeno) else: title('Surface elevation at lagrangian gauge %s' % gaugeno) plotaxes.afteraxes = fix_gauge #----------------------------------------- # 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 = range(40) plotdata.print_gaugenos = [15,25] # 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? plotdata.parallel = True # make multiple frame png's at once plotdata.html_movie_width = 700 # width used in JSAnimation return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ import os import numpy as np import matplotlib.pyplot as plt from clawpack.visclaw import geoplot, gaugetools, colormaps import clawpack.clawutil.data as clawutil import clawpack.amrclaw.data as amrclaw import clawpack.geoclaw.data import clawpack.geoclaw.multilayer.plot as ml_plot if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() from numpy import linspace plotdata.clearfigures() # clear any old figures,axes,items data plotdata.save_frames = False # 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')) geodata = clawpack.geoclaw.data.GeoClawData() geodata.read(os.path.join(plotdata.outdir, 'geoclaw.data')) multilayer_data = clawpack.geoclaw.data.MultilayerData() multilayer_data.read(os.path.join(plotdata.outdir, 'multilayer.data')) # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from clawpack.visclaw import gaugetools gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos='all', format_string='ko', add_labels=True) # ======================================================================== # Generic helper functions # ======================================================================== def pcolor_afteraxes(current_data): # bathy_ref_lines(current_data) gauge_locations(current_data) def contour_afteraxes(current_data): # gauge_locations(current_data) # m_to_km_labels() plt.hold(True) pos = -80.0 * (23e3 / 180) + 500e3 - 5e3 plt.plot([pos, pos], [-300e3, 300e3], 'b', [pos - 5e3, pos - 5e3], [-300e3, 300e3], 'y') plt.hold(False) wind_contours(current_data) bathy_ref_lines(current_data) def profile_afteraxes(current_data): pass def gauge_locations(current_data, gaugenos='all'): plt.hold(True) gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos=gaugenos, format_string='kx', add_labels=True) plt.hold(False) # ======================================================================== # Axis limits # xlimits = [amrdata.xlower,amrdata.xupper] xlimits = [-100.0, 100.0] # ylimits = [amrdata.ylower,amrdata.yupper] ylimits = [-100.0, 100.0] eta = [multilayer_data.eta[0], multilayer_data.eta[1]] top_surface_limits = [eta[0] - 10, eta[0] + 10] internal_surface_limits = [eta[1] - 5, eta[1] + 5] depth_limits = [0.0, 0.4] top_speed_limits = [0.0, 0.1] internal_speed_limits = [0.0, 0.03] # ======================================================================== # Surface Elevations # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface', figno=0) plotfigure.show = True plotfigure.kwargs = {'figsize': (14, 4)} # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Surface' plotaxes.axescmd = 'subplot(1,2,1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits ml_plot.add_inundation(plotaxes, 1, bounds=depth_limits) ml_plot.add_surface_elevation(plotaxes, 1, bounds=top_surface_limits) ml_plot.add_land(plotaxes, 1) # Bottom surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Internal Surface' plotaxes.axescmd = 'subplot(1,2,2)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits ml_plot.add_inundation(plotaxes, 2, bounds=depth_limits) ml_plot.add_surface_elevation(plotaxes, 2, bounds=internal_surface_limits) ml_plot.add_colorbar = True ml_plot.add_land(plotaxes, 2) # ======================================================================== # Figure for cross section # ======================================================================== plotfigure = plotdata.new_plotfigure(name='cross-section', figno=4) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title = 'Cross section at y=0' ml_plot.add_cross_section(plotaxes, 1) ml_plot.add_cross_section(plotaxes, 2) ml_plot.add_land_cross_section(plotaxes) # ======================================================================== # Water Speed # ======================================================================== plotfigure = plotdata.new_plotfigure(name='speed', figno=1) plotfigure.show = False plotfigure.kwargs = {'figsize': (14, 4)} # Top layer speed plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents - Top Layer' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(1,2,1)' ml_plot.add_speed(plotaxes, 1, bounds=top_speed_limits) ml_plot.add_land(plotaxes, 1) # Bottom layer speed plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents - Bottom Layer' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(1,2,2)' ml_plot.add_speed(plotaxes, 2, bounds=internal_speed_limits) ml_plot.add_land(plotaxes, 2) # Individual components plotfigure = plotdata.new_plotfigure(name='speed_components', figno=401) plotfigure.show = False plotfigure.kwargs = {'figsize': (14, 14)} # Top layer plotaxes = plotfigure.new_plotaxes() plotaxes.title = "X-Velocity - Top Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,1)' ml_plot.add_x_velocity(plotaxes, 1) ml_plot.add_land(plotaxes, 1) plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Y-Velocity - Top Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,2)' ml_plot.add_y_velocity(plotaxes, 1) ml_plot.add_land(plotaxes, 1) # Bottom layer plotaxes = plotfigure.new_plotaxes() plotaxes.title = "X-Velocity - Bottom Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,3)' ml_plot.add_x_velocity(plotaxes, 2) ml_plot.add_land(plotaxes, 2) plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Y-Velocity - Bottom Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,4)' ml_plot.add_y_velocity(plotaxes, 2) ml_plot.add_land(plotaxes, 2) #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface at gauges', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # Plot topo as green curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.show = False def gaugetopo(current_data): q = current_data.q h = q[0, :] eta = q[3, :] topo = eta - h return topo plotitem.plot_var = gaugetopo plotitem.plotstyle = 'g-' def add_zeroline(current_data): from pylab import plot, legend, xticks, floor, axis, xlabel t = current_data.t gaugeno = current_data.gaugeno if gaugeno == 32412: try: plot(TG32412[:, 0], TG32412[:, 1], 'r') legend(['GeoClaw', 'Obs'], loc='lower right') except: pass axis((0, t.max(), -0.3, 0.3)) plot(t, 0 * t, 'k') n = int(floor(t.max() / 3600.) + 2) xticks([3600 * i for i in range(n)], ['%i' % i for i in range(n)]) xlabel('time (hours)') #----------------------------------------- # 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() from clawpack.visclaw import colormaps plotdata.clearfigures() # clear any old figures,axes,items data # Figure for pcolor plot plotfigure = plotdata.new_plotfigure(name='q[0]', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'q[0]' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = 0 plotitem.pcolor_cmap = colormaps.red_yellow_blue plotitem.pcolor_cmin = -1. plotitem.pcolor_cmax = 1. plotitem.add_colorbar = True plotitem.celledges_show = 0 plotitem.patchedges_show = 1 plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotitem.show = True # show on plot? # Figure for contour plot plotfigure = plotdata.new_plotfigure(name='contour', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'q[0]' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = 0 plotitem.contour_levels = np.linspace(-0.9, 0.9, 10) plotitem.contour_colors = 'k' plotitem.patchedges_show = 1 plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotitem.show = True # show on plot? # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot from numpy import linspace if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'ascii' # 'ascii' or 'binary' to match setrun.py # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from clawpack.visclaw import gaugetools gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos='all', format_string='ko', add_labels=True) #----------------------------------------- # Figure for surface #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Surface' plotaxes.scaled = True def fixup(current_data): import pylab addgauges(current_data) t = current_data.t t = t / 3600. # hours pylab.title('Surface at %4.2f hours' % t, fontsize=20) pylab.xticks(fontsize=15) pylab.yticks(fontsize=15) plotaxes.afteraxes = fixup # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.2 plotitem.pcolor_cmax = 0.2 plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.patchedges_show = 1 # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [1,1,0] plotitem.patchedges_show = 1 plotaxes.xlimits = [-120,-60] plotaxes.ylimits = [-60,0] # add contour lines of bathy if desired: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.show = False plotitem.plot_var = geoplot.topo plotitem.contour_levels = linspace(-3000,-3000,1) plotitem.amr_contour_colors = ['y'] # color on each level plotitem.kwargs = {'linestyles':'solid','linewidths':2} plotitem.amr_contour_show = [1,0,0] plotitem.celledges_show = 0 plotitem.patchedges_show = 0 #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface at gauges', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # Plot topo as green curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.show = False def gaugetopo(current_data): q = current_data.q h = q[0,:] eta = q[3,:] topo = eta - h return topo plotitem.plot_var = gaugetopo plotitem.plotstyle = 'g-' def add_zeroline(current_data): from pylab import plot, legend, xticks, floor, axis, xlabel t = current_data.t gaugeno = current_data.gaugeno if gaugeno == 32412: try: plot(TG32412[:,0], TG32412[:,1], 'r') legend(['GeoClaw','Obs'],loc='lower right') except: pass axis((0,t.max(),-0.3,0.3)) plot(t, 0*t, 'k') n = int(floor(t.max()/3600.) + 2) xticks([3600*i for i in range(n)], ['%i' % i for i in range(n)]) xlabel('time (hours)') plotaxes.afteraxes = add_zeroline #----------------------------------------- # 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data def set_drytol(current_data): # The drytol parameter is used in masking land and water and # affects what color map is used for cells with small water depth h. # The cell will be plotted as dry if h < drytol. # The best value to use often depends on the application and can # be set here (measured in meters): current_data.user["drytol"] = 1.e-3 plotdata.beforeframe = set_drytol #----------------------------------------- # Figure for pcolor plot #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='pcolor', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Surface' plotaxes.scaled = True # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.surface plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.1 plotitem.pcolor_cmax = 0.1 plotitem.add_colorbar = True plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 1 # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 1 plotaxes.xlimits = [-2, 2] plotaxes.ylimits = [-2, 2] # Add contour lines of bathymetry: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = linspace(-.1, 0.5, 20) plotitem.amr_contour_colors = ['k'] # color on each level plotitem.kwargs = {'linestyles': 'solid'} plotitem.amr_contour_show = [1] plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True #----------------------------------------- # Figure for cross section #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='cross-section', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-2, 2] plotaxes.ylimits = [-0.15, 0.3] plotaxes.title = 'Cross section at y=0' def plot_topo_xsec(current_data): from pylab import plot, cos, sin, where, legend, nan t = current_data.t x = linspace(-2, 2, 201) y = 0. B = h0 * (x**2 + y**2) / a**2 - h0 eta1 = sigma * h0 / a**2 * (2. * x * cos(omega * t) + 2. * y * sin(omega * t) - sigma) etatrue = where(eta1 > B, eta1, nan) plot(x, etatrue, 'r', label="true solution", linewidth=2) plot(x, B, 'g', label="bathymetry") ## plot([0],[-1],'kx',label="Level 1") # shouldn't show up in plots, ## plot([0],[-1],'bo',label="Level 2") # but will produced desired legend plot([0], [-1], 'bo', label="Computed") ## need to fix plotstyle legend() plotaxes.afteraxes = plot_topo_xsec plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') def xsec(current_data): # Return x value and surface eta at this point, along y=0 from pylab import find, ravel x = current_data.x y = current_data.y dy = current_data.dy q = current_data.q ij = find((y <= dy / 2.) & (y > -dy / 2.)) x_slice = ravel(x)[ij] eta_slice = ravel(q[3, :, :])[ij] return x_slice, eta_slice plotitem.map_2d_to_1d = xsec plotitem.plotstyle = 'kx' ## need to be able to set amr_plotstyle plotitem.kwargs = {'markersize': 3} plotitem.amr_show = [1] # plot on all levels #----------------------------------------- # Figure for grids alone #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='grids', figno=2) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-2, 2] plotaxes.ylimits = [-2, 2] plotaxes.title = 'grids' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = [1, 1, 0] plotitem.amr_patchedges_show = [1] #----------------------------------------- # 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 = [] # 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() from clawpack.visclaw import colormaps plotdata.clearfigures() # clear any old figures,axes,items data #----------------------------------------- # Figure for pcolor plot #----------------------------------------- def change_fonts(current_data): pylab.xticks(fontsize=21, fontname="Tex Gyre Pagella") pylab.yticks(fontsize=21, fontname="Tex Gyre Pagella") "Fill the step area with a black rectangle." import matplotlib.pyplot as plt rectangle = plt.Rectangle((x1, y1), 0.4, 0.4, color="k", fill=True) plt.gca().add_patch(rectangle) def change_fonts2(current_data): pylab.xticks(fontsize=17, fontname="Tex Gyre Pagella") pylab.yticks(fontsize=17, fontname="Tex Gyre Pagella") "Fill the step area with a black rectangle." import matplotlib.pyplot as plt rectangle = plt.Rectangle((x1, y1), 0.4, 0.4, color="k", fill=True) plt.gca().add_patch(rectangle) plotfigure = plotdata.new_plotfigure(name='q[0]', figno=0) plotfigure.kwargs = {'figsize': [10, 10], 'facecolor': 'white'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Depth Contour' plotaxes.scaled = False # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = 0 plotitem.pcolor_cmap = colormaps.yellow_red_blue # not the default colormap plotitem.pcolor_cmin = 0.00 plotitem.pcolor_cmax = 2.80 * hn plotitem.add_colorbar = True plotitem.celledges_show = 0 plotitem.patchedges_show = 1 plotitem.show = True # show on plot? plotaxes.afteraxes = change_fonts #----------------------------------------- # Figure for zoomed-in pcolor plot #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='q[0]_zoomed', figno=1) plotfigure.kwargs = {'figsize': [10, 10], 'facecolor': 'white'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [39.4, domain_x] plotaxes.ylimits = [-domain_y / 2.0, domain_y / 2.0] plotaxes.title = 'Zoomed-in Depth Contour' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = 0 plotitem.pcolor_cmap = colormaps.yellow_red_blue # not the default colormap plotitem.pcolor_cmin = 0.00 plotitem.pcolor_cmax = 5.00 * hn plotitem.add_colorbar = True plotitem.celledges_show = 0 plotitem.patchedges_show = 1 plotitem.show = True # show on plot? plotaxes.afteraxes = change_fonts2 #----------------------------------------- # Figure for momentum pcolor plot #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='q[1]', figno=2) plotfigure.kwargs = {'figsize': [10, 10], 'facecolor': 'white'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'qx Contour' plotaxes.scaled = False # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = 1 plotitem.pcolor_cmap = colormaps.yellow_red_blue # not the default colormap plotitem.pcolor_cmin = 0.00 plotitem.pcolor_cmax = 'auto' plotitem.add_colorbar = True plotitem.celledges_show = 0 plotitem.patchedges_show = 1 plotitem.show = True # show on plot? plotaxes.afteraxes = change_fonts2 #----------------------------------------- # Figure for cross section at y=0 #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='cross-section', figno=3) plotfigure.kwargs = {'figsize': [10, 10], 'facecolor': 'white'} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0.0, domain_x] plotaxes.ylimits = [0.0, hn * 9.0] plotaxes.title = 'Cross section at y=0' def plot_topo_xsec(current_data): from pylab import plot, cos, sin, where, legend, nan t = current_data.t x = np.linspace(0.0, domain_x, 201) #y = 0. B = where(x > 40.0, where(x < 40.40, 7.0, 0.0), 0.0) plot(x, B, 'g', label="bathymetry") legend() pylab.xticks(fontsize=17, fontname="Tex Gyre Pagella") pylab.yticks(fontsize=17, fontname="Tex Gyre Pagella") plotaxes.afteraxes = plot_topo_xsec plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') def xsec(current_data): # Return x value and surface depth at this point, along y=0 from pylab import where, ravel x = current_data.x y = ravel(current_data.y) dy = current_data.dy q = current_data.q ij = where((y <= dy / 1.) & (y > -dy / 1.)) x_slice = ravel(x)[ij] ij1 = where((x_slice > 40.40) | (x_slice < 40.0)) x_slice = x_slice[ij1] depth_slice = ravel(q[0, :, :])[ij] depth_slice = depth_slice[ij1] return x_slice, depth_slice plotitem.map_2d_to_1d = xsec plotitem.plotstyle = 'k-o' ## need to be able to set amr_plotstyle plotitem.kwargs = {'markersize': 4} # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_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=None, bathy_location=0.15, bathy_angle=0.0, bathy_left=-1.0, bathy_right=-0.2): """Setup the plotting data objects. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. returns plotdata object """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() # Load data from output clawdata = clawutil.ClawInputData(2) clawdata.read(os.path.join(plotdata.outdir, 'claw.data')) multilayer_data = clawpack.geoclaw.data.MultilayerData() multilayer_data.read(os.path.join(plotdata.outdir, 'multilayer.data')) def transform_c2p(x, y, x0, y0, theta): return ((x + x0) * np.cos(theta) - (y + y0) * np.sin(theta), (x + x0) * np.sin(theta) + (y + y0) * np.cos(theta)) def transform_p2c(x, y, x0, y0, theta): return (x * np.cos(theta) + y * np.sin(theta) - x0, -x * np.sin(theta) + y * np.cos(theta) - y0) # Setup bathymetry reference lines with open(os.path.join(plotdata.outdir, "bathy_geometry.data"), 'r') \ as bathy_geometry_file: bathy_location = float(bathy_geometry_file.readline()) bathy_angle = float(bathy_geometry_file.readline()) x = [0.0, 0.0] y = [0.0, 1.0] x1, y1 = transform_c2p(x[0], y[0], bathy_location, 0.0, bathy_angle) x2, y2 = transform_c2p(x[1], y[1], bathy_location, 0.0, bathy_angle) if abs(x1 - x2) < 10**-3: x = [x1, x1] y = [clawdata.lower[1], clawdata.upper[1]] else: m = (y1 - y2) / (x1 - x2) x[0] = (clawdata.lower[1] - y1) / m + x1 y[0] = clawdata.lower[1] x[1] = (clawdata.upper[1] - y1) / m + x1 y[1] = clawdata.upper[1] ref_lines = [((x[0], y[0]), (x[1], y[1]))] plotdata.clearfigures() plotdata.save_frames = False # ======================================================================== # Generic helper functions def pcolor_afteraxes(current_data): bathy_ref_lines(current_data) def contour_afteraxes(current_data): axes = plt.gca() pos = -80.0 * (23e3 / 180) + 500e3 - 5e3 axes.plot([pos, pos], [-300e3, 300e3], 'b', [pos - 5e3, pos - 5e3], [-300e3, 300e3], 'y') wind_contours(current_data) bathy_ref_lines(current_data) def profile_afteraxes(current_data): pass def bathy_ref_lines(current_data): axes = plt.gca() for ref_line in ref_lines: x1 = ref_line[0][0] y1 = ref_line[0][1] x2 = ref_line[1][0] y2 = ref_line[1][1] axes.plot([x1, x2], [y1, y2], 'y--', linewidth=1) # ======================================================================== # Axis limits # xlimits = [5., 10.] # ylimits = [25., 30.] xlimits = [-25., 25.] ylimits = [20., 60.] eta = [multilayer_data.eta[0], multilayer_data.eta[1]] top_surface_limits = [eta[0] - 0.03, eta[0] + 0.03] internal_surface_limits = [eta[1] - 0.03, eta[1] + 0.03] top_speed_limits = [0.0, 0.1] internal_speed_limits = [0.0, 0.03] # ======================================================================== # Surface Elevations plotfigure = plotdata.new_plotfigure(name='Surface1') plotfigure.show = True plotfigure.kwargs = {'figsize': (14, 4)} # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Surface' plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits # plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_surface_elevation(plotaxes, 0, bounds=top_surface_limits) # ml_plot.add_surface_elevation(plotaxes,0,bounds=[-0.06,0.06]) # ml_plot.add_surface_elevation(plotaxes,0) ml_plot.add_land(plotaxes, 0) # Bottom surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Internal Surface' plotaxes.axescmd = 'subplot(1,2,2)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits # plotaxes.afteraxes = pcolor_afteraxes # ml_plot.add_surface_elevation(plotaxes,1,bounds=[-300-0.5,-300+0.5]) ml_plot.add_surface_elevation(plotaxes, 1, bounds=internal_surface_limits) # ml_plot.add_surface_elevation(plotaxes,1) ml_plot.add_land(plotaxes, 1) # ======================================================================== # Surface Elevations plotfigure = plotdata.new_plotfigure(name='Surface') plotfigure.show = True plotfigure.kwargs = {'figsize': (14, 4)} # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Surface' plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_surface_elevation(plotaxes, 0, bounds=top_surface_limits) # ml_plot.add_surface_elevation(plotaxes,0,bounds=[-0.06,0.06]) # ml_plot.add_surface_elevation(plotaxes,0) ml_plot.add_land(plotaxes, 0) # Bottom surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Internal Surface' plotaxes.axescmd = 'subplot(1,2,2)' plotaxes.scaled = True plotaxes.xlimits = [-20, 20] plotaxes.ylimits = [20, 60] plotaxes.afteraxes = pcolor_afteraxes # ml_plot.add_surface_elevation(plotaxes,1,bounds=[-300-0.5,-300+0.5]) ml_plot.add_surface_elevation(plotaxes, 1, bounds=internal_surface_limits) # ml_plot.add_surface_elevation(plotaxes,1) ml_plot.add_land(plotaxes, 1) # ======================================================================== # Depths # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Depths', figno=42) plotfigure.show = False plotfigure.kwargs = {'figsize': (14, 4)} # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Layer Depth' plotaxes.axescmd = 'subplot(1,2,1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_layer_depth(plotaxes, 0, bounds=[-0.1, 1.1]) ml_plot.add_land(plotaxes, 0) # Bottom surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Bottom Layer Depth' plotaxes.axescmd = 'subplot(1,2,2)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_layer_depth(plotaxes, 1, bounds=[-0.1, 0.7]) ml_plot.add_land(plotaxes, 1) # ======================================================================== # Water Speed plotfigure = plotdata.new_plotfigure(name='speed') plotfigure.show = True plotfigure.kwargs = {'figsize': (14, 4)} # Top layer speed plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents - Top Layer' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_speed(plotaxes, 0, bounds=top_speed_limits) ml_plot.add_land(plotaxes, 0) # Bottom layer speed plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents - Bottom Layer' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(1,2,2)' plotaxes.afteraxes = pcolor_afteraxes # add_speed(plotaxes,1,bounds=[0.0,1e-10]) ml_plot.add_speed(plotaxes, 1, bounds=internal_speed_limits) # add_speed(plotaxes,1) ml_plot.add_land(plotaxes, 1) # Individual components plotfigure = plotdata.new_plotfigure(name='speed_components', figno=401) plotfigure.show = False plotfigure.kwargs = {'figsize': (14, 14)} # Top layer plotaxes = plotfigure.new_plotaxes() plotaxes.title = "X-Velocity - Top Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,1)' plotaxes.afteraxes = pcolor_afteraxes # add_x_velocity(plotaxes,0,bounds=[-1e-10,1e-10]) ml_plot.add_x_velocity(plotaxes, 0) ml_plot.add_land(plotaxes, 0) plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Y-Velocity - Top Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,2)' plotaxes.afteraxes = pcolor_afteraxes # add_y_velocity(plotaxes,0,bounds=[-0.000125,0.000125]) ml_plot.add_y_velocity(plotaxes, 0) ml_plot.add_land(plotaxes, 0) # Bottom layer plotaxes = plotfigure.new_plotaxes() plotaxes.title = "X-Velocity - Bottom Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,3)' plotaxes.afteraxes = pcolor_afteraxes # add_x_velocity(plotaxes,1,bounds=[-1e-10,1e-10]) ml_plot.add_x_velocity(plotaxes, 1) ml_plot.add_land(plotaxes, 1) plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Y-Velocity - Bottom Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,4)' plotaxes.afteraxes = pcolor_afteraxes # add_y_velocity(plotaxes,1,bounds=[-0.8e-6,.8e-6]) ml_plot.add_y_velocity(plotaxes, 1) ml_plot.add_land(plotaxes, 1) # ======================================================================== # Profile Plots # Note that these are not currently plotted by default - set # `plotfigure.show = True` is you want this to be plotted plotfigure = plotdata.new_plotfigure(name='profile') plotfigure.show = False # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = [-1.1, 0.1] plotaxes.title = "Profile of depth" plotaxes.afteraxes = profile_afteraxes slice_index = 30 # Internal surface def bathy_profile(current_data): return current_data.x[:, slice_index], b(current_data)[:, slice_index] def lower_surface(current_data): if multilayer_data.init_type == 2: return current_data.x[:, slice_index], \ eta2(current_data)[:, slice_index] elif multilayer_data.init_type == 6: return current_data.y[slice_index, :], \ eta2(current_data)[slice_index, :] def upper_surface(current_data): if multilayer_data.init_type == 2: return current_data.x[:, slice_index], \ eta1(current_data)[:, slice_index] elif multilayer_data.init_type == 6: return current_data.y[slice_index, :], \ eta1(current_data)[slice_index, :] def top_speed(current_data): if multilayer_data.init_type == 2: return current_data.x[:, slice_index], \ water_u1(current_data)[:, slice_index] elif multilayer_data.init_type == 6: return current_data.y[slice_index, :], \ water_u1(current_data)[slice_index, :] def bottom_speed(current_data): if multilayer_data.init_type == 2: return current_data.x[:, slice_index], \ water_u2(current_data)[:, slice_index] elif multilayer_data.init_type == 6: return current_data.y[slice_index, :], \ water_u2(current_data)[slice_index, :] # Bathy plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') plotitem.map_2d_to_1d = bathy_profile plotitem.plot_var = 0 plotitem.amr_plotstyle = ['-', '+', 'x'] plotitem.color = 'k' plotitem.show = True # Internal Interface plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') plotitem.map_2d_to_1d = lower_surface plotitem.plot_var = 7 plotitem.amr_plotstyle = ['-', '+', 'x'] plotitem.color = 'b' plotitem.show = True # Upper Interface plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') plotitem.map_2d_to_1d = upper_surface plotitem.plot_var = 6 plotitem.amr_plotstyle = ['-', '+', 'x'] plotitem.color = (0.2, 0.8, 1.0) plotitem.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Y-Velocity' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = pcolor_afteraxes # Water # plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') # # plotitem.plot_var = geoplot.surface # plotitem.plot_var = water_v # plotitem.pcolor_cmap = colormaps.make_colormap({1.0:'r',0.5:'w',0.0:'b'}) # # plotitem.pcolor_cmin = -1.e-10 # # plotitem.pcolor_cmax = 1.e-10 # # plotitem.pcolor_cmin = -2.5 # -3.0 # # plotitem.pcolor_cmax = 2.5 # 3.0 # plotitem.add_colorbar = True # plotitem.amr_celledges_show = [0,0,0] # plotitem.amr_patchedges_show = [1,1,1] # Land ml_plot.add_land(plotaxes, 0) # ======================================================================== # Contour plot for surface # ======================================================================== plotfigure = plotdata.new_plotfigure(name='contour_surface', figno=15) plotfigure.show = False plotfigure.kwargs = {'figsize': (14, 4)} # Set up for axes in this figure: # Top Surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Surface' plotaxes.axescmd = 'subplot(1,2,1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = contour_afteraxes ml_plot.add_surface_elevation(plotaxes, plot_type='contour', surface=1, bounds=[-2.5, -1.5, -0.5, 0.5, 1.5, 2.5]) ml_plot.add_land(plotaxes, 0, plot_type='contour') # Internal Surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Internal Surface' plotaxes.axescmd = 'subplot(1,2,2)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = contour_afteraxes ml_plot.add_surface_elevation(plotaxes, plot_type='contour', surface=2, bounds=[-2.5, -1.5, -0.5, 0.5, 1.5, 2.5]) ml_plot.add_land(plotaxes, 1, plot_type='contour') # ======================================================================== # Contour plot for speed # ======================================================================== plotfigure = plotdata.new_plotfigure(name='contour_speed', figno=16) plotfigure.show = False plotfigure.kwargs = {'figsize': (14, 4)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Current' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = contour_afteraxes # Surface plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = ml_plot.water_speed_depth_ave plotitem.kwargs = {'linewidths': 1} # plotitem.contour_levels = [1.0,2.0,3.0,4.0,5.0,6.0] plotitem.contour_levels = [0.5, 1.5, 3, 4.5, 6.0] plotitem.amr_contour_show = [1, 1, 1] plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [1, 1, 1] plotitem.amr_contour_colors = 'k' # plotitem.amr_contour_colors = ['r','k','b'] # color on each level # plotitem.amr_grid_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.show = True # Land plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.land plotitem.contour_nlevels = 40 plotitem.contour_min = 0.0 plotitem.contour_max = 100.0 plotitem.amr_contour_colors = ['g'] # color on each level plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = 0 plotitem.amr_patchedges_show = 0 plotitem.show = True # ======================================================================== # Grid Cells # ======================================================================== # Figure for grid cells plotfigure = plotdata.new_plotfigure(name='cells', figno=2) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title = 'Grid patches' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = [0, 0, 0] plotitem.amr_patchedges_show = [1, 1, 1] # ======================================================================== # Figure for cross section # ======================================================================== plotfigure = plotdata.new_plotfigure(name='cross-section', figno=4) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = [-4010, 2050] plotaxes.title = 'Cross section at y=0' ml_plot.add_cross_section(plotaxes, 0, 40.) ml_plot.add_cross_section(plotaxes, 1, 40.) ml_plot.add_land_cross_section(plotaxes, 40.) # ======================================================================== # Figure for cross section # ======================================================================== plotfigure = plotdata.new_plotfigure(name='cross-section2', figno=40) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = [-1010, 150] plotaxes.title = 'Cross section at y=0' ml_plot.add_cross_section(plotaxes, 0, 40.) ml_plot.add_cross_section(plotaxes, 1, 40.) ml_plot.add_land_cross_section(plotaxes, 40.) # ======================================================================== # Figure for cross section # ======================================================================== plotfigure = plotdata.new_plotfigure(name='cross-section3', figno=41) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = [-1001, -999] plotaxes.title = 'Cross section at y=0' ml_plot.add_cross_section(plotaxes, 0, 40.) ml_plot.add_cross_section(plotaxes, 1, 40.) ml_plot.add_land_cross_section(plotaxes, 40.) # ======================================================================== # Figure for cross section # ======================================================================== plotfigure = plotdata.new_plotfigure(name='cross-section4', figno=39) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = [-1, 1] plotaxes.title = 'Cross section at y=0' ml_plot.add_cross_section(plotaxes, 0, 40.) ml_plot.add_cross_section(plotaxes, 1, 40.) ml_plot.add_land_cross_section(plotaxes, 40.) # ======================================================================== # Vorticity Plot # ======================================================================== # plotfigure = plotdata.new_plotfigure(name='vorticity',figno=17) # plotfigure.show = False # plotaxes = plotfigure.new_plotaxes() # plotaxes.title = "Vorticity" # plotaxes.scaled = True # plotaxes.xlimits = xlimits # plotaxes.ylimits = ylimits # plotaxes.afteraxes = pcolor_afteraxes # # # Vorticity # plotitem = plotaxes.new_plotitem(plot_type='2d_imshow') # plotitem.plot_var = 9 # plotitem.imshow_cmap = plt.get_cmap('PRGn') # # plotitem.pcolor_cmap = plt.get_cmap('PuBu') # # plotitem.pcolor_cmin = 0.0 # # plotitem.pcolor_cmax = 6.0 # plotitem.imshow_cmin = -1.e-2 # plotitem.imshow_cmax = 1.e-2 # plotitem.add_colorbar = True # plotitem.amr_celledges_show = [0,0,0] # plotitem.amr_patchedges_show = [1] # # # Land # plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') # plotitem.plot_var = geoplot.land # plotitem.pcolor_cmap = geoplot.land_colors # plotitem.pcolor_cmin = 0.0 # plotitem.pcolor_cmax = 80.0 # plotitem.add_colorbar = False # plotitem.amr_celledges_show = [0,0,0] # ======================================================================== # Figures for gauges # Top plotfigure = plotdata.new_plotfigure(name='Surface & topo', type='each_gauge', figno=301) plotfigure.show = True plotfigure.clf_each_gauge = True plotfigure.kwargs = {'figsize': (14, 4)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.xlimits = [0.0, 1.0] plotaxes.ylimits = top_surface_limits plotaxes.title = 'Top Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 6 plotitem.plotstyle = 'b-' # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1, 2, 2)' plotaxes.xlimits = [0.0, 1.0] plotaxes.ylimits = internal_surface_limits plotaxes.title = 'Bottom Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 7 plotitem.plotstyle = 'b-' # ========================================================================= # Other plots # Gauge Locations - Enable to see where gauges are located def locations_afteraxes(current_data, gaugenos='all'): gaugetools.plot_gauge_locations(current_data.plotdata, gaugenos=gaugenos, format_string='kx', add_labels=True) pcolor_afteraxes(current_data) plotfigure = plotdata.new_plotfigure(name='Gauge Locations') plotfigure.show = False plotfigure.kwargs = {'figsize': (14, 4)} # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Surface' plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = locations_afteraxes ml_plot.add_surface_elevation(plotaxes, 0, bounds=top_surface_limits) ml_plot.add_land(plotaxes, 0) # Bottom surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Internal Surface' plotaxes.axescmd = 'subplot(1, 2, 2)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = locations_afteraxes ml_plot.add_surface_elevation(plotaxes, 1, bounds=internal_surface_limits) ml_plot.add_land(plotaxes, 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_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): """""" if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() # clear any old figures,axes,items data plotdata.clearfigures() plotdata.format = 'ascii' # Load data from output clawdata = clawutil.ClawInputData(2) clawdata.read(os.path.join(plotdata.outdir, 'claw.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 = surgeplot.track_data(os.path.join(plotdata.outdir, 'fort.track')) # Set afteraxes function def surge_afteraxes(cd): surgeplot.surge_afteraxes(cd, track, plot_direction=False, kwargs={"markersize": 4}) # Color limits surface_limits = [-5.0, 5.0] speed_limits = [0.0, 3.0] wind_limits = [0, 64] pressure_limits = [935, 1013] friction_bounds = [0.01, 0.04] color_limits=[0,50] def friction_after_axes(cd): plt.title(r"Manning's $n$ Coefficient") # ========================================================================== # Plot specifications # ========================================================================== regions = {"Atlantic": {"xlimits": (clawdata.lower[0], clawdata.upper[0]), "ylimits": (clawdata.lower[1], clawdata.upper[1]), "figsize": (6.4, 4.8)}, "Atlantic City, NJ": {"xlimits": (-78, -74), "ylimits": (32,36), "figsize": (10.5, 11.5)}, "ChesapeakeBay Shelf": {"xlimits": (-77, -75), "ylimits": (36, 38), "figsize": (5, 6)}, "Manhattan Shelf": {"xlimits": (-75,-73), "ylimits": (38,40), "figsize": (5,6)}, "Sandy Hook, NJ": {"xlimits": (-76,-73), "ylimits": (38,41), "figsize":(5,6)}, "New Haven CT": {"xlimits": (-77,-73), "ylimits": (39,41), "figsize":(5,6)}, "New London CT": {"xlimits": (-74,-70), "ylimits": (39,43), "figsize":(5,6)}, "Boston MA": {"xlimits": (-72,-68), "ylimits": (40,44), "figsize":(5,6)}} for (name, region_dict) in regions.items(): # Surface Figure plotfigure = plotdata.new_plotfigure(name="Surface - %s" % name) plotfigure.kwargs = {"figsize": region_dict['figsize']} plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Surface" plotaxes.xlimits = region_dict["xlimits"] plotaxes.ylimits = region_dict["ylimits"] plotaxes.afteraxes = surge_afteraxes surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # Speed Figure plotfigure = plotdata.new_plotfigure(name="Currents - %s" % name) plotfigure.kwargs = {"figsize": region_dict['figsize']} plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Currents" plotaxes.xlimits = region_dict["xlimits"] plotaxes.ylimits = region_dict["ylimits"] plotaxes.afteraxes = surge_afteraxes surgeplot.add_speed(plotaxes, bounds=speed_limits) surgeplot.add_land(plotaxes,bounds=color_limits) plotaxes.plotitem_dict['speed'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # # Friction field # plotfigure = plotdata.new_plotfigure(name='Friction') plotfigure.show = friction_data.variable_friction and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Atlantic']['xlimits'] plotaxes.ylimits = regions['Atlantic']['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] * 10 plotaxes.plotitem_dict['friction'].colorbar_label = "$n$" # # Hurricane Forcing fields # # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure') plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Atlantic']['xlimits'] plotaxes.ylimits = regions['Atlantic']['ylimits'] plotaxes.title = "Pressure Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_pressure(plotaxes, bounds=pressure_limits) surgeplot.add_land(plotaxes) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed') plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Atlantic']['xlimits'] plotaxes.ylimits = regions['Atlantic']['ylimits'] plotaxes.title = "Wind Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_wind(plotaxes, bounds=wind_limits) surgeplot.add_land(plotaxes) # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Gauge Surfaces', figno=300, type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-3, 3] # plotaxes.xlabel = "Days from landfall" # plotaxes.ylabel = "Surface (m)" plotaxes.ylimits = [0,1.5] plotaxes.title = 'Surface' #Gauge Data from NOAA try: gauges = [np.loadtxt('gauge_data_1.txt'), np.loadtxt('gauge_data_2.txt'), np.loadtxt('gauge_data3.txt'), np.loadtxt('gauge_data_4.txt'), np.loadtxt('gauge_data_5.txt'), np.loadtxt('gauge_data_6.txt')] #Legend with Gauge Locations data_names = ["Duke Marine Lab, NC Data from NOAA", "Kiptopeke Beach, NC Data from NOAA", "Atlantic City, NJ Data from NOAA", "Sandy Hook, NJ Data from NOAA", "New London, CT Data from NOAA", "Boston, MA Data from NOAA"] except: print("Add gauge files to directory") def gauge_afteraxes(cd): axes = plt.gca() surgeplot.plot_landfall_gauge(cd.gaugesoln, axes) # Fix up plot - in particular fix time labels axes.set_title('Station %s' % cd.gaugeno) axes.set_xlabel('Days relative to landfall') axes.set_ylabel('Surface (m)') axes.set_xlim([-3, 3]) axes.set_ylim([0,1.5]) axes.set_xticks([-3, -2, -1, 0, 1, 2, 3]) axes.set_xticklabels([r"$-3$",r"$-2$",r"$-1$", r"$0$", r"$1$", r"$2$", r"$3$"]) axes.grid(True) try: gauge_data=gauges[cd.gaugeno-1] axes.plot(gauge_data[:,0], gauge_data[:,1], label=data_names[cd.gaugeno-1]) axes.legend() except: print('Gauge Data Unavailable') 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 = [-81, -70] plotaxes.ylimits = [33,45] plotaxes.afteraxes = gauge_location_afteraxes surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].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 = [1, 2, 3, 4, 5, 6] # list of gauges to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? plotdata.parallel = True # parallel plotting return plotdata
def setplot(plotdata): r"""Setplot function for surge plotting""" if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() 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 = 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 = 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, 8, 1, 12) - datetime.datetime(2008,1,1,0) landfall = landfall_dt.days * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function surge_afteraxes = lambda cd: surgeplot.surge_afteraxes(cd, track, landfall, plot_direction=False) # Limits for plots full_xlimits = [clawdata.lower[0], clawdata.upper[0]] full_ylimits = [clawdata.lower[1], clawdata.upper[1]] # Color limits surface_range = 1.0 speed_range = 2.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,55] pressure_limits = [966,1013] ref_lines = [] # ========================================================================== # Generic helper functions # ========================================================================== def pcolor_afteraxes(current_data): surge_afteraxes(current_data) # surgeplot.gauge_locations(current_data) def contour_afteraxes(current_data): surge_afteraxes(current_data) def bathy_ref_lines(current_data): pass # plt.hold(True) # y = [amrdata.ylower,amrdata.yupper] # for ref_line in ref_lines: # plt.plot([ref_line,ref_line],y,'y--') # plt.hold(False) # ========================================================================== # ========================================================================== # Plot specifications # ========================================================================== # ========================================================================== # ======================================================================== # Surface Elevations - Entire Domain # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface', figno=0) 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 = pcolor_afteraxes surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes,topo_min=-10.0,topo_max=5.0) # ======================================================================== # Water Speed - Entire Domain # ======================================================================== plotfigure = plotdata.new_plotfigure(name='speed', figno=1) 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 = pcolor_afteraxes # Speed surgeplot.add_speed(plotaxes,bounds=speed_limits) # Land surgeplot.add_land(plotaxes) # ======================================================================== # Hurricane forcing - Entire Domain # ======================================================================== # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure', figno=2) plotfigure.show = surge_data.pressure_forcing plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Pressure Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_pressure(plotaxes,bounds=pressure_limits) # add_pressure(plotaxes) surgeplot.add_land(plotaxes) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed',figno=4) plotfigure.show = surge_data.wind_forcing plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Wind Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.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') surgeplot.add_land(plotaxes) # Wind field components plotfigure = plotdata.new_plotfigure(name='Wind Components',figno=5) plotfigure.show = surge_data.wind_forcing and False plotfigure.kwargs = {'figsize':(16,6)} plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = "subplot(121)" plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "X-Component of Wind Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_imshow') plotitem.plot_var = surgeplot.wind_x plotitem.imshow_cmap = colormaps.make_colormap({1.0:'r',0.5:'w',0.0:'b'}) plotitem.imshow_cmin = -wind_limits[1] plotitem.imshow_cmax = wind_limits[1] plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1] plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = "subplot(122)" plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Y-Component of Wind Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type='2d_imshow') plotitem.plot_var = surgeplot.wind_y plotitem.imshow_cmap = colormaps.make_colormap({1.0:'r',0.5:'w',0.0:'b'}) plotitem.imshow_cmin = -wind_limits[1] plotitem.imshow_cmax = wind_limits[1] plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1] # ======================================================================== # 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() # plotaxes.xlimits = [0.0,amrdata.tfinal] # plotaxes.ylimits = [0,150.0] plotaxes.ylimits = surface_limits plotaxes.title = 'Surface' plotaxes.afteraxes = surgeplot.gauge_afteraxes # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'r-' # ================= # Plot bathymetry # ================= plotfigure = plotdata.new_plotfigure(name='Bathymetry', figno=301) plotfigure.show = True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = full_xlimits plotaxes.ylimits = full_ylimits plotaxes.title = "Bathymetry" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True plotitem = plotaxes.new_plotitem(plot_type="2d_pcolor") plotitem.plot_var = geoplot.topo # plotitem.pcolor_cmap = geoplot.seafloor_colormap plotitem.pcolor_cmin = -3000.0 plotitem.pcolor_cmax = 300.0 plotitem.add_colorbar = True surgeplot.add_land(plotaxes) #----------------------------------------- # Figures for gauges #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='Surface & topo', figno=300, \ # type='each_gauge') # plotfigure.clf_each_gauge = True # # # Set up for axes in this figure: # plotaxes = plotfigure.new_plotaxes() # plotaxes.xlimits = 'auto' # plotaxes.ylimits = 'auto' # plotaxes.title = 'Surface' # # # Plot surface as blue curve: # plotitem = plotaxes.new_plotitem(plot_type='1d_plot') # plotitem.plot_var = 3 # plotitem.plotstyle = 'b-' # # # Plot topo as green curve: # plotitem = plotaxes.new_plotitem(plot_type='1d_plot') # plotitem.show = False # # def gaugetopo(current_data): # q = current_data.q # h = q[0,:] # eta = q[3,:] # topo = eta - h # return topo # # plotitem.plot_var = gaugetopo # plotitem.plotstyle = 'g-' # # def add_zeroline(current_data): # from pylab import plot, legend, xticks, floor # t = current_data.t # #legend(('surface','topography'),loc='lower left') # plot(t, 0*t, 'k') # n = int(floor(t.max()/3600.) + 2) # xticks([3600*i for i in range(n)]) # # plotaxes.afteraxes = add_zeroline #----------------------------------------- # 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_framenos = [45,46,47,48] 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=None, bathy_location=0.15, bathy_angle=0.0, bathy_left=-1.0, bathy_right=-0.2): """Setup the plotting data objects. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. returns plotdata object """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() # Load data from output clawdata = clawutil.ClawInputData(2) clawdata.read(os.path.join(plotdata.outdir, 'claw.data')) multilayer_data = clawpack.geoclaw.data.MultilayerData() multilayer_data.read(os.path.join(plotdata.outdir, 'multilayer.data')) def transform_c2p(x, y, x0, y0, theta): return ((x+x0)*np.cos(theta) - (y+y0)*np.sin(theta), (x+x0)*np.sin(theta) + (y+y0)*np.cos(theta)) def transform_p2c(x, y, x0, y0, theta): return (x*np.cos(theta) + y*np.sin(theta) - x0, -x*np.sin(theta) + y*np.cos(theta) - y0) # Setup bathymetry reference lines with open(os.path.join(plotdata.outdir, "bathy_geometry.data"), 'r') \ as bathy_geometry_file: bathy_location = float(bathy_geometry_file.readline()) bathy_angle = float(bathy_geometry_file.readline()) x = [0.0, 0.0] y = [0.0, 1.0] x1, y1 = transform_c2p(x[0], y[0], bathy_location, 0.0, bathy_angle) x2, y2 = transform_c2p(x[1], y[1], bathy_location, 0.0, bathy_angle) if abs(x1 - x2) < 10**-3: x = [x1, x1] y = [clawdata.lower[1], clawdata.upper[1]] else: m = (y1 - y2) / (x1 - x2) x[0] = (clawdata.lower[1] - y1) / m + x1 y[0] = clawdata.lower[1] x[1] = (clawdata.upper[1] - y1) / m + x1 y[1] = clawdata.upper[1] ref_lines = [((x[0], y[0]), (x[1], y[1]))] plotdata.clearfigures() plotdata.save_frames = False # ======================================================================== # Generic helper functions def pcolor_afteraxes(current_data): bathy_ref_lines(current_data) def contour_afteraxes(current_data): axes = plt.gca() pos = -80.0 * (23e3 / 180) + 500e3 - 5e3 axes.plot([pos, pos], [-300e3, 300e3], 'b', [pos-5e3, pos-5e3], [-300e3, 300e3], 'y') wind_contours(current_data) bathy_ref_lines(current_data) def profile_afteraxes(current_data): pass def bathy_ref_lines(current_data): axes = plt.gca() for ref_line in ref_lines: x1 = ref_line[0][0] y1 = ref_line[0][1] x2 = ref_line[1][0] y2 = ref_line[1][1] axes.plot([x1, x2], [y1, y2], 'y--', linewidth=1) # ======================================================================== # Axis limits xlimits = [-0.5, 0.5] ylimits = [-0.5, 0.5] eta = [multilayer_data.eta[0], multilayer_data.eta[1]] top_surface_limits = [eta[0] - 0.03, eta[0] + 0.03] internal_surface_limits = [eta[1] - 0.015, eta[1] + 0.015] top_speed_limits = [0.0, 0.1] internal_speed_limits = [0.0, 0.03] # ======================================================================== # Surface Elevations plotfigure = plotdata.new_plotfigure(name='Surface') plotfigure.show = True plotfigure.kwargs = {'figsize': (14, 4)} # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Surface' plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_surface_elevation(plotaxes,1,bounds=top_surface_limits) # ml_plot.add_surface_elevation(plotaxes,1,bounds=[-0.06,0.06]) # ml_plot.add_surface_elevation(plotaxes,1) ml_plot.add_land(plotaxes, 1) # Bottom surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Internal Surface' plotaxes.axescmd = 'subplot(1,2,2)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = pcolor_afteraxes # ml_plot.add_surface_elevation(plotaxes,2,bounds=[-300-0.5,-300+0.5]) ml_plot.add_surface_elevation(plotaxes,2,bounds=internal_surface_limits) # ml_plot.add_surface_elevation(plotaxes,2) ml_plot.add_land(plotaxes, 2) # ======================================================================== # Depths # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Depths', figno=42) plotfigure.show = False plotfigure.kwargs = {'figsize':(14,4)} # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Layer Depth' plotaxes.axescmd = 'subplot(1,2,1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_layer_depth(plotaxes,1,bounds=[-0.1,1.1]) ml_plot.add_land(plotaxes, 1) # Bottom surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Bottom Layer Depth' plotaxes.axescmd = 'subplot(1,2,2)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_layer_depth(plotaxes,2,bounds=[-0.1,0.7]) ml_plot.add_land(plotaxes, 2) # ======================================================================== # Water Speed plotfigure = plotdata.new_plotfigure(name='speed') plotfigure.show = True plotfigure.kwargs = {'figsize': (14, 4)} # Top layer speed plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents - Top Layer' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.afteraxes = pcolor_afteraxes ml_plot.add_speed(plotaxes, 1, bounds=top_speed_limits) ml_plot.add_land(plotaxes, 1) # Bottom layer speed plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents - Bottom Layer' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(1,2,2)' plotaxes.afteraxes = pcolor_afteraxes # add_speed(plotaxes,2,bounds=[0.0,1e-10]) ml_plot.add_speed(plotaxes,2,bounds=internal_speed_limits) # add_speed(plotaxes,2) ml_plot.add_land(plotaxes, 2) # Individual components plotfigure = plotdata.new_plotfigure(name='speed_components',figno=401) plotfigure.show = False plotfigure.kwargs = {'figsize':(14,14)} # Top layer plotaxes = plotfigure.new_plotaxes() plotaxes.title = "X-Velocity - Top Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,1)' plotaxes.afteraxes = pcolor_afteraxes # add_x_velocity(plotaxes,1,bounds=[-1e-10,1e-10]) ml_plot.add_x_velocity(plotaxes,1) ml_plot.add_land(plotaxes, 1) plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Y-Velocity - Top Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,2)' plotaxes.afteraxes = pcolor_afteraxes # add_y_velocity(plotaxes,1,bounds=[-0.000125,0.000125]) ml_plot.add_y_velocity(plotaxes,1) ml_plot.add_land(plotaxes, 1) # Bottom layer plotaxes = plotfigure.new_plotaxes() plotaxes.title = "X-Velocity - Bottom Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,3)' plotaxes.afteraxes = pcolor_afteraxes # add_x_velocity(plotaxes,2,bounds=[-1e-10,1e-10]) ml_plot.add_x_velocity(plotaxes,2) ml_plot.add_land(plotaxes, 2) plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Y-Velocity - Bottom Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,4)' plotaxes.afteraxes = pcolor_afteraxes # add_y_velocity(plotaxes,2,bounds=[-0.8e-6,.8e-6]) ml_plot.add_y_velocity(plotaxes,2) ml_plot.add_land(plotaxes, 2) # ======================================================================== # Profile Plots # Note that these are not currently plotted by default - set # `plotfigure.show = True` is you want this to be plotted plotfigure = plotdata.new_plotfigure(name='profile') plotfigure.show = False # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = [-1.1, 0.1] plotaxes.title = "Profile of depth" plotaxes.afteraxes = profile_afteraxes slice_index = 30 # Internal surface def bathy_profile(current_data): return current_data.x[:, slice_index], b(current_data)[:, slice_index] def lower_surface(current_data): if multilayer_data.init_type == 2: return current_data.x[:, slice_index], \ eta2(current_data)[:, slice_index] elif multilayer_data.init_type == 6: return current_data.y[slice_index, :], \ eta2(current_data)[slice_index, :] def upper_surface(current_data): if multilayer_data.init_type == 2: return current_data.x[:, slice_index], \ eta1(current_data)[:, slice_index] elif multilayer_data.init_type == 6: return current_data.y[slice_index, :], \ eta1(current_data)[slice_index, :] def top_speed(current_data): if multilayer_data.init_type == 2: return current_data.x[:, slice_index], \ water_u1(current_data)[:, slice_index] elif multilayer_data.init_type == 6: return current_data.y[slice_index, :], \ water_u1(current_data)[slice_index, :] def bottom_speed(current_data): if multilayer_data.init_type == 2: return current_data.x[:, slice_index], \ water_u2(current_data)[:, slice_index] elif multilayer_data.init_type == 6: return current_data.y[slice_index, :], \ water_u2(current_data)[slice_index, :] # Bathy plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') plotitem.map_2d_to_1d = bathy_profile plotitem.plot_var = 0 plotitem.amr_plotstyle = ['-', '+', 'x'] plotitem.color = 'k' plotitem.show = True # Internal Interface plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') plotitem.map_2d_to_1d = lower_surface plotitem.plot_var = 7 plotitem.amr_plotstyle = ['-', '+', 'x'] plotitem.color = 'b' plotitem.show = True # Upper Interface plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') plotitem.map_2d_to_1d = upper_surface plotitem.plot_var = 6 plotitem.amr_plotstyle = ['-', '+', 'x'] plotitem.color = (0.2, 0.8, 1.0) plotitem.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Y-Velocity' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = pcolor_afteraxes # Water # plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') # # plotitem.plot_var = geoplot.surface # plotitem.plot_var = water_v # plotitem.pcolor_cmap = colormaps.make_colormap({1.0:'r',0.5:'w',0.0:'b'}) # # plotitem.pcolor_cmin = -1.e-10 # # plotitem.pcolor_cmax = 1.e-10 # # plotitem.pcolor_cmin = -2.5 # -3.0 # # plotitem.pcolor_cmax = 2.5 # 3.0 # plotitem.add_colorbar = True # plotitem.amr_celledges_show = [0,0,0] # plotitem.amr_patchedges_show = [1,1,1] # Land ml_plot.add_land(plotaxes, 1) # ======================================================================== # Contour plot for surface # ======================================================================== plotfigure = plotdata.new_plotfigure(name='contour_surface',figno=15) plotfigure.show = False plotfigure.kwargs = {'figsize':(14,4)} # Set up for axes in this figure: # Top Surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Surface' plotaxes.axescmd = 'subplot(1,2,1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = contour_afteraxes ml_plot.add_surface_elevation(plotaxes,plot_type='contour',surface=1,bounds=[-2.5,-1.5,-0.5,0.5,1.5,2.5]) ml_plot.add_land(plotaxes, 1, plot_type='contour') # Internal Surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Internal Surface' plotaxes.axescmd = 'subplot(1,2,2)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = contour_afteraxes ml_plot.add_surface_elevation(plotaxes,plot_type='contour',surface=2,bounds=[-2.5,-1.5,-0.5,0.5,1.5,2.5]) ml_plot.add_land(plotaxes, 2, plot_type='contour') # ======================================================================== # Contour plot for speed # ======================================================================== plotfigure = plotdata.new_plotfigure(name='contour_speed',figno=16) plotfigure.show = False plotfigure.kwargs = {'figsize':(14,4)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Current' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = contour_afteraxes # Surface plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = ml_plot.water_speed_depth_ave plotitem.kwargs = {'linewidths':1} # plotitem.contour_levels = [1.0,2.0,3.0,4.0,5.0,6.0] plotitem.contour_levels = [0.5,1.5,3,4.5,6.0] plotitem.amr_contour_show = [1,1,1] plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1] plotitem.amr_contour_colors = 'k' # plotitem.amr_contour_colors = ['r','k','b'] # color on each level # plotitem.amr_grid_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.show = True # Land plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.land plotitem.contour_nlevels = 40 plotitem.contour_min = 0.0 plotitem.contour_max = 100.0 plotitem.amr_contour_colors = ['g'] # color on each level plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = 0 plotitem.amr_patchedges_show = 0 plotitem.show = True # ======================================================================== # Grid Cells # ======================================================================== # Figure for grid cells plotfigure = plotdata.new_plotfigure(name='cells', figno=2) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title = 'Grid patches' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = [0,0,0] plotitem.amr_patchedges_show = [1,1,1] # ======================================================================== # Vorticity Plot # ======================================================================== # plotfigure = plotdata.new_plotfigure(name='vorticity',figno=17) # plotfigure.show = False # plotaxes = plotfigure.new_plotaxes() # plotaxes.title = "Vorticity" # plotaxes.scaled = True # plotaxes.xlimits = xlimits # plotaxes.ylimits = ylimits # plotaxes.afteraxes = pcolor_afteraxes # # # Vorticity # plotitem = plotaxes.new_plotitem(plot_type='2d_imshow') # plotitem.plot_var = 9 # plotitem.imshow_cmap = plt.get_cmap('PRGn') # # plotitem.pcolor_cmap = plt.get_cmap('PuBu') # # plotitem.pcolor_cmin = 0.0 # # plotitem.pcolor_cmax = 6.0 # plotitem.imshow_cmin = -1.e-2 # plotitem.imshow_cmax = 1.e-2 # plotitem.add_colorbar = True # plotitem.amr_celledges_show = [0,0,0] # plotitem.amr_patchedges_show = [1] # # # Land # plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') # plotitem.plot_var = geoplot.land # plotitem.pcolor_cmap = geoplot.land_colors # plotitem.pcolor_cmin = 0.0 # plotitem.pcolor_cmax = 80.0 # plotitem.add_colorbar = False # plotitem.amr_celledges_show = [0,0,0] # ======================================================================== # Figures for gauges # Top plotfigure = plotdata.new_plotfigure(name='Surface & topo', type='each_gauge', figno=301) plotfigure.show = True plotfigure.clf_each_gauge = True plotfigure.kwargs = {'figsize': (14, 4)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.xlimits = [0.0, 1.0] plotaxes.ylimits = top_surface_limits plotaxes.title = 'Top Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 6 plotitem.plotstyle = 'b-' # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1, 2, 2)' plotaxes.xlimits = [0.0, 1.0] plotaxes.ylimits = internal_surface_limits plotaxes.title = 'Bottom Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 7 plotitem.plotstyle = 'b-' # ========================================================================= # Other plots # Gauge Locations - Enable to see where gauges are located def locations_afteraxes(current_data, gaugenos='all'): gaugetools.plot_gauge_locations(current_data.plotdata, gaugenos=gaugenos, format_string='kx', add_labels=True) pcolor_afteraxes(current_data) plotfigure = plotdata.new_plotfigure(name='Gauge Locations') plotfigure.show = False plotfigure.kwargs = {'figsize': (14, 4)} # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Surface' plotaxes.axescmd = 'subplot(1, 2, 1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = locations_afteraxes ml_plot.add_surface_elevation(plotaxes, 1, bounds=top_surface_limits) ml_plot.add_land(plotaxes, 1) # Bottom surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Internal Surface' plotaxes.axescmd = 'subplot(1, 2, 2)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.afteraxes = locations_afteraxes ml_plot.add_surface_elevation(plotaxes, 2, bounds=internal_surface_limits) ml_plot.add_land(plotaxes, 2) # ----------------------------------------- # 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_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): """""" if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() # clear any old figures,axes,items data plotdata.clearfigures() plotdata.format = 'ascii' # Load data from output clawdata = clawutil.ClawInputData(2) clawdata.read(os.path.join(plotdata.outdir, 'claw.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 = surgeplot.track_data(os.path.join(plotdata.outdir, 'fort.track')) # Set afteraxes function def surge_afteraxes(cd): surgeplot.surge_afteraxes(cd, track, plot_direction=False, kwargs={"markersize": 4}) # Color limits surface_limits = [-4.0, 4.0] speed_limits = [0.0, 3.0] wind_limits = [0, 64] pressure_limits = [935, 1013] friction_bounds = [0.01, 0.04] ''' surface_limits = [-2.0, 2.0] speed_limits = [0.0, 3.0] wind_limits = [0, 70] pressure_limits = [990, 1010] friction_bounds = [0.01, 0.04] ''' def friction_after_axes(cd): plt.title(r"Manning's $n$ Coefficient") # ========================================================================== # Plot specifications # ========================================================================== # surface region regions = { "Gulf": { "xlimits": (clawdata.lower[0], clawdata.upper[0]), "ylimits": (clawdata.lower[1], clawdata.upper[1]), "figsize": (6.4, 3.2) }, "LaTex Shelf": { "xlimits": (-94.5, -86), "ylimits": (27, 32), "figsize": (10, 5) } } for (name, region_dict) in regions.items(): # Surface Figure plotfigure = plotdata.new_plotfigure(name="Surface - %s" % name) plotfigure.kwargs = {"figsize": region_dict['figsize']} plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Surface" plotaxes.xlimits = region_dict["xlimits"] plotaxes.ylimits = region_dict["ylimits"] plotaxes.afteraxes = surge_afteraxes surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # Speed Figure plotfigure = plotdata.new_plotfigure(name="Currents - %s" % name) plotfigure.kwargs = {"figsize": region_dict['figsize']} plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Currents" plotaxes.xlimits = region_dict["xlimits"] plotaxes.ylimits = region_dict["ylimits"] plotaxes.afteraxes = surge_afteraxes surgeplot.add_speed(plotaxes, bounds=speed_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['speed'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # # Friction field # plotfigure = plotdata.new_plotfigure(name='Friction') plotfigure.show = friction_data.variable_friction and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Gulf']['xlimits'] plotaxes.ylimits = regions['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] * 10 plotaxes.plotitem_dict['friction'].colorbar_label = "$n$" # # Hurricane Forcing fields # # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure') plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Gulf']['xlimits'] plotaxes.ylimits = regions['Gulf']['ylimits'] plotaxes.title = "Pressure Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_pressure(plotaxes, bounds=pressure_limits) surgeplot.add_land(plotaxes) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed') plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Gulf']['xlimits'] plotaxes.ylimits = regions['Gulf']['ylimits'] plotaxes.title = "Wind Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_wind(plotaxes, bounds=wind_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['wind'].amr_patchedges_show = [0] * 10 # added # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Gauge Surfaces', figno=300, type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True # 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.0, 2.5] plotaxes.title = 'Surface' def gauge_afteraxes(cd): axes = plt.gca() surgeplot.plot_landfall_gauge(cd.gaugesoln, axes) gauge_id = ['8770822', '8768094', '8764227', '8761305', '8760922'] gauge_title = [ 'Texas Point, Sabine Pass, TX', 'Calcasieu Pass, LA', 'LAWMA, Amerada Pass, LA', 'Shell Beach, LA', 'Pilots Station East, S.W. Pass, LA' ] if (cd.gaugeno < 6): realData = util.fetch_noaa_tide_data(gauge_id[cd.gaugeno - 1], datetime.datetime(2019, 7, 10, hour=12), datetime.datetime(2019, 7, 16, hour=12), datum='MLLW') values = realData[1] - realData[2] times = [] for time in realData[0]: times.append( (time - numpy.datetime64("2019-07-13T15:00")).astype(float) / 1440) plt.plot(times, values, color='orange', label='real') axes.set_title('Gauge %s: %s' % (cd.gaugeno, gauge_title[cd.gaugeno - 1])) # i for i in gauge_title axes.set_xlabel('Days relative to landfall') axes.set_ylabel('Surface (m)') axes.set_xlim([-2, 1]) axes.set_ylim([-1.0, 2.5]) axes.set_xticks([-2, -1, 0, 1]) axes.set_xticklabels([r"$-2$", r"$-1$", r"$0$", r"$1$"]) axes.grid(True) 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 # # All gauges 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 Location") plotfigure.show = True plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Gauge Locations' plotaxes.scaled = True plotaxes.xlimits = [-95, -88.5] plotaxes.ylimits = [28, 31] plotaxes.afteraxes = gauge_location_afteraxes surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # Gauge 01: Texas Point, Sabine Pass, TX [8770822] def gauge_location_afteraxes1(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=[1], format_string='ko', add_labels=True) plotfigure = plotdata.new_plotfigure(name="Gauge 01") plotfigure.show = True plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Gauge 01 Location' plotaxes.scaled = True plotaxes.xlimits = [-93.84 - 0.2, -93.84 + 0.2] plotaxes.ylimits = [29.69 - 0.2, 29.69 + 0.2] plotaxes.afteraxes = gauge_location_afteraxes1 surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # Gauge 02: Calcasieu Pass, LA [8768094] def gauge_location_afteraxes2(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=[2], format_string='ko', add_labels=True) plotfigure = plotdata.new_plotfigure(name="Gauge 02") plotfigure.show = True plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Gauge 02 Location' plotaxes.scaled = True plotaxes.xlimits = [-93.34 - 0.2, -93.34 + 0.2] plotaxes.ylimits = [29.77 - 0.2, 29.77 + 0.2] plotaxes.afteraxes = gauge_location_afteraxes2 surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # Gauge 03: LAWMA, Amerada Pass, LA [8764227] def gauge_location_afteraxes3(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=[3], format_string='ko', add_labels=True) plotfigure = plotdata.new_plotfigure(name="Gauge 03") plotfigure.show = True plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Gauge 03 Location' plotaxes.scaled = True plotaxes.xlimits = [-91.34 - 0.2, -91.34 + 0.2] plotaxes.ylimits = [29.45 - 0.2, 29.45 + 0.2] plotaxes.afteraxes = gauge_location_afteraxes3 surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # Gauge 04: Shell Beach, LA [8761305] def gauge_location_afteraxes4(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=[4], format_string='ko', add_labels=True) plotfigure = plotdata.new_plotfigure(name="Gauge 04") plotfigure.show = True plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Gauge 04 Location' plotaxes.scaled = True plotaxes.xlimits = [-89.67 - 0.2, -89.67 + 0.2] plotaxes.ylimits = [29.87 - 0.2, 29.87 + 0.2] plotaxes.afteraxes = gauge_location_afteraxes4 surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # Gauge 05: Pilots Station East, S.W. Pass, LA [8760922] def gauge_location_afteraxes5(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=[5], format_string='ko', add_labels=True) plotfigure = plotdata.new_plotfigure(name="Gauge 05") plotfigure.show = True plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Gauge 05 Location' plotaxes.scaled = True plotaxes.xlimits = [-89.41 - 0.2, -89.41 + 0.2] plotaxes.ylimits = [28.93 - 0.2, 28.93 + 0.2] plotaxes.afteraxes = gauge_location_afteraxes5 surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].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 = [1, 2, 3, 4, 5] # list of gauges to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? plotdata.parallel = True # parallel plotting return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # Figure for pcolor plotfigure = plotdata.new_plotfigure(name='q[0]', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'q[0]' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = 0 plotitem.pcolor_cmap = colormaps.yellow_red_blue plotitem.pcolor_cmin = 0.1 plotitem.pcolor_cmax = 1.0 plotitem.add_colorbar = True plotitem.show = True # show on plot? # Figure for contour plotfigure = plotdata.new_plotfigure(name='contour', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'q[0]' plotaxes.scaled = True plotaxes.afteraxes = addgauges # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = 0 plotitem.contour_levels = np.linspace(0.2, 0.9, 8) plotitem.amr_contour_colors = ['b', 'k', 'r'] plotitem.amr_celledges_show = [0, 0, 0] plotitem.patchedges_show = 0 # Figure for grid cells plotfigure = plotdata.new_plotfigure(name='cells', figno=2) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0, 1] plotaxes.ylimits = [0, 1] plotaxes.title = 'Grid patches' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = [1, 0] plotitem.amr_patchedges_show = [1] #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='q', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'q' plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = 'b-' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_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.html_movie = 'JSAnimation' # new style, or "4.x" for old style plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # Figure for q[0] plotfigure = plotdata.new_plotfigure(name='Pressure and Velocity', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(2,1,1)' # top figure plotaxes.xlimits = 'auto' plotaxes.ylimits = [-.5,1.1] plotaxes.title = 'Pressure' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = '-o' plotitem.color = 'b' # Figure for q[1] # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(2,1,2)' # bottom figure plotaxes.xlimits = 'auto' plotaxes.ylimits = [-.5,1.1] plotaxes.title = 'Velocity' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 1 plotitem.plotstyle = '-o' plotitem.color = 'b' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ import os import numpy as np import matplotlib.pyplot as plt from clawpack.visclaw import geoplot, gaugetools, colormaps import clawpack.clawutil.data as clawutil import clawpack.amrclaw.data as amrclaw import clawpack.geoclaw.data import clawpack.geoclaw.multilayer.plot as ml_plot if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() from numpy import linspace plotdata.clearfigures() # clear any old figures,axes,items data plotdata.save_frames = False # 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')) geodata = clawpack.geoclaw.data.GeoClawData() geodata.read(os.path.join(plotdata.outdir,'geoclaw.data')) multilayer_data = clawpack.geoclaw.data.MultilayerData() multilayer_data.read(os.path.join(plotdata.outdir,'multilayer.data')) # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from clawpack.visclaw import gaugetools gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos='all', format_string='ko', add_labels=True) # ======================================================================== # Generic helper functions # ======================================================================== def pcolor_afteraxes(current_data): # bathy_ref_lines(current_data) gauge_locations(current_data) def contour_afteraxes(current_data): # gauge_locations(current_data) # m_to_km_labels() plt.hold(True) pos = -80.0 * (23e3 / 180) + 500e3 - 5e3 plt.plot([pos,pos],[-300e3,300e3],'b',[pos-5e3,pos-5e3],[-300e3,300e3],'y') plt.hold(False) wind_contours(current_data) bathy_ref_lines(current_data) def profile_afteraxes(current_data): pass def gauge_locations(current_data,gaugenos='all'): plt.hold(True) gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos=gaugenos, format_string='kx', add_labels=True) plt.hold(False) # ======================================================================== # Axis limits # xlimits = [amrdata.xlower,amrdata.xupper] xlimits = [-100.0, 100.0] # ylimits = [amrdata.ylower,amrdata.yupper] ylimits = [-100.0, 100.0] eta = [multilayer_data.eta[0],multilayer_data.eta[1]] top_surface_limits = [eta[0]-10,eta[0]+10] internal_surface_limits = [eta[1]-5,eta[1]+5] depth_limits = [0.0, 0.4] top_speed_limits = [0.0,0.1] internal_speed_limits = [0.0,0.03] # ======================================================================== # Surface Elevations # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Surface', figno=0) plotfigure.show = True plotfigure.kwargs = {'figsize':(14,4)} # Top surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Top Surface' plotaxes.axescmd = 'subplot(1,2,1)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits ml_plot.add_inundation(plotaxes, 1, bounds=depth_limits) ml_plot.add_surface_elevation(plotaxes,1,bounds=top_surface_limits) ml_plot.add_land(plotaxes, 1) # Bottom surface plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Internal Surface' plotaxes.axescmd = 'subplot(1,2,2)' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits ml_plot.add_inundation(plotaxes, 2, bounds=depth_limits) ml_plot.add_surface_elevation(plotaxes,2,bounds=internal_surface_limits) ml_plot.add_colorbar = True ml_plot.add_land(plotaxes, 2) # ======================================================================== # Figure for cross section # ======================================================================== plotfigure = plotdata.new_plotfigure(name='cross-section', figno=4) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title = 'Cross section at y=0' ml_plot.add_cross_section(plotaxes, 1) ml_plot.add_cross_section(plotaxes, 2) ml_plot.add_land_cross_section(plotaxes) # ======================================================================== # Water Speed # ======================================================================== plotfigure = plotdata.new_plotfigure(name='speed', figno=1) plotfigure.show = False plotfigure.kwargs = {'figsize':(14,4)} # Top layer speed plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents - Top Layer' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(1,2,1)' ml_plot.add_speed(plotaxes,1,bounds=top_speed_limits) ml_plot.add_land(plotaxes, 1) # Bottom layer speed plotaxes = plotfigure.new_plotaxes() plotaxes.title = 'Currents - Bottom Layer' plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(1,2,2)' ml_plot.add_speed(plotaxes,2,bounds=internal_speed_limits) ml_plot.add_land(plotaxes, 2) # Individual components plotfigure = plotdata.new_plotfigure(name='speed_components',figno=401) plotfigure.show = False plotfigure.kwargs = {'figsize':(14,14)} # Top layer plotaxes = plotfigure.new_plotaxes() plotaxes.title = "X-Velocity - Top Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,1)' ml_plot.add_x_velocity(plotaxes,1) ml_plot.add_land(plotaxes, 1) plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Y-Velocity - Top Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,2)' ml_plot.add_y_velocity(plotaxes,1) ml_plot.add_land(plotaxes, 1) # Bottom layer plotaxes = plotfigure.new_plotaxes() plotaxes.title = "X-Velocity - Bottom Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,3)' ml_plot.add_x_velocity(plotaxes,2) ml_plot.add_land(plotaxes, 2) plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Y-Velocity - Bottom Layer" plotaxes.scaled = True plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.axescmd = 'subplot(2,2,4)' ml_plot.add_y_velocity(plotaxes,2) ml_plot.add_land(plotaxes, 2) #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface at gauges', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' # Plot topo as green curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.show = False def gaugetopo(current_data): q = current_data.q h = q[0,:] eta = q[3,:] topo = eta - h return topo plotitem.plot_var = gaugetopo plotitem.plotstyle = 'g-' def add_zeroline(current_data): from pylab import plot, legend, xticks, floor, axis, xlabel t = current_data.t gaugeno = current_data.gaugeno if gaugeno == 32412: try: plot(TG32412[:,0], TG32412[:,1], 'r') legend(['GeoClaw','Obs'],loc='lower right') except: pass axis((0,t.max(),-0.3,0.3)) plot(t, 0*t, 'k') n = int(floor(t.max()/3600.) + 2) xticks([3600*i for i in range(n)], ['%i' % i for i in range(n)]) xlabel('time (hours)') #----------------------------------------- # 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): """""" if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() # clear any old figures,axes,items data plotdata.clearfigures() plotdata.format = 'binary' # Load data from output clawdata = clawutil.ClawInputData(2) clawdata.read(os.path.join(plotdata.outdir, 'claw.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 = surgeplot.track_data(os.path.join(plotdata.outdir, 'fort.track')) # Set afteraxes function def surge_afteraxes(cd): surgeplot.surge_afteraxes(cd, track, plot_direction=False, kwargs={"markersize": 4}) # Color limits surface_range = 5.0 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, 3.0] wind_limits = [0, 64] pressure_limits = [935, 1013] friction_bounds = [0.01, 0.04] def friction_after_axes(cd): plt.title(r"Manning's $n$ Coefficient") # ========================================================================== # Plot specifications # ========================================================================== regions = { "Entire Region": { "xlimits": (clawdata.lower[0], clawdata.upper[0]), "ylimits": (clawdata.lower[1], clawdata.upper[1]), "figsize": (13, 10) }, "Caribbean Sub-region": { "xlimits": (-86, -58.0), "ylimits": (9, 28), "figsize": (16, 6) }, } for (name, region_dict) in regions.items(): # Surface Figure plotfigure = plotdata.new_plotfigure(name="Surface - %s" % name) plotfigure.kwargs = {"figsize": region_dict['figsize']} plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Surface" plotaxes.xlimits = region_dict["xlimits"] plotaxes.ylimits = region_dict["ylimits"] plotaxes.afteraxes = surge_afteraxes surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [1] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [1] * 10 # Speed Figure plotfigure = plotdata.new_plotfigure(name="Currents - %s" % name) plotfigure.kwargs = {"figsize": region_dict['figsize']} plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Currents" plotaxes.xlimits = region_dict["xlimits"] plotaxes.ylimits = region_dict["ylimits"] plotaxes.afteraxes = surge_afteraxes surgeplot.add_speed(plotaxes, bounds=speed_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['speed'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # # Friction field # plotfigure = plotdata.new_plotfigure(name='Friction') plotfigure.show = friction_data.variable_friction and False plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Entire Region']['xlimits'] plotaxes.ylimits = regions['Entire Region']['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] * 10 plotaxes.plotitem_dict['friction'].colorbar_label = "$n$" # # Hurricane Forcing fields # # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure') plotfigure.show = surge_data.pressure_forcing and False plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Entire Region']['xlimits'] plotaxes.ylimits = regions['Entire Region']['ylimits'] plotaxes.title = "Pressure Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_pressure(plotaxes, bounds=pressure_limits) surgeplot.add_land(plotaxes) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed') plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Entire Region']['xlimits'] plotaxes.ylimits = regions['Entire Region']['ylimits'] plotaxes.title = "Wind Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_wind(plotaxes, bounds=wind_limits) surgeplot.add_land(plotaxes) # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Gauge Surfaces', figno=300, type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True # 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' def gauge_afteraxes(cd): axes = plt.gca() surgeplot.plot_landfall_gauge(cd.gaugesoln, axes) # Fix up plot - in particular fix time labels 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) 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 = [clawdata.lower[0], clawdata.upper[0]] plotaxes.ylimits = [clawdata.lower[1], clawdata.upper[1]] plotaxes.afteraxes = gauge_location_afteraxes surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 #----------------------------------------- # Figures for fgmax plots #----------------------------------------- from clawpack.geoclaw import fgmax_tools fgmax_plotdir = '_plots' os.system('mkdir -p %s' % fgmax_plotdir) # Read fgmax data: fgno = 1 while (True): fg = fgmax_tools.FGmaxGrid() try: fg.read_fgmax_grids_data(fgno) fg.read_output(outdir=plotdata.outdir) fg.B0 = fg.B # no seafloor deformation in this problem fg.h_onshore = np.ma.masked_where(fg.B0 < 0., fg.h) plt.figure(figsize=(20, 20)) pc = plt.pcolormesh(fg.X, fg.Y, fg.h_onshore, cmap='hot_r') cb = plt.colorbar(pc, extend='max', shrink=0.7) cb.set_label('meters') plt.contour(fg.X, fg.Y, fg.B, [0], colors='g') plt.gca().set_aspect(1. / np.cos(48 * np.pi / 180.)) plt.ticklabel_format(useOffset=False) plt.xticks(rotation=20) plt.title('Maximum Onshore flow depth\nfgmax grid {fgno}') img_name = f'fgmax{str(fgno).zfill(4)}_h_onshore.png' plt.savefig(fname=f'{fgmax_plotdir}/{img_name}') otherfigure = plotdata.new_otherfigure( name=f'max depth on fgmax grid {fgno}', fname=img_name) fgno = fgno + 1 except: break # ----------------------------------------- # 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.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? plotdata.parallel = True # parallel plotting return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data def draw_interface_add_legend(current_data): from pylab import plot plot([0., 0.], [-1000., 1000.], 'k--') try: from clawpack.visclaw import legend_tools labels = ['Level 1','Level 2', 'Level 3'] legend_tools.add_legend(labels, colors=['g','b','r'], markers=['^','s','o'], linestyles=['','',''], loc='upper left') except: pass # Figure for q[0] plotfigure = plotdata.new_plotfigure(name='Pressure and Velocity', figno=1) plotfigure.kwargs = {'figsize': (8,8)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(2,1,1)' # top figure plotaxes.xlimits = 'auto' plotaxes.ylimits = [-.5,1.1] plotaxes.title = 'Pressure' plotaxes.afteraxes = draw_interface_add_legend # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.amr_color = ['g','b','r'] plotitem.amr_plotstyle = ['^-','s-','o-'] plotitem.amr_data_show = [1,1,1] plotitem.amr_kwargs = [{'markersize':5},{'markersize':4},{'markersize':3}] # Figure for q[1] # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(2,1,2)' # bottom figure plotaxes.xlimits = 'auto' plotaxes.ylimits = [-.5,1.1] plotaxes.title = 'Velocity' plotaxes.afteraxes = draw_interface_add_legend # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 1 plotitem.amr_color = ['g','b','r'] plotitem.amr_plotstyle = ['^-','s-','o-'] plotitem.amr_data_show = [1,1,1] plotitem.amr_kwargs = [{'markersize':5},{'markersize':4},{'markersize':3}] #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='q', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(211)' plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Pressure' plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = 'b-' plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(212)' plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Velocity' plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 1 plotitem.plotstyle = 'b-' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # Figure for q[0] plotfigure = plotdata.new_plotfigure(name='q[0]', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0,1.5] plotaxes.ylimits = [-2.,4.] plotaxes.title = 'q[0]' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d') plotitem.plot_var = 0 plotitem.plotstyle = '-' plotitem.color = 'b' plotitem.show = True # show on plot? # Figure for q[1] plotfigure = plotdata.new_plotfigure(name='q[1]', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'q[1]' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d') plotitem.plot_var = 1 plotitem.plotstyle = '-' plotitem.color = 'b' plotitem.show = True # show on plot? # 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_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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): """""" if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() # clear any old figures,axes,items data plotdata.clearfigures() plotdata.format = 'ascii' # Load data from output clawdata = clawutil.ClawInputData(2) clawdata.read(os.path.join(plotdata.outdir, 'claw.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 = surgeplot.track_data(os.path.join(plotdata.outdir, 'fort.track')) # Calculate landfall time # Landfall for Ike in Houston was September 13th, at 7 UTC landfall_dt = datetime.datetime(2008, 9, 13, 7) - \ datetime.datetime(2008, 1, 1, 0) landfall = landfall_dt.days * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function def surge_afteraxes(cd): surgeplot.surge_afteraxes(cd, track, landfall, plot_direction=False, kwargs={"markersize": 4}) # Color limits surface_limits = [-5.0, 5.0] speed_limits = [0.0, 3.0] wind_limits = [0, 64] pressure_limits = [935, 1013] friction_bounds = [0.01, 0.04] def gulf_after_axes(cd): # plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) surge_afteraxes(cd) def latex_after_axes(cd): # plt.subplot_adjust() surge_afteraxes(cd) 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) # ========================================================================== # Plot specifications # ========================================================================== regions = { "Gulf": { "xlimits": (clawdata.lower[0], clawdata.upper[0]), "ylimits": (clawdata.lower[1], clawdata.upper[1]), "figsize": (6.4, 4.8) }, "LaTex Shelf": { "xlimits": (-97.5, -88.5), "ylimits": (27.5, 30.5), "figsize": (8, 2.7) } } for (name, region_dict) in regions.iteritems(): # Surface Figure plotfigure = plotdata.new_plotfigure(name="Surface - %s" % name) plotfigure.kwargs = {"figsize": region_dict['figsize']} plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Surface" plotaxes.xlimits = region_dict["xlimits"] plotaxes.ylimits = region_dict["ylimits"] plotaxes.afteraxes = surge_afteraxes surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # Speed Figure plotfigure = plotdata.new_plotfigure(name="Currents - %s" % name) plotfigure.kwargs = {"figsize": region_dict['figsize']} plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Currents" plotaxes.xlimits = region_dict["xlimits"] plotaxes.ylimits = region_dict["ylimits"] plotaxes.afteraxes = surge_afteraxes surgeplot.add_speed(plotaxes, bounds=speed_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['speed'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # # Friction field # plotfigure = plotdata.new_plotfigure(name='Friction') plotfigure.show = friction_data.variable_friction and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Gulf']['xlimits'] plotaxes.ylimits = regions['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] * 10 plotaxes.plotitem_dict['friction'].colorbar_label = "$n$" # # Hurricane Forcing fields # # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure') plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Gulf']['xlimits'] plotaxes.ylimits = regions['Gulf']['ylimits'] plotaxes.title = "Pressure Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_pressure(plotaxes, bounds=pressure_limits) surgeplot.add_land(plotaxes) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed') plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Gulf']['xlimits'] plotaxes.ylimits = regions['Gulf']['ylimits'] plotaxes.title = "Wind Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_wind(plotaxes, bounds=wind_limits) surgeplot.add_land(plotaxes) # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Gauge Surfaces', figno=300, type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True # 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' def gauge_afteraxes(cd): axes = plt.gca() surgeplot.plot_landfall_gauge(cd.gaugesoln, axes, landfall=landfall) # Fix up plot - in particular fix time labels 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) 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 = [-95.5, -94] plotaxes.ylimits = [29.0, 30.0] plotaxes.afteraxes = gauge_location_afteraxes surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].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 = [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.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? plotdata.parallel = True # parallel plotting return plotdata
def setplot(plotdata=None): if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() def fixticks1(current_data): from pylab import ticklabel_format, grid ticklabel_format(format='plain', useOffset=False) grid(True) def fixticks(current_data): from pylab import ticklabel_format, plot,grid,ones,sqrt, \ legend,title,ylabel,text ticklabel_format(format='plain', useOffset=False) # to plot max elevation over entire computation: #if xmax is not None: # plot(xmax, etamax, 'r') #grid(True) hl = 3200. hr = 200. greens = (hl / hr)**(0.25) print('greens = ', greens) #plot(current_data.x, greens*ones(current_data.x.shape),'g--') plot(xlimits, [greens, greens], 'g--', label='$C_g$, Greens Law') ctrans = 2 * sqrt(hl) / (sqrt(hl) + sqrt(hr)) crefl = (sqrt(hl) - sqrt(hr)) / (sqrt(hl) + sqrt(hr)) print('ctrans = ', ctrans) plot(xlimits, [ctrans, ctrans], 'r--', label='$C_T$, Transmission coefficient') print('crefl = ', crefl) plot(xlimits, [crefl, crefl], 'm--', label='$C_R$, Reflection coefficient') legend(loc='upper left') title('') ylabel('meters', fontsize=14) if current_data.frameno == 0: text(-80, -0.4, '$\longrightarrow$', fontsize=20) text(-80, -0.6, 'Incident') h = current_data.q[0, :] mx2 = int(round(len(h) / 2.)) etamax2 = (h[:mx2] - hl).max() print('mx2 = %i, etamax2 = %g' % (mx2, etamax2)) if (current_data.frameno == 5) and (etamax2 > 0.1): text(-220, -0.4, '$\longleftarrow$', fontsize=20) text(-220, -0.6, 'Reflected') text(30, -0.4, '$\longrightarrow$', fontsize=20) text(15, -0.6, 'Transmitted') plotfigure = plotdata.new_plotfigure(name='domain', figno=0) plotfigure.kwargs = {'figsize': (7, 6.5)} plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'axes([.1,.4,.8,.5])' #'subplot(211)' plotaxes.xlimits = xlimits #plotaxes.xlimits = [-100e3,-20e3] plotaxes.ylimits = [-1, 3] plotaxes.title = 'Surface displacement' plotaxes.afteraxes = fixticks plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = geoplot.surface plotitem.color = 'b' plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.show = False plotitem.plot_var = geoplot.topo plotitem.color = 'k' plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotaxes = plotfigure.new_plotaxes() plotaxes.show = False plotaxes.axescmd = 'subplot(312)' plotaxes.xlimits = xlimits #plotaxes.xlimits = [-100e3,-20e3] #plotaxes.ylimits = [-1000, 1000] #plotaxes.title = 'Full depth' plotaxes.title = 'momentum' plotaxes.afteraxes = fixticks1 plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotitem = plotaxes.new_plotitem(plot_type='1d_fill_between') plotitem.show = False plotitem.plot_var = geoplot.surface plotitem.plot_var2 = geoplot.topo plotitem.color = 'b' plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.show = False plotitem.plot_var = geoplot.topo plotitem.color = 'k' plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 1 plotitem.color = 'k' plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'axes([.1,.1,.8,.2])' #'subplot(212)' plotaxes.xlimits = xlimits #plotaxes.xlimits = [-100e3,-20e3] #plotaxes.ylimits = [-1000, 1000] #plotaxes.title = 'Full depth' #plotaxes.title = 'topography' def fix_topo_plot(current_data): from pylab import title, xlabel title('') xlabel('kilometers', fontsize=14) plotaxes.afteraxes = fix_topo_plot plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotitem = plotaxes.new_plotitem(plot_type='1d_plot') #plotitem.show = False plotitem.plot_var = geoplot.topo plotitem.color = 'k' plotitem.MappedGrid = True plotitem.mapc2p = mapc2p #---------- plotfigure = plotdata.new_plotfigure(name='shore', figno=1) #plotfigure.kwargs = {'figsize':(9,11)} plotfigure.show = False plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(211)' plotaxes.xlimits = [0, 80e3] plotaxes.ylimits = [-4, 4] plotaxes.title = 'Zoom on shelf' plotaxes.afteraxes = fixticks plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = geoplot.surface #plotitem = plotaxes.new_plotitem(plot_type='1d_fill_between') #plotitem.plot_var = geoplot.surface #plotitem.plot_var2 = geoplot.topo plotitem.color = 'b' plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = geoplot.topo plotitem.color = 'k' plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(212)' #plotaxes.xlimits = [-2000,2000] plotaxes.xlimits = [-1000, 1000] #plotaxes.ylimits = [-10,40] plotaxes.ylimits = [-20, 60] plotaxes.title = 'Zoom around shore' plotaxes.afteraxes = fixticks plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.show = False plotitem.plot_var = geoplot.surface plotitem = plotaxes.new_plotitem(plot_type='1d_fill_between') plotitem.plot_var = geoplot.surface plotitem.plot_var2 = geoplot.topo plotitem.color = 'b' plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = geoplot.topo plotitem.color = 'k' plotitem.MappedGrid = True plotitem.mapc2p = mapc2p plotdata.printfigs = True # Whether to output figures plotdata.print_format = 'png' # What type of output format plotdata.print_framenos = 'all' # Which frames to output plotdata.print_fignos = 'all' # Which figures to print plotdata.html = True # Whether to create HTML files plotdata.latex = False # Whether to make LaTeX output plotdata.parallel = True return plotdata
def setplot(plotdata=None): """""" if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() # clear any old figures,axes,items data plotdata.clearfigures() plotdata.format = 'ascii' # Load data from output clawdata = clawutil.ClawInputData(2) clawdata.read(os.path.join(plotdata.outdir, 'claw.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 = surgeplot.track_data(os.path.join(plotdata.outdir, 'fort.track')) # Calculate landfall time # Landfall for Ike in Houston was September 13th, at 7 UTC landfall_dt = datetime.datetime(2008, 9, 13, 7) - \ datetime.datetime(2008, 1, 1, 0) landfall = landfall_dt.days * 24.0 * 60**2 + landfall_dt.seconds # Set afteraxes function def surge_afteraxes(cd): surgeplot.surge_afteraxes(cd, track, landfall, plot_direction=False, kwargs={"markersize": 4}) # Color limits surface_limits = [-5.0, 5.0] speed_limits = [0.0, 3.0] wind_limits = [0, 64] pressure_limits = [935, 1013] friction_bounds = [0.01, 0.04] def gulf_after_axes(cd): # plt.subplots_adjust(left=0.08, bottom=0.04, right=0.97, top=0.96) surge_afteraxes(cd) def latex_after_axes(cd): # plt.subplot_adjust() surge_afteraxes(cd) 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) # ========================================================================== # Plot specifications # ========================================================================== regions = {"Gulf": {"xlimits": (clawdata.lower[0], clawdata.upper[0]), "ylimits": (clawdata.lower[1], clawdata.upper[1]), "figsize": (6.4, 4.8)}, "LaTex Shelf": {"xlimits": (-97.5, -88.5), "ylimits": (27.5, 30.5), "figsize": (8, 2.7)}} for (name, region_dict) in regions.iteritems(): # Surface Figure plotfigure = plotdata.new_plotfigure(name="Surface - %s" % name) plotfigure.kwargs = {"figsize": region_dict['figsize']} plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Surface" plotaxes.xlimits = region_dict["xlimits"] plotaxes.ylimits = region_dict["ylimits"] plotaxes.afteraxes = surge_afteraxes surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # Speed Figure plotfigure = plotdata.new_plotfigure(name="Currents - %s" % name) plotfigure.kwargs = {"figsize": region_dict['figsize']} plotaxes = plotfigure.new_plotaxes() plotaxes.title = "Currents" plotaxes.xlimits = region_dict["xlimits"] plotaxes.ylimits = region_dict["ylimits"] plotaxes.afteraxes = surge_afteraxes surgeplot.add_speed(plotaxes, bounds=speed_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['speed'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].amr_patchedges_show = [0] * 10 # # Friction field # plotfigure = plotdata.new_plotfigure(name='Friction') plotfigure.show = friction_data.variable_friction and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Gulf']['xlimits'] plotaxes.ylimits = regions['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] * 10 plotaxes.plotitem_dict['friction'].colorbar_label = "$n$" # # Hurricane Forcing fields # # Pressure field plotfigure = plotdata.new_plotfigure(name='Pressure') plotfigure.show = surge_data.pressure_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Gulf']['xlimits'] plotaxes.ylimits = regions['Gulf']['ylimits'] plotaxes.title = "Pressure Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_pressure(plotaxes, bounds=pressure_limits) surgeplot.add_land(plotaxes) # Wind field plotfigure = plotdata.new_plotfigure(name='Wind Speed') plotfigure.show = surge_data.wind_forcing and True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = regions['Gulf']['xlimits'] plotaxes.ylimits = regions['Gulf']['ylimits'] plotaxes.title = "Wind Field" plotaxes.afteraxes = surge_afteraxes plotaxes.scaled = True surgeplot.add_wind(plotaxes, bounds=wind_limits) surgeplot.add_land(plotaxes) # ======================================================================== # Figures for gauges # ======================================================================== plotfigure = plotdata.new_plotfigure(name='Gauge Surfaces', figno=300, type='each_gauge') plotfigure.show = True plotfigure.clf_each_gauge = True # 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' def gauge_afteraxes(cd): axes = plt.gca() surgeplot.plot_landfall_gauge(cd.gaugesoln, axes, landfall=landfall) # Fix up plot - in particular fix time labels 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) 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 = [-95.5, -94] plotaxes.ylimits = [29.0, 30.0] plotaxes.afteraxes = gauge_location_afteraxes surgeplot.add_surface_elevation(plotaxes, bounds=surface_limits) surgeplot.add_land(plotaxes) plotaxes.plotitem_dict['surface'].amr_patchedges_show = [0] * 10 plotaxes.plotitem_dict['land'].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 = [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.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? plotdata.parallel = True # parallel plotting return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # Figure for pressure and velocity: plotfigure = plotdata.new_plotfigure(name='Pressure and Velocity', figno=1) # Pressure: # --------- # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(2,1,1)' # top figure plotaxes.xlimits = 'auto' plotaxes.ylimits = [-.5,1.] plotaxes.title = 'Pressure' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = '-' plotitem.color = 'b' # Velocity: # --------- # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(2,1,2)' # bottom figure plotaxes.xlimits = 'auto' plotaxes.ylimits = [-1.,1.] plotaxes.title = 'Velocity' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 1 plotitem.plotstyle = '-' plotitem.color = 'b' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot from clawpack.visclaw.data import ClawPlotData from numpy import linspace if plotdata is None: plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # To plot gauge locations on pcolor or contour plot, use this as # an afteraxis function: def addgauges(current_data): from clawpack.visclaw import gaugetools gaugetools.plot_gauge_locations(current_data.plotdata, \ gaugenos='all', format_string='wo', add_labels=True) def fixup(current_data): import pylab addgauges(current_data) t = current_data.t t = t / 3600. # hours pylab.title('Surface at %4.2f hours' % t, fontsize=15) #pylab.xticks(fontsize=15) #pylab.yticks(fontsize=15) #----------------------------------------- # Figure for surface #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Full Domain', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.afteraxes = fixup # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.2 plotitem.pcolor_cmax = 0.2 plotitem.add_colorbar = True plotitem.amr_celledges_show = [1, 1, 0] plotitem.patchedges_show = 1 # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [1, 1, 0] plotitem.patchedges_show = 1 plotaxes.xlimits = [-120, -60] plotaxes.ylimits = [-60, 0] #----------------------------------------- # Figure for zoom near Peru #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Peru coast', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Surface' plotaxes.scaled = True plotaxes.afteraxes = fixup plotaxes.xlimits = [-85, -70] plotaxes.ylimits = [-20, 0] # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.surface_or_depth plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.2 plotitem.pcolor_cmax = 0.2 plotitem.add_colorbar = True plotitem.amr_celledges_show = [1, 1, 0] plotitem.patchedges_show = 1 # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [1, 1, 0] plotitem.patchedges_show = 1 #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='Surface at gauges', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Surface' # Plot surface as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 3 plotitem.plotstyle = 'b-' def add_zeroline(current_data): from pylab import plot, legend, xticks, floor, axis, xlabel t = current_data.t gaugeno = current_data.gaugeno if gaugeno == 32412: try: plot(TG32412[:, 0], TG32412[:, 1], 'r') legend(['GeoClaw', 'Obs'], loc='lower right') except: pass axis((0, t.max(), -0.3, 0.3)) plot(t, 0 * t, 'k') n = int(floor(t.max() / 3600.) + 2) xticks([3600 * i for i in range(n)], ['%i' % i for i in range(n)]) xlabel('time (hours)') plotaxes.afteraxes = add_zeroline #----------------------------------------- # 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # Figure for q[0] plotfigure = plotdata.new_plotfigure(name='Solution', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0,1] plotaxes.ylimits = [-.6,1.2] plotaxes.title = 'q' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.amr_color = ['g','b','r'] plotitem.amr_plotstyle = ['^-','s-','o-'] plotitem.amr_data_show = [1,1,1] plotitem.amr_kwargs = [{'markersize':8},{'markersize':6},{'markersize':5}] # Plot true solution for comparison: def plot_qtrue(current_data): from pylab import plot, legend x = linspace(0,1,1000) t = current_data.t q = qtrue(x,t) plot(x,q,'k',label='true solution') def plot_qtrue_with_legend(current_data): from pylab import plot, legend x = linspace(0,1,1000) t = current_data.t q = qtrue(x,t) plot(x,q,'k',label='true solution') try: from clawpack.visclaw import legend_tools labels = ['Level 1','Level 2', 'Level 3','True solution'] legend_tools.add_legend(labels, colors=['g','b','r','k'], markers=['^','s','o',''], linestyles=['','','','-'], loc='lower right') except: legend(loc='lower right') plotaxes.afteraxes = plot_qtrue_with_legend # ------------------------------------------ # Figure with each level plotted separately: plotfigure = plotdata.new_plotfigure(name='By AMR Level', figno=2) plotfigure.kwargs = {'figsize':(8,10)} for level in range(1,4): # Set up plot for this level: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(3,1,%i)' % level plotaxes.xlimits = [0,1] plotaxes.ylimits = [-.5,1.3] plotaxes.title = 'Level %s' % level plotaxes.afteraxes = plot_qtrue plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.amr_color = ['g','b','r'] plotitem.amr_plotstyle = ['^-','s-','o-'] plotitem.amr_data_show = [0,0,0] plotitem.amr_data_show[level-1] = 1 # show only one level #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='q', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Solution' plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = 'b-' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data def set_drytol(current_data): # The drytol parameter is used in masking land and water and # affects what color map is used for cells with small water depth h. # The cell will be plotted as dry if h < drytol. # The best value to use often depends on the application and can # be set here (measured in meters): current_data.user["drytol"] = 1.e-3 plotdata.beforeframe = set_drytol #----------------------------------------- # Figure for pcolor plot #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='pcolor', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('pcolor') plotaxes.title = 'Surface' plotaxes.scaled = True # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.surface plotitem.pcolor_cmap = geoplot.tsunami_colormap plotitem.pcolor_cmin = -0.1 plotitem.pcolor_cmax = 0.1 plotitem.add_colorbar = True plotitem.amr_celledges_show = [0,0,0] plotitem.patchedges_show = 1 # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land plotitem.pcolor_cmap = geoplot.land_colors plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 100.0 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0,0,0] plotitem.patchedges_show = 1 plotaxes.xlimits = [-2,2] plotaxes.ylimits = [-2,2] # Add contour lines of bathymetry: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = geoplot.topo from numpy import arange, linspace plotitem.contour_levels = linspace(-.1, 0.5, 20) plotitem.amr_contour_colors = ['k'] # color on each level plotitem.kwargs = {'linestyles':'solid'} plotitem.amr_contour_show = [1] plotitem.celledges_show = 0 plotitem.patchedges_show = 0 plotitem.show = True #----------------------------------------- # Figure for cross section #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='cross-section', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-2,2] plotaxes.ylimits = [-0.15,0.3] plotaxes.title = 'Cross section at y=0' def plot_topo_xsec(current_data): from pylab import plot, cos,sin,where,legend,nan t = current_data.t x = linspace(-2,2,201) y = 0. B = h0*(x**2 + y**2)/a**2 - h0 eta1 = sigma*h0/a**2 * (2.*x*cos(omega*t) + 2.*y*sin(omega*t) -sigma) etatrue = where(eta1>B, eta1, nan) plot(x, etatrue, 'r', label="true solution", linewidth=2) plot(x, B, 'g', label="bathymetry") ## plot([0],[-1],'kx',label="Level 1") # shouldn't show up in plots, ## plot([0],[-1],'bo',label="Level 2") # but will produced desired legend plot([0],[-1],'bo',label="Computed") ## need to fix plotstyle legend() plotaxes.afteraxes = plot_topo_xsec plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') def xsec(current_data): # Return x value and surface eta at this point, along y=0 from pylab import find,ravel x = current_data.x y = current_data.y dy = current_data.dy q = current_data.q ij = find((y <= dy/2.) & (y > -dy/2.)) x_slice = ravel(x)[ij] eta_slice = ravel(q[3,:,:])[ij] return x_slice, eta_slice plotitem.map_2d_to_1d = xsec plotitem.plotstyle = 'kx' ## need to be able to set amr_plotstyle plotitem.kwargs = {'markersize':3} plotitem.amr_show = [1] # plot on all levels #----------------------------------------- # Figure for grids alone #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='grids', figno=2) plotfigure.show = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [-2,2] plotaxes.ylimits = [-2,2] plotaxes.title = 'grids' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = [1,1,0] plotitem.amr_patchedges_show = [1] #----------------------------------------- # 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 = [] # 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- r"""Setplot function for surge plotting""" if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() 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 = 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 = 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? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data # Figure for density - pcolor plotfigure = plotdata.new_plotfigure(name='Density', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0,1] plotaxes.ylimits = [0,1] plotaxes.title = 'Density' plotaxes.scaled = True plotaxes.afteraxes = addgauges # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = 0 #plotitem.pcolor_cmap = colormaps.yellow_red_blue plotitem.pcolor_cmin = 0. plotitem.pcolor_cmax = 2. plotitem.add_colorbar = True plotitem.amr_patchedges_show = [0] plotitem.amr_celledges_show = [0] # Figure for density - Schlieren plotfigure = plotdata.new_plotfigure(name='Schlieren', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0,1] plotaxes.ylimits = [0,1] plotaxes.title = 'Density' plotaxes.scaled = True # so aspect ratio is 1 # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_schlieren') plotitem.schlieren_cmin = 0.0 plotitem.schlieren_cmax = 1.0 plotitem.plot_var = 0 plotitem.add_colorbar = False # Figure for grid cells plotfigure = plotdata.new_plotfigure(name='cells', figno=2) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0,1] plotaxes.ylimits = [0,1] plotaxes.title = 'Grid patches' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee'] plotitem.amr_celledges_show = [1,0] plotitem.amr_patchedges_show = [1] #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='q', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0,1] plotaxes.ylimits = [0,1] plotaxes.title = 'Density' # Plot q as blue curve: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = 'b-' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_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.html_movie = 'JSAnimation' # new style, or "4.x" for old style plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? plotdata.parallel = True # make multiple frame png's at once return plotdata
def setplot(plotdata): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps from numpy import linspace if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data def plot_corner(current_data): from pylab import plot plot([.0,.0],[-1,0],'r',linewidth=2) plot([.0,1],[0,.55],'r',linewidth=2) def sigmatr(current_data): # trace of sigma q = current_data.q return q[0,:,:] + q[1,:,:] # Figure for trace of sigma plotfigure = plotdata.new_plotfigure(name='trace(sigma)', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'trace(sigma)' plotaxes.scaled = True plotaxes.afteraxes = plot_corner # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = sigmatr plotitem.pcolor_cmap = colormaps.red_yellow_blue plotitem.pcolor_cmin = -1. plotitem.pcolor_cmax = 1. plotitem.add_colorbar = True plotitem.show = True # show on plot? # Figure for shear stress plotfigure = plotdata.new_plotfigure(name='shear', figno=1) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'shear stress' plotaxes.scaled = True plotaxes.afteraxes = plot_corner # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = 2 # sigma_12 plotitem.pcolor_cmap = colormaps.red_yellow_blue plotitem.pcolor_cmin = -0.2 plotitem.pcolor_cmax = 0.2 plotitem.add_colorbar = True plotitem.show = True # show on plot? # Figure for contours plotfigure = plotdata.new_plotfigure(name='contours', figno=2) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'pressure(black) and shear(green)' plotaxes.scaled = True plotaxes.afteraxes = plot_corner # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = sigmatr plotitem.contour_levels = linspace(-2,8,50) plotitem.contour_colors = 'k' plotitem.show = True # show on plot? # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = 2 # sigma_12 plotitem.contour_levels = linspace(-0.4,0.4,30) plotitem.contour_colors = 'g' plotitem.show = True # show on plot? # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' # 'ascii', 'binary', 'netcdf' def draw_interface_add_legend(current_data): from pylab import plot plot([0., 0.], [-1000., 1000.], 'k--') try: from clawpack.visclaw import legend_tools labels = ['Level 1','Level 2', 'Level 3'] legend_tools.add_legend(labels, colors=['g','b','r'], markers=['^','s','o'], linestyles=['','',''], loc='upper left') except: pass # Figure for q[0] plotfigure = plotdata.new_plotfigure(name='Adjoint and Velocity', figno=1) plotfigure.kwargs = {'figsize': (8,8)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(2,1,1)' # top figure plotaxes.xlimits = 'auto' plotaxes.ylimits = [-.5,1.1] plotaxes.title = 'Adjoint' plotaxes.afteraxes = draw_interface_add_legend # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.amr_color = ['g','b','r'] plotitem.amr_plotstyle = ['^-','s-','o-'] plotitem.amr_data_show = [1,1,1] plotitem.amr_kwargs = [{'markersize':5},{'markersize':4},{'markersize':3}] # Figure for q[1] # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(2,1,2)' # bottom figure plotaxes.xlimits = 'auto' plotaxes.ylimits = [-.5,1.1] plotaxes.title = 'Velocity' plotaxes.afteraxes = draw_interface_add_legend # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 1 plotitem.amr_color = ['g','b','r'] plotitem.amr_plotstyle = ['^-','s-','o-'] plotitem.amr_data_show = [1,1,1] plotitem.amr_kwargs = [{'markersize':5},{'markersize':4},{'markersize':3}] #----------------------------------------- # Figures for gauges #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='q', figno=300, \ type='each_gauge') plotfigure.clf_each_gauge = True plotfigure.kwargs = {'figsize': (10,10)} plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(211)' plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Pressure' plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = 'b-' plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(212)' plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Velocity' plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 1 plotitem.plotstyle = 'b-' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data gamma = 1.4 def pressure(current_data): q = current_data.q rho = q[0, :] u = q[1, :] / rho p = (gamma - 1) * (q[2, :] - 0.5 * rho * u**2) return p plotfigure = plotdata.new_plotfigure(name='Density and Pressure', figno=1) plotfigure.kwargs = {'figsize': (10, 5)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1,2,1)' # left figure plotaxes.xlimits = [0, 1] plotaxes.ylimits = [0, 7] plotaxes.title = 'Density' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = 0 plotitem.plotstyle = '-' plotitem.color = 'b' # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(1,2,2)' # right plotaxes.xlimits = [0, 1] plotaxes.ylimits = [0, 1450] plotaxes.title = 'Pressure' # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.plot_var = pressure plotitem.plotstyle = '-' plotitem.color = 'b' # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() from clawpack.visclaw import colormaps plotdata.clearfigures() # clear any old figures,axes,items data # Figure for pressure # ------------------- plotfigure = plotdata.new_plotfigure(name='Pressure', figno=0) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = 'auto' plotaxes.ylimits = 'auto' plotaxes.title = 'Pressure' plotaxes.scaled = True # so aspect ratio is 1 # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = 0 plotitem.pcolor_cmap = colormaps.blue_yellow_red plotitem.pcolor_cmin = -2.0 plotitem.pcolor_cmax = 2.0 plotitem.add_colorbar = True # Figure for scatter plot # ----------------------- plotfigure = plotdata.new_plotfigure(name='scatter', figno=3) plotfigure.show = (qref_dir is not None) # don't plot if 1d solution is missing # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = [0,1.5] plotaxes.ylimits = [-2.,4.] plotaxes.title = 'Scatter plot' # Set up for item on these axes: scatter of 2d data plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data') def p_vs_r(current_data): # Return radius of each grid cell and p value in the cell from pylab import sqrt x = current_data.x y = current_data.y r = sqrt(x**2 + y**2) q = current_data.q p = q[0,:,:] return r,p plotitem.map_2d_to_1d = p_vs_r plotitem.plot_var = 0 plotitem.plotstyle = 'o' plotitem.color = 'b' plotitem.show = (qref_dir is not None) # show on plot? # Set up for item on these axes: 1d reference solution plotitem = plotaxes.new_plotitem(plot_type='1d_plot') plotitem.outdir = qref_dir plotitem.plot_var = 0 plotitem.plotstyle = '-' plotitem.color = 'r' plotitem.kwargs = {'linewidth': 2} plotitem.show = True # show on plot? def make_legend(current_data): import matplotlib.pyplot as plt plt.legend(('2d data', '1d reference solution')) plotaxes.afteraxes = make_legend # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_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.html_movie = 'JSAnimation' # new style, or "4.x" for old style 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=None): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of pyclaw.plotters.data.ClawPlotData. Output: a modified version of plotdata. """ from clawpack.visclaw import colormaps, geoplot from numpy import linspace if plotdata is None: from clawpack.visclaw.data import ClawPlotData plotdata = ClawPlotData() plotdata.clearfigures() # clear any old figures,axes,items data def speed(current_data): from numpy import ma, where, sqrt, log10 drytol = 1e-3 q = current_data.q h = q[0, :, :] hu = q[1, :, :] hv = q[2, :, :] u = where(h > 0.0, hu / h, 0.) v = where(h > 0.0, hv / h, 0.) speed = sqrt(u**2 + v**2) return speed def stress(current_data): from numpy import ma, where, sqrt, log10 q = current_data.q h = q[0, :, :] hu = q[1, :, :] hv = q[2, :, :] u = where(h > 0.0, hu / h, 0.) v = where(h > 0.0, hv / h, 0.) speed = np.sqrt(u**2 + v**2) #Speed calc, same as above n = 0.06 #Manning's n g = 9.8 #gravity cf = where( h > 0.0, (g * n**2) / (h**(1. / 3)), 0. ) #calculate friction coefficient, DONT FORGET THE F*****G PERIOD YOU IDIOT (mike) stress = 1000 * cf * (speed**2) return stress # def erodibilityratio(current_data): # ratio of impelling forces (dimensionless shear stress T) to resisting forces (critical shear stress Tc) # from numpy import ma, where, sqrt, log10 # q=current_data.q # h=q[0,:,:] # hu=q[1,:,:] # hv=q[2,:,:] # u = where(h>0.0, hu/h, 0.) # v = where(h>0.0, hv/h, 0.) # speed = sqrt(u**2 +v**2) #Speed calc, same as above # n = 0.06 #Manning's n # g = 9.8 #gravity # def dsp(current_data): # dsp = depth slope product # from numpy import ma, where, sqrt, log10 # q = current_data.q # h=q[0,:,:] # g = 9.8 # gravity # dsp = 1000*g*h*0.02 # using a bulk channel gradient of 0.02-- will need to figure out how to make a localized measurement of this # return dsp # def froude(current_data): # from numpy import ma, where, sqrt, log10 # drytol = 1e-3 # q = current_data.q # h=q[0,:,:] # hu=q[1,:,:] # hv=q[2,:,:] # u = where(h>0.0, hu/h, 0.) # v = where(h>0.0, hv/h, 0.) # g = 9.8 # speed = np.sqrt(u**2 +v**2) # froude = speed/((g*h)**(1.2)) # return froude # def blocksize(current_data): # from numpy import ma, where, sqrt, log10 # q = current_data.q # h=q[0,:,:] # hu=q[1,:,:] # hv=q[2,:,:] # u = where(h>0.0, hu/h, 0.) # v = where(h>0.0, hv/h, 0.) # speed = np.sqrt(u**2 +v**2) #Speed calc, same as above # n = 0.04 #Manning's n # g = 9.8 #gravity idiot # cf = where(h>0.0, (g*n**2)/(h**(1./3)), 0.) # stress = 1000*cf*(speed**2) # tc = 0.15*((0.02)**(1./4)) #need to choose a slope here, sooooo 0.02 # blocksize = stress/(tc*g*1700) # return blocksize #####----------------------------------------- # Backflow up the Siyom (depth) - arrives at Frame 35 #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='backflow_depth', figno=39) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 10]} # # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Depth') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.6, 95.1] plotaxes.ylimits = [28.00, 28.35] # Water plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = geoplot.depth #variable to plot plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 200.0 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 100.0 plotitem.pcolor_cmax = 2000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #####----------------------------------------- # Backflow up the Siyom (speed) #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='backflow_speed', figno=40) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 10]} # # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Speed') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.6, 95.1] plotaxes.ylimits = [28.00, 28.35] # speed plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = speed plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 60 plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 100.0 plotitem.pcolor_cmax = 2000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #####----------------------------------------- # Backflow up the Siyom (stress) #----------------------------------------- plotfigure = plotdata.new_plotfigure(name='backflow_stress', figno=41) plotfigure.show = False plotfigure.kwargs = {'figsize': [15, 10]} # # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes('Stress') #plotaxes.title = 'Water Surface' plotaxes.scaled = True plotaxes.xlimits = [94.6, 95.1] plotaxes.ylimits = [28.00, 28.35] # stress plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') #plotitem.plot_var = geoplot.surface plotitem.plot_var = stress plotitem.pcolor_cmap = geoplot.custom_river plotitem.pcolor_cmin = 0.0 plotitem.pcolor_cmax = 20000 #make this reasonable max stress plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Land plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = geoplot.land #plotitem.pcolor_cmap = geoplot.blank plotitem.pcolor_cmap = geoplot.bw_colormap plotitem.pcolor_cmin = 100.0 plotitem.pcolor_cmax = 2000.0 #plotitem.add_colorbar = True #turn off for making movies plotitem.amr_celledges_show = [0] #plotaxes.afteraxes = addgauges # #####----------------------------------------- # # Backflow up the Siyom (blocksize) # #----------------------------------------- # plotfigure = plotdata.new_plotfigure(name='blocksize_stress', figno=42) # plotfigure.show = False # plotfigure.kwargs = {'figsize':[15,10]} # # # # Set up for axes in this figure: # plotaxes = plotfigure.new_plotaxes('Maximum grain size capable of being moved') # #plotaxes.title = 'Water Surface' # plotaxes.scaled = True # plotaxes.xlimits = [94.65,95.0] # plotaxes.ylimits = [28.15,28.35] # # stress # plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') # #plotitem.plot_var = geoplot.surface # plotitem.plot_var = blocksize # plotitem.pcolor_cmap = geoplot.custom_river # plotitem.pcolor_cmin = 0.0 # plotitem.pcolor_cmax = 32.8 #make this reasonable max stress # plotitem.add_colorbar = True #turn off for making movies # plotitem.amr_celledges_show = [0] # plotitem.amr_patchedges_show = [0] # # Land # plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') # plotitem.plot_var = geoplot.land # #plotitem.pcolor_cmap = geoplot.blank # plotitem.pcolor_cmap = geoplot.bw_colormap # plotitem.pcolor_cmin = 100.0 # plotitem.pcolor_cmax = 2000.0 # #plotitem.add_colorbar = True #turn off for making movies # plotitem.amr_celledges_show = [0] # #plotaxes.afteraxes = addgauges #----------------------------------------- # 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 = np.arange(0,5,1) # list of frames to print #plotdata.print_framenos = [9] #frame is a timestep, so this is the way #plotdata.print_gaugenos = [1,2,3,4] # list of gauges to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = False # 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? plotdata.parallel = True # make multiple frame png's at once return plotdata