53 Adding anthropogenic geometries to PyVista#

Geological models are often constructed for the purpose of tunneling or any other type of excavation. As such a tunnel is not a geological but rather anthropegnic feature, it is desirable to visualize the planned or the actual path of the tunnel into the model.

af09e28ac8d24796aa4773a0cc440401

Set File Paths and download Tutorial Data#

If you downloaded the latest GemGIS version from the Github repository, append the path so that the package can be imported successfully. Otherwise, it is recommended to install GemGIS via pip install gemgis and import GemGIS using import gemgis as gg. In addition, the file path to the folder where the data is being stored is set. The tutorial data is downloaded using Pooch (https://www.fatiando.org/pooch/latest/index.html) and stored in the specified folder. Use pip install pooch if Pooch is not installed on your system yet.

[1]:
import gemgis as gg

file_path ='data/53_adding_anthropogenic_geometries_to_pyvista/'
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\ale93371\Anaconda3\envs\test_gempy\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
  warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
[2]:
gg.download_gemgis_data.download_tutorial_data(filename="53_adding_anthropogenic_geometries_to_pyvista.zip", dirpath=file_path)
Downloading file '53_adding_anthropogenic_geometries_to_pyvista.zip' from 'https://rwth-aachen.sciebo.de/s/AfXRsZywYDbUF34/download?path=%2F53_adding_anthropogenic_geometries_to_pyvista.zip' to 'C:\Users\ale93371\Documents\gemgis\docs\getting_started\tutorial\data\53_adding_anthropogenic_geometries_to_pyvista'.

Load Layer Data#

The example model will be loaded and a tunnel will be defined to cross the layers later on.

[3]:
import pyvista as pv

mesh1 = pv.read(file_path+'Layer1.vtk')
mesh2 = pv.read(file_path+'Layer2.vtk')
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\ale93371\Anaconda3\envs\test_gempy\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
  warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
[4]:
mesh1
[4]:
HeaderData Arrays
PolyDataInformation
N Cells4174
N Points2303
X Bounds9.720e+00, 9.623e+02
Y Bounds1.881e+02, 9.491e+02
Z Bounds3.050e+02, 7.250e+02
N Arrays1
NameFieldTypeN CompMinMax
Depth [m]Pointsfloat6413.050e+027.250e+02
[5]:
mesh2
[5]:
HeaderData Arrays
PolyDataInformation
N Cells5111
N Points2739
X Bounds9.720e+00, 9.623e+02
Y Bounds3.578e+02, 1.058e+03
Z Bounds3.050e+02, 7.265e+02
N Arrays1
NameFieldTypeN CompMinMax
Depth [m]Pointsfloat6413.050e+027.265e+02
[7]:
sargs = dict(fmt="%.0f", color='black')

p = pv.Plotter(notebook=True)

p.add_mesh(mesh1, scalars= 'Depth [m]', scalar_bar_args=sargs)
p.add_mesh(mesh2, scalars= 'Depth [m]', scalar_bar_args=sargs)

p.set_background('white')
p.show_grid(color='black')
p.show()
../../_images/getting_started_tutorial_53_adding_anthropogenic_geometries_to_pyvista_8_0.png

Defining Tunnel Object#

The tunnel object will be created as tube from a line.

[30]:
import numpy as np

points = np.array([[200,1000,400],
                [300,800,500],
                [700,600,400],
                [900,200,400]])
points
[30]:
array([[ 200, 1000,  400],
       [ 300,  800,  500],
       [ 700,  600,  400],
       [ 900,  200,  400]])
[31]:
poly = pv.PolyData(points)
poly.points = points
the_cell = np.arange(0, len(points), dtype=np.int_)
the_cell = np.insert(the_cell, 0, len(points))
poly.lines = the_cell
poly
[31]:
PolyDataInformation
N Cells5
N Points4
X Bounds2.000e+02, 9.000e+02
Y Bounds2.000e+02, 1.000e+03
Z Bounds4.000e+02, 5.000e+02
N Arrays0
[32]:
sargs = dict(fmt="%.0f", color='black')

p = pv.Plotter(notebook=True)

p.add_mesh(mesh1, scalars= 'Depth [m]', scalar_bar_args=sargs)
p.add_mesh(mesh2, scalars= 'Depth [m]', scalar_bar_args=sargs)
p.add_mesh(poly, color='red')

p.set_background('white')
p.show_grid(color='black')
p.show()
../../_images/getting_started_tutorial_53_adding_anthropogenic_geometries_to_pyvista_12_0.png
[35]:
poly['scalars'] = np.arange(len(points))
tube = poly.tube(radius=50)

tube
[35]:
HeaderData Arrays
PolyDataInformation
N Cells22
N Points120
X Bounds1.540e+02, 9.440e+02
Y Bounds1.770e+02, 1.028e+03
Z Bounds3.500e+02, 5.490e+02
N Arrays2
NameFieldTypeN CompMinMax
scalarsPointsint3210.000e+003.000e+00
TubeNormalsPointsfloat323-9.951e-019.951e-01
[41]:
sargs = dict(fmt="%.0f", color='black')

p = pv.Plotter(notebook=True)

p.add_mesh(mesh1, scalars= 'Depth [m]', scalar_bar_args=sargs)
p.add_mesh(mesh2, scalars= 'Depth [m]', scalar_bar_args=sargs)
p.add_mesh(poly, color='red')
p.add_mesh(tube, show_scalar_bar=False, cmap='gray')

p.set_background('white')
p.show_grid(color='black')
p.show()
../../_images/getting_started_tutorial_53_adding_anthropogenic_geometries_to_pyvista_14_0.png
[ ]:

[ ]:

[ ]: