Selectivity curvesΒΆ

This file demonstrates the use of Selectivity curves

Import packagesΒΆ

In [1]:
import numpy as np
import pandas as pd
import sys
import os
import matplotlib.pyplot as plt
import gstlearn as gl
import gstlearn.plot as gp
import gstlearn.document as gdoc

gdoc.setNoScroll()

Reading the Grid file

In [2]:
filename = gdoc.loadData("Selectivity", "Grid_100.ascii")
db100 = gl.DbGrid.createFromNF(filename)
db100.display()
Data Base Grid Characteristics
==============================

Data Base Summary
-----------------
File is organized as a regular grid
Space dimension              = 2
Number of Columns            = 4
Total number of samples      = 100

Grid characteristics:
---------------------
Origin :      0.000     0.000
Mesh   :      1.000     1.000
Number :         10        10

Variables
---------
Column = 0 - Name = rank - Locator = NA
Column = 1 - Name = x1 - Locator = x1
Column = 2 - Name = x2 - Locator = x2
Column = 3 - Name = z1 - Locator = z1
 

Plotting the grid of samples

In [3]:
gp.setDefaultGeographic(xlim=[-1,10],ylim=[-1,10])
gp.printDefault()
Non geographical defaults:
- Figure dimensions = [5, 5]
- Limits along X (not defined)
- Limits along Y (not defined)
- Aspect = auto
Geographical defaults:
- Figure dimensions = [8, 8]
- Limits along X = [-1, 10]
- Limits along Y = [-1, 10]
- Aspect = 1
In [4]:
fig, ax = gp.initGeographic()
ax.raster(db100, name="z1")
ax.decoration(title="Data")
plt.show()
No description has been provided for this image
In [5]:
fig, ax = gp.initGeographic()
ax.literal(db100, name="z1")
ax.decoration(title="Data")
plt.show()
No description has been provided for this image
In [6]:
fig, ax = gp.init()
ax.histogram(db100, name="z1", bins=20)
ax.decoration(title="Data")
plt.show()
No description has been provided for this image
In [7]:
gl.dbStatisticsMono(db100,["z1"],[gl.EStatOption.MEAN, gl.EStatOption.VAR])
Out[7]:
         Mean   Variance
z1      1.531      1.615

Creating the grid of blocks by averaging samples 2 by 2

In [8]:
db25 = gl.DbGrid.create(nx=[5,5], dx=[2,2], x0=[0.5,0.5])
dum = gl.dbStatisticsOnGrid(db100, db25, gl.EStatOption.MEAN, namconv = gl.NamingConvention(""))
In [9]:
fig, ax = gp.initGeographic()
ax.raster(db25, name="z1")
ax.decoration(title="Blocks")
plt.show()
No description has been provided for this image
In [10]:
fig, ax = gp.initGeographic()
ax.literal(db25,name="z1")
ax.decoration(title="Blocks")
plt.show()
No description has been provided for this image
In [11]:
fig, ax = gp.init()
ax.histogram(db25, name="z1", bins=10)
ax.decoration(title="Blocks")
plt.show()
No description has been provided for this image
In [12]:
gl.dbStatisticsMono(db25, ["z1"],[gl.EStatOption.MEAN, gl.EStatOption.VAR])
Out[12]:
         Mean   Variance
z1      1.531      0.974

Creating a samping grid keeping only the upper right corner sample for each block

In [13]:
db25s = gl.DbGrid.create(nx=[5,5],dx=[2,2],x0=[0.5,0.5])
dum = gl.migrate(db100,db25s,name="z1",namconv=gl.NamingConvention(""))
In [14]:
fig, ax = gp.initGeographic()
ax.raster(db25s, name="z1")
ax.decoration(title="Sampling")
plt.show()
No description has been provided for this image
In [15]:
fig, ax = gp.initGeographic()
ax.literal(db25s,name="z1")
ax.decoration(title="Sampling")
plt.show()
No description has been provided for this image
In [16]:
gl.dbStatisticsMono(db25s, ["z1"],[gl.EStatOption.MEAN, gl.EStatOption.VAR])
Out[16]:
         Mean   Variance
z1      1.364      1.165

Using the Selectivity CurvesΒΆ

We compare the selectivity curves between Data and Blocks:

In [17]:
selectivity = gl.Selectivity(100)
table100 = selectivity.eval(db100, True)
table25  = selectivity.eval(db25,  True)
table25s = selectivity.eval(db25s, True)
In [18]:
table100.getColumnNames()
Out[18]:
('Z-Cut', 'T-estim', 'Q-estim', 'B-estim', 'M-estim')
  • Ore tonnage as a function of the cutoff
In [19]:
fig, ax = gp.init()
ax.table(table100,[1,0],color='blue')
ax.table(table25,[1,0],color='red')
ax.decoration(title="T(z)")
plt.show()
No description has been provided for this image
  • Metal as a function of the cutoff
In [20]:
fig, ax = gp.init()
ax.table(table100,[2,0],color='blue')
ax.table(table25,[2,0],color='red')
ax.decoration(title="Q(z)")
plt.show()
No description has been provided for this image
  • Recovered grade as a function of the cutoff
In [21]:
fig, ax = gp.init()
ax.table(table100,[4,0],color='blue')
ax.table(table25,[4,0],color='red')
ax.decoration(title="M(z)")
plt.show()
No description has been provided for this image
  • Conventional Benefit as a function of the cutoff
In [22]:
fig, ax = gp.init()
ax.table(table100,[3,0],color='blue')
ax.table(table25,[3,0],color='red')
ax.decoration(title="B(z)")
plt.show()
No description has been provided for this image
  • Metal as a function of Ore Tonnage
In [23]:
fig, ax = gp.init()
ax.table(table100,[2,1],color='blue')
ax.table(table25,[2,1],color='red')
ax.plot([0.,1.], [0.,db100.getMean("z1")], linestyle='dashed')
ax.decoration(title="Q(T)")
plt.show()
No description has been provided for this image

RegressionsΒΆ

Display regressions

In [24]:
fig, ax = gp.init()
ax.correlation(db25,namex="z1",namey="z1",db2=db25s, asPoint=True, diagLine=True, regrLine=True)
ax.decoration(ylabel="Blocks",xlabel="Samples",title="Block vs. Sample")
plt.show()
No description has been provided for this image
In [25]:
fig, ax = gp.init()
ax.correlation(db25s,namex="z1",namey="z1",db2=db25, asPoint=True, diagLine=True, regrLine=True)
ax.decoration(xlabel="Blocks",ylabel="Samples",title="Sample vs. Block")
plt.show()
No description has been provided for this image

Comparing selectivity curvesΒΆ

In [26]:
fig, ax = gp.init()
ax.table(table100,[2,1],color='blue')
ax.table(table25,[2,1],color='red')
ax.table(table25s,[2,1],color='green')
ax.plot([0.,1.], [0.,db100.getMean("z1")], linestyle='dashed')
ax.plot([0.,1.], [0.,db25s.getMean("z1")], linestyle='dashed')
ax.decoration(title="Q(T)")
plt.show()
No description has been provided for this image
In [ ]: