53 Adding anthropogenic geometries to PyVista
Contents
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.
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]:
Header | Data Arrays | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
[5]:
mesh2
[5]:
Header | Data Arrays | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
[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()
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]:
PolyData | Information |
---|---|
N Cells | 5 |
N Points | 4 |
X Bounds | 2.000e+02, 9.000e+02 |
Y Bounds | 2.000e+02, 1.000e+03 |
Z Bounds | 4.000e+02, 5.000e+02 |
N Arrays | 0 |
[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()
[35]:
poly['scalars'] = np.arange(len(points))
tube = poly.tube(radius=50)
tube
[35]:
Header | Data Arrays | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
[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()
[ ]:
[ ]:
[ ]: