-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examples: add PyVista/VTK example (#132)
Co-authored-by: LSchueler <mostem@posteo.de>
- Loading branch information
1 parent
d8b7582
commit 07ec46d
Showing
9 changed files
with
90 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,3 +125,4 @@ docs/source/generated/ | |
|
||
*.vtu | ||
*.vtr | ||
*.vtk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
""" | ||
Exporting Fields | ||
---------------- | ||
""" | ||
GSTools provides simple exporting routines to convert generated fields to | ||
`VTK <https://vtk.org/>`__ files. | ||
These can be viewed for example with `Paraview <https://www.paraview.org/>`__. | ||
""" | ||
# sphinx_gallery_thumbnail_path = 'pics/paraview.png' | ||
import gstools as gs | ||
|
||
x = y = range(100) | ||
model = gs.Gaussian(dim=2, var=1, len_scale=10) | ||
srf = gs.SRF(model) | ||
field = srf((x, y), mesh_type="structured") | ||
srf.vtk_export(filename="field") | ||
|
||
############################################################################### | ||
# The result displayed with Paraview: | ||
# | ||
# .. image:: https://raw.githubusercontent.com/GeoStat-Framework/GeoStat-Framework.github.io/master/img/paraview.png | ||
# :width: 400px | ||
# :align: center |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
""" | ||
Using PyVista meshes | ||
-------------------- | ||
`PyVista <https://www.pyvista.org>`__ is a helper module for the | ||
Visualization Toolkit (VTK) that takes a different approach on interfacing with | ||
VTK through NumPy and direct array access. | ||
It provides mesh data structures and filtering methods for spatial datasets, | ||
makes 3D plotting simple and is built for large/complex data geometries. | ||
The :any:`Field.mesh` method enables easy field creation on PyVista meshes | ||
used by the :any:`SRF` or :any:`Krige` class. | ||
""" | ||
# sphinx_gallery_thumbnail_path = 'pics/GS_pyvista_cut.png' | ||
import pyvista as pv | ||
import gstools as gs | ||
|
||
############################################################################### | ||
# We create a structured grid with PyVista containing 50 segments on all three | ||
# axes each with a length of 2 (whatever unit). | ||
|
||
dim, spacing = (50, 50, 50), (2, 2, 2) | ||
grid = pv.UniformGrid(dim, spacing) | ||
|
||
############################################################################### | ||
# Now we set up the SRF class as always. We'll use an anisotropic model. | ||
|
||
model = gs.Gaussian(dim=3, len_scale=[16, 8, 4], angles=(0.8, 0.4, 0.2)) | ||
srf = gs.SRF(model, seed=19970221) | ||
|
||
############################################################################### | ||
# The PyVista mesh can now be directly passed to the :any:`SRF.mesh` method. | ||
# When dealing with meshes, one can choose if the field should be generated | ||
# on the mesh-points (`"points"`) or the cell-centroids (`"centroids"`). | ||
# | ||
# In addition we can set a name, under which the resulting field is stored | ||
# in the mesh. | ||
|
||
srf.mesh(grid, points="points", name="random-field") | ||
|
||
############################################################################### | ||
# Now we have access to PyVista's abundancy of methods to explore the field. | ||
# | ||
# .. note:: | ||
# PyVista is not working on readthedocs, but you can try it out yourself by | ||
# uncommenting the following line of code. | ||
|
||
# grid.contour(isosurfaces=8).plot() | ||
|
||
############################################################################### | ||
# The result should look like this: | ||
# | ||
# .. image:: https://github.com/GeoStat-Framework/GeoStat-Framework.github.io/raw/master/img/GS_pyvista_cut.png | ||
# :width: 400px | ||
# :align: center |
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters