当前位置: 首页>>代码示例>>Python>>正文


Python ClawPlotData.beforeframe方法代码示例

本文整理汇总了Python中clawpack.visclaw.data.ClawPlotData.beforeframe方法的典型用法代码示例。如果您正苦于以下问题:Python ClawPlotData.beforeframe方法的具体用法?Python ClawPlotData.beforeframe怎么用?Python ClawPlotData.beforeframe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在clawpack.visclaw.data.ClawPlotData的用法示例。


在下文中一共展示了ClawPlotData.beforeframe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setplot

# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import beforeframe [as 别名]
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
#.........这里部分代码省略.........
开发者ID:aks2203,项目名称:geoclaw,代码行数:103,代码来源:setplot.py

示例2: setplot

# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import beforeframe [as 别名]
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
#.........这里部分代码省略.........
开发者ID:rjleveque,项目名称:geoclaw,代码行数:103,代码来源:setplot.py


注:本文中的clawpack.visclaw.data.ClawPlotData.beforeframe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。