This file demonstrates the use of Selectivity curves
%%javascript
IPython.OutputArea.prototype._should_scroll = function(lines) {
return false;
}
import numpy as np
import pandas as pd
import sys
import os
import urllib.request
import matplotlib.pyplot as plt
import gstlearn as gl
import gstlearn.plot as gp
Reading the Grid file
url = 'https://soft.minesparis.psl.eu/gstlearn/data/Selectivity/Grid_100.ascii'
filename, head = urllib.request.urlretrieve(url)
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 Maximum Number of UIDs = 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
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
fig, ax = gp.initGeographic()
ax.raster(db100, name="z1")
ax.decoration(title="Data")
plt.show()
fig, ax = gp.initGeographic()
ax.literal(db100, name="z1")
ax.decoration(title="Data")
plt.show()
fig, ax = gp.init()
ax.histogram(db100, name="z1", bins=20)
ax.decoration(title="Data")
plt.show()
dum = db100.statistics(["z1"],[gl.EStatOption.MEAN, gl.EStatOption.VAR])
1.531 1.615
Creating the grid of blocks by averaging samples 2 by 2
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(""))
fig, ax = gp.initGeographic()
ax.raster(db25, name="z1")
ax.decoration(title="Blocks")
plt.show()
fig, ax = gp.initGeographic()
ax.literal(db25,name="z1")
ax.decoration(title="Blocks")
plt.show()
fig, ax = gp.init()
ax.histogram(db25, name="z1", bins=10)
ax.decoration(title="Blocks")
plt.show()
dum = db25.statistics(["z1"],[gl.EStatOption.MEAN, gl.EStatOption.VAR])
1.531 0.974
Creating a samping grid keeping only the upper right corner sample for each block
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("",False))
fig, ax = gp.initGeographic()
ax.raster(db25s, name="z1")
ax.decoration(title="Sampling")
plt.show()
fig, ax = gp.initGeographic()
ax.literal(db25s,name="z1")
ax.decoration(title="Sampling")
plt.show()
dum = db25s.statistics(["z1"],[gl.EStatOption.MEAN, gl.EStatOption.VAR])
1.364 1.165
We compare the selectivity curves between Data and Blocks:
selectivity = gl.Selectivity(100)
table100 = selectivity.eval(db100, True)
table25 = selectivity.eval(db25, True)
table25s = selectivity.eval(db25s, True)
table100.getColumnNames()
('Z-Cut', 'T-estim', 'Q-estim', 'B-estim', 'M-estim', 'T-stdev', 'Q-stdev')
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()
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()
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()
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()
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()
Display regressions
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()
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()
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()