ROMS Glider

Virtual glider extraction: (lon,lat,time) interpolation from ROMS files


In [1]:
%matplotlib inline
from okean.roms import glider
from okean import netcdf
import numpy as np
import matplotlib.pyplot as plt

Lets use some ROMS-ESPRESSO output and load info from a glider:


In [2]:
froms='http://tds.marine.rutgers.edu/thredds/dodsC/roms/espresso/2009_da/his'
#fglider='http://tds.marine.rutgers.edu/thredds/dodsC/cool/glider/mab/Gridded/20101025T1600_marcoos_ru22_active.nc'
fglider='http://tds.marine.rutgers.edu:8080/thredds/dodsC/cool/glider/all/ru23-20121025T1944.ncCFMA.nc3.nc'
x=netcdf.use(fglider,'longitude')
y=netcdf.use(fglider,'latitude')
t=netcdf.nctime(fglider,'time')

In [3]:
a=glider.RomsGlider(froms,x,y,t)
fig = plt.figure(figsize=(12,12))
a.plot()


<matplotlib.figure.Figure at 0x7f730869a590>

Extract and plot the glider data


In [4]:
z=netcdf.use(fglider,'depth')
v=netcdf.use(fglider,'temperature')

In [5]:
print v.shape
print z.shape
print t.shape


(1560, 362)
(1560, 362)
(1560,)

In [6]:
vmin=10.0
vmax=17.0
fig = plt.figure(figsize=(12,4))
plt.pcolormesh(t,-z,v,vmin=vmin,vmax=vmax)
plt.colorbar()

wk=plt.matplotlib.dates.WeekdayLocator()
fmt=plt.matplotlib.dates.DateFormatter('%d-%b-%Y')
ax=plt.gca()
ax.xaxis.set_major_locator(wk)
ax.xaxis.set_major_formatter(fmt)
plt.title('Observed Glider data: ru23-20121025T1944)');


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-7bcff96326c5> in <module>()
      2 vmax=17.0
      3 fig = plt.figure(figsize=(12,4))
----> 4 plt.pcolormesh(t,-z,v,vmin=vmin,vmax=vmax)
      5 plt.colorbar()
      6 

/home/usgs/miniconda/envs/ioos/lib/python2.7/site-packages/matplotlib/pyplot.pyc in pcolormesh(*args, **kwargs)
   3034         ax.hold(hold)
   3035     try:
-> 3036         ret = ax.pcolormesh(*args, **kwargs)
   3037         draw_if_interactive()
   3038     finally:

/home/usgs/miniconda/envs/ioos/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in pcolormesh(self, *args, **kwargs)
   5087         allmatch = (shading == 'gouraud')
   5088 
-> 5089         X, Y, C = self._pcolorargs('pcolormesh', *args, allmatch=allmatch)
   5090         Ny, Nx = X.shape
   5091 

/home/usgs/miniconda/envs/ioos/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in _pcolorargs(funcname, *args, **kw)
   4706             raise TypeError(
   4707                 'Incompatible X, Y inputs to %s; see help(%s)' % (
-> 4708                 funcname, funcname))
   4709         if allmatch:
   4710             if not (Nx == numCols and Ny == numRows):

TypeError: Incompatible X, Y inputs to pcolormesh; see help(pcolormesh)

Extract and plot a ROMS variable:


In [ ]:
v=a.extract('salt',method='fast')
z=a.depth('salt')
t2=np.tile(a.t[:,np.newaxis],(1,v.shape[1]))

In [ ]:
fig = plt.figure(figsize=(12,4))
plt.pcolormesh(t2,z,v,vmin=vmin,vmax=vmax)
plt.colorbar()

wk=plt.matplotlib.dates.WeekdayLocator()
fmt=plt.matplotlib.dates.DateFormatter('%d-%b-%Y')
ax=plt.gca()
ax.xaxis.set_major_locator(wk)
ax.xaxis.set_major_formatter(fmt)
plt.title('Virtual Glider data from ROMS');

In [ ]: