Visualization Script Examples
This page presents a comparison of ParaView, Visit, and Ensight scripting for the same analysis problem.
Conceptual description of problem analysis steps
Open c:\myDirectory\data\can.exo Change geometry to look down the +X axis clip snapshot to c:\myDirectory\snapshots\picture1.jpg
Ensight Record file Script for problem
VERSION 8.26 prefs: user_defined_input OFF prefs: macro_panel ON prefs: part_panel ON prefs: user_input_zoomsens 1.000000 prefs: user_input_postranssens 1.000000 prefs: user_input_valtranssens 1.000000 prefs: user_input_rotateusing mixed_mode prefs: user_input_rotatesens 1.000000 prefs: user_defined_input OFF prefs: macro_panel ON prefs: part_panel ON prefs: user_input_zoomsens 1.000000 prefs: user_input_postranssens 1.000000 prefs: user_input_valtranssens 1.000000 prefs: user_input_rotateusing mixed_mode prefs: user_input_rotatesens 1.000000 data: binary_files_are big_endian data: format MultiExodusII data: reader_option 'Use distribution factors' ON data: reader_option 'Ignore side sets' OFF data: reader_option 'Ignore node sets' OFF data: reader_option 'Use node and element maps' ON data: reader_option 'Verbose mode' OFF data: reader_option 'Use higher-order elements' ON data: reader_option 'Ignore constant variables' OFF data: reader_option 'NaN filter input data' ON data: reader_option 'Clip overlapping timesteps' OFF data: reader_option 'Autodetect spatial decomp' OFF data: reader_option 'Use undef value for missing vars' ON data: reader_option 'Ignore elment attribute vars' OFF data: reader_option 'Epsilon' 1.000000e+000 data: reader_option 'Scale factor' 1.000000e+000 data: shift_time 1.000000 0.000000 0.000000 data: replace C:/alan/demos/Training/can.ex2 view_transf: view_recall +Y view_transf: view_recall -Y clip: select_default part: modify_begin clip: tool plane clip: plane 1 -4.727466e+000 -9.445257e-001 -5.110948e+000 clip: plane 2 5.161586e+000 -9.445257e-001 -5.110948e+000 clip: plane 3 5.161586e+000 8.944526e+000 -5.110948e+000 part: modify_end tools: plane ON clip: select_default part: modify_begin clip: domain inside clip: tool plane part: modify_end view_transf: function plane view_transf: axis y view_transf: rotate 0.000000e+000 -9.000000e+001 0.000000e+000 frame: select_begin 0 frame: select_end part: select_begin 1 2 part: select_end clip: begin clip: domain inside clip: tool plane clip: plane 1 2.170597e-001 -1.008669e+000 -1.011961e+001 clip: plane 2 2.170605e-001 -1.008669e+000 -1.022791e-001 clip: plane 3 2.170605e-001 9.008667e+000 -1.022791e-001 clip: end clip: create part: select_begin 6 7 part: select_end part: modify_begin clip: domain outside clip: tool plane part: modify_end file: image_format jpg file: image_format_options Quality 75 anim_recorders: render_offscreen ON file: image_numpasses 1 file: image_stereo current file: image_screen_tiling 1 1 file: image_file C:\alan\work\junk6\deleteMe5.jpg file: save_image
ParaView XML Record and Save State Files for Sample Problem
ParaView Record File
<?xml version="1.0" ?> <pqevents> <pqevent object="MainWindow/menubar/menuFile/menuRecentFiles" command="activate" arguments="C:\alan\demos\Training\can.ex2" /> <pqevent object="MainWindow/objectInspectorDock/1pqProxyTabWidget0/qt_tabwidget_stackedwidget/objectInspector/ScrollArea/qt_scrollarea_viewport/PanelArea/Editor/Variables/1QHeaderView0" command="mousePress" arguments="1,1,0,0,0,0" /> <pqevent object="MainWindow/objectInspectorDock/1pqProxyTabWidget0/qt_tabwidget_stackedwidget/objectInspector/ScrollArea/qt_scrollarea_viewport/PanelArea/Editor/Variables/1QHeaderView0" command="mouseRelease" arguments="1,0,0,0,0,0" /> <pqevent object="MainWindow/objectInspectorDock/1pqProxyTabWidget0/qt_tabwidget_stackedwidget/objectInspector/Accept" command="activate" arguments="" /> <pqevent object="MainWindow/cameraToolbar/1QToolButton3" command="activate" arguments="" /> <pqevent object="MainWindow/commonFilters/1QToolButton2" command="activate" arguments="" /> <pqevent object="MainWindow/objectInspectorDock/1pqProxyTabWidget0/qt_tabwidget_stackedwidget/objectInspector/Accept" command="activate" arguments="" /> <pqevent object="MainWindow/menubar/menuFile" command="activate" arguments="actionFileSaveScreenshot" /> <pqevent object="MainWindow/FileSaveScreenshotDialog" command="filesSelected" arguments="C:/alan/work/junk6/deleteMe4" /> </pqevents>
The ParaView state file is too big an complicated to bother to list here.
Paraview Python Script with PVFWrap
import PVStartup from paraview import servermanager as SM from PVFWrap import * if (PVStartup.GUIClient == 0): connection = SM.Connect() my_reader = ExodusIIReader("can2.exo") my_clip = Clip(my_reader, clip_function="Plane") my_view = CreateRenderView() my_clip_rep = CreateRepresentation(my_reader, my_view) my_view.WriteImage('canclip.png', 'vtkPNGWriter', 1)
Some notes:
- I didn't actually run the script for this data, so a couple things are missing. I'll update this after I grab the data.
- The clip is not completely defined, so I picked a plane.
- The first four lines could probably be condensed, but I'd rather not hide the connection step.
Visit XML GUI and State Files
VisIt XML GUI File
<?xml version="1.0"?> <Object name="VisIt"> <Field name="Version" type="string">1.9.1</Field> <Object name="GUI"> <Object name="FileServerList"> <Field name="path" type="string">C:\\alan\\demos\\Training</Field> <Field name="filter" type="string">*</Field> <Field name="useCurrentDir" type="bool">false</Field> <Field name="automaticFileGrouping" type="bool">true</Field> <Field name="smartFileGrouping" type="bool">true</Field> <Object name="recentpaths"> <Field name="localhost" type="stringVector">"C:\\Program%32Files\\LLNL\\VisIt%321.9.1" "C:\\Program%32Files\\LLNL\\VisIt%321.9.1\\data" "C:\\Program%32Files\\LLNL" "C:\\Program%32Files" "C:" "C:\\alan" "C:\\alan\\demos" "C:\\alan\\demos\\Training" </Field> </Object> </Object> <Object name="AppearanceAttributes"> <Field name="background" type="string">#ece9d8</Field> <Field name="foreground" type="string">#000000</Field> <Field name="fontName" type="string">Helvetica,12,-1,5,50,0,0,0,0,0</Field> <Field name="style" type="string">windows</Field> <Field name="orientation" type="int">0</Field> </Object> <Field name="postWhenShown" type="bool">false</Field> <Object name="File open"> <Field name="x" type="int">44</Field> <Field name="y" type="int">58</Field> <Field name="width" type="int">654</Field> <Field name="height" type="int">476</Field> <Field name="visible" type="bool">false</Field> </Object> <Object name="File selection"> <Field name="x" type="int">88</Field> <Field name="y" type="int">115</Field> <Field name="width" type="int">895</Field> <Field name="height" type="int">437</Field> <Field name="visible" type="bool">false</Field> </Object> <Object name="Help"> <Field name="x" type="int">-4</Field> <Field name="y" type="int">-4</Field> <Field name="width" type="int">1600</Field> <Field name="height" type="int">1110</Field> <Field name="visible" type="bool">true</Field> <Field name="activeTab" type="int">1</Field> </Object> <Object name="Information"> <Field name="x" type="int">66</Field> <Field name="y" type="int">87</Field> <Field name="width" type="int">566</Field> <Field name="height" type="int">281</Field> <Field name="visible" type="bool">false</Field> </Object> <Object name="Set save options"> <Field name="x" type="int">22</Field> <Field name="y" type="int">29</Field> <Field name="width" type="int">395</Field> <Field name="height" type="int">584</Field> <Field name="visible" type="bool">false</Field> <Field name="posted" type="bool">false</Field> </Object> <Object name="MainWin"> <Field name="x" type="int">0</Field> <Field name="y" type="int">0</Field> <Field name="width" type="int">400</Field> <Field name="height" type="int">1102</Field> <Field name="SPLITTER_VALUES" type="floatVector">0.296618 0.296618 0.395169 </Field> </Object> <Field name="plotDatabases" type="stringVector">"localhost:C:\\alan\\demos\\Training\\can.ex2" </Field> <Object name="TimeFormat"> <Field name="displayMode" type="string">Cycles</Field> <Field name="precision" type="int">5</Field> </Object> <Field name="showSelectedFiles" type="bool">true</Field> <Field name="allowFileSelectionChange" type="bool">true</Field> </Object> </Object>
The VisIt XML State File is too big an complicated to bother the list here.
Visit Python Script
I just typed this into Visit's script interface, and it pretty much did what we wanted:
>>> OpenDatabase("/Users/kmorel/data/ParaViewData/Data/can.ex2") Running: engine_ser1.10.0 -host 127.0.0.1 -timeout 480 -port 5600 1L >>> AddPlot("Pseudocolor", "EQPS") 1L >>> DrawPlots() 1L >>> AddOperator("Clip") 1L >>> SaveWindow() VisIt: Message - Rendering window 1... VisIt: Message - Saving window 1... VisIt: Message - Saved visit0000.tif 'visit0000.tif'
Spymaster/spyplot
IN PROGRESS!
spy PlotTime(0, 5e-5); define main() { pprintf(" Plot: Cycle = %d, Time = %g\n",CYCLE,TIME); XLimits(0,800); YLimits(0,800); ZLimits(0,800); Image("Mats",WHITE, BLACK); RotateAbout(250,500,250); RotateZ(120); RotateX(-60); MatColors(BROWN,LIGHT_GRAY,NO_COLOR); Plot3DMats(); Draw3DBlockEdges(); EndImage(); } endspy
I never got to the step where we adjust the camera angle, but you have to admit that this script is remarkably easy for what it does.
Acknowledgments
This work was done in part at Sandia National Laboratories. Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy's National Nuclear Security Administration under contract DE-AC04-94AL85000.
SAND 2008-6528P