timedomainresonace/pmovie.py

56 lines
1.1 KiB
Python
Raw Normal View History

2015-02-10 07:17:40 +00:00
#!/usr/bin/python
from numpy import *
from matplotlib.pyplot import *
from matplotlib import animation
2015-02-22 10:36:23 +00:00
from run import *
2015-02-10 07:17:40 +00:00
import sys
inst=0
2015-02-22 10:36:23 +00:00
parr=load('pdata.npy')
uarr=load('udata.npy')
2015-02-10 07:17:40 +00:00
# save(pdat,'p.npy')
2015-02-22 10:36:23 +00:00
imax=parr.shape[0]
2015-02-10 07:17:40 +00:00
2015-02-22 10:36:23 +00:00
amplitude=1
2015-02-10 07:17:40 +00:00
fig = figure(figsize=(12,8))
2015-02-22 10:36:23 +00:00
ax = axes(xlim=(0,x[-1]),ylim=(-amplitude,amplitude))
2015-02-10 07:17:40 +00:00
grid('on')
line, = plot([],[],lw=2)
def init():
line.set_data([], [])
return line,
# print(imax)
2015-02-22 10:36:23 +00:00
def animatep(i):
# update_progress(int(round(100*i/imax)))
line.set_data(x,parr[i])
return line,
# animp = animation.FuncAnimation(fig, animatep, init_func=init,
# frames=imax, interval=20, blit=True,repeat=False)
def animateu(i):
# update_progress(int(round(100*i/imax)))
line.set_data(x,uarr[i])
2015-02-10 07:17:40 +00:00
return line,
print("Creating animation...")
2015-02-22 10:36:23 +00:00
animu = animation.FuncAnimation(fig, animateu, init_func=init,
frames=imax, interval=20, blit=True,repeat=False)
2015-02-10 07:17:40 +00:00
# print("Saving animation...")
# anim.save('p.mp4', fps=20, extra_args=['-vcodec', 'libx264'])
print("Showing animation...")
show()
2015-02-22 10:36:23 +00:00