In [24]:
import numpy as np
from matplotlib import animation
from matplotlib import pylab as plt
# requires ImageMagicks
# JS Animation import is available at http://github.com/jakevdp/JSAnimation
from JSAnimation import IPython_display
In [15]:
filename = '../py4we/test/mann/sim1'
with open(filename, 'r') as f:
data = f.read()
In [16]:
M = np.fromstring(data, np.float32)
In [17]:
M.shape[0]/128/128
Out[17]:
In [18]:
N = M.reshape(1024,128,128)
In [19]:
import matplotlib.pylab as pl
In [20]:
pl.contourf(N[1,:,:])
Out[20]:
In [21]:
pl.plot(N[:,1,1]);
In [30]:
fig = plt.figure(figsize=[6,6])
ax = plt.subplot(111)
im = ax.imshow(N[1,:,:], origin='upper', )
# initialization function: plot the background of each frame
def init():
im = ax.imshow(N[1,:,:], origin='upper', )
return im,
# animation function. This is called sequentially
Nframes = 12
def animate(i):
#im.set_data(N[i,:,:])
im = ax.imshow(N[i,:,:], origin='upper', )
return im,
anim = animation.FuncAnimation(fig, animate, init_func=init, frames=Nframes, interval=50)
IPython_display.display_animation(anim, default_mode='once')
#anim.save('MagicTriangle.gif', writer='imagemagick')
Out[30]:
In [4]:
In [ ]: