def anim(filename,varname,cax):
template = filename+'_%03i.nc'
nc0 = Dataset(template%(0),'r') # open proc 0 nc file
nt = len(nc0.dimensions['t'])
nc0.close()
def animate(i):
global kt
time,z2d=read(filename,varname,kt)
im.set_data(z2d)
ti.set_text('%.0f '%time)
kt +=5
return im,ti
fig=plt.figure()
ax = fig.add_subplot(111)
time,z2d=read(filename,varname,0)
im=ax.imshow(z2d,vmin=cax[0],vmax=cax[1])
ti=ax.text(100,-50,'%.0f '%time)
print('launch the animation')
global kt
kt = 0
ani = animation.FuncAnimation(fig, animate,arange(nt),interval=5, blit=True)
plt.show()
评论列表
文章目录