Let's see if we can read a generic h5 file using netCDF4


In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import netCDF4

In [2]:
url='/usgs/data2/rsignell/temp_delta_newer.h5'

In [3]:
nc = netCDF4.Dataset(url)

In [4]:
nc.variables.keys()


Out[4]:
[u'lat', u'lon']

In [5]:
lat = nc.variables['lat'][:]
lon = nc.variables['lon'][:]

Do we have groups? Yep!


In [6]:
g = nc.groups

In [7]:
g


Out[7]:
OrderedDict([(u'2020', <type 'netCDF4._netCDF4.Group'>
              group /2020:
                  created: 2015-11-05 11:56:11
                  dimensions(sizes): 
                  variables(dimensions): 
                  groups: 45, 85), (u'2050', <type 'netCDF4._netCDF4.Group'>
              group /2050:
                  created: 2015-11-05 11:56:50
                  dimensions(sizes): 
                  variables(dimensions): 
                  groups: 45, 85), (u'2080', <type 'netCDF4._netCDF4.Group'>
              group /2080:
                  created: 2015-11-05 11:57:32
                  dimensions(sizes): 
                  variables(dimensions): 
                  groups: 45, 85)])

In [8]:
g['2020']['45'].variables.keys()


Out[8]:
[u'10', u'25', u'75', u'90', u'mean']

In [9]:
t = g['2020']['45'].variables['10'][:,:]

In [10]:
print lat.shape,lon.shape,t.shape


(61, 161) (61, 161) (61, 161)

In [14]:
plt.pcolormesh(lon,lat,t)
plt.colorbar();



In [ ]: