In [ ]:
import netCDF4
import pyugrid
import matplotlib.tri as tri
In [2]:
# dataset form FVcom...
# big
url = 'http://comt.sura.org/thredds/dodsC/data/testbed/inundation_tropical/UND_ADCIRC/Hurricane_Ike_2D_final_run_with_waves'
# little
#url = 'http://www.smast.umassd.edu:8080/thredds/dodsC/FVCOM/NECOFS/Forecasts/NECOFS_GOM2_FORECAST.nc'
url='http://geoport.whoi.edu/thredds/dodsC/usgs/data2/rsignell/estofs/estofs.ncml'
# get the datasets:
# note: this reads the whole thing in to memory at once: maybe we don't want to do that.
print "Loading data: This could take a while..."
ug = pyugrid.UGrid.from_ncfile(url)
# What's in there?
print "There are %i nodes"%ug.nodes.shape[0]
print "There are %i edges"%ug.edges.shape[0]
print "There are %i faces"%ug.faces.shape[0]
In [3]:
lon = ug.nodes[:,0]
lat = ug.nodes[:,1]
nv = ug.faces[:]
In [4]:
triang = tri.Triangulation(lon,lat,triangles=nv)
In [5]:
nc = netCDF4.Dataset(url)
ncv = nc.variables
In [6]:
nc.variables.keys()
Out[6]:
In [7]:
print ncv['zeta']
In [8]:
#z = ncv['zeta'][700,:]
z = ncv['zeta'][10,:]
In [9]:
print z.min()
print z.max()
In [10]:
figure(figsize=(12,8))
levs=arange(-1,5,.2)
gca().set_aspect(1./cos(lat.mean()*pi/180))
tricontourf(triang, z,levels=levs)
colorbar()
tricontour(triang, z, colors='k',levels=levs)
In [ ]: