In [1]:
import gam
import pygslib


test with arbitrary gslib files


In [2]:
parameters = {
    'datafl' : '../pygslib/data/true.dat',     # path to file, or none (to use '_xxx_.in') or numpy array (with columns [x,y])
    'ivar'   : [1,2],                      # variables column numbers to be used in ivtail and ivhead,                       # variables column numbers to be used in ivtail and ivhead,
    'tmin'   : -1.0e21,                      # trimming limits min and max (raws out of this range will be ignored)
    'tmax'   :  1.0e21,
    'outfl'  :  None,                       # path to the output file or None (to use '_xxx_.out')
    'igrid'  : 1,                          # grid realization number
    'nx'    : 50,                          # number of rows, cols and levels
    'ny'    : 50,
    'nz'    : 1,
    'xmn'   : .5,                        # coordinates of the centroid of first/corner block
    'ymn'   : .5,
    'zmn'   : .5,
    'xsiz'  : 1.,                        # grid node separation
    'ysiz'  : 1.,
    'zsiz'  : 1.,    
    'nlag'  : 10,                        # number of lags
    'igdir' : [[1,0,0],
               [0,1,0]],                 # [[ixd1,iyd1,izd1],...] directions along the grid (unit offsets) (array with shape [ndir,3])
    'standardize': 1,                     # standardize sill? (0=no, 1=yes)
    'ivpar': [[1, 1, 4, None],
              [1, 1, 3, None],
              [2, 2, 1, None],
              [2, 2, 3, None],
              [1, 1, 9, 2.5]]}              # tail, head, variogram type, and cut (with shape [nvarg,4])

In [3]:
vg, fig, ax = gam.gam(parameters)


                  Parameters for GAM
                  *******************

START OF PARAMETERS:
../pygslib/data/true.dat                          -file with data
2 1 2                    - number of variables: column numbers
-1e+21 1e+21                     - trimming limits
_xxx_.out                           -file for variogram output
1                           -realization number
50  0.5  1.0               -nx,xmn,xsiz
50  0.5  1.0               -ny,ymn,ysiz
1  0.5  1.0               -nz,zmn,zsiz
2 10                     -number of direction and number of lags
1  0  0
0  1  0                          -directions along the grid (unit offsets) (array with shape [ndir,3])
1                     -standardize sill? (0=no, 1=yes)
5                           -number of variograms
1  1  4  None
1  1  3  None
2  2  1  None
2  2  3  None
1  1  9   2.5                          -tail, head, variogram type, cut (array with shape [nvarg,4])


cut[i] is only required if ivtype[i] == 9 or == 10



GAM Version: 2.905

 data file = ../pygslib/data/true.dat                
 number of variables =           2
 columns =           1           2
 trimming limits =   -1.000000E+21    1.000000E+21
 output file = _xxx_.out                               
 grid number =           1
 nx,xmn,xsiz =          50    5.000000E-01        1.000000
 ny,ymn,ysiz =          50    5.000000E-01        1.000000
 nz,zmn,zsiz =           1    5.000000E-01        1.000000
 ndir,nlag =           2          10
 direction =           1           0           0
 direction =           0           1           0
 flag to standardize sills =           1
 number of variograms =           5
 tail,head,type =           1           1           4
 tail,head,type =           1           1           3
 tail,head,type =           2           2           1
 tail,head,type =           2           2           3
 tail,head,type =           1           1           9
 indicator threshold:         2.500000

Variable number           1
  Number   =        2500
  Average  =        2.580196
  Variance =       26.531800
Variable number           2
  Number   =        2500
  Average  =        2.320084
  Variance =        7.318668

Variogram  1 Correlogram            :  tail=Primary      head=Primary        
Variogram  2 Covariance             :  tail=Primary      head=Primary        
Variogram  3 Semivariogram          :  tail=Secondary    head=Secondary      
Variogram  4 Covariance             :  tail=Secondary    head=Secondary      
Variogram  5 Indicator 1/2 Variogram:  tail=Indicator  1 head=Indicator  1   

GAM Version: 2.905 Finished

Stop - Program terminated.



In [4]:
vg


Out[4]:
average separation var funct number of pairs mean on tail mean on head variance tail variance head tail head type cut
Variogram Direction Lag
0 0 1 1.0 0.49386 2450 2.53364 2.53909 24.77946 26.68244 1 1 4 None
2 2.0 0.35267 2400 2.49753 2.52300 24.33429 27.06660 1 1 4 None
3 3.0 0.21134 2350 2.46945 2.50771 23.99160 27.10748 1 1 4 None
4 4.0 0.14590 2300 2.45293 2.49312 23.63398 27.23370 1 1 4 None
5 5.0 0.14299 2250 2.46641 2.49146 24.02911 27.46606 1 1 4 None
6 6.0 0.09852 2200 2.48491 2.50075 24.45203 27.90143 1 1 4 None
7 7.0 0.06420 2150 2.50757 2.52079 24.82824 28.44364 1 1 4 None
8 8.0 0.05674 2100 2.53510 2.53821 25.29958 29.01886 1 1 4 None
9 9.0 0.03009 2050 2.55013 2.56459 25.46875 29.58677 1 1 4 None
10 10.0 0.04508 2000 2.57868 2.55968 25.91320 29.43568 1 1 4 None
1 1 1.0 0.49794 2450 2.61572 2.51775 26.99231 25.34337 1 1 4 None
2 2.0 0.35596 2400 2.64921 2.45918 27.46367 24.61412 1 1 4 None
3 3.0 0.26077 2350 2.68369 2.37889 27.93690 20.20762 1 1 4 None
4 4.0 0.21491 2300 2.72356 2.34000 28.42551 20.06138 1 1 4 None
5 5.0 0.18971 2250 2.75722 2.31314 28.91733 20.05589 1 1 4 None
6 6.0 0.11553 2200 2.79176 2.30304 29.45732 20.22440 1 1 4 None
7 7.0 0.06660 2150 2.78771 2.27861 28.73200 19.80329 1 1 4 None
8 8.0 0.03007 2100 2.78614 2.25039 28.82400 19.69888 1 1 4 None
9 9.0 0.00824 2050 2.79200 2.17433 29.15552 17.10762 1 1 4 None
10 10.0 -0.01659 2000 2.81165 2.15231 29.65246 16.47518 1 1 4 None
1 0 1 1.0 12.69870 2450 2.53364 2.53909 NaN NaN 1 1 3 None
2 2.0 9.05096 2400 2.49753 2.52300 NaN NaN 1 1 3 None
3 3.0 5.38966 2350 2.46945 2.50771 NaN NaN 1 1 3 None
4 4.0 3.70148 2300 2.45293 2.49312 NaN NaN 1 1 3 None
5 5.0 3.67338 2250 2.46641 2.49146 NaN NaN 1 1 3 None
6 6.0 2.57340 2200 2.48491 2.50075 NaN NaN 1 1 3 None
7 7.0 1.70601 2150 2.50757 2.52079 NaN NaN 1 1 3 None
8 8.0 1.53731 2100 2.53510 2.53821 NaN NaN 1 1 3 None
9 9.0 0.82612 2050 2.55013 2.56459 NaN NaN 1 1 3 None
10 10.0 1.24504 2000 2.57868 2.55968 NaN NaN 1 1 3 None
... ... ... ... ... ... ... ... ... ... ... ... ... ...
3 1 1 1.0 6.81336 2450 2.34399 2.25918 NaN NaN 2 2 3 None
2 2.0 5.98391 2400 2.36914 2.20534 NaN NaN 2 2 3 None
3 3.0 4.93632 2350 2.39641 2.16029 NaN NaN 2 2 3 None
4 4.0 3.78569 2300 2.42585 2.13018 NaN NaN 2 2 3 None
5 5.0 2.64749 2250 2.45196 2.11109 NaN NaN 2 2 3 None
6 6.0 1.73774 2200 2.47143 2.10190 NaN NaN 2 2 3 None
7 7.0 0.95898 2150 2.48291 2.09609 NaN NaN 2 2 3 None
8 8.0 0.33199 2100 2.48809 2.09287 NaN NaN 2 2 3 None
9 9.0 -0.11095 2050 2.48430 2.09213 NaN NaN 2 2 3 None
10 10.0 -0.39648 2000 2.46351 2.09358 NaN NaN 2 2 3 None
4 0 1 1.0 0.07327 2450 0.25714 0.25102 NaN NaN 1 1 9 2.5
2 2.0 0.10146 2400 0.25458 0.24500 NaN NaN 1 1 9 2.5
3 3.0 0.11745 2350 0.25106 0.24085 NaN NaN 1 1 9 2.5
4 4.0 0.13370 2300 0.25043 0.23870 NaN NaN 1 1 9 2.5
5 5.0 0.14467 2250 0.25156 0.23867 NaN NaN 1 1 9 2.5
6 6.0 0.15568 2200 0.25364 0.23864 NaN NaN 1 1 9 2.5
7 7.0 0.16488 2150 0.25628 0.24000 NaN NaN 1 1 9 2.5
8 8.0 0.16643 2100 0.25857 0.24000 NaN NaN 1 1 9 2.5
9 9.0 0.16683 2050 0.26098 0.24244 NaN NaN 1 1 9 2.5
10 10.0 0.16950 2000 0.26350 0.24150 NaN NaN 1 1 9 2.5
1 1 1.0 0.08041 2450 0.26041 0.25388 NaN NaN 1 1 9 2.5
2 2.0 0.10375 2400 0.26333 0.24917 NaN NaN 1 1 9 2.5
3 3.0 0.12298 2350 0.26638 0.24426 NaN NaN 1 1 9 2.5
4 4.0 0.14109 2300 0.27043 0.24043 NaN NaN 1 1 9 2.5
5 5.0 0.15644 2250 0.27244 0.23689 NaN NaN 1 1 9 2.5
6 6.0 0.16636 2200 0.27500 0.23409 NaN NaN 1 1 9 2.5
7 7.0 0.17326 2150 0.27535 0.23209 NaN NaN 1 1 9 2.5
8 8.0 0.17667 2100 0.27619 0.22667 NaN NaN 1 1 9 2.5
9 9.0 0.18098 2050 0.27561 0.22390 NaN NaN 1 1 9 2.5
10 10.0 0.18475 2000 0.27800 0.22250 NaN NaN 1 1 9 2.5

100 rows × 11 columns

test with numpy array


In [5]:
data = pygslib.gslib.read_gslib_file('../pygslib/data/true.dat')
data.columns


Out[5]:
Index(['Primary', 'Secondary'], dtype='object')

In [6]:
parameters = {
    'datafl' : data[['Primary', 
                     'Secondary']].values,     # path to file, or none (to use '_xxx_.in') or numpy array (with columns [x,y])
    'tmin'   : -1.0e21,                      # trimming limits min and max (raws out of this range will be ignored)
    'tmax'   :  1.0e21,
    'outfl'  :  None,                       # path to the output file or None (to use '_xxx_.out')
    'igrid'  : 1,                          # grid realization number
    'nx'    : 50,                          # number of rows, cols and levels
    'ny'    : 50,
    'nz'    : 1,
    'xmn'   : .5,                        # coordinates of the centroid of first/corner block
    'ymn'   : .5,
    'zmn'   : .5,
    'xsiz'  : 1.,                        # grid node separation
    'ysiz'  : 1.,
    'zsiz'  : 1.,    
    'nlag'  : 10,                        # number of lags
    'igdir' : [[1,0,0],
               [0,1,0]],                 # [[ixd1,iyd1,izd1],...] directions along the grid (unit offsets) (array with shape [ndir,3])
    'standardize': 1,                     # standardize sill? (0=no, 1=yes)
    'ivpar': [[1, 1, 1, None],
              [1, 1, 3, None],
              [2, 2, 1, None],
              [2, 2, 3, None],
              [1, 1, 9, 2.5]]}              # tail, head, variogram type, and cut (with shape [nvarg,4])

In [7]:
vg = gam.gam(parameters)


                  Parameters for GAM
                  *******************

START OF PARAMETERS:
_xxx_.in                          -file with data
2 1 2                    - number of variables: column numbers
-1e+21 1e+21                     - trimming limits
_xxx_.out                           -file for variogram output
1                           -realization number
50  0.5  1.0               -nx,xmn,xsiz
50  0.5  1.0               -ny,ymn,ysiz
1  0.5  1.0               -nz,zmn,zsiz
2 10                     -number of direction and number of lags
1  0  0
0  1  0                          -directions along the grid (unit offsets) (array with shape [ndir,3])
1                     -standardize sill? (0=no, 1=yes)
5                           -number of variograms
1  1  1  None
1  1  3  None
2  2  1  None
2  2  3  None
1  1  9   2.5                          -tail, head, variogram type, cut (array with shape [nvarg,4])


cut[i] is only required if ivtype[i] == 9 or == 10



GAM Version: 2.905

 data file = _xxx_.in                                
 number of variables =           2
 columns =           1           2
 trimming limits =   -1.000000E+21    1.000000E+21
 output file = _xxx_.out                               
 grid number =           1
 nx,xmn,xsiz =          50    5.000000E-01        1.000000
 ny,ymn,ysiz =          50    5.000000E-01        1.000000
 nz,zmn,zsiz =           1    5.000000E-01        1.000000
 ndir,nlag =           2          10
 direction =           1           0           0
 direction =           0           1           0
 flag to standardize sills =           1
 number of variograms =           5
 tail,head,type =           1           1           1
 tail,head,type =           1           1           3
 tail,head,type =           2           2           1
 tail,head,type =           2           2           3
 tail,head,type =           1           1           9
 indicator threshold:         2.500000

Variable number           1
  Number   =        2500
  Average  =        2.580196
  Variance =       26.531800
Variable number           2
  Number   =        2500
  Average  =        2.320084
  Variance =        7.318668

Variogram  1 Semivariogram          :  tail=v1           head=v1             
Variogram  2 Covariance             :  tail=v1           head=v1             
Variogram  3 Semivariogram          :  tail=v2           head=v2             
Variogram  4 Covariance             :  tail=v2           head=v2             
Variogram  5 Indicator 1/2 Variogram:  tail=Indicator  1 head=Indicator  1   

GAM Version: 2.905 Finished

Stop - Program terminated.



In [8]:
import numpy as np
any(np.array([1,2,3,4,5])==40)


Out[8]:
False

In [ ]: