In [1]:
import numpy as np
import matplotlib.pyplot as plt
import netCDF4
import numpy.ma as ma
import seawater
%matplotlib inline
This is a url from Kerfooot's TDS server, using the multidimensional NetCDF datasets created by a private ERDDAP instance. These multidimensonal datasets are also available from ERDDAP, along with a flattened NetCDF representation and a ragged NetCDF representation.
The glider ERDDAP is here: http://erddap.marine.rutgers.edu/erddap
The glider TDS is here: http://tds.marine.rutgers.edu:8080/thredds/catalog/cool/glider/all/catalog.html
In [2]:
url = 'http://tds.marine.rutgers.edu:8080/thredds/dodsC/cool/glider/all/ru22-20130924T2010.ncCFMA.nc3.nc'
In [3]:
nc = netCDF4.Dataset(url)
ncv = nc.variables
In [4]:
ncv.keys()
Out[4]:
In [5]:
lon = ncv['longitude'][:]
lat = ncv['latitude'][:]
In [6]:
import iris
In [7]:
t = iris.load_cube(url,'sea_water_temperature')
In [8]:
print t
In [9]:
lon=t.coord(axis='X')
In [10]:
lat=t.coord(axis='Y')
In [11]:
z = t.coord(axis='Z')
In [12]:
tvar = t.coord(axis='T')
In [13]:
shape(t)
Out[13]:
In [14]:
tvals= t[0,::5,::2].data
In [15]:
tvals=ma.masked_where(tvals==-999.,tvals)
In [16]:
pcolormesh(flipud(tvals.T));colorbar()
Out[16]:
In [17]:
dist, pha = seawater.extras.dist(lat.points[0],lon.points[0],units='km')
In [18]:
d = np.cumsum(dist)
d = np.insert(d,0,0)
In [19]:
print shape(d)
In [20]:
x = (d*np.ones([680,1])).T
In [21]:
zval = z.points
In [22]:
shape(zval)
Out[22]:
In [23]:
print shape(x[::5,::2])
print shape(zval[0,::5,::2])
print shape(tvals)
In [24]:
shape(x)
Out[24]:
In [25]:
pcolormesh(x[::5,::2],zval[0,::5,::2],tvals)
Out[25]: