Visualisation

This page describes the visualisation functions in MiningPy

plot3D

miningpy.visualisation.plot3D(blockmodel: DataFrame, xyz_cols: Tuple[str, str, str] = ('x', 'y', 'z'), col: Optional[str] = None, dims: Optional[Tuple[Union[int, float], Union[int, float], Union[int, float]]] = None, rotation: Tuple[Union[int, float], Union[int, float], Union[int, float]] = (0, 0, 0), widget: Optional[str] = None, min_max: Optional[Tuple[Union[int, float], Union[int, float]]] = None, legend_colour: str = 'bwr', window_size: Optional[Tuple[int, int]] = None, show_edges: bool = True, show_grid: bool = True, shadows: bool = True, show_plot: bool = True) Plotter

create activate 3D vtk plot of block model that is fully interactive

Parameters
blockmodel: pd.DataFrame

pandas dataframe of block model

xyz_cols: tuple of strings, default (‘x’, ‘y’, ‘z’)

names of x,y,z columns in model

col: str

attribute column to plot (e.g., tonnage, grade, etc)

dims: tuple of floats or ints

x,y,z dimension of regular parent blocks

rotation: tuple of floats or ints, default (0, 0, 0)

rotation of block model grid around x,y,z axis, -180 to 180 degrees

widget: {“slider”,”section”}

add widgets such as slider (cut off grade) or cross-section.

min_max: tuple of floats or ints

minimum and maximum to colour by values above/below these values will just be coloured the max/min colours

legend_colour: {optional} str, default ‘bwr’

set the legend colour scale. can be any matplotlib cmap colour spectrum.

see: https://matplotlib.org/3.1.1/gallery/color/colormap_reference.html

see: https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html

window_size: {optional} tuple of ints, default (1920, 1080)

size of plot window in pixels

show_edges: bool, default True

whether to show the edges of blocks or not.

show_grid: bool, default True

add x,y,z grid to see coordinates on plot.

shadows: bool, default True

whether to model shadows with a light source from the users perspective. if False, it is like the block model has been lit up with lights from all angles.

show_plot: bool, default True

whether to open active window or just return pyvistaqt.plotting.BackgroundPlotter object to .show() later.

Returns
pyvistaqt.plotting.BackgroundPlotter object & active window of block model 3D plot

export_html

miningpy.visualisation.export_html(blockmodel: DataFrame, path: Optional[str] = None, xyz_cols: Tuple[str, str, str] = ('x', 'y', 'z'), dims: Optional[Tuple[Union[int, float], Union[int, float], Union[int, float]]] = None, rotation: Tuple[Union[int, float], Union[int, float], Union[int, float]] = (0, 0, 0), cols: Optional[List[str]] = None, data_name: str = 'blockModel', colour: Tuple[float] = (0.666667, 1, 0.498039), split_by: Optional[str] = None, colour_range: Tuple[str] = ('blue', 'red')) bool

exports blocks and attributes of block model and embeds the data in a paraview glance html app to visualise and distribute

Parameters
blockmodel: pd.DataFrame

pandas dataframe of block model

path: str

filename for html file

xyz_cols: tuple of strings, default (‘x’, ‘y’, ‘z’)

names of x,y,z columns in model

dims: tuple of floats or ints

x,y,z dimension of regular parent blocks

rotation: tuple of floats or ints, default (0, 0, 0)

rotation of block model grid around x,y,z axis, -180 to 180 degrees

cols: list of strings

columns of attributes to visualise using vtk. If None then exports all columns

data_name: str, default ‘blockModel’

base name used for dataset in Paraview Glance if the split_by column is specified then the unique values in the split_by colum are appended to the base name

colour: tuple of floats, default (0.666667, 1, 0.498039)

default solid colouring of blocks if a column is chosen to split by then this colouring is not considered.

split_by: str

column that is used to split up the block model into components in the Paraview Glance app HTML file. The maximum number of unique values in this column is 256.

colour_range: tuple of two strings, default (‘blue’, ‘red’)

colouring range of values in the split_by column if no split_by then colour_range is ignored. accepted colours are: ‘red’, ‘blue’, ‘green’, ‘white’, ‘black’ default is (‘blue’, ‘red’). i.e. colour blue to red

Returns
True if .html file is exported with no errors

plot3D_dxf

miningpy.visualisation.plot3D_dxf(path: Optional[str] = None, colour: Tuple[float] = (0.666667, 1, 0.498039), show_wireframe: bool = False, show_grid: bool = False, cross_section: bool = False, show_plot: bool = True) Plotter

create activate 3D vtk plot of dxf that is fully interactive the dxf has to either be strings or a triangulation

Parameters
path: str

path to dxf file to visualise

colour: tuple of floats, default (0.666667, 1, 0.498039)

default solid colouring of the triangulation

show_wireframe: bool, default False

whether to show the edges/lines of a wireframe or not

show_grid: bool, default False

add x,y,z grid to see coordinates on plot

cross_section: bool, default False

add widget cross-section to plot

show_plot: bool, default True

whether to open active window or just return pyvista.Plotter object to .show() later

Returns
pyvista.Plotter object & active window of dxf visualisation

export_dxf_html

miningpy.visualisation.export_dxf_html(path: Optional[str] = None, output: Optional[str] = None, data_name: str = 'DXF', colour: Tuple[float] = (0.666667, 1, 0.498039)) bool

exports dxf file and embeds the data in a paraview glance html app to visualise and distribute

Parameters
path: str

path of input dxf file

output: str

path of .vtp file to export

data_name: str, default ‘DXF’

base name used for dataset in Paraview Glance

colour: tuple of floats, default (0.666667, 1, 0.498039)

default solid colouring of the triangulation - RGB ranges 0 to 1

Returns
True if .html file is exported with no errors

dxf2vtk

miningpy.visualisation.dxf2vtk(path: Optional[str] = None, output: Optional[str] = None, colour: Tuple[float] = (0.666667, 1, 0.498039)) PolyData

save dxf to .vtp (vtk polydata) file format so that it can be opened in paraview for external viewing

Parameters
path: str

path of input dxf file

output: str

path of html file to export

colour: tuple of floats, default (0.666667, 1, 0.498039)

default solid colouring of the triangulation

Returns
exports .vtp file and returns pyvista.PolyData object

blocks2vtk

miningpy.visualisation.blocks2vtk(blockmodel: DataFrame, path: Optional[str] = None, xyz_cols: Tuple[str, str, str] = ('x', 'y', 'z'), dims: Optional[Tuple[Union[int, float], Union[int, float], Union[int, float]]] = None, rotation: Tuple[Union[int, float], Union[int, float], Union[int, float]] = (0, 0, 0), cols: Optional[List[str]] = None, output_file: bool = True) vtkUnstructuredGrid

exports blocks and attributes of block model to a vtk file to visualise in paraview

Parameters
blockmodel: pd.DataFrame

pandas dataframe of block model

path: str

filename for vtk file

xyz_cols: tuple of strings, default (‘x’, ‘y’, ‘z’)

names of x,y,z columns in model

dims: tuple of floats or ints

x,y,z dimension of regular parent blocks

rotation: tuple of floats or ints, default (0, 0, 0)

rotation of block model grid around x,y,z axis, -180 to 180 degrees

cols: list of str

columns of attributes to visualise using vtk. If None then exports all columns

output_file: bool, default True

whether to output .vtu (vtk unstructured grid file) or to just return vtu object to user

Returns
vtkUnstructredGrid object if .vtu file is exported with no errors

blocks2dxf

miningpy.visualisation.blocks2dxf(blockmodel: DataFrame, path: Optional[str] = None, dxf_split: Optional[str] = None, facetype: str = '3DFACE', xyz_cols: Tuple[str, str, str] = ('x', 'y', 'z'), dims: Optional[Tuple[Union[int, float], Union[int, float], Union[int, float]]] = None, rotation: Tuple[Union[int, float], Union[int, float], Union[int, float]] = (0, 0, 0)) bool

exports blocks and attributes of block model to a vtk file to visualise in paraview

Parameters
blockmodel: pd.DataFrame

pandas dataframe of block model

path: str

filename for dxf files. If multiple dxfs produced, this will be used as the file suffix

dxf_split: str

column to split dxf files by. for example, could be the year mined column from minemax if None then one dxf is made of every block in blockmodel

facetype: {‘3DFACE’, ‘MESH’, None}, default ‘3DFACE’

type of face for the blocks 3DFACE will create standard dxf faces which are understood by most software MESH is a newer type which requires less space but might not work well None will create no face (could be useful when we add line drawing functionality in the function)

xyz_cols: tuple of strings, default (‘x’, ‘y’, ‘z’)

names of x,y,z columns in model

dims: tuple of floats or ints

x,y,z dimension of regular parent blocks

rotation: tuple of floats or ints, default (0, 0, 0)

rotation of block model grid around x,y,z axis, -180 to 180 degrees

Returns
True if .dxf file(s) are exported with no errors

face_position_dxf

miningpy.visualisation.face_position_dxf()