Virtual glider extraction: (lon,lat,time) interpolation from ROMS files using the OKEAN python package: https://github.com/martalmeida/okean
In [1]:
%matplotlib inline
from okean.roms import glider
from okean import netcdf
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.dates import MO, TU, WE, TH, FR, SA, SU
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/20121025T000000_20121105T000000_maracoos_ru23.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')
a=glider.RomsGlider(froms,x,y,t)
a.plot()
Extract and plot the glider data
In [3]:
z=netcdf.use(fglider,'depth')
v=netcdf.use(fglider,'temperature')
In [4]:
print z.shape
print v.shape
print t.shape
In [5]:
print z[0,0]
print z[-1,0]
In [6]:
vmin=10.0
vmax=17.0
fig = plt.figure(figsize=(12,4))
plt.pcolormesh(t,z.T,v.T,vmin=vmin,vmax=vmax)
plt.ylim([-60,0])
plt.colorbar()
wk=plt.matplotlib.dates.WeekdayLocator(byweekday=MO)
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: 20121025T000000_20121105T000000_maracoos_ru23.nc)');
Extract and plot a ROMS-Espresso variable:
In [7]:
v2=a.extract('temp',method='fast')
z2=a.depth('temp')
t2=np.tile(a.t[:,np.newaxis],(1,v2.shape[1]))
Plot with same vertical scale as obs data
In [8]:
fig = plt.figure(figsize=(12,4))
plt.pcolormesh(t2,z2,v2,vmin=vmin,vmax=vmax)
plt.ylim([-60,0])
plt.colorbar()
wk=plt.matplotlib.dates.WeekdayLocator(byweekday=MO)
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 Espresso');
In [9]:
fig = plt.figure(figsize=(12,4))
plt.pcolormesh(t2,z2,v2,vmin=vmin,vmax=vmax)
plt.colorbar()
wk=plt.matplotlib.dates.WeekdayLocator(byweekday=MO)
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 Espresso');
In [9]:
In [9]: