Paraview Trace

From PHASTA Wiki
Jump to: navigation, search

Paraview traces are ways to create a python script of a set of actions that can be later applied to different datasets or over a loop of datasets automatically. The following will brefly explain the creation, cleaning, and running of a python trace in Paraview (which will often be shortened to pvTrace or something similar).

Creation

General steps are to start a trace, do whatever you're wanting to record, then stop the trace.

1. Start Trace

Tools > Start Trace

This will bring up a dialog with different options for which things to record. Of note is "Skip Rendering Components" (useful if your trace doesn't involve any visual capturing). You can also select "Show Incremental Trace" so to verify what command are being recorded as you do them.

2. Do something

Do whatever you were wanting to have recorded in Paraview.

3. Stop Trace

Tools > Stop Trace

This will then bring up the resulting Python script, which you can then save to a file, edit, and rerun.

Basic Changes to the Python Script

When rerunning a trace script, it's just run via a normal Python interpreter in a Paraview-specific environment. All Python standard library packages are available to the script.

This allows for significant flexibility in what can be done in and during the script. For example, in this Paraview script file, originally created from a trace, we use a for loop to do the same action multiple times. Additionally, the os package is used to symlink and delete files so that the data read in during the for loop changes. We've even added print statements to log what the script is doing.

Python Versions

Note: The version of Python used by Paraview is often different than the version installed on your system.

To determine the version of Python used by Paraview, you can select "View > Python Shell" in Paraview, which will show the Python interpreter. The version of Python used should be printed on the shell at the top. If not, run import sys; print(sys.version) to display the Python version information. If you're using Paraview through the server/client mode, you MUST do this while attached to a pvserver; the version of Python on your local Paraview client is not guaranteed to match the version on the server.

The Python Shell in Paraview can also be used to verify if certain functions will work and what libraries are available (such as numpy).

Running a Trace

Running a pvTrace, whether on the same or a different dataset requires only a few key steps. For now, it will be assumed that the trace is being run on Cooley at ALCF, though many of the steps should be shared for other machines.

If you are running the trace on a dataset that is not the same as the one for which you created the trace, it is good practice to always check your script and inputs. Make sure you have all of the restart and geombc files that you will need, and that you are pointing to the correct locations in the python script (it is recommended that you use absolute paths to reduce the chances for error). Also check your output file name and location.

Once your python script is ready, you need to get an interactive allocation on Cooley and load the same version of paraview with which the trace was created:

soft add +paraview-5.5.2

This loads pvpython which is what is used to run the python trace script. To run this scrip is simply a modification of a standard python run command.

pvpython Trace_Script.py