Note
Go to the end to download the full example code.
1c. Visualising models#
The following tutorial will demonstrate how to use the Loop structural visualisation module. This module provides a wrapper for the lavavu model that is written by Owen Kaluza.
Lavavu allows for interactive visualisation of 3D models within a jupyter notebook environment.
Imports#
Import the required objects from LoopStructural for visualisation and model building
from LoopStructural import GeologicalModel
from LoopStructural.visualisation import Loop3DView
from LoopStructural.datasets import load_claudius # demo data
Build the model#
data, bb = load_claudius()
model = GeologicalModel(bb[0, :], bb[1, :])
model.set_model_data(data)
strati = model.create_and_add_foliation("strati",nelements=1e4)
vals = [0, 60, 250, 330, 600]
for i in range(len(vals) - 1):
model.stratigraphic_column.add_unit(
f"unit_{i}",
thickness=vals[i + 1] - vals[i],
id=i,
)
model.stratigraphic_column.group_mapping['Group_0'] = 'strati'
Visualising results#
The Loop3DView is an LoopStructural class that provides easy 3D plotting options for plotting data points and resulting implicit functions.
the Loop3DView is a wrapper around the pyvista Plotter class. Allowing any of the methods for the pyvista Plotter class to be used.
The implicit function can be visualised by looking at isosurfaces of the scalar field.
viewer = Loop3DView()
viewer.plot_surface(feature,**kwargs)
Where optional kwargs can be:
valuespecifying the number of regularly spaced isosurfacespaint_withthe geological feature to colour the surface withcmapcolour map for the colouringnormalsto plot the normal vectors to the surfacenameto give the surfacecolourthe colour of the surfaceopacitythe opacity of the surfacevminminimum value of the colour mapvmaxmaximum value of the colour mappyvista_kwargs- other kwargs for passing directly to pyvista Plotter.add_mesh
Alternatively the scalar fields can be displayed on a rectangular cuboid.
viewer.plot_scalar_field(geological_feature, **kwargs)
Other possible kwargs are:
cmapcolour map for the propertyvminminimum value of the colour mapvmaxmaximum value of the colour mapopacitythe opacity of the blockpyvista_kwargs- other kwargs for passing directly to pyvista Plotter.add_mesh
The input data for the model can be visualised by calling either:
viewer.plot_data(feature,**kwargs)
Where optional kwargs can be:
- value - whether to add value data
- vector - whether to add gradient data
- scale - scale of the gradient vectors
- pyvista_kwargs - other kwargs for passing directly to pyvista Plotter.add_mesh
The gradient of a geological feature can be visualised by calling:
viewer.add_vector_field(feature, **kwargs)
Where the optional kwargs can be:
- scale - scale of the gradient vectors
viewer = Loop3DView(model, background="white")
# determine the number of unique surfaces in the model from
# the input data and then calculate isosurfaces for this
viewer.plot_surface(strati, value=vals, cmap="prism", paint_with=strati)
viewer.display()
viewer = Loop3DView(model, background="white")
viewer.plot_scalar_field(strati, cmap="prism")
viewer.display()
viewer = Loop3DView(model, background="white")
# print(viewer._build_stratigraphic_cmap(model))
viewer.plot_block_model(cmap='tab20')
viewer.display()
viewer = Loop3DView(model, background="white")
# Add the data addgrad/addvalue arguments are optional
viewer.plot_data(strati, vector=True, value=True)
viewer.display() # to add an interactive display
Total running time of the script: (0 minutes 3.985 seconds)



