ParaView Python InterfaceUsage on the Horus and Rigi clusters31-07-2009Dr. Jean M. FavreData Analysis and Visualization GroupParaView at CSCS paraview and pvbatch can run in a single or multi-cpusession The “standard” version called paraview, will run interactively, i.e. with a graphics OpenGL window. This is intended to do exploratory visualization, and to prepare a visualization script. ParaView should be run on horus. The “batch-oriented” tool called pvbatch, will run without user’s interaction. It can execute a hand-written python script, or reload a script generated with paraview, and save images to disk. pvbatch uses offscreen-rendering and the Mesa3D rendering library. Pvbatch should be run on rigi.Reloading a script paraview can reload a script with the command File->Load State pvbatch can reload the same script with the commandfrom paraview.simple import *servermanager.Connect()servermanager.LoadState('/users/jfavre/state.pvsm')N.B. if necessary, load your plugin before your stateState files should not be hand-edited.Reloading the coloredSphere example paraview (interactive) can reload the stateFile->Load State (select file)/apps-vis/ParaView3BatchExamples/coloredSphere.pvsmor pvbatch can execute the python script/apps-vis/ParaView3BatchExamples/coloredSphere.0.py (which itself reloads the state and writes an image)All the above was tested in serial and parallel mode with ParaView version 3.6, on horus and rigiRunning ...
ParaView Python Interface Usage on the Horus and Rigi clusters
31-07-2009
Dr. Jean M. Favre
Data Analysis and Visualization Group
ParaView at CSCS
paraview and pvbatch can run in a single or multi-cpu session
The “standard version called p araview , will run interactively, i.e. with a graphics OpenGL window. This is intended to do exploratory visualization, and to prepare a visualization script. ParaView should be run on horus .
The “batch-oriented tool called pvbatch , will run without user’s interaction. It can execute a hand-written python script, or reload a script generated with paraview , and save images to disk. pvbatch uses offscreen-rendering and the Mesa3D rendering library. Pvbatch should be run on rigi .
Reloading a script
paraview can reload a script with the command File->Load State
pvbatch can reload the same script with the command
from paraview.simple import * servermanager.Connect() servermanager.LoadState('/users/jfavre/state.pvsm')
N.B. if necessary, load your plugin before your state State files should not be hand-edited.
Reloading the coloredSphere example
paraview (interactive) can reload the state File->Load State (select file)
for f in files: file.FileName = f view.StillRender()
Run the same visualization for multiple files
If your data reader is time-aware, then AnimateReader() will animate. The execution is run on-demand by the view.
Problem: it always start at the beginning and runs to the end with a fixed increment. You can change that and do your own start, end, and time increment.
tsteps = reader.TimestepValues start = 0 i = start incr = 1 while i < len(tsteps): view.ViewTime = tsteps[i] view.StillRender() imgfile = “/scratch/images/image.%03d.png %i view.WriteImage(imgfile, “vtkPNGWriter,1) i = i + incr
Run the same visualization for multiple files
how do we update the pipeline objects?
must find the names of the objects to be modified
view = servermanager.GetRenderView()
#assume you created a pipeline and read a file called file.000.dat #using the GUI Open menu # the object called 'file.000.dat' shows in the pipeline viewer
reader = FindSource('file.000.dat') # reader can now be updated reader.Filename = files[i] view.StillRender()