In [3]:
import netCDF4
import datetime as dt
In [4]:
url = 'http://www.smast.umassd.edu:8080/thredds/dodsC/FVCOM/NECOFS/Forecasts/NECOFS_FVCOM_OCEAN_MASSBAY_FORECAST.nc'
nc = netCDF4.Dataset(url)
In [5]:
nc.variables['h'][0]
Out[5]:
In [6]:
nc.variables['zeta'][0][0]
Out[6]:
In [7]:
nc.variables['siglev'][:,0]
Out[7]:
In [8]:
# the vertical coordinate for variables that have dimension 'siglay', like "temperature" and "salt"
tz = nc.variables['siglay'][:,0] * (nc.variables['zeta'][0][0] + nc.variables['h'][0]) + nc.variables['zeta'][0][0]
In [9]:
# is this the resulting depth for the ppoint i=0 at the timestamp=0 for a total of qo levels ?
In [10]:
tz
Out[10]:
In [11]:
# the vertical coordinate for variables that have dimension 'siglev', like "vertical velocity"
wz = nc.variables['siglev'][:,0] * (nc.variables['zeta'][0][0] + nc.variables['h'][0]) + nc.variables['zeta'][0][0]
In [12]:
wz
Out[12]:
The vertical coordinate for "u" and "v" velocity is a bit tricky since velocity is defined at face centers, while the vertical coordinate is defined at nodes
In [14]:
nv = nc.variables['nv'][:].T - 1
print shape(nv)
In [16]:
tz = nc.variables['siglay'][:]* (nc.variables['zeta'][0][:] + nc.variables['h'][:]) + nc.variables['zeta'][0][:]
print shape(tz)
In [25]:
# so here are the z values for the "u" and "v" variables
uz = mean(tz[:,nv],axis=2)
print shape(uz)
In [27]:
# depth at the center of element 0
uz[:,0]
Out[27]:
In [ ]: