In [1]:
import matplotlib.tri as tri
import datetime as dt
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
In [2]:
import iris
iris.FUTURE.netcdf_promote = True
from iris.fileformats.cf import reference_terms
In [3]:
import cartopy.crs as ccrs
import pyugrid
%matplotlib inline
In [4]:
#ADCIRC
#url = 'http://comt.sura.org/thredds/dodsC/data/comt_1_archive/inundation_tropical/UND_ADCIRC/Hurricane_Ike_3D_final_run_with_waves'
#FVCOM
#url = 'http://www.smast.umassd.edu:8080/thredds/dodsC/FVCOM/NECOFS/Forecasts/NECOFS_GOM3_FORECAST.nc'
#SELFE
url = 'http://comt.sura.org/thredds/dodsC/data/comt_1_archive/inundation_tropical/VIMS_SELFE/Hurricane_Ike_3D_final_run_with_waves'
In [5]:
ucube = iris.load_cube(url,'eastward_sea_water_velocity')
vcube = iris.load_cube(url,'northward_sea_water_velocity')
In [6]:
reference_terms['ocean_s_coordinate_g1'] = ['s', 'c', 'eta', 'depth', 'depth_c']
zcube = iris.load_cube(url,'depth_below_geoid')
z = zcube.data
In [7]:
# Desired time for snapshot
# ....right now (or some number of hours from now) ...
start = dt.datetime.utcnow() + dt.timedelta(hours=6)
# ... or specific time (UTC)
#start = dt.datetime(2013,3,2,15,0,0)
In [13]:
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 [9]:
ug.data
Out[9]:
In [10]:
lon = ug.nodes[:,0]
lat = ug.nodes[:,1]
nv = ug.faces[:]
In [11]:
triang = tri.Triangulation(lon,lat,triangles=nv)
In [11]:
In [12]:
# skip trying to find the closest time index to requested time, because it's messy
ind = -1 # just take the last time index for now
zcube = cube[ind]
In [ ]:
plt.figure(figsize=(12,12))
ax = plt.axes(projection=ccrs.PlateCarree())
ax.set_extent([-90, -60, 5, 50])
ax.coastlines()
levs = np.arange(0,5,.2)
plt.tricontourf(triang, z, levels=[10, 20, 50, 100, 200, 500, 1000, 2000])
plt.colorbar()
plt.tricontour(triang, z, colors='k',levels=levs)
tvar = ucube.coord('time')
tstr = tvar.units.num2date(tvar.points[ind])
gl = ax.gridlines(draw_labels=True)
gl.xlabels_top = False
gl.ylabels_right = False
plt.title('%s: Depth (m): %s' % (ucube.attributes['title'],tstr));
In [ ]: