Updates to video function (skip frames)

This commit is contained in:
rowanc1
2013-12-05 11:31:43 -08:00
parent 8fb9f3683b
commit 3221b3c750
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -372,7 +372,7 @@ class TensorView(object):
return animate(fig, animateFrame, frames=mesh.nCv['xyz'.index(normal)])
def video(mesh,var,function,figsize=(10,8),colorbar=True):
def video(mesh, var, function, figsize=(10, 8), colorbar=True, skip=1):
"""
Call a function for a list of models to create a video.
@@ -393,9 +393,11 @@ class TensorView(object):
if colorbar:
plt.colorbar(function(var[0],ax,clim,tlt,0))
def animateFrame(i):
frames = np.arange(0,len(var),skip)
def animateFrame(j):
i = frames[j]
function(var[i],ax,clim,tlt,i)
return animate(fig, animateFrame, frames=len(var))
return animate(fig, animateFrame, frames=len(frames))
+1 -1
View File
@@ -172,7 +172,7 @@ def randomModel(shape, seed=None, anisotropy=None, its=100, bounds=[0,1]):
if len(shape) is 1:
smth = np.array([1,10.,1],dtype=float)
elif len(shape) is 2:
smth = np.array([[1,2,1],[7,10,7],[1,2,1]],dtype=float)
smth = np.array([[1,7,1],[2,10,2],[1,7,1]],dtype=float)
elif len(shape) is 3:
kernal = np.array([1,4,1], dtype=float).reshape((1,3))
smth = np.array(sp.kron(sp.kron(kernal,kernal.T).todense()[:],kernal).todense()).reshape((3,3,3))