In [1]:
import h5py
In [2]:
dat = h5py.File("10yr-MORESNOW.h5", 'r')
In [3]:
print dat
In [4]:
print dat.keys()
In [5]:
dat['precipitation rain [m s^-1]']
Out[5]:
In [6]:
dat['precipitation rain [m s^-1]'][:]
Out[6]:
In [7]:
import numpy as np
In [8]:
dat['precipitation rain [m s^-1]'][:].max()
Out[8]:
In [9]:
from matplotlib import pyplot as plt
plt.plot(dat['time [s]'][:], dat['precipitation rain [m s^-1]'][:])
Out[9]:
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]:
In [18]:
plt.show()
In [19]:
dat.create_dataset("time [s]", data=time)
Out[19]:
In [20]:
dat.create_dataset("precipitation rain [m s^-1]", data=pr)
Out[20]:
In [21]:
dat.keys()
Out[21]:
In [22]:
dat.close()
In [ ]:
precip = np.loadtxt("myfile.txt")