In [1]:
# In ArcMap, with the multidimensional supplemental tools installed, go to:
# Geoprocessing=>Python
# and type these commands into the python command window
In [2]:
import netCDF4
url='http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3/mean'
nc = netCDF4.Dataset(url)
In [3]:
nc.variables.keys()
Out[3]:
In [4]:
temp = nc.variables['temp']
print temp
In [5]:
timevar = nc.variables['time']
print timevar
In [6]:
# get first (0) and last (-1) time values and convert to datestamps
start = netCDF4.num2date(timevar[0],timevar.units)
stop = netCDF4.num2date(timevar[-1],timevar.units)
print('start: %s' % start.strftime('%Y-%b-%d %H:%M:%S'))
print(' stop: %s' % stop.strftime('%Y-%b-%d %H:%M:%S'))
In [7]:
siglay = nc.variables['siglay'] # fraction of total depth
h=nc.variables['h'] # water depth
print siglay
print h
In [8]:
# z(meters) of layer 20 at node 2000
node = 2000
lev = 20
z = siglay[lev,node]*h[node]
print z
In [9]:
# plot sigma values at specified node
import matplotlib.pyplot as plt
plt.plot(siglay[:,node],'k-o')
plt.grid()
plt.xlabel('sigma level')
plt.ylabel('fraction of total depth')
plt.show()
In [9]: