In [72]:
%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
import h5py

from matplotlib.colors import LinearSegmentedColormap

In [63]:
output = h5py.File('analysis_tasks/analysis_tasks_s1.h5', 'r')

In [49]:
list(output.keys())


Out[49]:
['scales', 'tasks']

In [50]:
scales = output['scales']

In [51]:
list(scales.items())


Out[51]:
[('constant', <HDF5 dataset "constant": shape (1,), type "<f8">),
 ('iteration', <HDF5 dataset "iteration": shape (100,), type "<i8">),
 ('kx', <HDF5 dataset "kx": shape (48,), type "<f8">),
 ('ky', <HDF5 dataset "ky": shape (95,), type "<f8">),
 ('sim_time', <HDF5 dataset "sim_time": shape (100,), type "<f8">),
 ('timestep', <HDF5 dataset "timestep": shape (100,), type "<f8">),
 ('wall_time', <HDF5 dataset "wall_time": shape (100,), type "<f8">),
 ('world_time', <HDF5 dataset "world_time": shape (100,), type "<f8">),
 ('write_number', <HDF5 dataset "write_number": shape (100,), type "<i8">),
 ('x', <HDF5 group "/scales/x" (2 members)>),
 ('y', <HDF5 group "/scales/y" (2 members)>)]

In [52]:
ts = scales['timestep']

In [53]:
ts.value


Out[53]:
array([  1.00000000e-06,   3.37483192e-05,   3.50797835e-05,
         3.40436570e-05,   3.45700640e-05,   4.05445268e-05,
         4.23222140e-05,   4.24783371e-05,   3.94628807e-05,
         3.83986309e-05,   3.83454336e-05,   4.10248815e-05,
         4.13508863e-05,   4.35310456e-05,   3.99673352e-05,
         3.81075001e-05,   3.74113942e-05,   3.90699844e-05,
         3.94295790e-05,   4.02279899e-05,   4.10368844e-05,
         4.18383946e-05,   4.12564247e-05,   3.98650947e-05,
         3.85387843e-05,   3.72948776e-05,   3.74280768e-05,
         3.84706382e-05,   3.93597329e-05,   3.99819806e-05,
         3.90299947e-05,   3.91478924e-05,   3.91412554e-05,
         3.87369804e-05,   3.81052934e-05,   3.74000561e-05,
         3.74470016e-05,   3.80564715e-05,   3.87582537e-05,
         4.01640868e-05,   4.13589033e-05,   3.92573590e-05,
         3.72246814e-05,   3.72030078e-05,   3.77068213e-05,
         3.84379988e-05,   4.00172717e-05,   4.13711198e-05,
         4.29292361e-05,   4.65974358e-05,   4.68578946e-05,
         4.67832871e-05,   4.59459572e-05,   5.06071625e-05,
         5.33112719e-05,   5.18594689e-05,   4.82191558e-05,
         4.87475989e-05,   4.96096221e-05,   4.56099687e-05,
         4.31925130e-05,   4.17320844e-05,   4.15224206e-05,
         4.50862877e-05,   4.94973677e-05,   4.99087477e-05,
         4.85886589e-05,   4.75386055e-05,   4.78619174e-05,
         4.85004574e-05,   4.93423188e-05,   4.98133444e-05,
         4.97691799e-05,   4.92835451e-05,   4.91707761e-05,
         4.89118793e-05,   4.82928212e-05,   4.74708370e-05,
         4.70456425e-05,   4.64164526e-05,   4.53701788e-05,
         4.44633065e-05,   4.32608835e-05,   4.26108567e-05,
         4.25263835e-05,   4.29261411e-05,   4.37717167e-05,
         4.46523595e-05,   4.63539582e-05,   4.75729524e-05,
         4.86849422e-05,   4.88192958e-05,   4.82688189e-05,
         4.70550598e-05,   4.55808595e-05,   4.45152070e-05,
         4.34289203e-05,   4.29725817e-05,   4.28155711e-05,
         4.28062890e-05])

In [64]:
zeta = output['tasks/zeta']

In [129]:
for i in range(10):
    fig, ax = plt.subplots(figsize=(12,12))

    cdict = {'red':   ((0.0, 1.0, 1.0),
                       (0.6, 1.0, 1.0),
                       (1.0, 0.0, 0.0)),

             'green': ((0.0, 0.0, 0.0),
                       (0.25, 1.0, 1.0),
                       (0.75, 1.0, 1.0),
                       (1.0, 0.0, 0.0)),

             'blue':  ((0.0, 0.0, 0.0),
                       (0.4, 1.0, 1.0),
                       (1.0, 1.0, 1.0))
            }

    cmap = LinearSegmentedColormap('jp', cdict)

    plt.imshow(zeta.value[i,:,:], cmap=cmap)
    plt.savefig('img%d.png' % (i+1))
    plt.close('all')
    #plt.clim(np.min(zeta)*.3,np.max(zeta)*.3)

In [47]:
zeta.value[1,:,:]


Out[47]:
array([[ nan,  nan,  nan, ...,  nan,  nan,  nan],
       [ nan,  nan,  nan, ...,  nan,  nan,  nan],
       [ nan,  nan,  nan, ...,  nan,  nan,  nan],
       ..., 
       [ nan,  nan,  nan, ...,  nan,  nan,  nan],
       [ nan,  nan,  nan, ...,  nan,  nan,  nan],
       [ nan,  nan,  nan, ...,  nan,  nan,  nan]])

In [59]:
import matplotlib

In [60]:
matplotlib.__version__


Out[60]:
'1.4.3'

In [ ]: