Plotting data with Paraview
Boovysa, Milano, 2020.
This page is in the Junk directory! Make sure to check some better material on the MAIN PAGE!
That's a very trivial page, but I wish I knew this trick before.
Do you ever need to plot 3D data fields, extract stuff, do contours etc?
ParaView is a great option for that. And the best thing is: you don't need to use VTK!
Indeed, the simplest way is producing a CSV file containing a bunch of points and the fields that you wish to plot
at these points.
We'll consider here two options:
- Structured data;
- Unstructured data.
Structured data
The simplest option is using a set of equally spaced points, in 3 dimensions.
Write them in a CSV file with the following syntax (in the example, the first line is made by labels, then you have x,y,z,
coordinates and then the data fields that you need):
x,y,z,value1,value2
1.0,1.0,1.0,949.2,123983.3
2.0,1.0,1.0,948.2,93938.2
3.0,1.0,1.0,947.2113290.3
...
3.0,3.0,3.0,999.3,202023.3
Then you do the following:
- Open the CSV file with ParaView;
- Go to filters and select Table to Structured Grid;
- Select for X,Y,Z the relevant columns, sorted by label;
- Fill the "Whole Extent" fields: if your x,y,z vectors will be 100 elements long, say for the Whole Extent "0" to "99". Click Apply;
- Now you need to plot the result (it may not plot automatically): split the screen with the small icon at the top right, create a Render view and then
enable the "eye" in the TableToStructuredGrid object, in the left menu.
This strategy is pretty fast and you can load 1GB of data in a matter of a couple minutes (as of 2020, on an average laptop).
Check out an example result here, of a contour from a data field:
Unstructured data
It is possible to do similar operations using non-structured meshes, aka a bunch of kind of random points in space.
To do that, again you can feed the points in CSV format and then you ask ParaView to run a 3D Delaunay triangulation algorithm.
This will take a bit of time if the dataset is very large and you need to create many points.
You can click here to download an example file.
The operations are:
- Open the CSV file with ParaView, and click Apply.
- Go to filters and select (check under "alphabetical order") TableToPoints. Set the X,Y,Z point coordinates to the proper columns. Then click Apply.
- Finally, go to filters again and run Delaunay3D. Click Apply.
- Enjoy the dataset.
Here's a plot for the field in the example.
Cheers!
-Stefano -> BACK TO THE HOMEPAGE <-