Using Iris to access NCEP CFS Forecast

This demonstrates extracting data from a large aggregated archive via OPeNDAP, taking advantage of CF conventions to enable a plot without specification of lon,lat variables, and save extracted data to GRIB2


In [1]:
from IPython.core.display import HTML
HTML('<iframe src=http://scitools.org.uk/iris/ width=800 height=350></iframe>')


Out[1]:

In [9]:
import iris
import iris.quickplot as qplt

In [10]:
# DAP URL: 30 year East Coast wave hindcast (Wave Watch 3 driven by CFSR Winds) 
#cubes = iris.load('http://geoport.whoi.edu/thredds/dodsC/fmrc/NCEP/ww3/cfsr/4m/best'); # 4 arc minute resolution
url='http://geoport.whoi.edu/thredds/dodsC/usgs/data2/rsignell/models/ncep/CFS/flxf.01.2012121706.201212.avrg.grib.00Z.grb2'
cubes = iris.load(url)

In [11]:
# let's see what variables are here
print cubes


0: Categorical Rain (1_Month Average) @ Ground or water surface / (unknown) (time: 1; latitude: 190; longitude: 384)
1: Pressure (1_Month Average) @ High cloud top level / (Pa) (time: 1; latitude: 190; longitude: 384)
2: Planetary Boundary Layer Height (1_Month Average) @ Ground or water surface / (m) (time: 1; latitude: 190; longitude: 384)
3: Surface roughness (1_Month Average) @ Ground or water surface / (m) (time: 1; latitude: 190; longitude: 384)
4: Maximum specific humidity at 2m (1_Month Average) @ Specified height level above ground / (kg/kg) (time: 1; Specified height level above ground: 1; latitude: 190; longitude: 384)
5: v-component of wind (1_Month Average) @ Hybrid level / (m/s) (time: 1; Hybrid level: 1; latitude: 190; longitude: 384)
6: Cloud Work Function (1_Month Average) @ Entire atmosphere layer / (J.kg-1) (time: 1; latitude: 190; longitude: 384)
7: Upward Long-Wave Rad. Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
8: Clear Sky Downward Long Wave Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
9: Surface Slope Type (1_Month Average) @ Ground or water surface / (unknown) (time: 1; latitude: 190; longitude: 384)
10: Momentum flux, v-component (1_Month Average) @ Ground or water surface / (N.m-2) (time: 1; latitude: 190; longitude: 384)
11: Visible Diffuse Downward Solar Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
12: Near IR Diffuse Downward Solar Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
13: Downward Short-Wave Radiation Flux (1_Month Average) @ Nominal top of the atmosphere / (W.m-2) (time: 1; latitude: 190; longitude: 384)
14: Temperature (1_Month Average) @ Depth below land surface layer / (K) (time: 1; Depth below land surface: 4; latitude: 190; longitude: 384)
15: Temperature (1_Month Average) @ Hybrid level / (K) (time: 1; Hybrid level: 1; latitude: 190; longitude: 384)
16: Near IR Beam Downward Solar Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
17: Upward Long-Wave Rad. Flux (1_Month Average) @ Nominal top of the atmosphere / (W.m-2) (time: 1; latitude: 190; longitude: 384)
18: Ice cover (1_Month Average) @ Ground or water surface / (unknown) (time: 1; latitude: 190; longitude: 384)
19: u-component of wind (1_Month Average) @ Specified height level above ground / (m/s) (time: 1; Specified height level above ground: 1; latitude: 190; longitude: 384)
20: Snow Phase Change Heat Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
21: Potential Evaporation Rate (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
22: UV-B Downward Solar Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
23: Pressure (1_Month Average) @ Low cloud top level / (Pa) (time: 1; latitude: 190; longitude: 384)
24: Temperature (1_Month Average) @ Specified height level above ground / (K) (time: 1; Specified height level above ground: 1; latitude: 190; longitude: 384)
25: Total cloud cover (1_Month Average) @ Low cloud layer / (%) (time: 1; latitude: 190; longitude: 384)
26: Total cloud cover (1_Month Average) @ Entire atmosphere layer / (%) (time: 1; latitude: 190; longitude: 384)
27: Storm Surface Runoff (1_Month Average) @ Ground or water surface / (kg.m-2) (time: 1; latitude: 190; longitude: 384)
28: Upward Short-Wave Radiation Flux (1_Month Average) @ Nominal top of the atmosphere / (W.m-2) (time: 1; latitude: 190; longitude: 384)
29: Land cover (0 = sea, 1 = land) (1_Month Average) @ Ground or water surface / (unknown) (time: 1; latitude: 190; longitude: 384)
30: Meridional Flux of Gravity Wave Stress (1_Month Average) @ Ground or water surface / (N.m-2) (time: 1; latitude: 190; longitude: 384)
31: Water equivalent of accumulated snow depth (1_Month Average) @ Ground or water surface / (kg.m-2) (time: 1; latitude: 190; longitude: 384)
32: Albedo (1_Month Average) @ Ground or water surface / (%) (time: 1; latitude: 190; longitude: 384)
33: Soil type (1_Month Average) @ Ground or water surface / (unknown) (time: 1; latitude: 190; longitude: 384)
34: Precipitation rate (1_Month Average) @ Ground or water surface / (kg.m-2.s-1) (time: 1; latitude: 190; longitude: 384)
35: Precipitable water (1_Month Average) @ Entire atmosphere layer / (kg.m-2) (time: 1; latitude: 190; longitude: 384)
36: Maximum temperature (1_Month Average) @ Specified height level above ground / (K) (time: 1; Specified height level above ground: 1; latitude: 190; longitude: 384)
37: Water runoff (1_Month Average) @ Ground or water surface / (kg.m-2) (time: 1; latitude: 190; longitude: 384)
38: v-component of wind (1_Month Average) @ Specified height level above ground / (m/s) (time: 1; Specified height level above ground: 1; latitude: 190; longitude: 384)
39: Clear Sky Upward Solar Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
40: Soil moisture content (1_Month Average) @ Depth below land surface layer / (kg.m-2) (time: 1; Depth below land surface: 1; latitude: 190; longitude: 384)
41: Total cloud cover (1_Month Average) @ Boundary layer cloud layer / (%) (time: 1; latitude: 190; longitude: 384)
42: Latent heat net flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
43: Specific humidity (1_Month Average) @ Hybrid level / (kg/kg) (time: 1; Hybrid level: 1; latitude: 190; longitude: 384)
44: Liquid Volumetric Soil Moisture (non Frozen) (1_Month Average) @ Depth below land surface layer / (unknown) (time: 1; Depth below land surface: 4; latitude: 190; longitude: 384)
45: Pressure (1_Month Average) @ Convective cloud top level / (Pa) (time: 1; latitude: 190; longitude: 384)
46: Clear Sky Upward Long Wave Flux (1_Month Average) @ Nominal top of the atmosphere / (W.m-2) (time: 1; latitude: 190; longitude: 384)
47: Ice thickness (1_Month Average) @ Ground or water surface / (m) (time: 1; latitude: 190; longitude: 384)
48: Geopotential height (1_Month Average) @ Hybrid level / (unknown) (time: 1; Hybrid level: 1; latitude: 190; longitude: 384)
49: Pressure (1_Month Average) @ Low cloud bottom level / (Pa) (time: 1; latitude: 190; longitude: 384)
50: Specific humidity (1_Month Average) @ Specified height level above ground / (kg/kg) (time: 1; Specified height level above ground: 1; latitude: 190; longitude: 384)
51: Geopotential height (1_Month Average) @ Ground or water surface / (unknown) (time: 1; latitude: 190; longitude: 384)
52: Pressure (1_Month Average) @ Ground or water surface / (Pa) (time: 1; latitude: 190; longitude: 384)
53: Temperature (1_Month Average) @ High cloud top level / (K) (time: 1; latitude: 190; longitude: 384)
54: Direct evaporation from bare soil (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
55: Convective Precipitation Rate (1_Month Average) @ Ground or water surface / (kg.m-2.s-1) (time: 1; latitude: 190; longitude: 384)
56: Frictional Velocity (1_Month Average) @ Ground or water surface / (m.s-1) (time: 1; latitude: 190; longitude: 384)
57: Clear Sky Downward Solar Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
58: Vegetation (1_Month Average) @ Ground or water surface / (%) (time: 1; latitude: 190; longitude: 384)
59: Temperature (1_Month Average) @ Ground or water surface / (K) (time: 1; latitude: 190; longitude: 384)
60: Exchange Coefficient (1_Month Average) @ Ground or water surface / ((kg.m-3).(m.s-1)) (time: 1; latitude: 190; longitude: 384)
61: Aerodynamic conductance (1_Month Average) @ Ground or water surface / (m.s-1) (time: 1; latitude: 190; longitude: 384)
62: Pressure (1_Month Average) @ High cloud bottom level / (Pa) (time: 1; latitude: 190; longitude: 384)
63: Transpiration (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
64: Visible Beam Downward Solar Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
65: Canopy water evaporation (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
66: Minimum temperature (1_Month Average) @ Specified height level above ground / (K) (time: 1; Specified height level above ground: 1; latitude: 190; longitude: 384)
67: Temperature (1_Month Average) @ Middle cloud top level / (K) (time: 1; latitude: 190; longitude: 384)
68: Downward Long-Wave Rad. Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
69: Pressure (1_Month Average) @ Convective cloud bottom level / (Pa) (time: 1; latitude: 190; longitude: 384)
70: Momentum flux, u-component (1_Month Average) @ Ground or water surface / (N.m-2) (time: 1; latitude: 190; longitude: 384)
71: u-component of wind (1_Month Average) @ Hybrid level / (m/s) (time: 1; Hybrid level: 1; latitude: 190; longitude: 384)
72: Minimum specific humidity at 2m (1_Month Average) @ Specified height level above ground / (kg/kg) (time: 1; Specified height level above ground: 1; latitude: 190; longitude: 384)
73: Total cloud cover (1_Month Average) @ Convective cloud layer / (%) (time: 1; latitude: 190; longitude: 384)
74: Volumetric Soil Moisture Content (1_Month Average) @ Depth below land surface layer / (unknown) (time: 1; Depth below land surface: 4; latitude: 190; longitude: 384)
75: Clear sky UV-B Downward Solar Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
76: Snow Cover (1_Month Average) @ Ground or water surface / (%) (time: 1; latitude: 190; longitude: 384)
77: Ground Heat Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
78: Sensible heat net flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
79: Plant Canopy Surface Water (1_Month Average) @ Ground or water surface / (kg.m-2) (time: 1; latitude: 190; longitude: 384)
80: Upward Short-Wave Radiation Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
81: Pressure (1_Month Average) @ Middle cloud top level / (Pa) (time: 1; latitude: 190; longitude: 384)
82: Total cloud cover (1_Month Average) @ High cloud layer / (%) (time: 1; latitude: 190; longitude: 384)
83: Clear Sky Upward Long Wave Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
84: Temperature (1_Month Average) @ Low cloud top level / (K) (time: 1; latitude: 190; longitude: 384)
85: Total cloud cover (1_Month Average) @ Middle cloud layer / (%) (time: 1; latitude: 190; longitude: 384)
86: Vegetation Type (1_Month Average) @ Ground or water surface / (unknown) (time: 1; latitude: 190; longitude: 384)
87: Snow depth (1_Month Average) @ Ground or water surface / (m) (time: 1; latitude: 190; longitude: 384)
88: Clear Sky Upward Solar Flux (1_Month Average) @ Nominal top of the atmosphere / (W.m-2) (time: 1; latitude: 190; longitude: 384)
89: Snowfall rate water equivalent (1_Month Average) @ Ground or water surface / (kg.m-2.s-1) (time: 1; latitude: 190; longitude: 384)
90: Zonal Flux of Gravity Wave Stress (1_Month Average) @ Ground or water surface / (N.m-2) (time: 1; latitude: 190; longitude: 384)
91: Sublimation (evaporation from snow) (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
92: Downward Short-Wave Radiation Flux (1_Month Average) @ Ground or water surface / (W.m-2) (time: 1; latitude: 190; longitude: 384)
93: Pressure (1_Month Average) @ Middle cloud bottom level / (Pa) (time: 1; latitude: 190; longitude: 384)

In [12]:
# select a variable
temp = cubes[24]

In [13]:
# print the coordinates
print[coord.name() for coord in temp.coords()]


[u'time', u'Specified height level above ground', 'latitude', 'longitude']

In [14]:
# extract 1st time step and surface layer
t_surf = temp[0,0,:,:]

In [15]:
# plot it up
figure(figsize=(14,10))
qplt.contourf(t_surf,25);