def plotframe(frameno, level=1): plotdata = ClawPlotData() plotdata.outdir = "_output" print "Plotting solution from ", plotdata.outdir plotdata = setplot(plotdata) try: frame = plotdata.getframe(frameno) except: print "Unable to get frame" return mlab.figure(1, bgcolor=(1, 1, 1), size=(700, 600)) mlab.clf() for grid in frame.grids: if grid.level <= level: y = grid.c_center[1] x = grid.c_center[0] q = grid.q eta = q[:, :, 3] h = q[:, :, 0] #return x,y,eta #eta = where(q[:,:,0] > 1.,eta,nan) #import pdb; pdb.set_trace() topo = eta - h cutoff = 0.5 #cutoff2 = -500. shift = 0. scale = 10. topo1 = scale * where(topo < cutoff, topo - shift, cutoff - shift) #topo1 = scale*where(topo>cutoff2, topo1, nan) eta1 = scale * where(eta < cutoff, eta - shift, cutoff - shift) water1 = where(h >= 1.e-3, eta1, nan) mlab.mesh(x, y, topo1, colormap='Greens', vmin=-1.0, vmax=0.8) mlab.mesh(x, y, water1, colormap='Blues', vmin=-0.8, vmax=0.8) #mlab.surf(x,y,topo1,colormap='Greens',warp_scale=10,vmin=-0.8,vmax=0.5) #mlab.surf(x,y,water1,colormap='Blues',warp_scale=10,vmin=-0.8,vmax=0.5) V = (150.95115856920216,\ 80.12676623482308,\ 13.359093592227218,\ array([ 2.744 , 1.70099999, -0.04745156])) V = (-108.612973405259,\ 62.96905073871072,\ 13.359093592227456,\ array([ 2.744 , 1.70099999, -0.04745156])) mlab.view(*V) t = frame.t mlab.title('Time = %5.2f' % t, color=(0, 0, 0), height=0.1, size=0.5)
def plotframe(frameno,level=1): plotdata = ClawPlotData() plotdata.outdir = "_output" print "Plotting solution from ",plotdata.outdir plotdata = setplot(plotdata) try: frame = plotdata.getframe(frameno) except: print "Unable to get frame" return mlab.figure(1,bgcolor=(1,1,1),size=(700,600)) mlab.clf() for grid in frame.grids: if grid.level <= level: y = grid.c_center[1] x = grid.c_center[0] q = grid.q eta = q[:,:,3] h = q[:,:,0] #return x,y,eta #eta = where(q[:,:,0] > 1.,eta,nan) #import pdb; pdb.set_trace() topo = eta - h cutoff = 0.5 #cutoff2 = -500. shift = 0. scale = 10. topo1 = scale*where(topo<cutoff, topo-shift, cutoff-shift) #topo1 = scale*where(topo>cutoff2, topo1, nan) eta1 = scale*where(eta<cutoff, eta-shift, cutoff-shift) water1 = where(h>=1.e-3, eta1, nan) mlab.mesh(x,y,topo1,colormap='Greens',vmin=-1.0, vmax=0.8) mlab.mesh(x,y,water1,colormap='Blues',vmin=-0.8, vmax=0.8) #mlab.surf(x,y,topo1,colormap='Greens',warp_scale=10,vmin=-0.8,vmax=0.5) #mlab.surf(x,y,water1,colormap='Blues',warp_scale=10,vmin=-0.8,vmax=0.5) V = (150.95115856920216,\ 80.12676623482308,\ 13.359093592227218,\ array([ 2.744 , 1.70099999, -0.04745156])) V = (-108.612973405259,\ 62.96905073871072,\ 13.359093592227456,\ array([ 2.744 , 1.70099999, -0.04745156])) mlab.view(*V) t = frame.t mlab.title('Time = %5.2f' % t,color=(0,0,0),height=0.1,size=0.5)
def plotframe(frameno,level=1, water_opacity=1.): plotdata = ClawPlotData() plotdata.outdir = outdir print "Plotting solution from ",plotdata.outdir plotdata = setplot(plotdata) try: frame = plotdata.getframe(frameno) except: print "Unable to get frame" return mlab.figure(1,bgcolor=(1,1,1),size=(700,600)) mlab.clf() for grid in frame.grids: if grid.level == level: y = grid.c_center[1] x = grid.c_center[0] q = grid.q eta = q[:,:,3] h = q[:,:,0] topo = eta - h cutoff = 0.5 #cutoff2 = -500. shift = 0. scale = 1. topo1 = scale*where(topo<cutoff, topo-shift, cutoff-shift) #topo1 = scale*where(topo>cutoff2, topo1, nan) eta1 = scale*where(eta<cutoff, eta-shift, cutoff-shift) water1 = where(h>=1.e-3, eta1, nan) scale = 12. #mlab.mesh(x,y,topo1,colormap='Greens',vmin=-1.0, vmax=0.8) #mlab.mesh(x,y,water1,colormap='Blues',vmin=-0.8, vmax=0.8) mlab.surf(x,y,topo1,colormap='YlGn',warp_scale=scale,\ vmin=-0.3,vmax=0.3) mlab.surf(x,y,water1,colormap='Blues',warp_scale=scale,\ vmin=-0.2,vmax=0.3, opacity=water_opacity) # set the view: (Do V = view() to figure out the current view) V = (29.157490879985176,\ 67.560491214404507,\ 79.798910042690324,\ array([ 0. , 1. , -0.07500005])) mlab.view(*V) t = frame.t mlab.title('Time = %5.2f' % t,color=(0,0,0),height=0.1,size=0.5)
def plotframe(frameno,level=1, water_opacity=1.): plotdata = ClawPlotData() plotdata.outdir = outdir print "Plotting solution from ",plotdata.outdir plotdata = setplot(plotdata) try: frame = plotdata.getframe(frameno) except: print "Unable to get frame" return mlab.figure(1,bgcolor=(1,1,1),size=(700,600)) mlab.clf() for grid in frame.grids: if grid.level == level: y = grid.c_center[1] x = grid.c_center[0] q = grid.q eta = q[:,:,3] h = q[:,:,0] topo = eta - h cutoff = 100. #cutoff2 = -500. shift = 0. scale = 1. topo1 = scale*where(topo<cutoff, topo-shift, cutoff-shift) #topo1 = scale*where(topo>cutoff2, topo1, nan) eta1 = scale*where(eta<cutoff, eta-shift, cutoff-shift) water1 = where(h>=1.e-3, eta1, nan) scale = 10. #mlab.mesh(x,y,topo1,colormap='Greens',vmin=-1.0, vmax=0.8) #mlab.mesh(x,y,water1,colormap='Blues',vmin=-0.8, vmax=0.8) if 0: mlab.surf(x,y,topo1,colormap='YlGn',warp_scale=scale,\ vmin=-0.3,vmax=0.3) mlab.surf(x,y,water1,colormap='Blues',warp_scale=scale,\ vmin=-0.2,vmax=0.3, opacity=water_opacity) # set the view: (Do V = view() to figure out the current view) #mlab.view(*V) t = frame.t
def plotframe(frameno): plotdata = ClawPlotData() plotdata.outdir = "_output" plotdata = setplot(plotdata) frame = plotdata.getframe(frameno) x = frame.grids[0].c_center[0] y = frame.grids[0].c_center[1] q = frame.grids[0].q eta = q[:,:,3] eta = where(q[:,:,0] > 1.,eta,nan) #import pdb; pdb.set_trace() mlab.figure(3,bgcolor=(1,1,1)) mlab.clf() #plot_solid_sphere() plot_lat_long_lines() #x = 360 - x X,Y,Z = plot_eta(x,y,eta)
dtopodir = '/Users/rjl/git/tohoku2011a/sources/' gaugenos = [21401, 21413, 21418, 21419] models = """GCMT Hayes UCSB3 Ammon Caltech Fujii Saito Gusman GusmanAU pmelWei""".split() models = ["GCMT"] for model in models: print "Model: ",model rundata = setrun.setrun() rundata.geodata.dtopofiles = [[1,4,4,dtopodir+'%s.txydz' % model]] rundata.write() # create *.data files outdir = '_output_%s' % model runclaw.runclaw('xgeoclaw',outdir) pd = ClawPlotData() pd = setplot.setplot(pd) pd.outdir = outdir for gaugeno in gaugenos: g = pd.getgauge(gaugeno) d = np.vstack([g.t,g.q[:,3]]).T fname = '../simulation_results/%s_%s.txt' % (model,gaugeno) np.savetxt(fname, d) print "Created ",fname
import setplot import numpy as np dtopodir = '/Users/rjl/git/tohoku2011a/sources/' gaugenos = [21401, 21413, 21418, 21419] models = """GCMT Hayes UCSB3 Ammon Caltech Fujii Saito Gusman GusmanAU pmelWei""".split() models = ["GCMT"] for model in models: print "Model: ", model rundata = setrun.setrun() rundata.geodata.dtopofiles = [[1, 4, 4, dtopodir + '%s.txydz' % model]] rundata.write() # create *.data files outdir = '_output_%s' % model runclaw.runclaw('xgeoclaw', outdir) pd = ClawPlotData() pd = setplot.setplot(pd) pd.outdir = outdir for gaugeno in gaugenos: g = pd.getgauge(gaugeno) d = np.vstack([g.t, g.q[:, 3]]).T fname = '../simulation_results/%s_%s.txt' % (model, gaugeno) np.savetxt(fname, d) print "Created ", fname
from pylab import * from setplot import setplot plotdata = setplot() plotdata.outdir = '_output' g123 = plotdata.getgauge(123) figure() t = g123.t / 3600. # convert to hours eta = g123.q[3, :] # eta = h + B (depth plus bathymetry) plot(t, eta) xlim(3, 8) xlabel('Hours since earthquake') ylabel('meters') title('Sea surface elevation at gauge 123') fname = 'gauge123_surface.png' savefig(fname, bbox_inches='tight') # remove excess white space print "Created ", fname figure() h = g123.q[0, :] # water depth u = g123.q[1, :] / h # u = east-west velocity v = g123.q[2, :] / h # v = north-south velocity plot(t, u, 'g', label='u') plot(t, v, 'r', label='v') legend() title('Velocities at gauge 123') xlabel('Hours since earthquake') ylabel('meters per second')
from pylab import * import os import setplot from clawpack.visclaw.frametools import plotframe from clawpack.visclaw.plottools import plotbox pd = setplot.setplot() pd.outdir=os.path.abspath('_output') savefig_ext = '.jpg' figdir = '../figures' os.system('mkdir -p %s' % figdir) def save_figure(fname): """Save figure to figdir with desired extension""" full_fname = os.path.join(figdir,fname) + savefig_ext savefig(full_fname, bbox_inches='tight') print('Created %s' % full_fname) frameno = 1 plotframe(frameno,pd) figure(0) #axis([-140,-122,40,50]) # set in setplot.py plotbox([-128,-123.5,43,45],kwargs={'color':'k','linewidth':1.5}) fname = 'pacific_f%s' % str(frameno).zfill(4) save_figure(fname) figure(1) plot([-127,-124],[44.4,44.4],'k')
# create executable and .data files: os.system('make .exe') os.system('make data') savefig_ext = '.jpg' figdir = '../figures' os.system('mkdir -p %s' % figdir) def save_figure(fname): """Save figure to figdir with desired extension""" full_fname = os.path.join(figdir, fname) + savefig_ext savefig(full_fname, bbox_inches='tight') print('Created %s' % full_fname) makegrid.makegrid() outdir = '_output' if run_code: runclaw(xclawcmd='xgeo', outdir=outdir) # run clawpack code pd = ClawPlotData() pd = setplot.setplot(pd) # reload grid.data for each xs value pd.outdir = os.path.abspath(outdir) for frameno in [0, 18]: plotframe(frameno, pd) fname = 'transect_frame%s' % str(frameno).zfill(2) save_figure(fname)