Global RTOFS (Real-Time Ocean Forecast System)

Global RTOFS is a data-assimilated product from NOAA’s Environmental Modeling Center.

This tutorial came from here (bottom of page):

Dependencies: netcdf4-python and Basemap

First you need to download the data from one of the directories here:

Then run the following code (after updating the “file name”)

# For original tutorial, see (bottom of page): This tutorial came from here (bottom of page):

from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
from pylab import *
import netCDF4


nc = '/data/SSTlobster/RTOFS/'

# In this example we will extract the surface temperature field from the model.
# Remember that indexing in Python starts at zero.
file = netCDF4.Dataset(nc)
lat  = file.variables['Latitude'][:]
lon  = file.variables['Longitude'][:]
data = file.variables['temperature'][0,0,:,:]

#There is a quirk to the global NetCDF files that isn't in the NOMADS data, namely that there are junk values of longitude (lon>500) in the rightmost column of the longitude array (they are ignored by the model itself). So we have to work around them a little with NaN substitution.
lon = np.where(np.greater_equal(lon,500),np.nan,lon)

#Plot the field using Basemap. Start with setting the map projection using the limits of the lat/lon data itself
m=Basemap(projection='mill',lat_ts=10, \
      llcrnrlon=np.nanmin(lon),urcrnrlon=np.nanmax(lon), \
      llcrnrlat=lat.min(),urcrnrlat=lat.max(), \

#Convert the lat/lon values to x/y projections.
x, y = m(lon,lat)

#Plot the field using the fast pcolormesh routine and set the colormap to jet.
cs = m.pcolormesh(x,y,data,shading='flat', \

#Add a coastline and axis values.
m.drawparallels(np.arange(-90.,120.,30.), \
m.drawmeridians(np.arange(-180.,180.,60.), \

#Add a colorbar and title, and then show the plot.
plt.title('Global RTOFS SST from NetCDF')

2 thoughts on “Global RTOFS (Real-Time Ocean Forecast System)

  1. It appears a KeyErrow establishing
    data = file.variables[‘temperature’][0,0,:,:]

    tried different str like ‘temp’, ‘sst’ and ‘t’
    please help
    running on Os X Yosemite – Jupyter Terminal Launcher

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s