Getting Started

Load the class and data

The main class of scikit-gstat is the Variogram. It can directly be imported from the module, called skgstat. The main class can easily be demonstrated on the data module available with version >=0.5.5.

In [1]: import skgstat as skg

In [2]: import numpy as np

In [3]: import matplotlib.pyplot as plt

In [4]: plt.style.use('ggplot')

In [5]: data = skg.data.pancake(N=500, seed=42)

In [6]: print(data.get('origin'))
Image of a pancake with apparent spatial structure.
    Copyright Mirko Mälicke, 2020. If you use this data,
    cite SciKit-GStat: https://doi.org/10.5281/zenodo.1345584
    

In [7]: coordinates, values = data.get('sample')

The Variogram needs at least an array of coordinates and an array of values on instantiation.

In [8]: V = skg.Variogram(coordinates=coordinates, values=values)

In [9]: print(V)
spherical Variogram
-------------------
Estimator:         matheron
        
Effective Range:   311.76
        
Sill:              1210.20
        
Nugget:            0.00

Plot

The Variogram class has its own plotting method.

In [10]: V.plot()
Out[10]: 
In [11]: plt.close()
_images/default_variogram.png

With version 0.2, the histogram plot can also be disabled. This is most useful, when the binning method for the lag classes is changed from ‘even’ step classes to ‘uniform’ distribution in the lag classes.

In [12]: V.set_bin_func('uniform')

In [13]: V.plot(hist=False)
Out[13]: 
In [14]: plt.close()
_images/variogram_uniform.png

Mutating

One of the main strenghs of Variogram is its ability to change arguments in place. Any dependent result or parameter will be invalidated and re-caluculated. You can i.e. increase the number of lag classes:

In [15]: V.n_lags = 25

In [16]: V.maxlag = 500

In [17]: V.bin_func = 'kmeans'

In [18]: V.plot()
Out[18]: 
In [19]: plt.close()
_images/default_variogram_25lag.png

Note, how the experimental variogram was updated and the model was fitted to the new data automatically.