VTK   ParaView tutorial
13 Pages
English

VTK ParaView tutorial

-

Downloading requires you to have access to the YouScribe library
Learn all about the services we offer

Description

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 ...

Subjects

Informations

Published by
Reads 164
Language English
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)
or
/apps-vis/ParaView3BatchExamples/coloredSphere.pvsm
execute the /( p aw v ph b pi a cs t h-c  viit h ss/cePlafa nrrealVoiaedws3 tBhaet cs htpaEtyxet haaomnnp lsecsr/icptoloredSphere.0.py d writes an image)
All the above was tested in serial and parallel mode with ParaView version 3.6, on horus and rigi
Running pvbatch on rigi
N.B. Because of MPI compilation, please note that we must use a different path for the rigi pvbatch executable:
/apps-csvis/Paraview3BuildMesa/bin/pvbatch 
Example to run with 4 cpus on rigi:
you will need to submit a job via the OpenPBS Pro scheduler.
See /apps-vis/Paraview3BatchExamples/coloredSphere.sh
make your own copy, edit the path to write the image, and submit as:
qsub coloredSphere.sh
Example: /apps-vis/ParaView3BatchExamples/coloredSphere.0.py
from paraview.simple import * sm = servermanager sm.Connect() sphere = Sphere() sphere.ThetaResolution = 100 sphere.PhiResolution = 100 pidscal = ProcessIdScalars(sphere) view = sm.CreateRenderView() rep = Show(pidscal, view) nbprocs = sm.ActiveConnection.GetNumberOfDataPartitions
lt = MakeBlueToRedLT(0, nbprocs-1) lt.NumberOfTableValues = nbprocs
rep.LookupTable = lt rep.ColorAttributeType = 'POINT_DATA' rep.ColorArrayName = "ProcessId"  
bar = CreateScalarBar(LookupTable=lt, Title=“PID”) view.Representations.append(bar)
view.ResetCamera() view.StillRender() view.WriteImage("/project/csvis/ParaViewTests/Sphere.0.png","vtkPNGWriter")
Problem: Run the same ParaView visualization for multiple files
While running paraview, get the python interface. Find all files
Tools-> Python Shell
import glob, string
files = glob.glob(“/scratch/user/file*.dat”) files.sort()
# Find the source object
file = FindSource(“name”)
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()
imporfmop ra.sostr)(h5”)file(files*.bolbolgselig = tr sgfin grtb,loPdulL.aogaremrnaervet()snnecr.Coeganamrevres* trpoimlempsiw.ieavdeea:resNaleFir. rof0 =ilif ni fa()vamerStiliew.vfeiem =esCt.weR"/= erusjfs/reavneRl(redgmi)elifical/dssf.%03d.pP/orejtc/siBMode ,elifgmi(egamIeitWrw.ieiv% " ng1
another example script.py with pvbatch
i  +)1=ir", ritePNGW"vtk/'suig(nfjvare/srojere/PBioMcts/l/lacideiBZHTEbialicedoMinugPlSMs.'or)aeed r =osurces.BioH5(FileemaNif =[seld)]0= 3 ltfis.er(ID3r)dseade = rnputaDatre.siftlfs =erltFicefaurtSSe=dip)3d = tupnI(.Process filters(snIup tdIcSlaraw ieCr= ds= )vsfiVre)(weetaedneR
Images for cube fea s0?.mesh.h5: _ _