The GSLIb equivalent parameter file is
Parameters for TRANS
********************
START OF PARAMETERS:
1 \1=continuous, 0=categorical
data/true.dat \file with reference distribution
1 0 \ columns for variable and weight(0=none)
data/cluster.dat \file with original distributions
3 0 \ columns for variable and weight(0=none)
-1.0e21 1.0e21 \trimming limits
trans.out \file for transformed distributions
1 \number of realizations or "sets" to trans
50 50 1 \categorical: nx, ny, nz: size of 3-D model
2 2 0 \ wx, wy, wz: window size for tie-breaking
1000 \continuous: number to transform per "set"
0.0 75.0 \ minimum and maximum values
1 1.0 \ lower tail: option, parameter
1 75.0 \ upper tail: option, parameter
1 \honor local data? (1=yes, 0=no)
data/kt3d.out \ file with estimation variance
2 \ column number
0.5 \ control parameter ( 0.33 < w < 3.0 )
69069 \ random number seed (conditioning cat.)
In [1]:
#general imports
import matplotlib.pyplot as plt
import pygslib
import numpy as np
import pandas as pd
#make the plots inline
%matplotlib inline
In [2]:
#get the data in gslib format into a pandas Dataframe
true= pygslib.gslib.read_gslib_file('../datasets/true.dat')
cluster = pygslib.gslib.read_gslib_file('../datasets/cluster.dat')
kt3d = pygslib.gslib.read_gslib_file('../datasets/kt3d.out')
print ('\t\ttrue \n', true.tail())
print ('\n\t\tcluster \n',cluster.tail())
print ('\n\t\tkt3d \n',kt3d.tail())
In [3]:
print ('\t\ttrue \n', true.describe())
print ('\n\t\tcluster \n',cluster.describe())
print ('\n\t\tkt3d \n',kt3d.describe())
In [ ]:
In [4]:
print (pygslib.gslib.__trans.trans.__doc__)
In [5]:
true['Weight'] =1
cluster['NO-Weight']=1
parameters_trans = {
'ivtype' : 1, # 1=continuous, 0=categorical (in this case vo may have nxyza raws?)
'vr' : true['Primary'], # reference distribution (variable )
'wt' : true['Weight'], # reference distribution (weight)
'vo' : cluster['Primary'], # calibration scatterplot (secondary data)
'wo' : cluster['NO-Weight'], # calibration scatterplot (weight data)
'nx' : 50 , #categorical: nx, ny, nz: size of 3-D model
'ny' : 50,
'nz' : 1,
'wx' : 2, # wx, wy, wz: window size for tie-breaking
'wy' : 2,
'wz' : 0,
'nxyza' : 2500, # continuous: number to transform per "set"
'zmin' : 0 , # minimum and maximum values
'zmax' : 75,
'ltpar' : 1, # lower/upper tail: option, parameter
'utpar' : 75,
'ltail' : 1,
'utail' : 1,
'ldata' : 1, # honor local data?
'kv' : kt3d['EstimationVariance'].values,
'ef' : 0.5, # control parameter ( 0.33 < w < 3.0 )
'rseed' : 69069} # random number seed (conditioning cat.)
gmedian,rvr,rcdf,ncut,zval,error = pygslib.gslib.__trans.trans(**parameters_trans)
print ('error ? ', error != 0, error)
In [6]:
print ('gmedian', gmedian)
print ('zval')
print (pd.DataFrame({'transformed variable':zval}).head(6))
print (pd.DataFrame({'transformed variable':zval}).tail(6))
Results in GSLIB
0.04457
0.03996
0.06228
0.07809
0.07216
0.08818
***
18.868
23.231
6.643
4.917
1.598
2.869
In [7]:
# not in gslib output, not used here because this is continuous
i= np.arange(len(rcdf))+1
print (pd.DataFrame({'i':i, 'rcdf': rcdf, 'rvr': rvr}). head())
print (pd.DataFrame({'i':i, 'rcdf': rcdf, 'rvr': rvr}). tail())
expected results
By adding this into GSLIB code
print *, 'i', 'rcdf(i)', 'rvr(i)'
do i=1,ncut
print *, i, rcdf(i), rvr(i)
end do
we get this results
1 1.99999995E-04 9.99999978E-03
2 5.99999970E-04 9.99999978E-03
3 9.99999931E-04 9.99999978E-03
4 1.39999995E-03 1.99999996E-02
5 1.79999997E-03 1.99999996E-02
******
2496 0.998214602 43.5000000
2497 0.998614550 46.5299988
2498 0.999014616 54.3899994
2499 0.999414563 58.3199997
2500 0.999814570 102.699997
In [8]:
parameters_probplt = {
'iwt' : 0, #int, 1 use declustering weight
'va' : true['Primary'], # array('d') with bounds (nd)
'wt' : true['Weight']} # array('d') with bounds (nd), wight variable (obtained with declust?)
binval,cl,xpt025,xlqt,xmed,xuqt,xpt975,xmin,xmax,xcvr,xmen,xvar,error = pygslib.gslib.__plot.probplt(**parameters_probplt)
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
plt.plot (cl, binval, label = 'True')
parameters_probplt['va'] = cluster['Primary']
parameters_probplt['wt'] = cluster['NO-Weight']
binval,cl,xpt025,xlqt,xmed,xuqt,xpt975,xmin,xmax,xcvr,xmen,xvar,error = pygslib.gslib.__plot.probplt(**parameters_probplt)
plt.plot (cl, binval, label = 'Cluster not transformed')
parameters_probplt['va'] = zval
parameters_probplt['wt'] = cluster['NO-Weight']
binval,cl,xpt025,xlqt,xmed,xuqt,xpt975,xmin,xmax,xcvr,xmen,xvar,error = pygslib.gslib.__plot.probplt(**parameters_probplt)
plt.plot (cl, binval, label = 'Cluster transformed')
plt.grid(True)
ax.set_xscale('log')
#ax.set_yscale('log')
plt.legend(loc=4)
fig.show
Out[8]:
In [ ]: