uniform_conditioning¶
Uniform Conditioning¶
Overview¶
Uniform conditioning (UC) is a nonlinear estimation method that models the conditional distribution of smallest mining unit (SMU) block grades within panels. UC comes handy in geological applications when an operator wants to estimate metal and ore quantities above a cut-off within a mining panel (the production zone that encapsulates SMUs). This notebook introduces the discrete Gaussian model for change of support, block kriging to estimate the panel grades, and the computation of the quantity of metal and proportion of the panel above the cut-off grade.
Dataset¶
The 2D Walker Lake dataset will be used for demonstration purposes.
Required libraries¶
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import geolime as glm
# plt.rcParams["figure.figsize"] = (25,15)
Data preprocessing¶
walker_lake_path = "../../tests/data/walker_dataset/walker.csv"
data = pd.read_csv(walker_lake_path, sep= ' ')
data.loc[data['v'] > 1e10, 'v'] = 0
data.head()
id | x | y | u | v | t | |
---|---|---|---|---|---|---|
0 | 1 | 11 | 8 | 0.0 | 0.0 | 2 |
1 | 2 | 8 | 30 | 0.0 | 0.0 | 2 |
2 | 3 | 9 | 48 | 224.4 | 0.0 | 2 |
3 | 4 | 8 | 69 | 434.4 | 0.0 | 2 |
4 | 5 | 9 | 90 | 412.1 | 0.0 | 2 |
sample_coords = data[['x', 'y']].to_numpy()
sample_u = data[['u']].to_numpy()
sample_v = data[['v']].to_numpy()
Change of support¶
UC is nonlinear and requires a probabilistic model for the regionalized variable of interest to be considered. It relies on Gaussian assumptions and an anamorphosis is then introduced in order to apply it through change of support. This last topic has been thoroughly detailed in another notebook. The following cells details how it is possible to compute the change of support coefficient that permits to estimate panel quantities from SMUs. We first process the non-Gaussian u variable for anamorphosis.
anam = glm.Anamorphosis(sample_u.flatten())
Hermite polynomials mandatory for latter computations can be retrieved using the following method.
coeffs_point = anam.hermite_coefficients(50)
Here we define a punctual covariance model. The model parameters could also be adjusted automatically from an experimental semivariagram that choose to skip (it has been detailed on this dataset in other notebooks).
cov_model = 29535 * glm.Nugget() + 31156 * glm.Spherical(2,angles=339,scales=[30,37]) + 35487 * glm.Spherical(2,angles=160,scales=[30,90])
Change of support coefficient is computed on an estimation grid, that can be defined with the following commands.
target_grid = glm.create_grid_2d(origin=[0, 0], cell_size=[10, 10], n_dim=[26, 30], angle=[0, 0, 0])
pattern_smu = glm.GridPatternGenerator(target_grid, [5, 5])
Finally, we have all the mandatory variables to compute the change of support coefficient.
r, coeffs_block = glm.change_of_support(coeffs_point, cov_model, pattern_smu)
Uniform conditioning¶
Panel grid charateristics can be tailored with the same commands as seen before in a punctual case.
panel_grid = glm.create_grid_2d(origin=[0, 0], n_dim=[13, 15], cell_size=[20, 20], angle=[0.0, 0.0, 0.0])
pattern_panel = glm.GridPatternGenerator(panel_grid, [5, 5])
The Discrete Gaussian model requires a search neighborhood. We can simply define a unique neighborhood by calling the following class (a custom neighborhood can also be defined in order to reduce computation time).
neigh = glm.Neighborhood()
Uniform conditioning can be applied on all the panels of the previously defined grid and a range of cutoff values. Panels can be retrieved directly from the grid metadata. The range of cutoff values matches the amplitude of the variable of interest, and is here arbitrarily set from a range comprised between [0,1000] for steps equal to 10. The computation loops in the following chunk of code firstly loops on the panels and then loops on the cutoff defined cutoff values. The effective call to the UC computation separates for all cutoffs the balance between ore and metal.
ore = np.zeros(panel_grid.number_of_cells)
metal = np.zeros(panel_grid.number_of_cells)
x = np.linspace(0, 1000, 10)
panel_grid_centers = panel_grid.get_center()
var = glm.cvv(cov_model, pattern_panel)
for index_panel in range(panel_grid.number_of_cells):
kriging_gaussian_panel, s = glm.uc_prepare(
coeffs_point, panel_grid_centers[index_panel],sample_coords,
sample_v, cov_model, neigh, pattern_panel,var)
res_uc = np.array([glm.uc(zcut, kriging_gaussian_panel, coeffs_block, r, s)
for zcut in x])
ore[index_panel] = res_uc[6,0]
metal[index_panel] = res_uc[6,1]
The estimation result can be displayed for ore with the following call.
glm.display_grid(panel_grid, ore, sample_coords, z=None, title="Uniform Conditioning Ore");
(<Figure size 432x288 with 2 Axes>, <AxesSubplot:title={'center':'Uniform Conditioning Ore'}>)
The previous loop can simply be achieved using the following call. It applies uniform conditioning on the same range of cutoff values on the entire grid, in a more compact call. Although the loops in the previous cell shows the applied steps for an entire grid in one simple call, they are not irrelevant though when willing to obtain results for specific panels.
zcuts = np.linspace(0, 1000, 10)
ore, metal = glm.uc_on_grid(coeffs_point,
panel_grid,
sample_coords,
sample_v,
cov_model,
neigh,
pattern_panel,
zcuts,
r,
coeffs_block)
The UC computation on the entire grid shows the same visual result as before.
glm.display_grid(panel_grid, ore[:,6], sample_coords, z=None, title="Uniform Conditioning Ore")
(<Figure size 432x288 with 2 Axes>, <AxesSubplot:title={'center':'Uniform Conditioning Ore'}>)
Metal proportion can also be displayed in the same fashion.
glm.display_grid(panel_grid, metal[:,6], sample_coords, z=None, title="Uniform Conditioning Metal")
(<Figure size 432x288 with 2 Axes>, <AxesSubplot:title={'center':'Uniform Conditioning Metal'}>)