本文整理汇总了Python中clawpack.visclaw.data.ClawPlotData.setplot方法的典型用法代码示例。如果您正苦于以下问题:Python ClawPlotData.setplot方法的具体用法?Python ClawPlotData.setplot怎么用?Python ClawPlotData.setplot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clawpack.visclaw.data.ClawPlotData
的用法示例。
在下文中一共展示了ClawPlotData.setplot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plotclaw
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import setplot [as 别名]
def plotclaw(outdir='.', plotdir='_plots', setplot = 'setplot.py',format='ascii'):
"""
Create html and/or latex versions of plots.
INPUT:
setplot is a module containing a function setplot that will be called
to set various plotting parameters.
format specifies the format of the files output from Clawpack
"""
from clawpack.visclaw.data import ClawPlotData
from clawpack.visclaw import plotpages
plotdata = ClawPlotData()
plotdata.outdir = outdir
plotdata.plotdir = plotdir
plotdata.setplot = setplot
plotdata.format = format
plotpages.plotclaw_driver(plotdata, verbose=False, format=format)
示例2: plotclaw
# 需要导入模块: from clawpack.visclaw.data import ClawPlotData [as 别名]
# 或者: from clawpack.visclaw.data.ClawPlotData import setplot [as 别名]
def plotclaw(outdir='.', plotdir='_plots', setplot = 'setplot.py',
format='ascii', msgfile='', frames=None, verbose=False):
"""
Create html and/or latex versions of plots.
INPUT:
setplot is a module containing a function setplot that will be called
to set various plotting parameters.
format specifies the format of the files output from Clawpack
"""
from clawpack.visclaw.data import ClawPlotData
from clawpack.visclaw import plotpages
plotdata = ClawPlotData()
plotdata.outdir = outdir
plotdata.plotdir = plotdir
plotdata.setplot = setplot
plotdata.format = format
plotdata.msgfile = msgfile
frametools.call_setplot(plotdata.setplot, plotdata)
if plotdata.num_procs is None:
plotdata.num_procs = int(os.environ.get("OMP_NUM_THREADS", 1))
# Make sure plotdata.parallel is False in some cases:
if plotdata.parallel:
assert type(setplot) in [str, bool, type(None)], \
"*** Parallel plotting is not supported when ClawPlotData " \
+ "attribute setplot is a function."
if plotdata.parallel and (plotdata.num_procs > 1):
# If this is the original call then we need to split up the work and
# call this function again
# First set up plotdir:
plotdata._parallel_todo = 'initialize'
plotpages.plotclaw_driver(plotdata, verbose=False, format=format)
if frames is None:
if plotdata.num_procs is None:
plotdata.num_procs = int(os.environ.get("OMP_NUM_THREADS", 1))
frames = [[] for n in xrange(plotdata.num_procs)]
framenos = frametools.only_most_recent(plotdata.print_framenos,
outdir)
# don't use more procs than frames or infinite loop!!
num_procs = min(plotdata.num_procs, len(framenos))
for (n, frame) in enumerate(framenos):
frames[n%num_procs].append(frame)
# Create subprocesses to work on each
plotclaw_cmd = "python %s" % __file__
process_queue = []
for n in xrange(num_procs):
plot_cmd = "%s %s %s %s" % (plotclaw_cmd,
outdir,
plotdir,
setplot)
plot_cmd = plot_cmd + " " + " ".join([str(i) for i in frames[n]])
process_queue.append(subprocess.Popen(plot_cmd, shell=True))
poll_interval = 5
try:
while len(process_queue) > 0:
time.sleep(poll_interval)
for process in process_queue:
if process.poll() is not None:
process_queue.remove(process)
if verbose:
print "Number of processes currently:",len(process_queue)
# Stop child processes if interrupt was caught or something went
# wrong
except KeyboardInterrupt:
print "ABORTING: A keyboard interrupt was caught. All " + \
"child processes will be terminated as well."
for process in process_queue:
process.terminate()
raise
except:
print "ERROR: An error occurred while waiting for " + \
"plotting processes to complete. Aborting all " + \
"child processes."
for process in process_queue:
process.terminate()
raise
#.........这里部分代码省略.........