I have at least 1000 files of 3D numpy array (96 X 144 X 32) of climate variables that I want to visualize through time.
I have converted the numpy files to VTK files.
My question is, how can I animate the 3D map across time?
Methods and Problems I have encountered:
- Using ParaView application
- Load some vti (vtk) files (it visualizes correctly). Go to animation view and add new keyframe. Start animation (ParaView crashes and closes. The keyframe causes the crash).
- pvpython Script.
- I couldn’t find an example that does animation with vtk files.
Could someone show me an example script?
This is the script I got using ChatGPT. I load this into the paraview application ‘load sate’, but doesn’t render anything and outputs
"Traceback (most recent call last):
File “”, line 3, in start_cue
NameError: name ‘Text’ is not defined
Traceback (most recent call last):
File “”, line 11, in tick
NameError: name ‘GetAnimationScene’ is not defined
Traceback (most recent call last):
File “”, line 11, in tick
import sys, glob
from paraview.simple import *
# Load the first VTK file
vtkFileNames = sorted(glob.glob("*_0.vti"))
print(len(vtkFileNames))
print(vtkFileNames[0])
data = XMLImageDataReader(FileName=[vtkFileNames[0]])
# Load the remaining VTK files
for i in range(1, len(vtkFileNames)):
vtkFileName = vtkFileNames[i]
data = AppendDatasets(Input=[data, XMLImageDataReader(FileName=[vtkFileName])])
# Define the time values
timeValues = [i for i in range(len(vtkFileNames) - 1)]
data.PointData.GetArray("TimeValue").SetNumberOfTuples(len(timeValues))
data.PointData.GetArray("TimeValue").SetTuple1(0, timeValues[0])
for i in range(1, len(timeValues)):
data.PointData.GetArray("TimeValue").SetTuple1(i, timeValues[i])
# Show the animation
Show(data)
Render()
# Play the animation
animationScene = GetAnimationScene()
animationScene.Play()