In [1]:
%pylab


Using matplotlib backend: TkAgg
Populating the interactive namespace from numpy and matplotlib

In [2]:
%qtconsole

In [4]:
PP = load('PP.npy')

In [5]:
import matplotlib.animation

indices = [i for i in ndindex(*PP.shape)]
random.shuffle(indices)
def figg(n):
    return figure(n,(2,2))
def animate1(i):
    ff.clear()
    Pv = PP*nan
    for index in indices[:i*133*2]:
        Pv[index] = PP[index]
    imshow(Pv.T, origin='lower', interpolation='none')
    ff.axes[0].get_xaxis().set_visible(False)
    ff.axes[0].get_yaxis().set_visible(False)
    title('random')
    tight_layout()

In [6]:
ff = figg(1)
ani1 = matplotlib.animation.FuncAnimation(ff, animate1, frames=60)
ani1.save('random.gif', writer='imagemagick', fps=20)


/usr/lib/python2.7/dist-packages/numpy/ma/core.py:3847: UserWarning: Warning: converting a masked element to nan.
  warnings.warn("Warning: converting a masked element to nan.")

In [7]:
indices0 = [i for i in ndindex(*PP.shape)]
def animate0(i):
    f0.clear()
    Pv = PP*nan
    for index in indices0[:i*133*2]:
        Pv[index] = PP[index]
    imshow(Pv.T, origin='lower', interpolation='none')
    f0.axes[0].get_xaxis().set_visible(False)
    f0.axes[0].get_yaxis().set_visible(False)
    title('usual')
    tight_layout()

In [8]:
f0 = figg(0)
ani0 = matplotlib.animation.FuncAnimation(f0, animate0, frames=60)
ani0.save('normal.gif', writer='imagemagick', fps=20)

In [9]:
from scipy.interpolate import griddata as gd
def animate2(i):
    f2.clear()
    Pv = PP*nan
    for index in indices[:20]:
        Pv[index] = PP[index]
    for index in indices[:i*133*2]:
        Pv[index] = PP[index]
        
    X,Y = meshgrid(range(Pv.shape[1]), range(Pv.shape[0]))
    mask = ~isnan(Pv)
    pts = array([X[mask],Y[mask]]).transpose()
    values = Pv[mask]
    Pv = gd(pts, values, (X, Y), method = 'linear')

    imshow(Pv.T, origin='lower', interpolation='none')
    f2.axes[0].get_xaxis().set_visible(False)
    f2.axes[0].get_yaxis().set_visible(False)
    title('interpolated')
    tight_layout()

In [10]:
f2 = figg(2)
ani2 = matplotlib.animation.FuncAnimation(f2, animate2, frames=60)
ani2.save('interpolated.gif', writer='imagemagick', fps=20)

In [ ]: