Access AIRS data from GES DISC via OPeNDAP using CMR search result

This API allows access to visualize AIRS data from GES DISC through OPeNDAP using a Common Metadata Repository search result.

Copyright © 2017 The HDF Group

This example code illustrates how to access and visualize a Goddard Earth Sciences Data and Information Services Center (GES DISC) Atmospheric Infrared Sounder (AIRS) swath in Python.

If you have any questions, suggestions, or comments on this example, please use the HDF-EOS Forum ( If you would like to see an example of any other NASA HDF/HDF-EOS data product that is not listed in the HDF-EOS Comprehensive Examples page (, feel free to contact us at or post it at the HDF-EOS Forum.

Usage: save this script and run


The HDF file must be searchable by CMR and served by OPeNDAP server.

Tested under: Python 2.7.10 :: Anaconda 2.3.0 (x86_64) Last updated: 2017-1-05

Access AIRS data from GES DISC via OPeNDAP using CMR search result

import os
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.basemap import Basemap
from netCDF4 import Dataset

Please download and install PyCMR from

from pyCMR import CMR
# Change path to the sample cmr.cfg file.
# AIRS granule search doesn't return OPeNDAP URL.
# Retrieve the latest dataset using sort key.
results_g = cmr.searchGranule(limit=1,short_name="AIRH2RET",sort_key='-start_date')
# Collection does return OPeNDAP URL.
results = cmr.searchCollection(limit=1,short_name="AIRH2RET")

Let's check CMR results.

print len(results)
for res in results:
    # Check OPeNDAP URL.
    print  res.getOPeNDAPUrl()    

print len(results_g)
ourl = ''
for res in results_g:
    # Check Granule Data URL.
    print res.getDownloadUrl()
    ourl = res.getDownloadUrl()

As you can see from the above output, for GES_DISC AIRS, the download URL matches OPeNDAP URL except '/data/' and '/opendap/'. Let's replace it.

FILE_NAME = ourl.replace("data", "opendap")

The rest is same as example.

nc = Dataset(FILE_NAME)
data = nc.variables[DATAFIELD_NAME][:,:]
latitude = nc.variables['Latitude'][:]
longitude = nc.variables['Longitude'][:]

# Replace the filled value with NaN, replace with a masked array.
data[data == -9999.0] = np.nan
datam =, np.isnan(data))

# Draw a polar stereographic projection using the low resolution coastline
# database.
m = Basemap(projection='npstere', resolution='l',
            boundinglat=30, lon_0 = 180)
m.drawparallels(np.arange(-80., -50., 5.))
m.drawmeridians(np.arange(-180., 181., 20.), labels=[1, 0, 0, 1])
x, y = m(longitude, latitude)
m.pcolormesh(x, y, datam)

# See AIRS/AMSU/HSB Version 6 Level 2 Product User Guide [1]
units = 'm'
cb = m.colorbar()

basename = os.path.basename(FILE_NAME)
plt.title('{0}\n {1}'.format(basename, DATAFIELD_NAME))
fig = plt.gcf()
pngfile = "{0}.py.png".format(basename)

# References
# [1]




Last Updated
May 4, 2021