I am after some guidance on where to go with my project…
I currently have a python pre processing file that reads a netCDF and generates a .vtr rectilinear grid which I then read in, to another python vtk file where I use contour filter to successfully render the isosurfaces.
However, I know want to render a ‘video’. I understand that rectilinear grid cannot take a 4th dimension or a timestep. So my pre processing file is going to have to output a .vtr file for each timestep. Is it then possible to read in many .vtr files into my visualisation app and to render them together as a video…
I understand this is not really a question, I am more looking for some pointer or guidance on how to combine multiple rectilinear grids to output my video
You should try downloading ParaView then open all of the files at once as a time series. You can then press the play button in ParaView to preview the simulation and then select File->Save Animation to make a video. Here is a demo of what this looks like for a totally different data set (note I only open one file in this video but ParaView handles file series like yours with ease).
or do something like this (which I hacked together quickly - there should be a more elegant way to build a reader pipeline):
import vtk
import vtki
# All the VTR file names
filenames = ['foo-{}.vtr'.format(i) for i in range(4)]
reader = vtk.vtkXMLRectilinearGridReader()
def update_reader(fname):
reader.SetFileName(fname)
reader.Modified()
reader.Update()
update_reader(filenames[0])
grid = vtki.wrap(reader.GetOutput())
# Create a plotter object and set the scalars to the Z height
plotter = vtki.Plotter()
plotter.add_mesh(grid, name='foo')
# setup camera and close
plotter.plot(auto_close=False)
# Open a gif
plotter.open_gif('frames.gif')
# Update Z and write a frame for each updated position
nframe = 15
for fname in filenames:
update_reader(fname)
print(fname)
grid = vtki.wrap(reader.GetOutput())
plotter.add_mesh(grid, name='foo')
plotter.write_frame()
# Close movie and delete object
plotter.close()