Advanced State Management: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
Line 6: Line 6:
ParaView state files are saved by selecting the menu option File → Save State.  The pipeline, orientation of the data set, and all view windows are saved.  Select File → Load State to open a saved ParaView state file.
ParaView state files are saved by selecting the menu option File → Save State.  The pipeline, orientation of the data set, and all view windows are saved.  Select File → Load State to open a saved ParaView state file.


==Save Data and Save Geometry==
==Save Data==
 
ParaView offers two features to manage the complexity of your data sets – Save Data and Save Geometry. 
 
 
===Save Data===


The Save Data feature is selected from the main menu: File → Save Data.  This feature will save the data output from the selected source/filter.  The data type is the same as that produced by the source/filter.  For example, the data can be an unstructured grid, image data, etc…   
The Save Data feature is selected from the main menu: File → Save Data.  This feature will save the data output from the selected source/filter.  The data type is the same as that produced by the source/filter.  For example, the data can be an unstructured grid, image data, etc…   


In the example below we have created a simple pipeline using the can.ex2 data set along with a Clip filter.  We will then select the Save Data option.
==Export==
 
[[Image:advanced_state_management_1.png|800px]]


The Export feature is selected from the main menu: File → Export.  Export will write the actual data from a graph or spreadsheet to a file.  For instance, if a spreadsheet is highlighted, you will write a .csv file.  Csv files can be read by excel, which can then sort and plot this data. 


After selecting a name for the file that you wish to save the following widow will then appear:
You can also export the data from a 2d plot, using a trick.  After creating your 2d plot, split the window and select spreadsheet.  The data from your 2d plot filter will be displayed in the spreadsheet view, and this can be exported as described above.


Example:
*Open disk_out_ref.exo. turn on all variables.  Press '''Apply'''.
*Drag the object around with the left mouse button until you can see the inside.
*Select the '''Filters → Data Analysis→ Plot over line''' button.  Apply.
*Split the 2d plot vertically. Spreadsheet view.
*File/Export.  This will export the data in the spreadsheet view.  Note that the rows will be numbered from 0 to 100, representing 101 steps down the line.  Notice that there is a column named "arc_length" that represents the X axis of the plot.


[[Image:advanced_state_management_2.png]]


The Data Mode is a parameter on how the data is saved in the vtx files.  Appended is a good default; it means the data is written in binary format after the XML metadata in the file specified.  Other options include Binary and ASCII.  Binary means that the data is written in between tags of the XML metadata and ASCII means that all data is converted to ASCII strings – which is a very inefficient way of saving the data, but useful if you have a small data set and want to be able to read all the values in a text editor. 
==Traces==


The Ghost Level is only really valid for parallel data setsIt saves extra layers of cells between files that are used to remove inter-file artifactsHowever, if all the data is in one process, then this is meaningless.
ParaView can now automatically save traces, or macrosThis means that you can start recording a trace, do something, stop recording a trace, and save this trace into a file.  You can then use this trace file as input to the pvbatch program, or as a macro within ParaView.


For most users using the Appended mode along with a Ghost Level of 0 will suffice.   
Example:
*Start ParaView (3.6.2 or later)
*Tools/ Python Shell/ Trace/ Start Trace.
*Open disk_out_ref.exo, all variables on, Apply.
*Clip, Z normal, unselect show plane, Apply.
*Slice, unselect show plane, Apply.
*Color by Temp.
*In the Python Shell window, Stop Trace.
*Save traceSave this file somewhere.
*Edit/ Delete All


To open our saved data set select File → Open and browse to the .pvd file which was created.  Also worth noting is that once the data has been saved the complexity of the data is significantly reduced.  In our example above, we applied a clip filter to the data set; therefore when we reload the saved data set you will notice that only the relevant half of the original data set has been restored, thus reducing the size of our data.   
Now, lets run the trace.   
*In the Python Shell window, Run ScriptSelect your trace file.


Notice a few things:
*The Show Plane tool does not turn off.  This is a bug that will be resolved soon.


===Save Geometry===
*With multi-file CTH files, ParaView does not create internal variable names correctly.  Before using the trace file, edit this file and change names that look like spcta_a_0* to spcta_a_0.  I.e., get rid of the *.  This is also true for multi-file Exodus datasets.


Save Geometry will save the geometry for the entire animation.  The saved file will have as many time steps as there were in the animationAll the geometry in the view is saved, not merely the selected source.  The saved data is always polydata. 
*The Save Screenshot does not work.  You can add the following code to the trace, and screenshots will be saved.  You want to replace the line at the bottom of the trace that says '''Render()'''


To use this feature select File → Save Geometry.  To open our saved data set select File → Open and browse to the .pvd file which was created.
<source lang="python">
WriteImage("/path/to/image.png")
</source>


For Windows XP, use the following:
<source lang="python">
WriteImage("c:/wherever you want/fileName.png")
</source>


==Record Test==
Saving an animation isn't much harder - you use the following code in place of the '''Render()''' call.


Record Test offers the user the ability to capture various commands and actions to be replayed at a later time.  To use this feature select the menu item Tools → Record Test. You will be prompted to specify a file to save the recorded data to. At this point any action taken will be recorded and may be later played back by selecting Tools → Play Test. You can also run a test by using the –run-test=filename option when starting ParaView.
<source lang="python">
AnimateReader(reader, filename=".../movie.avi")
</source>


This feature is useful to group actions/commands that are common to a data set or a group of actions that can be applied to several different data sets.  The latter only makes sense when the recorded commands are compatible with the data set it is being played back on.  For example, if you were to record a series of actions specific to a data set with time steps, these actions may or may not be able to be played back on a different data set that has no time steps.


Another good use of this feature is to be able to record the steps needed to recreate bugs.  The recorded test file can then be sent to the ParaView developers.




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

Revision as of 02:50, 12 November 2009

Introduction

This tutorial covers different types of state management.

Save State / Load State

ParaView state files are saved by selecting the menu option File → Save State. The pipeline, orientation of the data set, and all view windows are saved. Select File → Load State to open a saved ParaView state file.

Save Data

The Save Data feature is selected from the main menu: File → Save Data. This feature will save the data output from the selected source/filter. The data type is the same as that produced by the source/filter. For example, the data can be an unstructured grid, image data, etc…

Export

The Export feature is selected from the main menu: File → Export. Export will write the actual data from a graph or spreadsheet to a file. For instance, if a spreadsheet is highlighted, you will write a .csv file. Csv files can be read by excel, which can then sort and plot this data.

You can also export the data from a 2d plot, using a trick. After creating your 2d plot, split the window and select spreadsheet. The data from your 2d plot filter will be displayed in the spreadsheet view, and this can be exported as described above.

Example:

  • Open disk_out_ref.exo. turn on all variables. Press Apply.
  • Drag the object around with the left mouse button until you can see the inside.
  • Select the Filters → Data Analysis→ Plot over line button. Apply.
  • Split the 2d plot vertically. Spreadsheet view.
  • File/Export. This will export the data in the spreadsheet view. Note that the rows will be numbered from 0 to 100, representing 101 steps down the line. Notice that there is a column named "arc_length" that represents the X axis of the plot.


Traces

ParaView can now automatically save traces, or macros. This means that you can start recording a trace, do something, stop recording a trace, and save this trace into a file. You can then use this trace file as input to the pvbatch program, or as a macro within ParaView.

Example:

  • Start ParaView (3.6.2 or later)
  • Tools/ Python Shell/ Trace/ Start Trace.
  • Open disk_out_ref.exo, all variables on, Apply.
  • Clip, Z normal, unselect show plane, Apply.
  • Slice, unselect show plane, Apply.
  • Color by Temp.
  • In the Python Shell window, Stop Trace.
  • Save trace. Save this file somewhere.
  • Edit/ Delete All

Now, lets run the trace.

  • In the Python Shell window, Run Script. Select your trace file.

Notice a few things:

  • The Show Plane tool does not turn off. This is a bug that will be resolved soon.
  • With multi-file CTH files, ParaView does not create internal variable names correctly. Before using the trace file, edit this file and change names that look like spcta_a_0* to spcta_a_0. I.e., get rid of the *. This is also true for multi-file Exodus datasets.
  • The Save Screenshot does not work. You can add the following code to the trace, and screenshots will be saved. You want to replace the line at the bottom of the trace that says Render()

<source lang="python"> WriteImage("/path/to/image.png") </source>

For Windows XP, use the following: <source lang="python"> WriteImage("c:/wherever you want/fileName.png") </source>

Saving an animation isn't much harder - you use the following code in place of the Render() call.

<source lang="python"> AnimateReader(reader, filename=".../movie.avi") </source>



Acknowledgements

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.