0% found this document useful (0 votes)
51 views64 pages

TGDG 2018 Introduction To Python Adrian Martinez November 2018

Uploaded by

mark overmars
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views64 pages

TGDG 2018 Introduction To Python Adrian Martinez November 2018

Uploaded by

mark overmars
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

Mineral resource

estimation with python


CSA Global
AN INTRODUCTION TO PYTHON, PYGSLIB, AND PARAVIEW
Mining FOR GEOLOGISTS
Industry
consultants

© OpenGeostat/CSA Global all rights reserved


The presenter
Adrian Martinez Vargas
CSA Global Senior Resource Geologist
Opengeostat project: http://opengeostat.com
PyGSLIB project https://github.com/opengeostat/pygslib
P.Geo, Ph.D. in Geological Sciences, ISMM Moa. Specialist in Geostatistics (CFSG), Paris Mining School.
B.Eng. Geology, ISMM Moa
Adrian is both a geologist and a geostatistician. He has worked as a consultant since 2002 covering many commodities
including gold, copper, nickel, chromium, and raw material for cement industry. He has experience in the application
of multiple indicator kriging for resource estimation of gold deposits with high nugget and domaining issues.
Additionally, he has experience with non-linear geostatistics and conditional simulations for various applications.
Adrian has worked as an Assistant Professor in Cuba and Ethiopia, teaching geology and geostatistics.

Adrian produces open source software for geostatistics and mineral resources in Python, Fortran, and Cython

© OpenGeostat/CSA Global all rights reserved


The attendees
Your name
Your background and current role

What do you know about Mineral resource estimation, Python, GSLIB,


PyGSLIB, Pandas, VTK, and Paraview?

What you would like to get out of this course?

© OpenGeostat/CSA Global all rights reserved


Course Outline
Introduction
◦ Introduction to mineral resource estimation (MRE). Why using python to do a MRE?
◦ Introduction to Python: language fundamentals, python distributions, python IDE, and python packages useful
to do MRE.
◦ Hello world in Jupyter Notebook/Lab and importing drillhole tables.
◦ Introduction to PyGSLIB
◦ Introduction to Paraview
Mineral resource estimation with PyGSLIB (big exercise with explanations)
◦ Creating and visualizing drill holes
◦ Modeling geological units using implicit functions operations
◦ Drillhole intervals tagging, compositing, declustering, statistical analysis, and variography
◦ Block modeling and estimation
◦ Block model validation
◦ Reporting

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 4
Introduction
A NECESSARY OVERVIEW OF MINERAL RESOURCE ESTIMATION

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 5
The mineral resource estimation (MRE)
Recurrence

Informing Geological Statistical Interpolation Reporting and


data (Drilling) modeling Analysis and validation Auditing

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 6
The mineral resource estimation (MRE)
Recurrence

Informing data Geological Statistical Interpolation Reporting and


(Drilling) modeling Analysis and validation Auditing

Selecting
Sampling and Exploratory data Exploratory data Prepare model
estimation
logging analysis analysis for engineers
technique
Selecting
Geological
Assaying Declustering estimation Report G/T
domains
parameters
Technical reports
Database Estimation Statistical
Interpolating and
validation domains analysis
documentation
Data quality
Sample and block Internal and
validation Variography Validating
model tagging external Audit
(QAQC)

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 7
The mineral resource estimation (MRE)
Tables Drill holes Solids and surfaces Sample/domains Blocks/domain

Desurvey Tagging
Wireframing

Compositing
Re-estimate

New data?
Testing different approaches?
Validation issues?
Estimation
GCOS/Swath parameters and Composites
plots/sections estimated values Variogram/stats/plots
Validation Variography
Interpolation Stats

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 8
The mineral resource estimation (MRE)
Advantages of using scripts/macros
1. Repeatability
2. Auditability and peer review
Desurvey Wireframing Tagging 3. Save you time. You can reuse code from
other projects.
4. More Flexibility. Allows you testing multiple

Compositing
Re-estimate

Python Open Source (PyGSLIB) scenarios. You can create new functionality.
You can do advanced stuff.
Python Proprietary (Micromine)
TCL (Surpac) Why open source tools?
Datamine macros 1. No black box policy
2. It is “free”
Validation Variography Alternatives to macros/scripts:
Interpolation
Stats 1. Parameter files
2. Just doing manual work

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 9
Introduction
ALL ABOUT PYTHON IN 10 MINUTES

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 10
Introduction to python
o General aspects
o What is python?
o What is a python version
o Python distributions
o Python integrated development environments (IDE)

o Python programming language


o Syntax
o Python objects, classes, functions and modules (pure python and compiled)
o Built-in data types and data structures (list, dictionaries, tuples, sets, strings)
o Modules for efficient data structure: numpy and pandas

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 11
Introduction to python (general aspects)
o General aspects Standard python console showing version and build platform
o What is python?
o What is a python
version
o Python
distributions
o Python integrated
development
environments
(IDE)

Python Distribution

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 12
Introduction to python (general aspects)
o General aspects Standard python console showing version
o What is python?
o What is a python
version
o Python
distributions
o Python integrated
development
environments
(IDE)

Python embedded in Paraview

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 13
Introduction to python (general aspects)
o Python integrated Jupyter Lab/Notebook IDE. The best option for interactive
development environments computing and scripting. We will use Jupyter Notebook in
(IDE)
this course.

Atom IDE (Good for development)

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 14
Introduction to python (general aspects)
o Using Anaconda/Miniconda https://anaconda.org/opengeostat/pygslib
distributions

win-64/pygslib-0.0.0.3.9.0-
py27h39e3cac_0.tar.bz2

linux-64/pygslib-0.0.0.3.9.0-
py36hf687e67_0.tar.bz2

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 15
Introduction to python (the language)
o Syntax

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 16
Introduction to python (the language)
o Python objects, classes, functions and modules (pure python and compiled)

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 17
Introduction to python (the language)
o Python objects, classes, functions and modules (pure python and compiled)
Save class, functions,
and any object in file
block.py to create a
pure python module

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 18
Introduction to python (the language)
o Built-in data types and data structures (list, tuples, and dictionaries)

{ key1 : value,
key2: value,

keyn: value,
}

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 19
Introduction to python (the language)
o Modules for efficient data structures: numpy and pandas Pandas DataFrames are to handle tables,
import csv, do SQL style queries, etc.
Numpy defines arrays for efficient It behaves +/- like dictionaries.
numerical operations (similar to lists)

Columns are numpy arrays

try:
Index >>> collar['XCOLLAR’].values

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 20
Exercise 1: Hello world in Jupyter Lab
Familiarizing yourself with Jupyer
• Open jupyter notebook
• Rename the file as MRE using python
• Add Markdown cell at the top and add some comments

Exploring Jupyter functionality


• Import pandas as pd, pygslib, numpy as np and
matplotlib.pyplot as plt
• Import drillhole tables into pandas.DataFrame objects
using function pd.read_csv()
• Explore data using pandas.DataFrame functions head(),
describe() and plot collar location using
pandas.DataFrame plot() function
• Create a column of log(Au) in table assays

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 21
Introduction to Paraview

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 22
Introduction to Paraview
Paraview is based on VTK (visualization
toolkit)
We will use it to visualize
▪ Points: vtkPolydata (*.vtp, *.vtk)
▪ Surfaces: vtkPolydata
▪ Full block models: vtkImageData (*.vti)
▪ Partial block models:
vtkUnstructuredGrid (*.vtu)
▪ Variogram grids and some models:
vtkStructuredGrid (*.vts)

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 23
Introduction to Paraview
Paraview uses Pipelines with:
▪ Sources: No input signal, only output.
Example readers (stl, csv, etc )
▪ Filters: Have input and output signal.
Examples, contour filter, tube filter.
Use CTR + Space key to see list of
commands available for the object
selected. Non-valid filters are in grey.
Use key v to activate query/selection

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 24
Introduction to Paraview
Paraview has many types of
visualizations, we will mostly
use:
▪ Render View Cell data
▪ SpreadSheet View
Point data
Visualizations share data and
selections
Important: vtk geometries
are composed by points and
cells. You can have:
▪ Point data Show only
▪ Cell data selected data

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 25
Exercise 1b: Plot collars in Paraview

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 26
Mineral resource estimation with
PyGSLIB
THE BIG EXERCISE EXPLAINED

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 27
PyGSLIB
Python package for mineral resource estimation consisting of:
▪ drillhole module: it creates drillholes, do desurvey, and composites
▪ blockmodel module: to creates block models, fill wireframes with blocks, etc.
▪ gslib: wraps modified Fortran code from GSLIB, it implements kriging, declustering,…
▪ vtktools: to handle and generate wireframes and do exports/imports from/to vtk (and Paraview)
▪ nonlinear: to do nonlinear geostat with discrete gaussian model
▪ sandbox: area to test new code before it goes to a module
▪ Sandbox2: Only available as source code
▪ Html plot: Plot using bokeh (the plan is using Altair(?))
Source code at https://github.com/opengeostat/pygslib, help at
https://opengeostat.github.io/pygslib/

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 28
PyGSLIB (drillholes)
Drillhole objects are composed by tables XCOLLAR, YCOLLAR, ZCOLLAR
Drillholes contains functions to:
(Pandas Dataframes) collar and survey. In
▪ Add or remove interval tables (assay, AT 0, DIP 90, AZ 345
addition you may add any number of
lithology)
interval tables:
Collar: may have fields ▪ Merge interval tables AT 50

▪ BHID: any type ▪ Validate drillhole and interval tables


▪ XCOLLAR, YCOLLAR, ZCOLLAR: type ▪ Downhole composite, and key composite
AT 100
float
▪ Desurvey
▪ (Optional) LENGTH: type float Interval
▪ Add gaps, Split long intervals
Survey: may have fields FROM 110,
▪ BHID: any type ▪ Export drillholes to VTK TO 115, Au 3 g/t

▪ AT,AZ, DIP: type float (AT at zero is ▪ Utility functions:


compulsory) 'fix_survey_one_interval_err’,
Interval: may have fields 'fix_zero_interval’, 'txt2intID’, collar2table
▪ BHID: any type ▪ Properties: collar, survey, tables,
▪ FROM, TO: type float table_mames

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 29
PyGSLIB (drillholes)
Common operations with drillhole data
Create Drillholes Visualize and Prepare for
modeling interpolation

• Define drillholes with • Combine tables • Tag interval with


tables Assay and Litho estimation
• Collar • Desurvey domains using
• Survey (calculate x,y,z) surfaces and solids
• IntervalAssay • Export to VTK • Composite
• Modeling downhole
• Assay
• Lithology • Composite per
•… litho
• Validate drillhole • Extract contacts
(manual)
• Validate tables

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 30
Exercise 2: Drillholes
Exploratory data analysis
• Create a drillhole object
• Add drillhole intervals
• Validate
• Desurvey
• Export drillhole as vtk file and identify mineralization
Modeling
• Label drillhole intervals with domain
• Optionally composite with key
• Extract contact points to model surfaces
Composite
• Composite downhole (only samples in mineralized
domain)

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 31
The mineral resource estimation (MRE)
Tables Drill holes Solids and surfaces Sample/domains Blocks/domain

Desurvey Tagging
Wireframing

Compositing
Re-estimate

New data?
Testing different approaches?
Validation issues?
Estimation
GCOS/Swath parameters and Composites
plots/sections estimated values Variogram/stats/plots
Validation Variography
Interpolation Stats

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 32
PyGSLIB (vtktools and modeling)
Vtktools is a collection of functions to Vtktools contains functions to:
work with spatial data, to import spatial
▪ 'SaveImageData', 'SaveRectilinearGrid’, Vtk cells
data (wireframes) and to do some
'SaveUnstructuredGrid’, 'define_region_grid’,
computational geometry.
'grid2vtkImageData’, 'partialgrid2vtkfile’,

We use this module to define domains ▪ 'GetPointsInPolydata', 'PolyData2dxf’,


(vtkPolyData) and to save block models 'SavePolydata’, 'dxf2PolyData’, 'delaunay2D',
(vtkImageData, vtkRectilinearGrid, 'SetPointsInPolydata’, 'clip_with_surface’,
vtkUnstructuredGrid). 'dmtable2wireframe’, 'loadSTL', 'loadVTP’,
'rbfinterpolate’,
We use this module to select points and ▪ 'getbounds',
blocks inside domains defined by ▪ 'evaluate_implicit_grid’, 'implicit_surface’,
vtkPolyData
'evaluate_implicit_points’, 'vtk_raycasting’,
'pointinsolid’, 'pointquering',

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 33
PyGSLIB (vtktools and modeling)
VTK uses implicit functions to do Implicit functions Distance to
some computational geometry surface (sign tells
operations, for example:
you if you are
▪ Find points inside/outside inside or outside)
solids
▪ Extracting an isosurface
▪ Cutting with planes or Normals
surfaces
▪ Generating blocks in solid
Surfaces (PolyData) need to be Resolution is
converted to implicit functions. important
In, out, and distance directions
are calculated with surface
normals.

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 34
PyGSLIB (vtktools and modeling)
There are different ways to Snapping
obtain similar models: and
VtkUnstructured
▪ Cut a VTK Grid (Structured
or Unstructured) grid

▪ Extracting an isosurface
and implicit boolean
▪ Using open implicit
surfaces
No snapping
▪ Intrusion (not
implemented) and vtkImage

We need closed surfaces to


calculate block volume

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 35
PyGSLIB (vtktools and modeling)
Implicit Boolean = max(hw,fw)

Hanging wall

Footwall

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 36
PyGSLIB (vtktools and modeling)
Raycasting is a non-implicit Intersection points Points below surface
tool based on rays and
intersections with solids.
Is used to find points
above/below or within
surfaces.
Works with open surfaces

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 37
Exercise 3: Model domains
• Define working region (regular grid or vtkImage)
• Create contact surfaces and topo interpolating with Rbf
(vtkPolyData with open surface triangulations)
Create solids
• Convert vtkPolyData surfaces to implicit functions
• Model solids:
• Use cutting tool (not recommended)
• Or evaluate distance in region and extract isosurface
Tag drillhole data
• Tag drillhole data is not necessary in this case, but you
will have to do this if using solids created in a different
way. There are many ways of tagging, example:
• pygslib.vtktools.evaluate_implicit_points()
• pygslib.vtktools.pointinsolid()
• pygslib.vtktools.vtk_raycasting()

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 38
The mineral resource estimation (MRE)
Tables Drill holes Solids and surfaces Sample/domains Blocks/domain

Desurvey Tagging
Wireframing

Compositing
Re-estimate

New data?
Testing different approach?
Validation issues?
Estimation
GCOS/Swath parameters and Composites
plots/sections estimated values Variogram/stats/plots
Validation Variography
Interpolation Stats

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 39
PyGSLIB (blockmodel)
Blockmodel class creates and handle Blockmodel contains functions to:
block models. Blocks models are defined
▪ 'block2point’, 'point2block’,
by origin of coordinates (lower left
'blockinsurface’,
corner), block size, and number of blocks.
Block values are stored in Pandas ▪ 'blocks2vtkImageData’,
DataFrames 'blocks2vtkUnstructuredGrid’,
'blocks2vtkUnstructuredGrid_p',
We use this module to define a block ▪ 'reblock’, 'set_block_size’, 'set_blocks’,
model object, calculate percentage of 'set_origin’, 'set_rcl',
blocks inside domain, and to export ▪ 'calc_ijk’, 'calc_ixyz_fromijk’,
blocks to vtk.
'calc_ixyz_fromxyz’, 'calc_xyz_fromixyz’,
'fillwireframe', 'create_3Dgrid’, 'create_IJK’,
Other interesting applications are: 'delete_blocks’,
migrating block data to point data (useful
for drillhole spacing studies) ▪ Properties: 'dx’, 'dy’, 'dz’, 'xorg’, 'yorg’,
'zorg’, 'bmtable’, 'nx', 'ny', 'nz',

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 40
PyGSLIB (blockmodel)
▪ In Pygslib a block model can be full or partial.
▪ It is fully defined by coordinates of the lower left corner,
number of blocks and block size.
▪ Block positions can be defined with an IJK index that
grows in X, then Y and finally Z direction. This is similar to
GSLIB and different to Datamine IJK value.
▪ The class includes functions to calculate block row, col,
and level index and coordinates from ijk and vice versa
▪ The function fillwireframe() generates a full model and
calculates percent inside closed surface (or horizontal
section polylines).
▪ Subcells are not implemented yet but can be handled.
You could use functions in vtktools to inspect subcell
centroids position relative to surfaces and solids.

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 41
Exercise 4: Block models
• Generate a block model with percentage inside solid and
validate the results in Paraview

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 42
The mineral resource estimation (MRE)
Tables Drill holes Solids and surfaces Sample/domains Blocks/domain

Desurvey Tagging
Wireframing

Compositing
Re-estimate

New data?
Testing different approaches?
Validation issues?
Estimation
GCOS/Swath parameters and Composites
plots/sections estimated values Variogram/stats/plots
Validation Variography
Interpolation Stats

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 43
http://www.gslib.com/gslib_help/gslibhlp.html
http://www.statios.com/Quick/gslib.html
PyGSLIB (gslib)
This module interfaces Fortran code: Hidden internal functions with direct access to
▪ modified from gslib source files code in Fortran, for example '__bigaus’ and
(gslib77_ls.tar.gz) '__block_covariance’.
▪ new Fortran code, inspired or not in
Python interface to low level functions:
gslib (example to read datamine files)
▪ 'kt3d’, 'postik’,
Two main changes were introduced in the
code: ▪ 'addcoord’, 'rotcoord', 'rotscale’,
▪ GSLIB code was reorganized as safe 'dm2csv_ep’, 'dm2csv_sp’, 'read_gslib_file’,
functions ▪ 'block_covariance’, 'check_gamv_par’,
▪ Data is directly transferred from 'cova3’, 'gam’, 'gamv’
python trough memory (for that ▪ 'setrot’, 'set_nan_value'
reason we use numpy arrays)
▪ 'cdfplt’, 'histgplt’,
▪ Data and parameters are defined as
dictionaries. ▪ 'declus'
▪ Improvements in the programs: Some are under construction or need redesign: Not all the gslib
variogram cloud and domain, etc. 'gamv3D’, 'cova3’, 'gam’, 'gamv’ programs are included

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 44
PyGSLIB (gslib & htmlplot)
Programs for exploratory data analysis:
▪ declus: Declustering
▪ plothtml.histgplt: plot histograms
PyGSLIB
plot
▪ plothtml.probplt: plot cdf and pdf
▪ plothtml.qpplt: plot qq plot
▪ plothtml.scatter2D: plot scatterplot and allows selection (no gslib)

To use bokeh with Jupyter Lab you may install the


extension (this may be difficult to do!):
c:\> jupyter labextension install
jupyterlab_bokeh
c:\> conda install -c conda-forge nodejs

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 45
PyGSLIB (gslib declustering)
Clustered

True

Clustered

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 46
PyGSLIB (gslib declustering)
Delustered

True

Declustered

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 47
PyGSLIB (gslib declustering)
Optimizing cell size

5m

10 m 20 m cell

Optimum cell size

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 48
PyGSLIB (gslib declustering)
Declustering parameter dictionary

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 49
Exercise 5: Stats and variography
• Composite
• Declustering
• Stats
• Variography (not implemented but explained)

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 50
The mineral resource estimation (MRE)
Tables Drill holes Solids and surfaces Sample/domains Blocks/domain

Desurvey Tagging
Wireframing

Compositing
Re-estimate

New data?
Testing different approaches?
Validation issues?
Estimation
GCOS/Swath parameters and Composites
plots/sections estimated values Variogram/stats/plots
Validation Variography
Interpolation Stats

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 51
PyGSLIB (gslib interpolation)
Interpolation overview Kriging, inverse of the distance and nearest neighbor
can be written as:
▪ Uses the function kt3d from GSLIB : pygslib.gslib.kt3d 𝑛
𝐴𝑢 𝑣 = ෍ 𝜆𝑖 𝐴𝑢(𝑥𝑖 )
▪ It support: 𝑖=1
▪ Ordinary/universal kriging The only difference is how you calculate the weights 𝜆𝑖
▪ Inverse of the distance
▪ Median indicator kriging Search ellipse
▪ Multiple indicator kriging is possible using function
pygslib.gslib.postik
Au(x1) Au(x4)
▪ support for maximum number of samples per
drillhole Au(v)
Au(x5)
▪ The output is a dictionary with: Au(x2)
▪ output : dict, estimation results at target points/blocks Au(x3)
▪ debug : debug output for the last block estimated
▪ estimate : estimation summary
discretization
Type help(pygslib.gslib.kt3d) to see full help points

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 52
Exercise 6: Interpolation
• Interpolate

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 53
The mineral resource estimation (MRE)
Tables Drill holes Solids and surfaces Sample/domains Blocks/domain

Desurvey Tagging
Wireframing

Compositing
Re-estimate

New data?
Testing different approaches?
Validation issues?
Estimation
GCOS/Swath parameters and Composites
plots/sections estimated values Variogram/stats/plots
Validation Variography
Interpolation Stats

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 54
PyGSLIB (nonlinear)
The nonlinear module implements the 'ana_options’, 'anamor’, Gaussian Anamorphosis in
discrete gaussian model with hermite 'anamor_blk’, 'anamor_raw’, point and block support
polynomials. The main applications are: 'backtr’, 'brentq’,
▪ Global Change Of Support (GCOS). A 'calauthorized’,
tool for global estimation of mineral 'calauthorized_blk',
resources and for estimation
validation 'expand_anamor’,
'f_covar_ZvZv’, 'f_var_Zv',

Au
▪ Normal score variogram
transformation. Not implemented yet 'findcontrolpoints’, 'fit_PCI’,
▪ Uniform conditioning: not 'get_r’, 'get_ro',
implemented yet. 'gtcurve’, 'norm’,
▪ Normal score transformation (also 'nscore’, 'plotgt',
available in pygslib.gslib)
'recurrentH', Au Gaussian
'ttable', (nscore)
'var_PCI' Control
points

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 55
PyGSLIB (nonlinear) GCOS
Global estimation in point support Ore: 20 % of total tonees

grade
Ore

Cumulative
Waste distribution
function

Waste: 80 % of total tonees

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 56
PyGSLIB (nonlinear) GCOS
Global estimation in block support Ore: 10 % of total tones

Block CDF
Ore

Waste

Waste: 90 % of total tones

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 57
PyGSLIB (nonlinear) GCOS
Global estimation in block support
a) Get Point
Anamorphosis

c) Use block b) Fit the block


Anamarphosis Anamorphosis
To deduce G/T

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 58
PyGSLIB Validations
▪ Global change of support
▪ Mean (declust.) comparisons
▪ Visual validations
▪ Swath plots not implemented but
there is a work around…

Visual
validations

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 59
Exercise 7: Validation
• Validate the estimate

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 60
The mineral resource estimation (MRE)
Tables Drill holes Solids and surfaces Sample/domains Blocks/domain

Desurvey Tagging
Wireframing

Compositing
Re-estimate

New data?
Testing different approaches?
Validation issues?
Estimation
GCOS/Swath parameters and Composites
plots/sections estimated values Variogram/stats/plots
Validation Variography
Interpolation Stats

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 61
Exercise 8: Reporting
• Reporting (Homework). Hint, use pandas dataframes

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 62
PyGSLIB what is next?
Pygslib TODO list:
(documentation) Better documentation
(nonlinear) Implement Uniform conditioning
(nonlinear) Add upper and lower tail CDF
model fitting tool
(gslib) complete variogram3d and python
interface and create an Ipython interface with
widgets for friendly variogram modeling
(blockmodel) implement grade tonnage report
and block cdf

© OpenGeostat/CSA Global all rights reserved MINERAL RESOURCE ESTIMATION WITH PYTHON 63
Questions?
◦ ?????????

End of
presentation
Thank you for participating in our
training courses!

Kind regards,

Adrian Martinez Vargas


[email protected]
Opengeostat and CSA Global
M. +1 647 773 2921

© OpenGeostat/CSA Global all rights reserved MACHINE LEARNING FOR GEOLOGISTS 64

You might also like