Home | Compare with Obs* | Data Assim* | Monitor* | RTOFS & WOCE* | Graphics Viewer* | Data Access | About the Model |
* -- MMAB internal use only |
The following examples use Sage Python to extract and visualize the sea surface height and ocean temperature in the RTOFS Atlantic model using data from the NOMADS data server and a downloaded RTOFS GRiB file.
The examples make use of the following free software:
Begin by importing the necessary modules and set up the figure
from mpl_toolkits.basemap import Basemap import numpy as np import matplotlib.pyplot as plt from pylab import * import netCDF4 plt.figure()
First set up the URL to access the data server.
See the
RTOFS directory on NOMADS for the list of available model run dates.
mydate='20240328'; url='http://nomads.ncep.noaa.gov:9090/dods/ofs/ofs'+ \ mydate+'/hourly/rtofs_forecast_atl'
Note that the NOMADS data server interpolates and delivers the data on a regular lat/lon field, not the native model grid. To analyze the model output on the native grid you will have to work from a downloaded GRiB file (see Example 2).
Extract the sea surface height field from NOMADS.
file = netCDF4.Dataset(url) lat = file.variables['lat'][:] lon = file.variables['lon'][:] data = file.variables['sshgsfc'][1,:,:] file.close()
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=lon.min(), \ urcrnrlon=lon.max(),llcrnrlat=lat.min(),urcrnrlat=lat.max(), \ resolution='c')
Lon, Lat = meshgrid(lon,lat) x, y = m(Lon,Lat)
cs = m.pcolormesh(x,y,data,shading='flat',cmap=plt.cm.jet)
m.drawcoastlines() m.fillcontinents() m.drawmapboundary() m.drawparallels(np.arange(-90.,120.,30.),labels=[1,0,0,0]) m.drawmeridians(np.arange(-180.,180.,60.),labels=[0,0,0,1])
colorbar(cs,orientation='vertical') plt.title('Example 1: RTOFS Sea Surface Height from NOMADS') plt.show()
This example requires that you download a GRiB file from either our NOMADS data server or the Production FTP Server (see our Data Access page for more information. For this exercise, I used the nowcast file for 20111004: ofs_atl.t00z.N000.grb.grib2 retrieved from NOMADS. This example assumes that the GRiB file is in the current working directory.
Begin by importing the necessary modules and set up the figure
from grib2 import Grib2Decode from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt from pylab import * plt.figure()
grib='ofs_atl.t00z.N000.grb.grib2';
want_level = 4 zgribs = [g for g in grbs if g.parameter == '3-D Temperature'] nlevs = len(zgribs) for nlev,zg in enumerate(zgribs): if nlev == want_level: temp = zg.data() for g in grbs: if g.parameter == 'Longitude of Presure Point': lon = g.data() if g.parameter == 'Latitude of Presure Point': lat = g.data()
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=lon.min(), \ urcrnrlon=lon.max(),llcrnrlat=lat.min(),urcrnrlat=lat.max(), \ resolution='c')
x, y = m(lon,lat)
cs = m.pcolormesh(x,y,data,shading='flat',cmap=plt.cm.jet)
m.drawcoastlines() m.fillcontinents() m.drawmapboundary() m.drawparallels(np.arange(-90.,120.,30.),labels=[1,0,0,0]) m.drawmeridians(np.arange(-180.,180.,60.),labels=[0,0,0,1])
colorbar(cs,orientation='vertical') plt.title('Example 2: RTOFS Temperature at level 5 from GRiB') plt.show()
About Us
About the MMAB -
Mission -
Other NCEP Centers -
MMAB Personnel -
NOAA Locator
USA.gov
is the U.S. government's official web portal to all federal,
state and local government web resources and services.
NOAA/
National Weather Service
National Centers for Environmental Prediction
Environmental Modeling Center
Marine Modeling and Analysis Branch
5200 Auth Road
Camp Springs, Maryland 20746-4304 USA
Comments/Feedback
Disclaimer
Privacy Policy
Page last modified: Friday, 07-Oct-2011 16:00:40 UTC