In [51]:
import gamv
import pygslib
import pandas as pd
import numpy as np

In [52]:
data = pygslib.gslib.read_gslib_file('../pygslib/data/cluster.dat')

In [53]:
data['Zlocation']= 0.0
data['Domain'] = 0
data.head()


Out[53]:
Xlocation Ylocation Primary Secondary Declustering Weight Zlocation Domain
0 39.5 18.5 0.06 0.22 1.619 0.0 0
1 5.5 1.5 0.06 0.27 1.619 0.0 0
2 38.5 5.5 0.08 0.40 1.416 0.0 0
3 20.5 1.5 0.09 0.39 1.821 0.0 0
4 27.5 14.5 0.09 0.24 1.349 0.0 0

In [54]:
#-----------------------------------------------------------------------------------------------------------------
#
#    Variograms GAMV low level functions
#
#-----------------------------------------------------------------------------------------------------------------

def gamv(parameters):
    """Calculate experimental variograms on sparse data

    This function is similar to the GSLIB gamv function but with some minor differences:

     - the indicator automatic transformation is not applied; you may define
       indicator variables externally.
     - a bhid variable is always required, to avoid downhole variogram use
       ``bhid=None`` or ``bhid = 0``.
     - Z variable is required, you can use constant coordinate to reduce
       dimensions, for example use Z=None in the parameter file or
       Z = 0 in the file.
     - The variogram cloud was implemented but it only works for the first
       variogram and first direction. It only works for some variogram types.


    Parameters
    ----------
        parameters  :  dict
            dictionary with calculation parameters

    The dictionary with parameters may be as follows::


            parameters = {
                    'data'   :  data,          # Pandas dataframe
                    'columns':  ['X','Y','Z','BHID'],  # X,Y,Z, and BHID column names
                    'vr'     :  ['v1','v2'],            # Variables names 
                    'tmin'   : -1.0e21,        # trimming limits, float, if None or basent = -1.0e21
                    'tmax'   :  1.0e21,        # trimming limits, float, if None or basent = 1.0e21
                    'nlag'   :  10,            # number of lags, int
                    'xlag'   :  4,             # lag separation distance, float
                    'xltol'  :  2,             # lag tolerance, float
                    'azm'    : [0,0,90],       # azimuth, array('f') with bounds (ndir)
                    'atol'   : [90,22.5,22.5], # azimuth tolerance, array('f') with bounds (ndir)
                    'bandwh' : [50,10,10],     # bandwidth 'horizontal', array('f') with bounds (ndir)
                    'dip'    : [0,0,0],        # dip, array('f') with bounds (ndir)
                    'dtol'   : [10,10,10],     # dip tolerance, array('f') with bounds (ndir)
                    'bandwd' : [10,10,10],     # bandwidth 'vertical', array('f') with bounds (ndir)
                    'isill'  : 0,              # standardize sills? (0=no, 1=yes), int
                    'sills'  : [100, 200],     # variance used to std the sills, array('f') with bounds (nv)
                    'ivtail' : 1,# tail var., array('i') with bounds (nvarg), nvarg is number of variograms
                    'ivhead' : 1,# head var., array('i') with bounds (nvarg)
                    'ivtype' : 1,# variogram type, array('i') with bounds (nvarg)
                    'maxclp' : 50000}          # maximum number of variogram point cloud to use, input int

    Warnings
    --------
    bhid must be an array of integers

    Returns
    -------
       pdis :  Distance of pairs falling into this lag
       pgam :  Semivariogram, covariance, correlogram,... value
       phm  :  Mean of the tail data
       ptm  :  Mean of the head data
       phv  :  Variance of the tail data
       ptv  :  Variance of the head data
       pnump:  Number of pairs
       cldi :  data index of the head
       cldj :  data index of the tail
       cldg :  Semivariogram, covariance, ... value
       cldh :  Distance of each pair


    Note
    -----
    The output variables with prefix *cld* are for variogram cloud and
    with prefix *p* are for directional variograms

    The variables with prefix *p* are similar to the output generated
    by the GSLIB standalone program **gamv**.

    The variogram cloud only works for the first variogram/direction
    and only if the variogram of type 1, 2, 6, 7 and 8.

    The variogram types are:

     - traditional semivariogram (1)
     - traditional cross semivariogram (2)
     - pairwise relative semivariogram (6)
     - semivariogram of logarithms (7)
     - semimadogram(8)

    """

    # we only use variograms from 1 to 8, gslib uses to 10
    assert (parameters['ivtype']>=0 and parameters['ivtype']<=8)
    
    newpar = {}
    newpar['x'] = parameters['data'][parameters['columns'][0]].values
    newpar['y'] = parameters['data'][parameters['columns'][1]].values
    newpar['z'] = parameters['data'][parameters['columns'][2]].values
    newpar['bhid'] = parameters['data'][parameters['columns'][3]].values
    newpar['vr'] = parameters['data'][parameters['vr']].values
    if 'tmin' in parameters:
        if parameters['tmin'] is not None:
            newpar['tmin'] = parameters['tmin']
        else:
            newpar['tmin'] = -1.0e21
    else:
        newpar['tmin'] = -1.0e21
        
    if 'tmax' in parameters:
        if parameters['tmax'] is not None:
            newpar['tmax'] = parameters['tmax']
        else:
            newpar['tmax'] = 1.0e21
    else:
        newpar['tmax'] = 1.0e21  
    
    if 'sills' in parameters:
        if parameters['sills'] is not None:
            newpar['sills'] = parameters['sills']
        else:
            newpar['sills'] = []
            for ivr in parameters['vr']:
                newpar['sills'].append(parameters['data'][ivr].var())
    else:
        newpar['sills'] = []
        for ivr in parameters['vr']:
            newpar['sills'].append(parameters['data'][ivr].var())     
    
    newpar['nlag'] = parameters['nlag'] 
    newpar['xlag'] = parameters['xlag'] 
    newpar['xltol'] = parameters['xltol'] 
    newpar['azm'] = parameters['azm'] 
    newpar['atol'] = parameters['atol'] 
    newpar['bandwh'] = parameters['bandwh'] 
    newpar['dip'] = parameters['dip'] 
    newpar['dtol'] = parameters['dtol'] 
    newpar['bandwd'] = parameters['bandwd']
    newpar['isill'] = [parameters['isill']] 
    newpar['ivtail'] = [parameters['ivtail']]    
    newpar['ivhead'] = [parameters['ivhead']] 
    newpar['ivtype'] = [parameters['ivtype']]
    newpar['maxclp'] = parameters['maxclp']
    
    npt,dis, gam, hm, tm, hv, tv, cldi, cldj, cldg, cldh, l = pygslib.gslib.__variograms.gamv(**newpar)

    if l==parameters['maxclp']:
        warnings.warn( 'Warning: l == maxclp; maximum number ' + \
                       'of point clouds reached, increase maxclp' + \
                       'or modify variogram parameters')

    #remove crap data from variogram cloud
    cldi=cldi[:l]
    cldj=cldj[:l]
    cldg=cldg[:l]
    cldh=cldh[:l]

    # get output like in gslib

    ndir = len(parameters['azm'])
    nlag = parameters['nlag']


    pdis,pgam, phm,ptm,phv,ptv,pnump = pygslib.gslib.__variograms.writeout(1,ndir,nlag,npt,dis,gam,hm,tm,hv,tv)
    
    # each is an array of (nvarg, ndir, nlag+2)
    lag = []
    azm = []
    dip = []
    vtail= []
    vhead= []
    vtype= []
    dirID = []

    for idr in range(ndir):

        lag.append(0)
        lag.append(0.5)

        azm.append(parameters['azm'][idr])
        dip.append(parameters['dip'][idr])
        azm.append(parameters['azm'][idr])
        dip.append(parameters['dip'][idr])

        vtail.append(parameters['vr'][parameters['ivtail']-1])
        vhead.append(parameters['vr'][parameters['ivhead']-1])
        vtype.append(parameters['ivtype'])
        vtail.append(parameters['vr'][parameters['ivtail']-1])
        vhead.append(parameters['vr'][parameters['ivhead']-1])
        vtype.append(parameters['ivtype'])   

        dirID.append(idr)
        dirID.append(idr)          


        for ilg in range(2,nlag+2):
            lag.append(ilg-1)
            azm.append(parameters['azm'][idr])
            dip.append(parameters['dip'][idr])
            vtail.append(parameters['vr'][parameters['ivtail']-1])
            vhead.append(parameters['vr'][parameters['ivhead']-1])
            vtype.append(parameters['ivtype'])
            dirID.append(idr)
                
                
    vtab = pd.DataFrame(
        {
            'Dip dir': azm,
            'Dip': dip,
            'Head' : vhead,
            'Tail' : vtail,
            'Lag distance': pdis.ravel()*0.0,
            'X': pdis.ravel()*0.0,
            'Y': pdis.ravel()*0.0,
            'Z': pdis.ravel()*0.0,
            'Average distance': pdis.ravel(), 
            'Spatial function value': pgam.ravel(), 
            'Spatial function type' : vtype,
            'Mean head': phm.ravel(),
            'Mean tail': ptm.ravel(),
            'Variance head': phv.ravel(),
            'Variance tail': ptv.ravel(),
            'Number of pairs': pnump.ravel(),
            'Dir ID': dirID,
            'Lag': lag,
        }
    )

    DEG2RAD=3.14159265/180.0
    
    vtab['Lag distance'] = vtab['Lag']*parameters['xlag'] 
    vtab['X'] = np.sin(DEG2RAD*vtab['Dip dir'])*np.cos(DEG2RAD*vtab['Dip'])*vtab['Lag distance'] 
    vtab['Y'] = np.cos(DEG2RAD*vtab['Dip dir'])*np.cos(DEG2RAD*vtab['Dip'])*vtab['Lag distance']
    vtab['Z'] =                                 np.sin(DEG2RAD*vtab['Dip'])*vtab['Lag distance'] 
    
    vtab.loc[vtab['Lag distance']==0, 'Spatial function value']=np.nan
    vtab.loc[vtab['Number of pairs']==0, 'Spatial function value']=np.nan
    
    cloud = pd.DataFrame(
        {
           'Index head': cldi, 
           'Index tail': cldj,
           'Spatial function value': cldg,  
           'Distance': cldh  
        }
    )
    
    return vtab, cloud

In [55]:
htol = 10 
dtol = 10
wh = 100000
wd = 100000

dips = np.arange(-85,90,dtol)
azms = np.arange(-5,365,htol)
ndip = dips.shape[0]
nazm = azms.shape[0]

azm = np.ones(nazm*ndip)
dip = np.ones(nazm*ndip)

di = -1
for i in range(ndip):
    for j in range(nazm):
        di = di+1
        azm[di]=azms[j]
        dip[di]=dips[i]
        
    

atol = np.ones(nazm*ndip)*htol
dtol = np.ones(nazm*ndip)*dtol

bandwh = np.ones(nazm*ndip)*wh
bandwd = np.ones(nazm*ndip)*wd
 
parameters = {
        'data'   :  data,          # Pandas dataframe
        'columns':  ['Xlocation','Ylocation','Zlocation','Domain'],  # X,Y,Z, and BHID column names
        'vr'     :  ['Primary'],            # Variables names 
        'nlag'   :  10,            # number of lags, int
        'xlag'   :  4,             # lag separation distance, float
        'xltol'  :  2,             # lag tolerance, float
        'azm'    : azm,       # azimuth, array('f') with bounds (ndir)
        'atol'   : atol, # azimuth tolerance, array('f') with bounds (ndir)
        'bandwh' : bandwh,     # bandwidth 'horizontal', array('f') with bounds (ndir)
        'dip'    : dip,        # dip, array('f') with bounds (ndir)
        'dtol'   : dtol,     # dip tolerance, array('f') with bounds (ndir)
        'bandwd' : bandwd,     # bandwidth 'vertical', array('f') with bounds (ndir)
        'isill'  : 1,              # standardize sills? (0=no, 1=yes), int
        'ivtail' : 1,# tail var., array('i') with bounds (nvarg), nvarg is number of variograms
        'ivhead' : 1,# head var., array('i') with bounds (nvarg)
        'ivtype' : 4,# variogram type, array('i') with bounds (nvarg)
        'maxclp' : 50000}          # maximum number of variogram point cloud to use, input int

In [56]:
vtab, cloud= gamv(parameters)

In [57]:
vtab.tail()


Out[57]:
Dip dir Dip Head Tail Lag distance X Y Z Average distance Spatial function value Spatial function type Mean head Mean tail Variance head Variance tail Number of pairs Dir ID Lag
7987 355.0 85.0 Primary Primary 24.0 -0.182307 2.083778 23.908673 0.0 NaN 4 0.0 0.0 0.0 0.0 0 665 6.0
7988 355.0 85.0 Primary Primary 28.0 -0.212691 2.431075 27.893452 0.0 NaN 4 0.0 0.0 0.0 0.0 0 665 7.0
7989 355.0 85.0 Primary Primary 32.0 -0.243076 2.778371 31.878230 0.0 NaN 4 0.0 0.0 0.0 0.0 0 665 8.0
7990 355.0 85.0 Primary Primary 36.0 -0.273460 3.125667 35.863009 0.0 NaN 4 0.0 0.0 0.0 0.0 0 665 9.0
7991 355.0 85.0 Primary Primary 40.0 -0.303845 3.472964 39.847788 0.0 NaN 4 0.0 0.0 0.0 0.0 0 665 10.0

In [58]:
vtab.to_csv('vtab.csv', index=False)

In [59]:
# variance and varianze from head/tail is not equal but close
print (data['Primary'].var())
vtab.loc[vtab['Lag distance']==0,'Variance head']


45.247481829393635
Out[59]:
0       44.924286
12      44.924286
24      44.924286
36      44.924286
48      44.924286
60      44.924286
72      44.924286
84      44.924286
96      44.924286
108     44.924286
120     44.924286
132     44.924286
144     44.924286
156     44.924286
168     44.924286
180     44.924286
192     44.924286
204     44.924286
216     44.924286
228     44.924286
240     44.924286
252     44.924286
264     44.924286
276     44.924286
288     44.924286
300     44.924286
312     44.924286
324     44.924286
336     44.924286
348     44.924286
          ...    
7632    44.924286
7644    44.924286
7656    44.924286
7668    44.924286
7680    44.924286
7692    44.924286
7704    44.924286
7716    44.924286
7728    44.924286
7740    44.924286
7752    44.924286
7764    44.924286
7776    44.924286
7788    44.924286
7800    44.924286
7812    44.924286
7824    44.924286
7836    44.924286
7848    44.924286
7860    44.924286
7872    44.924286
7884    44.924286
7896    44.924286
7908    44.924286
7920    44.924286
7932    44.924286
7944    44.924286
7956    44.924286
7968    44.924286
7980    44.924286
Name: Variance head, Length: 666, dtype: float64

In [60]:
import altair as alt
alt.renderers.enable('default')

vtab['tmp'] = '-->'
vtab['tmp2'] = '|'
vtab['test'] = vtab['Dip dir'].astype(str) + vtab['tmp'] + vtab['Dip'].astype(str) + \
               vtab['tmp2'] + vtab['Dir ID'].astype(str) + \
               vtab['tmp2'] + vtab['Spatial function type'].astype(str) 

alt.Chart(vtab).mark_line().encode(
    x='Average distance',
    y='Spatial function value',
    color='test',
    tooltip = 'Number of pairs'
) + \
alt.Chart(pd.DataFrame({'x':[0,45],'y':[0.3,.3]})).mark_line().encode(
    x='x',
    y='y'
)


---------------------------------------------------------------------------
MaxRowsError                              Traceback (most recent call last)
~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\vegalite\v2\api.py in to_dict(self, *args, **kwargs)
    406 
    407         try:
--> 408             dct = super(TopLevelMixin, copy).to_dict(*args, **kwargs)
    409         except jsonschema.ValidationError:
    410             dct = None

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\utils\schemapi.py in to_dict(self, validate, ignore, context)
    243             result = _todict(self._args[0])
    244         elif not self._args:
--> 245             result = _todict({k: v for k, v in self._kwds.items()
    246                               if k not in ignore})
    247         else:

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\utils\schemapi.py in _todict(val)
    235                 return [_todict(v) for v in val]
    236             elif isinstance(val, dict):
--> 237                 return {k: _todict(v) for k, v in val.items()
    238                         if v is not Undefined}
    239             else:

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\utils\schemapi.py in <dictcomp>(.0)
    236             elif isinstance(val, dict):
    237                 return {k: _todict(v) for k, v in val.items()
--> 238                         if v is not Undefined}
    239             else:
    240                 return val

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\utils\schemapi.py in _todict(val)
    233                 return val.to_dict(validate=sub_validate, context=context)
    234             elif isinstance(val, (list, tuple)):
--> 235                 return [_todict(v) for v in val]
    236             elif isinstance(val, dict):
    237                 return {k: _todict(v) for k, v in val.items()

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\utils\schemapi.py in <listcomp>(.0)
    233                 return val.to_dict(validate=sub_validate, context=context)
    234             elif isinstance(val, (list, tuple)):
--> 235                 return [_todict(v) for v in val]
    236             elif isinstance(val, dict):
    237                 return {k: _todict(v) for k, v in val.items()

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\utils\schemapi.py in _todict(val)
    231         def _todict(val):
    232             if isinstance(val, SchemaBase):
--> 233                 return val.to_dict(validate=sub_validate, context=context)
    234             elif isinstance(val, (list, tuple)):
    235                 return [_todict(v) for v in val]

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\vegalite\v2\api.py in to_dict(self, *args, **kwargs)
    396         copy = self.copy()
    397         original_data = getattr(copy, 'data', Undefined)
--> 398         copy.data = _prepare_data(original_data, context)
    399 
    400         if original_data is not Undefined:

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\vegalite\v2\api.py in _prepare_data(data, context)
     82     # convert dataframes to dict
     83     if isinstance(data, pd.DataFrame):
---> 84         data = pipe(data, data_transformers.get())
     85 
     86     # convert string input to a URLData

~\AppData\Local\Continuum\miniconda3\lib\site-packages\toolz\functoolz.py in pipe(data, *funcs)
    550     """
    551     for func in funcs:
--> 552         data = func(data)
    553     return data
    554 

~\AppData\Local\Continuum\miniconda3\lib\site-packages\toolz\functoolz.py in __call__(self, *args, **kwargs)
    281     def __call__(self, *args, **kwargs):
    282         try:
--> 283             return self._partial(*args, **kwargs)
    284         except TypeError as exc:
    285             if self._should_curry(args, kwargs, exc):

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\vegalite\data.py in default_data_transformer(data, max_rows)
     10 @curry
     11 def default_data_transformer(data, max_rows=5000):
---> 12     return pipe(data, limit_rows(max_rows=max_rows), to_values)
     13 
     14 

~\AppData\Local\Continuum\miniconda3\lib\site-packages\toolz\functoolz.py in pipe(data, *funcs)
    550     """
    551     for func in funcs:
--> 552         data = func(data)
    553     return data
    554 

~\AppData\Local\Continuum\miniconda3\lib\site-packages\toolz\functoolz.py in __call__(self, *args, **kwargs)
    281     def __call__(self, *args, **kwargs):
    282         try:
--> 283             return self._partial(*args, **kwargs)
    284         except TypeError as exc:
    285             if self._should_curry(args, kwargs, exc):

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\utils\data.py in limit_rows(data, max_rows)
     70                            'than the maximum allowed ({0}). '
     71                            'For information on how to plot larger datasets '
---> 72                            'in Altair, see the documentation'.format(max_rows))
     73     return data
     74 

MaxRowsError: The number of rows in your dataset is greater than the maximum allowed (5000). For information on how to plot larger datasets in Altair, see the documentation
Out[60]:
LayerChart({
  layer: [Chart({
    data:       Dip dir   Dip     Head     Tail  Lag distance         X         Y  \
    0        -5.0 -85.0  Primary  Primary           0.0 -0.000000  0.000000   
    1        -5.0 -85.0  Primary  Primary           2.0 -0.015192  0.173648   
    2        -5.0 -85.0  Primary  Primary           4.0 -0.030384  0.347296   
    3        -5.0 -85.0  Primary  Primary           8.0 -0.060769  0.694593   
    4        -5.0 -85.0  Primary  Primary          12.0 -0.091153  1.041889   
    5        -5.0 -85.0  Primary  Primary          16.0 -0.121538  1.389185   
    6        -5.0 -85.0  Primary  Primary          20.0 -0.151922  1.736482   
    7        -5.0 -85.0  Primary  Primary          24.0 -0.182307  2.083778   
    8        -5.0 -85.0  Primary  Primary          28.0 -0.212691  2.431075   
    9        -5.0 -85.0  Primary  Primary          32.0 -0.243076  2.778371   
    10       -5.0 -85.0  Primary  Primary          36.0 -0.273460  3.125667   
    11       -5.0 -85.0  Primary  Primary          40.0 -0.303845  3.472964   
    12        5.0 -85.0  Primary  Primary           0.0  0.000000  0.000000   
    13        5.0 -85.0  Primary  Primary           2.0  0.015192  0.173648   
    14        5.0 -85.0  Primary  Primary           4.0  0.030384  0.347296   
    15        5.0 -85.0  Primary  Primary           8.0  0.060769  0.694593   
    16        5.0 -85.0  Primary  Primary          12.0  0.091153  1.041889   
    17        5.0 -85.0  Primary  Primary          16.0  0.121538  1.389185   
    18        5.0 -85.0  Primary  Primary          20.0  0.151922  1.736482   
    19        5.0 -85.0  Primary  Primary          24.0  0.182307  2.083778   
    20        5.0 -85.0  Primary  Primary          28.0  0.212691  2.431075   
    21        5.0 -85.0  Primary  Primary          32.0  0.243076  2.778371   
    22        5.0 -85.0  Primary  Primary          36.0  0.273460  3.125667   
    23        5.0 -85.0  Primary  Primary          40.0  0.303845  3.472964   
    24       15.0 -85.0  Primary  Primary           0.0  0.000000  0.000000   
    25       15.0 -85.0  Primary  Primary           2.0  0.045115  0.168372   
    26       15.0 -85.0  Primary  Primary           4.0  0.090230  0.336744   
    27       15.0 -85.0  Primary  Primary           8.0  0.180461  0.673488   
    28       15.0 -85.0  Primary  Primary          12.0  0.270691  1.010232   
    29       15.0 -85.0  Primary  Primary          16.0  0.360921  1.346976   
    ...       ...   ...      ...      ...           ...       ...       ...   
    7962    335.0  85.0  Primary  Primary          20.0 -0.736672  1.579799   
    7963    335.0  85.0  Primary  Primary          24.0 -0.884007  1.895758   
    7964    335.0  85.0  Primary  Primary          28.0 -1.031341  2.211718   
    7965    335.0  85.0  Primary  Primary          32.0 -1.178676  2.527678   
    7966    335.0  85.0  Primary  Primary          36.0 -1.326010  2.843637   
    7967    335.0  85.0  Primary  Primary          40.0 -1.473344  3.159597   
    7968    345.0  85.0  Primary  Primary           0.0 -0.000000  0.000000   
    7969    345.0  85.0  Primary  Primary           2.0 -0.045115  0.168372   
    7970    345.0  85.0  Primary  Primary           4.0 -0.090230  0.336744   
    7971    345.0  85.0  Primary  Primary           8.0 -0.180461  0.673488   
    7972    345.0  85.0  Primary  Primary          12.0 -0.270691  1.010232   
    7973    345.0  85.0  Primary  Primary          16.0 -0.360921  1.346976   
    7974    345.0  85.0  Primary  Primary          20.0 -0.451151  1.683720   
    7975    345.0  85.0  Primary  Primary          24.0 -0.541382  2.020464   
    7976    345.0  85.0  Primary  Primary          28.0 -0.631612  2.357208   
    7977    345.0  85.0  Primary  Primary          32.0 -0.721842  2.693951   
    7978    345.0  85.0  Primary  Primary          36.0 -0.812072  3.030695   
    7979    345.0  85.0  Primary  Primary          40.0 -0.902303  3.367439   
    7980    355.0  85.0  Primary  Primary           0.0 -0.000000  0.000000   
    7981    355.0  85.0  Primary  Primary           2.0 -0.015192  0.173648   
    7982    355.0  85.0  Primary  Primary           4.0 -0.030384  0.347296   
    7983    355.0  85.0  Primary  Primary           8.0 -0.060769  0.694593   
    7984    355.0  85.0  Primary  Primary          12.0 -0.091153  1.041889   
    7985    355.0  85.0  Primary  Primary          16.0 -0.121538  1.389185   
    7986    355.0  85.0  Primary  Primary          20.0 -0.151922  1.736482   
    7987    355.0  85.0  Primary  Primary          24.0 -0.182307  2.083778   
    7988    355.0  85.0  Primary  Primary          28.0 -0.212691  2.431075   
    7989    355.0  85.0  Primary  Primary          32.0 -0.243076  2.778371   
    7990    355.0  85.0  Primary  Primary          36.0 -0.273460  3.125667   
    7991    355.0  85.0  Primary  Primary          40.0 -0.303845  3.472964   
    
                  Z  Average distance  Spatial function value         ...          \
    0     -0.000000               0.0                     NaN         ...           
    1     -1.992389               0.0                     NaN         ...           
    2     -3.984779               0.0                     NaN         ...           
    3     -7.969558               0.0                     NaN         ...           
    4    -11.954336               0.0                     NaN         ...           
    5    -15.939115               0.0                     NaN         ...           
    6    -19.923894               0.0                     NaN         ...           
    7    -23.908673               0.0                     NaN         ...           
    8    -27.893452               0.0                     NaN         ...           
    9    -31.878230               0.0                     NaN         ...           
    10   -35.863009               0.0                     NaN         ...           
    11   -39.847788               0.0                     NaN         ...           
    12    -0.000000               0.0                     NaN         ...           
    13    -1.992389               0.0                     NaN         ...           
    14    -3.984779               0.0                     NaN         ...           
    15    -7.969558               0.0                     NaN         ...           
    16   -11.954336               0.0                     NaN         ...           
    17   -15.939115               0.0                     NaN         ...           
    18   -19.923894               0.0                     NaN         ...           
    19   -23.908673               0.0                     NaN         ...           
    20   -27.893452               0.0                     NaN         ...           
    21   -31.878230               0.0                     NaN         ...           
    22   -35.863009               0.0                     NaN         ...           
    23   -39.847788               0.0                     NaN         ...           
    24    -0.000000               0.0                     NaN         ...           
    25    -1.992389               0.0                     NaN         ...           
    26    -3.984779               0.0                     NaN         ...           
    27    -7.969558               0.0                     NaN         ...           
    28   -11.954336               0.0                     NaN         ...           
    29   -15.939115               0.0                     NaN         ...           
    ...         ...               ...                     ...         ...           
    7962  19.923894               0.0                     NaN         ...           
    7963  23.908673               0.0                     NaN         ...           
    7964  27.893452               0.0                     NaN         ...           
    7965  31.878230               0.0                     NaN         ...           
    7966  35.863009               0.0                     NaN         ...           
    7967  39.847788               0.0                     NaN         ...           
    7968   0.000000               0.0                     NaN         ...           
    7969   1.992389               0.0                     NaN         ...           
    7970   3.984779               0.0                     NaN         ...           
    7971   7.969558               0.0                     NaN         ...           
    7972  11.954336               0.0                     NaN         ...           
    7973  15.939115               0.0                     NaN         ...           
    7974  19.923894               0.0                     NaN         ...           
    7975  23.908673               0.0                     NaN         ...           
    7976  27.893452               0.0                     NaN         ...           
    7977  31.878230               0.0                     NaN         ...           
    7978  35.863009               0.0                     NaN         ...           
    7979  39.847788               0.0                     NaN         ...           
    7980   0.000000               0.0                     NaN         ...           
    7981   1.992389               0.0                     NaN         ...           
    7982   3.984779               0.0                     NaN         ...           
    7983   7.969558               0.0                     NaN         ...           
    7984  11.954336               0.0                     NaN         ...           
    7985  15.939115               0.0                     NaN         ...           
    7986  19.923894               0.0                     NaN         ...           
    7987  23.908673               0.0                     NaN         ...           
    7988  27.893452               0.0                     NaN         ...           
    7989  31.878230               0.0                     NaN         ...           
    7990  35.863009               0.0                     NaN         ...           
    7991  39.847788               0.0                     NaN         ...           
    
          Mean head  Mean tail  Variance head  Variance tail  Number of pairs  \
    0      4.350429   4.350429      44.924286      44.924286              140   
    1      0.000000   0.000000       0.000000       0.000000                0   
    2      0.000000   0.000000       0.000000       0.000000                0   
    3      0.000000   0.000000       0.000000       0.000000                0   
    4      0.000000   0.000000       0.000000       0.000000                0   
    5      0.000000   0.000000       0.000000       0.000000                0   
    6      0.000000   0.000000       0.000000       0.000000                0   
    7      0.000000   0.000000       0.000000       0.000000                0   
    8      0.000000   0.000000       0.000000       0.000000                0   
    9      0.000000   0.000000       0.000000       0.000000                0   
    10     0.000000   0.000000       0.000000       0.000000                0   
    11     0.000000   0.000000       0.000000       0.000000                0   
    12     4.350429   4.350429      44.924286      44.924286              140   
    13     0.000000   0.000000       0.000000       0.000000                0   
    14     0.000000   0.000000       0.000000       0.000000                0   
    15     0.000000   0.000000       0.000000       0.000000                0   
    16     0.000000   0.000000       0.000000       0.000000                0   
    17     0.000000   0.000000       0.000000       0.000000                0   
    18     0.000000   0.000000       0.000000       0.000000                0   
    19     0.000000   0.000000       0.000000       0.000000                0   
    20     0.000000   0.000000       0.000000       0.000000                0   
    21     0.000000   0.000000       0.000000       0.000000                0   
    22     0.000000   0.000000       0.000000       0.000000                0   
    23     0.000000   0.000000       0.000000       0.000000                0   
    24     4.350429   4.350429      44.924286      44.924286              140   
    25     0.000000   0.000000       0.000000       0.000000                0   
    26     0.000000   0.000000       0.000000       0.000000                0   
    27     0.000000   0.000000       0.000000       0.000000                0   
    28     0.000000   0.000000       0.000000       0.000000                0   
    29     0.000000   0.000000       0.000000       0.000000                0   
    ...         ...        ...            ...            ...              ...   
    7962   0.000000   0.000000       0.000000       0.000000                0   
    7963   0.000000   0.000000       0.000000       0.000000                0   
    7964   0.000000   0.000000       0.000000       0.000000                0   
    7965   0.000000   0.000000       0.000000       0.000000                0   
    7966   0.000000   0.000000       0.000000       0.000000                0   
    7967   0.000000   0.000000       0.000000       0.000000                0   
    7968   4.350429   4.350429      44.924286      44.924286              140   
    7969   0.000000   0.000000       0.000000       0.000000                0   
    7970   0.000000   0.000000       0.000000       0.000000                0   
    7971   0.000000   0.000000       0.000000       0.000000                0   
    7972   0.000000   0.000000       0.000000       0.000000                0   
    7973   0.000000   0.000000       0.000000       0.000000                0   
    7974   0.000000   0.000000       0.000000       0.000000                0   
    7975   0.000000   0.000000       0.000000       0.000000                0   
    7976   0.000000   0.000000       0.000000       0.000000                0   
    7977   0.000000   0.000000       0.000000       0.000000                0   
    7978   0.000000   0.000000       0.000000       0.000000                0   
    7979   0.000000   0.000000       0.000000       0.000000                0   
    7980   4.350429   4.350429      44.924286      44.924286              140   
    7981   0.000000   0.000000       0.000000       0.000000                0   
    7982   0.000000   0.000000       0.000000       0.000000                0   
    7983   0.000000   0.000000       0.000000       0.000000                0   
    7984   0.000000   0.000000       0.000000       0.000000                0   
    7985   0.000000   0.000000       0.000000       0.000000                0   
    7986   0.000000   0.000000       0.000000       0.000000                0   
    7987   0.000000   0.000000       0.000000       0.000000                0   
    7988   0.000000   0.000000       0.000000       0.000000                0   
    7989   0.000000   0.000000       0.000000       0.000000                0   
    7990   0.000000   0.000000       0.000000       0.000000                0   
    7991   0.000000   0.000000       0.000000       0.000000                0   
    
          Dir ID   Lag  tmp tmp2                test  
    0          0   0.0  -->    |    -5.0-->-85.0|0|4  
    1          0   0.5  -->    |    -5.0-->-85.0|0|4  
    2          0   1.0  -->    |    -5.0-->-85.0|0|4  
    3          0   2.0  -->    |    -5.0-->-85.0|0|4  
    4          0   3.0  -->    |    -5.0-->-85.0|0|4  
    5          0   4.0  -->    |    -5.0-->-85.0|0|4  
    6          0   5.0  -->    |    -5.0-->-85.0|0|4  
    7          0   6.0  -->    |    -5.0-->-85.0|0|4  
    8          0   7.0  -->    |    -5.0-->-85.0|0|4  
    9          0   8.0  -->    |    -5.0-->-85.0|0|4  
    10         0   9.0  -->    |    -5.0-->-85.0|0|4  
    11         0  10.0  -->    |    -5.0-->-85.0|0|4  
    12         1   0.0  -->    |     5.0-->-85.0|1|4  
    13         1   0.5  -->    |     5.0-->-85.0|1|4  
    14         1   1.0  -->    |     5.0-->-85.0|1|4  
    15         1   2.0  -->    |     5.0-->-85.0|1|4  
    16         1   3.0  -->    |     5.0-->-85.0|1|4  
    17         1   4.0  -->    |     5.0-->-85.0|1|4  
    18         1   5.0  -->    |     5.0-->-85.0|1|4  
    19         1   6.0  -->    |     5.0-->-85.0|1|4  
    20         1   7.0  -->    |     5.0-->-85.0|1|4  
    21         1   8.0  -->    |     5.0-->-85.0|1|4  
    22         1   9.0  -->    |     5.0-->-85.0|1|4  
    23         1  10.0  -->    |     5.0-->-85.0|1|4  
    24         2   0.0  -->    |    15.0-->-85.0|2|4  
    25         2   0.5  -->    |    15.0-->-85.0|2|4  
    26         2   1.0  -->    |    15.0-->-85.0|2|4  
    27         2   2.0  -->    |    15.0-->-85.0|2|4  
    28         2   3.0  -->    |    15.0-->-85.0|2|4  
    29         2   4.0  -->    |    15.0-->-85.0|2|4  
    ...      ...   ...  ...  ...                 ...  
    7962     663   5.0  -->    |  335.0-->85.0|663|4  
    7963     663   6.0  -->    |  335.0-->85.0|663|4  
    7964     663   7.0  -->    |  335.0-->85.0|663|4  
    7965     663   8.0  -->    |  335.0-->85.0|663|4  
    7966     663   9.0  -->    |  335.0-->85.0|663|4  
    7967     663  10.0  -->    |  335.0-->85.0|663|4  
    7968     664   0.0  -->    |  345.0-->85.0|664|4  
    7969     664   0.5  -->    |  345.0-->85.0|664|4  
    7970     664   1.0  -->    |  345.0-->85.0|664|4  
    7971     664   2.0  -->    |  345.0-->85.0|664|4  
    7972     664   3.0  -->    |  345.0-->85.0|664|4  
    7973     664   4.0  -->    |  345.0-->85.0|664|4  
    7974     664   5.0  -->    |  345.0-->85.0|664|4  
    7975     664   6.0  -->    |  345.0-->85.0|664|4  
    7976     664   7.0  -->    |  345.0-->85.0|664|4  
    7977     664   8.0  -->    |  345.0-->85.0|664|4  
    7978     664   9.0  -->    |  345.0-->85.0|664|4  
    7979     664  10.0  -->    |  345.0-->85.0|664|4  
    7980     665   0.0  -->    |  355.0-->85.0|665|4  
    7981     665   0.5  -->    |  355.0-->85.0|665|4  
    7982     665   1.0  -->    |  355.0-->85.0|665|4  
    7983     665   2.0  -->    |  355.0-->85.0|665|4  
    7984     665   3.0  -->    |  355.0-->85.0|665|4  
    7985     665   4.0  -->    |  355.0-->85.0|665|4  
    7986     665   5.0  -->    |  355.0-->85.0|665|4  
    7987     665   6.0  -->    |  355.0-->85.0|665|4  
    7988     665   7.0  -->    |  355.0-->85.0|665|4  
    7989     665   8.0  -->    |  355.0-->85.0|665|4  
    7990     665   9.0  -->    |  355.0-->85.0|665|4  
    7991     665  10.0  -->    |  355.0-->85.0|665|4  
    
    [7992 rows x 21 columns],
    encoding: EncodingWithFacet({
      color: Color({
        shorthand: 'test'
      }),
      tooltip: Tooltip({
        shorthand: 'Number of pairs'
      }),
      x: X({
        shorthand: 'Average distance'
      }),
      y: Y({
        shorthand: 'Spatial function value'
      })
    }),
    mark: 'line'
  }), Chart({
    data:     x    y
    0   0  0.3
    1  45  0.3,
    encoding: EncodingWithFacet({
      x: X({
        shorthand: 'x'
      }),
      y: Y({
        shorthand: 'y'
      })
    }),
    mark: 'line'
  })]
})

In [61]:
# get order as in a vtk structured grid 
vtab['ijk']=0
vtab.loc[vtab.sort_values(by = ['Dip','Lag','Dip dir']).index,'ijk']= np.arange(vtab.shape[0])
alt.Chart(vtab.reset_index()).mark_point().encode(
    x='X',
    y='Y',
    color='Spatial function value',
    tooltip='ijk:O'
)


---------------------------------------------------------------------------
MaxRowsError                              Traceback (most recent call last)
~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\vegalite\v2\api.py in to_dict(self, *args, **kwargs)
    396         copy = self.copy()
    397         original_data = getattr(copy, 'data', Undefined)
--> 398         copy.data = _prepare_data(original_data, context)
    399 
    400         if original_data is not Undefined:

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\vegalite\v2\api.py in _prepare_data(data, context)
     82     # convert dataframes to dict
     83     if isinstance(data, pd.DataFrame):
---> 84         data = pipe(data, data_transformers.get())
     85 
     86     # convert string input to a URLData

~\AppData\Local\Continuum\miniconda3\lib\site-packages\toolz\functoolz.py in pipe(data, *funcs)
    550     """
    551     for func in funcs:
--> 552         data = func(data)
    553     return data
    554 

~\AppData\Local\Continuum\miniconda3\lib\site-packages\toolz\functoolz.py in __call__(self, *args, **kwargs)
    281     def __call__(self, *args, **kwargs):
    282         try:
--> 283             return self._partial(*args, **kwargs)
    284         except TypeError as exc:
    285             if self._should_curry(args, kwargs, exc):

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\vegalite\data.py in default_data_transformer(data, max_rows)
     10 @curry
     11 def default_data_transformer(data, max_rows=5000):
---> 12     return pipe(data, limit_rows(max_rows=max_rows), to_values)
     13 
     14 

~\AppData\Local\Continuum\miniconda3\lib\site-packages\toolz\functoolz.py in pipe(data, *funcs)
    550     """
    551     for func in funcs:
--> 552         data = func(data)
    553     return data
    554 

~\AppData\Local\Continuum\miniconda3\lib\site-packages\toolz\functoolz.py in __call__(self, *args, **kwargs)
    281     def __call__(self, *args, **kwargs):
    282         try:
--> 283             return self._partial(*args, **kwargs)
    284         except TypeError as exc:
    285             if self._should_curry(args, kwargs, exc):

~\AppData\Local\Continuum\miniconda3\lib\site-packages\altair\utils\data.py in limit_rows(data, max_rows)
     70                            'than the maximum allowed ({0}). '
     71                            'For information on how to plot larger datasets '
---> 72                            'in Altair, see the documentation'.format(max_rows))
     73     return data
     74 

MaxRowsError: The number of rows in your dataset is greater than the maximum allowed (5000). For information on how to plot larger datasets in Altair, see the documentation
Out[61]:
Chart({
  data:       index  Dip dir   Dip     Head     Tail  Lag distance         X  \
  0         0     -5.0 -85.0  Primary  Primary           0.0 -0.000000   
  1         1     -5.0 -85.0  Primary  Primary           2.0 -0.015192   
  2         2     -5.0 -85.0  Primary  Primary           4.0 -0.030384   
  3         3     -5.0 -85.0  Primary  Primary           8.0 -0.060769   
  4         4     -5.0 -85.0  Primary  Primary          12.0 -0.091153   
  5         5     -5.0 -85.0  Primary  Primary          16.0 -0.121538   
  6         6     -5.0 -85.0  Primary  Primary          20.0 -0.151922   
  7         7     -5.0 -85.0  Primary  Primary          24.0 -0.182307   
  8         8     -5.0 -85.0  Primary  Primary          28.0 -0.212691   
  9         9     -5.0 -85.0  Primary  Primary          32.0 -0.243076   
  10       10     -5.0 -85.0  Primary  Primary          36.0 -0.273460   
  11       11     -5.0 -85.0  Primary  Primary          40.0 -0.303845   
  12       12      5.0 -85.0  Primary  Primary           0.0  0.000000   
  13       13      5.0 -85.0  Primary  Primary           2.0  0.015192   
  14       14      5.0 -85.0  Primary  Primary           4.0  0.030384   
  15       15      5.0 -85.0  Primary  Primary           8.0  0.060769   
  16       16      5.0 -85.0  Primary  Primary          12.0  0.091153   
  17       17      5.0 -85.0  Primary  Primary          16.0  0.121538   
  18       18      5.0 -85.0  Primary  Primary          20.0  0.151922   
  19       19      5.0 -85.0  Primary  Primary          24.0  0.182307   
  20       20      5.0 -85.0  Primary  Primary          28.0  0.212691   
  21       21      5.0 -85.0  Primary  Primary          32.0  0.243076   
  22       22      5.0 -85.0  Primary  Primary          36.0  0.273460   
  23       23      5.0 -85.0  Primary  Primary          40.0  0.303845   
  24       24     15.0 -85.0  Primary  Primary           0.0  0.000000   
  25       25     15.0 -85.0  Primary  Primary           2.0  0.045115   
  26       26     15.0 -85.0  Primary  Primary           4.0  0.090230   
  27       27     15.0 -85.0  Primary  Primary           8.0  0.180461   
  28       28     15.0 -85.0  Primary  Primary          12.0  0.270691   
  29       29     15.0 -85.0  Primary  Primary          16.0  0.360921   
  ...     ...      ...   ...      ...      ...           ...       ...   
  7962   7962    335.0  85.0  Primary  Primary          20.0 -0.736672   
  7963   7963    335.0  85.0  Primary  Primary          24.0 -0.884007   
  7964   7964    335.0  85.0  Primary  Primary          28.0 -1.031341   
  7965   7965    335.0  85.0  Primary  Primary          32.0 -1.178676   
  7966   7966    335.0  85.0  Primary  Primary          36.0 -1.326010   
  7967   7967    335.0  85.0  Primary  Primary          40.0 -1.473344   
  7968   7968    345.0  85.0  Primary  Primary           0.0 -0.000000   
  7969   7969    345.0  85.0  Primary  Primary           2.0 -0.045115   
  7970   7970    345.0  85.0  Primary  Primary           4.0 -0.090230   
  7971   7971    345.0  85.0  Primary  Primary           8.0 -0.180461   
  7972   7972    345.0  85.0  Primary  Primary          12.0 -0.270691   
  7973   7973    345.0  85.0  Primary  Primary          16.0 -0.360921   
  7974   7974    345.0  85.0  Primary  Primary          20.0 -0.451151   
  7975   7975    345.0  85.0  Primary  Primary          24.0 -0.541382   
  7976   7976    345.0  85.0  Primary  Primary          28.0 -0.631612   
  7977   7977    345.0  85.0  Primary  Primary          32.0 -0.721842   
  7978   7978    345.0  85.0  Primary  Primary          36.0 -0.812072   
  7979   7979    345.0  85.0  Primary  Primary          40.0 -0.902303   
  7980   7980    355.0  85.0  Primary  Primary           0.0 -0.000000   
  7981   7981    355.0  85.0  Primary  Primary           2.0 -0.015192   
  7982   7982    355.0  85.0  Primary  Primary           4.0 -0.030384   
  7983   7983    355.0  85.0  Primary  Primary           8.0 -0.060769   
  7984   7984    355.0  85.0  Primary  Primary          12.0 -0.091153   
  7985   7985    355.0  85.0  Primary  Primary          16.0 -0.121538   
  7986   7986    355.0  85.0  Primary  Primary          20.0 -0.151922   
  7987   7987    355.0  85.0  Primary  Primary          24.0 -0.182307   
  7988   7988    355.0  85.0  Primary  Primary          28.0 -0.212691   
  7989   7989    355.0  85.0  Primary  Primary          32.0 -0.243076   
  7990   7990    355.0  85.0  Primary  Primary          36.0 -0.273460   
  7991   7991    355.0  85.0  Primary  Primary          40.0 -0.303845   
  
               Y          Z  Average distance  ...   Mean tail  Variance head  \
  0     0.000000  -0.000000               0.0  ...    4.350429      44.924286   
  1     0.173648  -1.992389               0.0  ...    0.000000       0.000000   
  2     0.347296  -3.984779               0.0  ...    0.000000       0.000000   
  3     0.694593  -7.969558               0.0  ...    0.000000       0.000000   
  4     1.041889 -11.954336               0.0  ...    0.000000       0.000000   
  5     1.389185 -15.939115               0.0  ...    0.000000       0.000000   
  6     1.736482 -19.923894               0.0  ...    0.000000       0.000000   
  7     2.083778 -23.908673               0.0  ...    0.000000       0.000000   
  8     2.431075 -27.893452               0.0  ...    0.000000       0.000000   
  9     2.778371 -31.878230               0.0  ...    0.000000       0.000000   
  10    3.125667 -35.863009               0.0  ...    0.000000       0.000000   
  11    3.472964 -39.847788               0.0  ...    0.000000       0.000000   
  12    0.000000  -0.000000               0.0  ...    4.350429      44.924286   
  13    0.173648  -1.992389               0.0  ...    0.000000       0.000000   
  14    0.347296  -3.984779               0.0  ...    0.000000       0.000000   
  15    0.694593  -7.969558               0.0  ...    0.000000       0.000000   
  16    1.041889 -11.954336               0.0  ...    0.000000       0.000000   
  17    1.389185 -15.939115               0.0  ...    0.000000       0.000000   
  18    1.736482 -19.923894               0.0  ...    0.000000       0.000000   
  19    2.083778 -23.908673               0.0  ...    0.000000       0.000000   
  20    2.431075 -27.893452               0.0  ...    0.000000       0.000000   
  21    2.778371 -31.878230               0.0  ...    0.000000       0.000000   
  22    3.125667 -35.863009               0.0  ...    0.000000       0.000000   
  23    3.472964 -39.847788               0.0  ...    0.000000       0.000000   
  24    0.000000  -0.000000               0.0  ...    4.350429      44.924286   
  25    0.168372  -1.992389               0.0  ...    0.000000       0.000000   
  26    0.336744  -3.984779               0.0  ...    0.000000       0.000000   
  27    0.673488  -7.969558               0.0  ...    0.000000       0.000000   
  28    1.010232 -11.954336               0.0  ...    0.000000       0.000000   
  29    1.346976 -15.939115               0.0  ...    0.000000       0.000000   
  ...        ...        ...               ...  ...         ...            ...   
  7962  1.579799  19.923894               0.0  ...    0.000000       0.000000   
  7963  1.895758  23.908673               0.0  ...    0.000000       0.000000   
  7964  2.211718  27.893452               0.0  ...    0.000000       0.000000   
  7965  2.527678  31.878230               0.0  ...    0.000000       0.000000   
  7966  2.843637  35.863009               0.0  ...    0.000000       0.000000   
  7967  3.159597  39.847788               0.0  ...    0.000000       0.000000   
  7968  0.000000   0.000000               0.0  ...    4.350429      44.924286   
  7969  0.168372   1.992389               0.0  ...    0.000000       0.000000   
  7970  0.336744   3.984779               0.0  ...    0.000000       0.000000   
  7971  0.673488   7.969558               0.0  ...    0.000000       0.000000   
  7972  1.010232  11.954336               0.0  ...    0.000000       0.000000   
  7973  1.346976  15.939115               0.0  ...    0.000000       0.000000   
  7974  1.683720  19.923894               0.0  ...    0.000000       0.000000   
  7975  2.020464  23.908673               0.0  ...    0.000000       0.000000   
  7976  2.357208  27.893452               0.0  ...    0.000000       0.000000   
  7977  2.693951  31.878230               0.0  ...    0.000000       0.000000   
  7978  3.030695  35.863009               0.0  ...    0.000000       0.000000   
  7979  3.367439  39.847788               0.0  ...    0.000000       0.000000   
  7980  0.000000   0.000000               0.0  ...    4.350429      44.924286   
  7981  0.173648   1.992389               0.0  ...    0.000000       0.000000   
  7982  0.347296   3.984779               0.0  ...    0.000000       0.000000   
  7983  0.694593   7.969558               0.0  ...    0.000000       0.000000   
  7984  1.041889  11.954336               0.0  ...    0.000000       0.000000   
  7985  1.389185  15.939115               0.0  ...    0.000000       0.000000   
  7986  1.736482  19.923894               0.0  ...    0.000000       0.000000   
  7987  2.083778  23.908673               0.0  ...    0.000000       0.000000   
  7988  2.431075  27.893452               0.0  ...    0.000000       0.000000   
  7989  2.778371  31.878230               0.0  ...    0.000000       0.000000   
  7990  3.125667  35.863009               0.0  ...    0.000000       0.000000   
  7991  3.472964  39.847788               0.0  ...    0.000000       0.000000   
  
        Variance tail  Number of pairs  Dir ID   Lag  tmp  tmp2  \
  0         44.924286              140       0   0.0  -->     |   
  1          0.000000                0       0   0.5  -->     |   
  2          0.000000                0       0   1.0  -->     |   
  3          0.000000                0       0   2.0  -->     |   
  4          0.000000                0       0   3.0  -->     |   
  5          0.000000                0       0   4.0  -->     |   
  6          0.000000                0       0   5.0  -->     |   
  7          0.000000                0       0   6.0  -->     |   
  8          0.000000                0       0   7.0  -->     |   
  9          0.000000                0       0   8.0  -->     |   
  10         0.000000                0       0   9.0  -->     |   
  11         0.000000                0       0  10.0  -->     |   
  12        44.924286              140       1   0.0  -->     |   
  13         0.000000                0       1   0.5  -->     |   
  14         0.000000                0       1   1.0  -->     |   
  15         0.000000                0       1   2.0  -->     |   
  16         0.000000                0       1   3.0  -->     |   
  17         0.000000                0       1   4.0  -->     |   
  18         0.000000                0       1   5.0  -->     |   
  19         0.000000                0       1   6.0  -->     |   
  20         0.000000                0       1   7.0  -->     |   
  21         0.000000                0       1   8.0  -->     |   
  22         0.000000                0       1   9.0  -->     |   
  23         0.000000                0       1  10.0  -->     |   
  24        44.924286              140       2   0.0  -->     |   
  25         0.000000                0       2   0.5  -->     |   
  26         0.000000                0       2   1.0  -->     |   
  27         0.000000                0       2   2.0  -->     |   
  28         0.000000                0       2   3.0  -->     |   
  29         0.000000                0       2   4.0  -->     |   
  ...             ...              ...     ...   ...  ...   ...   
  7962       0.000000                0     663   5.0  -->     |   
  7963       0.000000                0     663   6.0  -->     |   
  7964       0.000000                0     663   7.0  -->     |   
  7965       0.000000                0     663   8.0  -->     |   
  7966       0.000000                0     663   9.0  -->     |   
  7967       0.000000                0     663  10.0  -->     |   
  7968      44.924286              140     664   0.0  -->     |   
  7969       0.000000                0     664   0.5  -->     |   
  7970       0.000000                0     664   1.0  -->     |   
  7971       0.000000                0     664   2.0  -->     |   
  7972       0.000000                0     664   3.0  -->     |   
  7973       0.000000                0     664   4.0  -->     |   
  7974       0.000000                0     664   5.0  -->     |   
  7975       0.000000                0     664   6.0  -->     |   
  7976       0.000000                0     664   7.0  -->     |   
  7977       0.000000                0     664   8.0  -->     |   
  7978       0.000000                0     664   9.0  -->     |   
  7979       0.000000                0     664  10.0  -->     |   
  7980      44.924286              140     665   0.0  -->     |   
  7981       0.000000                0     665   0.5  -->     |   
  7982       0.000000                0     665   1.0  -->     |   
  7983       0.000000                0     665   2.0  -->     |   
  7984       0.000000                0     665   3.0  -->     |   
  7985       0.000000                0     665   4.0  -->     |   
  7986       0.000000                0     665   5.0  -->     |   
  7987       0.000000                0     665   6.0  -->     |   
  7988       0.000000                0     665   7.0  -->     |   
  7989       0.000000                0     665   8.0  -->     |   
  7990       0.000000                0     665   9.0  -->     |   
  7991       0.000000                0     665  10.0  -->     |   
  
                      test   ijk  
  0       -5.0-->-85.0|0|4     0  
  1       -5.0-->-85.0|0|4    37  
  2       -5.0-->-85.0|0|4    74  
  3       -5.0-->-85.0|0|4   111  
  4       -5.0-->-85.0|0|4   148  
  5       -5.0-->-85.0|0|4   185  
  6       -5.0-->-85.0|0|4   222  
  7       -5.0-->-85.0|0|4   259  
  8       -5.0-->-85.0|0|4   296  
  9       -5.0-->-85.0|0|4   333  
  10      -5.0-->-85.0|0|4   370  
  11      -5.0-->-85.0|0|4   407  
  12       5.0-->-85.0|1|4     1  
  13       5.0-->-85.0|1|4    38  
  14       5.0-->-85.0|1|4    75  
  15       5.0-->-85.0|1|4   112  
  16       5.0-->-85.0|1|4   149  
  17       5.0-->-85.0|1|4   186  
  18       5.0-->-85.0|1|4   223  
  19       5.0-->-85.0|1|4   260  
  20       5.0-->-85.0|1|4   297  
  21       5.0-->-85.0|1|4   334  
  22       5.0-->-85.0|1|4   371  
  23       5.0-->-85.0|1|4   408  
  24      15.0-->-85.0|2|4     2  
  25      15.0-->-85.0|2|4    39  
  26      15.0-->-85.0|2|4    76  
  27      15.0-->-85.0|2|4   113  
  28      15.0-->-85.0|2|4   150  
  29      15.0-->-85.0|2|4   187  
  ...                  ...   ...  
  7962  335.0-->85.0|663|4  7804  
  7963  335.0-->85.0|663|4  7841  
  7964  335.0-->85.0|663|4  7878  
  7965  335.0-->85.0|663|4  7915  
  7966  335.0-->85.0|663|4  7952  
  7967  335.0-->85.0|663|4  7989  
  7968  345.0-->85.0|664|4  7583  
  7969  345.0-->85.0|664|4  7620  
  7970  345.0-->85.0|664|4  7657  
  7971  345.0-->85.0|664|4  7694  
  7972  345.0-->85.0|664|4  7731  
  7973  345.0-->85.0|664|4  7768  
  7974  345.0-->85.0|664|4  7805  
  7975  345.0-->85.0|664|4  7842  
  7976  345.0-->85.0|664|4  7879  
  7977  345.0-->85.0|664|4  7916  
  7978  345.0-->85.0|664|4  7953  
  7979  345.0-->85.0|664|4  7990  
  7980  355.0-->85.0|665|4  7584  
  7981  355.0-->85.0|665|4  7621  
  7982  355.0-->85.0|665|4  7658  
  7983  355.0-->85.0|665|4  7695  
  7984  355.0-->85.0|665|4  7732  
  7985  355.0-->85.0|665|4  7769  
  7986  355.0-->85.0|665|4  7806  
  7987  355.0-->85.0|665|4  7843  
  7988  355.0-->85.0|665|4  7880  
  7989  355.0-->85.0|665|4  7917  
  7990  355.0-->85.0|665|4  7954  
  7991  355.0-->85.0|665|4  7991  
  
  [7992 rows x 23 columns],
  encoding: EncodingWithFacet({
    color: Color({
      shorthand: 'Spatial function value'
    }),
    tooltip: Tooltip({
      shorthand: 'ijk:O'
    }),
    x: X({
      shorthand: 'X'
    }),
    y: Y({
      shorthand: 'Y'
    })
  }),
  mark: 'point'
})

In [62]:
import vtk
from vtk.numpy_interface import dataset_adapter as vtkdsa
points = vtk.vtkPoints()
dataval = []
stGrid = vtk.vtkStructuredGrid()
properties = ['Spatial function value', 'Number of pairs']
for i in range(len(properties)):
    dataval.append(vtk.vtkDoubleArray())
    dataval[i].SetName(properties[i])

for i in range(vtab.shape[0]):
    x,y,z = vtab.loc[vtab['ijk']==i,['X','Y','Z']].values[0]
    points.InsertNextPoint(x, y, z)
    values = vtab.loc[vtab['ijk']==i, properties].values[0]
    for i in range(len(properties)):
        dataval[i].InsertNextTuple([values[i]])

    
stGrid.SetDimensions(nazm,parameters['nlag']+2,ndip)
stGrid.SetPoints(points)
for i in range(len(properties)):
    stGrid.GetPointData().AddArray(dataval[i])    

writer = vtk.vtkXMLStructuredGridWriter()
writer.SetFileName('grid.vts')
writer.SetDataModeToBinary()
writer.SetInputData(stGrid)
writer.Write()


Out[62]:
1

In [63]:
vtab.shape[0]


Out[63]:
7992

In [64]:
a.sort()


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-64-2ed0d7de6146> in <module>()
----> 1 a.sort()

NameError: name 'a' is not defined

In [ ]:
a.flags

In [ ]:
a

In [ ]: