In [1]:
import h5py

In [2]:
dat = h5py.File("10yr-MORESNOW.h5", 'r')

In [3]:
print dat


<HDF5 file "10yr-MORESNOW.h5" (mode r)>

In [4]:
print dat.keys()


[u'air temperature [K]', u'incoming longwave radiation [W m^-2]', u'incoming shortwave radiation [W m^-2]', u'precipitation rain [m s^-1]', u'precipitation snow [m SWE s^-1]', u'relative humidity [-]', u'time [s]', u'wind speed [m s^-1]']

In [5]:
dat['precipitation rain [m s^-1]']


Out[5]:
<HDF5 dataset "precipitation rain [m s^-1]": shape (3650,), type "<f8">

In [6]:
dat['precipitation rain [m s^-1]'][:]


Out[6]:
array([ 0.,  0.,  0., ...,  0.,  0.,  0.])

In [7]:
import numpy as np

In [8]:
dat['precipitation rain [m s^-1]'][:].max()


Out[8]:
8.3445138888888883e-09

In [9]:
from matplotlib import pyplot as plt
plt.plot(dat['time [s]'][:], dat['precipitation rain [m s^-1]'][:])


/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
Out[9]:
[<matplotlib.lines.Line2D at 0x10b063390>]

In [10]:
plt.show()



In [11]:
dat.close()

In [12]:
dat = h5py.File("my_data.h5",'w')

In [13]:
dat.keys()


Out[13]:
[]

In [14]:
dat.create_dataset?

In [15]:
time = np.arange(0,10*86400, 86400)

In [16]:
pr = np.random.random(time.shape)

In [17]:
plt.plot(time, pr)


Out[17]:
[<matplotlib.lines.Line2D at 0x10dd1ac90>]

In [18]:
plt.show()



In [19]:
dat.create_dataset("time [s]", data=time)


Out[19]:
<HDF5 dataset "time [s]": shape (10,), type "<i8">

In [20]:
dat.create_dataset("precipitation rain [m s^-1]", data=pr)


Out[20]:
<HDF5 dataset "precipitation rain [m s^-1]": shape (10,), type "<f8">

In [21]:
dat.keys()


Out[21]:
[u'precipitation rain [m s^-1]', u'time [s]']

In [22]:
dat.close()

In [ ]:
precip = np.loadtxt("myfile.txt")