In [1]:
#general imports
import matplotlib.pyplot as plt
import pygslib
import numpy as np
#make the plots inline
%matplotlib inline
In [2]:
#get the data in gslib format into a pandas Dataframe
mydata= pygslib.gslib.read_gslib_file('../datasets/cluster.dat')
In [3]:
# This is a 2D file, in this GSLIB version we require 3D data and drillhole name or domain code
# so, we are adding constant elevation = 0 and a dummy BHID = 1
mydata['Zlocation']=0
mydata['bhid']=1
# printing to verify results
print (' \n **** 5 first rows in my datafile \n\n ', mydata.head(n=5))
In [4]:
#view data in a 2D projection
plt.scatter(mydata['Xlocation'],mydata['Ylocation'], c=mydata['Primary'])
plt.colorbar()
plt.grid(True)
plt.show()
This parameters ar selected bu default... as in the file declus.par included in the gslib 77 distribution
Parameters for DECLUS
*********************
START OF PARAMETERS:
../data/cluster.dat \file with data
1 2 0 3 \ columns for X, Y, Z, and variable
-1.0e21 1.0e21 \ trimming limits
declus.sum \file for summary output
declus.out \file for output with data & weights
1.0 1.0 \Y and Z cell anisotropy (Ysize=size*Yanis)
0 \0=look for minimum declustered mean (1=max)
24 1.0 25.0 \number of cell sizes, min size, max size
5 \number of origin offsets
Note: The trimming limits are not implemented in the Fortran module. you may filter the data before using this function
In [5]:
#Check the data is ok
a=mydata['Primary'].isnull()
print ("Undefined values:", len(a[a==True]))
print ("Minimum value :", mydata['Primary'].min())
print ("Maximum value :", mydata['Primary'].max())
In [6]:
parameters_declus = {
'x' : mydata['Xlocation'], # data x coordinates, array('f') with bounds (na), na is number of data points
'y' : mydata['Ylocation'], # data y coordinates, array('f') with bounds (na)
'z' : mydata['Zlocation'], # data z coordinates, array('f') with bounds (na)
'vr' : mydata['Primary'], # variable, array('f') with bounds (na)
'anisy' : 1., # Y cell anisotropy (Ysize=size*Yanis), 'f'
'anisz' : 1., # Z cell anisotropy (Zsize=size*Zanis), 'f'
'minmax' : 0, # 0=look for minimum declustered mean (1=max), 'i'
'ncell' : 24, # number of cell sizes, 'i'
'cmin' : 1., # minimum cell sizes, 'i'
'cmax' : 25., # maximum cell sizes, 'i'. Will be update to cmin if ncell == 1
'noff' : 5, # number of origin offsets, 'i'. This is to avoid local minima/maxima
'maxcel' : 100000} # maximum number of cells, 'i'. This is to avoid large calculations, if MAXCEL<1 this check will be ignored
wtopt,vrop,wtmin,wtmax,error,xinc,yinc,zinc,rxcs,rycs,rzcs,rvrcr = pygslib.gslib.declus(parameters_declus)
In [7]:
# to know what the output means print the help
help(pygslib.gslib.declus)
In [8]:
%matplotlib inline
import matplotlib.pyplot as plt
plt.figure(num=None, figsize=(10, 10), dpi=200, facecolor='w', edgecolor='k')
#view data in a 2D projection
plt.scatter(mydata['Xlocation'],mydata['Ylocation'], c=wtopt, s=wtopt*320, alpha=0.5)
plt.plot(mydata['Xlocation'],mydata['Ylocation'], '.', color='k')
l=plt.colorbar()
l.set_label('Declustering weight')
plt.grid(True)
plt.show()
In [9]:
#The declustering size
plt.plot (rxcs, rvrcr)
Out[9]:
In [10]:
rvrcr
Out[10]:
In [11]:
print ('=========================================')
print ('declustered mean :', vrop )
print ('weight minimum :', wtmin )
print ('weight maximum :', wtmax )
print ('runtime error :', error )
print ('cell size increments :', xinc,yinc,zinc )
print ('sum of weight :', np.sum(wtopt) )
print ('n data :', len(wtopt) )
print ('=========================================')
In [12]:
parameters_declus = {
'x' : mydata['Xlocation'], # data x coordinates, array('f') with bounds (na), na is number of data points
'y' : mydata['Ylocation'], # data y coordinates, array('f') with bounds (na)
'z' : mydata['Zlocation'], # data z coordinates, array('f') with bounds (na)
'vr' : mydata['Primary'], # variable, array('f') with bounds (na)
'anisy' : 1., # Y cell anisotropy (Ysize=size*Yanis), 'f'
'anisz' : 1., # Z cell anisotropy (Zsize=size*Zanis), 'f'
'minmax' : 0, # 0=look for minimum declustered mean (1=max), 'i'
'ncell' : 1, # number of cell sizes, 'i'
'cmin' : 5., # minimum cell sizes, 'i'
'cmax' : 5., # maximum cell sizes, 'i'. Will be update to cmin if ncell == 1
'noff' : 5, # number of origin offsets, 'i'. This is to avoid local minima/maxima
'maxcel' : 100000} # maximum number of cells, 'i'. This is to avoid large calculations, if MAXCEL<1 this check will be ignored
wtopt,vrop,wtmin,wtmax,error,xinc,yinc,zinc,rxcs,rycs,rzcs,rvrcr = pygslib.gslib.declus(parameters_declus)
In [12]:
print ('=========================================')
print ('declustered mean :', vrop )
print ('weight minimum :', wtmin )
print ('weight maximum :', wtmax )
print ('runtime error :', error )
print ('cell size increments :', xinc,yinc,zinc )
print ('sum of weight :', np.sum(wtopt) )
print ('n data :', len(wtopt) )
print ('=========================================')
In [ ]:
In [ ]: