本文整理汇总了Python中clawpack.visclaw.data.ClawPlotData.new_plotfigure方法的典型用法代码示例。如果您正苦于以下问题:Python ClawPlotData.new_plotfigure方法的具体用法?Python ClawPlotData.new_plotfigure怎么用?Python ClawPlotData.new_plotfigure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clawpack.visclaw.data.ClawPlotData
的用法示例。
在下文中一共展示了ClawPlotData.new_plotfigure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [as 别名]
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
示例2: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [as 别名]
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
示例3: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [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
#.........这里部分代码省略.........
示例4: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [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.
"""
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
#.........这里部分代码省略.........
示例5: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [as 别名]
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
#.........这里部分代码省略.........
示例6: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [as 别名]
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
#.........这里部分代码省略.........
示例7: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [as 别名]
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:
#.........这里部分代码省略.........
示例8: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [as 别名]
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
示例9: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [as 别名]
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?
#.........这里部分代码省略.........
示例10: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [as 别名]
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)
#.........这里部分代码省略.........
示例11: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [as 别名]
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
示例12: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [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
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)])
#.........这里部分代码省略.........
示例13: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [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
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'
#.........这里部分代码省略.........
示例14: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [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()
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
示例15: setplot
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import new_plotfigure [as 别名]
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
#.........这里部分代码省略.........