%pylab inline import os CLAW = os.environ['CLAW'] print CLAW example_dir = os.getcwd() print example_dir %%system make .exe from clawpack.clawutil.runclaw import runclaw import setrun outdir = '_output' rundata = setrun.setrun() rundata.clawdata.num_cells = [40,40] rundata.gaugedata.gauges.append([2, 0.6, 0.8, 0., 10.]) rundata.probdata.u = 0.5 rundata.probdata.v = 1.0 rundata.clawdata.limiter = ['vanleer'] rundata.write() runclaw(xclawcmd='xamr', outdir=outdir, overwrite=True, restart=False, rundir='.') from clawpack.visclaw.data import ClawPlotData import setplot plotdir = '_plots' plotdata = ClawPlotData() plotdata = setplot.setplot(plotdata) plotdata.outdir = outdir plotdata.plotdir = plotdir plotdata.plotframe(2); show() plotdata.showitems() plotitem = plotdata.getitem('ITEM1','AXES1','pcolor') plotitem.amr_patchedges_show = [1] # show patch edges on all levels plotitem.amr_celledges_show = [1,0] # only show grid cells on coarsest level for frameno in range(4): plotdata.plotframe(frameno) show() import sys sys_stdout = sys.stdout sys_stderr = sys.stderr #plotdata.setplot = False # to keep changes made above to plotdata plotdata.setplot = setplot.setplot # to use original setplot function plotdata.plotdir = plotdir from clawpack.visclaw import plotpages plotpages.plotclaw_driver(plotdata, verbose=False) sys.stdout = sys_stdout; sys.stderr = sys_stderr import glob from matplotlib import image from clawpack.visclaw.JSAnimation import IPython_display from matplotlib import animation figno = 0 fname = '_plots/*fig' + str(figno) + '.png' filenames=sorted(glob.glob(fname)) fig = plt.figure() im = plt.imshow(image.imread(filenames[0])) def init(): im.set_data(image.imread(filenames[0])) return im, def animate(i): image_i=image.imread(filenames[i]) im.set_data(image_i) return im, animation.FuncAnimation(fig, animate, init_func=init, frames=len(filenames), interval=20, blit=True) for gaugeno in [1,2]: gauge = plotdata.getgauge(gaugeno) q = gauge.q[0,:] t = gauge.t qmax = q.max() tmax = t[q.argmax()] print "Gauge %s at %s has a maximum value of q = %7.5f at t = %7.5f" % (gaugeno, gauge.location, qmax, tmax) plot(t,q,label="Gauge %s" % gaugeno) legend() ylim(-0.1,1.1) xlabel('time') ylabel('q at gauge') title("Gauge output")