Geostatistical methods are widely used in almost all geoscientific disciplines, i.e., for interpolation, rescaling, data assimilation or modeling. At its core, geostatistics aims to detect, quantify, describe, analyze and model spatial covariance of observations. The variogram, a tool to describe this spatial covariance in a formalized way, is at the heart of every such method. Unfortunately, many applications of geostatistics focus on the interpolation method or the result rather than the quality of the estimated variogram. Not least because estimating a variogram is commonly left as a task for computers, and some software implementations do not even show a variogram to the user. This is a miss, because the quality of the variogram largely determines whether the application of geostatistics makes sense at all. Furthermore, the Python programming language was missing a mature, well-established and tested package for variogram estimation a couple of years ago.

Here I present SciKit-GStat, an open-source Python package for variogram estimation that fits well into established frameworks for scientific computing and puts the focus on the variogram before more sophisticated methods are about to be applied. SciKit-GStat is written in a mutable, object-oriented way that mimics the typical geostatistical analysis workflow. Its main strength is the ease of use and interactivity, and it is therefore usable with only a little or even no knowledge of Python. During the last few years, other libraries covering geostatistics for Python developed along with SciKit-GStat. Today, the most important ones can be interfaced by SciKit-GStat. Additionally, established data structures for scientific computing are reused internally, to keep the user from learning complex data models, just for using SciKit-GStat. Common data structures along with powerful interfaces enable the user to use SciKit-GStat along with other packages in established workflows rather than forcing the user to stick to the author's programming paradigms.

SciKit-GStat ships with a large number of predefined procedures, algorithms and models, such as variogram estimators, theoretical spatial models or binning algorithms. Common approaches to estimate variograms are covered and can be used out of the box. At the same time, the base class is very flexible and can be adjusted to less common problems, as well. Last but not least, it was made sure that a user is aided in implementing new procedures or even extending the core functionality as much as possible, to extend SciKit-GStat to uncovered use cases. With broad documentation, a user guide, tutorials and good unit-test coverage, SciKit-GStat enables the user to focus on variogram estimation rather than implementation details.

Today, geoscientific models are more available than they have ever been.
Hence, producing in situ datasets to test and validate models is as important as ever.
One challenge that most observations of our environment have in common is that they are non-exhaustive and often only observe a fraction of the observation space.
A prime example is the German national rainfall observation network.
Considering the actual size of a Hellmann observation device, the approx. 1900 stations and the meteorological service operates, the area sums up to only 38

If one takes an aerial observation, such as a rainfall radar, into account, at face value this can seem to be different.
But a rainfall radar is actually only observing a quite narrow band in height, which might well be a few thousand meters above ground

I hereby present SciKit-GStat, a Python package that implements the most fundamental processing and analysis step of geostatistics: the variogram estimation. It is open source, object-oriented, well-documented, flexible and powerful enough to overcome the limitations that other software implementations may have.

The successful journey of geostatistics started in the early 1950s, and continuous progress has been made ever since.
The earliest work was published in 1951 by the South African engineer David Krige

From this limited use case, geostatistics gained importance and spread annually. A major review work is published almost every decade, illustrating the continuous progress of the subject.
Today, it is a widely accepted field that is used throughout all disciplines in geoscience.

Such studies are only a small extract from what has been published during recent years. They are only outnumbered by the many domain-specific studies that focus on improving geostatistical methods for specific applications.

In recent years the field of geostatistics has experienced many extensions.
Many processes and their spatial patterns studied in geoscience are not static but dynamically change on different scales.
A prime example is soil moisture, which changes on multiple temporal scales, exposing spatial patterns that are not necessarily driven by the same processes throughout the year

The variogram is the most fundamental means of geostatistics and a prerequisite to apply other methods, such as interpolation.
It relates the similarity of observations to their separating distance using a spatial model function.
This function, bearing information about the spatial covariance in the dataset, is used to derive weights for interpolating at unobserved locations.
Thus, any uncertainty or error made during variogram estimation will be propagated into the final result.
As described, geoscientific datasets are often sparse in space, and that makes it especially complex to choose the correct estimator for similarity and to decide when two points are considered

De facto standard libraries for geostatistics can be found in a number of commonly used programming languages.
In FORTRAN, there is

For the Python programming language, there was no package comparable to

At the time, several undocumented issues arose and solving them was not straightforward.

All of the reviewed packages focus only on a specific part of geostatistics, and in general, interfacing options were missing.
Thus, I decided to develop an open-source geostatistics package for the Python programming language called SciKit-GStat.
In the course of the following years, another Python package with similar objectives was developed called

A number of works were especially influential during the development of SciKit-GStat.
An early work by

SciKit-GStat is a toolbox that fits well into the SciPy environment.
For scientific computing in Python, SciPy

SciKit-GStat enables the user to estimate standard but also more exotic variograms. This process is aided by a multitude of helpful plotting functions and statistical output. In other geostatistical software solutions, the estimation of a variogram is often left entirely to the computer. Some kind of evaluation criterion or objective function takes the responsibility of assessing the variograms suitability for expressing the spatial structure of the given input data in a model function. Once used in other geostatistical applications, such as kriging, the theoretical model does not bear any information about its suitability or even goodness of fit to the actual experimental data used. Further advanced geostatistical applications do present a variogram to the user, while performing other geostatistical tasks, but this often seems as passive information that the user may recognize or ignore. The focus is on the application itself. This can be fatal as the variogram might actually not represent the statistical properties well enough. One must remember that the variogram is the foundation of any geostatistical method and unnoticed errors within the variogram will have an impact on the results even if the maps look viable. The variogram itself is a crucial tool for the educated user to interpret whether data interpolation using geostatistics is valid at all.

SciKit-GStat takes a fundamentally different approach here. The variogram itself is the main result. The user may use a variogram and pass it to a kriging algorithm or use one of the interfaces for other libraries. However, SciKit-GStat makes this a manual step by design. The user changes from a passive role to an active role, and this is therefore close to geostatistical textbooks, which usually present the variogram first.

SciKit-GStat is also designed for educational applications. Both students and instructors are specifically targeted within SciKit-GStat's documentation and user guide. While some limited knowledge of the Python programming language is assumed, the user guide starts from zero in terms of geostatistics. Besides a technical description of the SciKit-GStat classes, the user is guided through the implementation of the most important functionality. This fosters a deeper understanding of the underlying methodology for the user. By using SciKit-GStat documentation, a novice user not only learns how to use the code but also learns what it does. This should be considered a crucial feature for scientific applications, especially in geostatistics where a multitude of one-click software packages are available, producing questionable results if used by uneducated users.

SciKit-GStat is well documented and tested.
The current unit-test coverage is

The following section will give a more detailed overview of SciKit-GStat. Section

The source code repository contains the Python package itself, the documentation and sample data.
This work will focus mainly on the Python package, starting with a detailed overview in Sect.

There are already some benchmark datasets for geostatistics, such as the

Original photograph of the pancake used to generate the pancake dataset. The white points indicate the 500 sampling locations that were chosen randomly, without repeating. The observation value is the red-channel value of the RGB value of the specified pixel.

Neither the pancake nor the meuse dataset provide space-time data.
To demonstrate the support of a space-time variogram within SciKit-GStat,
another dataset of distributed soil temperature measurements was utilized and distributed with the software.
The data are part of a dense network of cosmic-ray neutron sensors

Note that I only used a measurement every 1.5 h and did not aggregate the time series.

SciKit-GStat is a library for geostatistical analysis written in the Python programming language.
The Python interpreter must be of version 3.6 or later.
The source files can be downloaded and installed from the Python package index using pip, which is the standard tool for Python 3.

SciKit-GStat is also available on conda-forge, the largest community-driven Anaconda channel. This package is not covered here, as the content is the same and installation requires the presence of an Anaconda environment and some knowledge of the system. Nevertheless, Anaconda is widely spread among scientists, and it might be worth mentioning the existence for Anaconda users.

All dependencies are installed along with the source files. This is the standard and recommended procedure for installing and updating packages in Python 3. Additionally, the source code is open and available on GitHub and can be downloaded and installed from source. SciKit-GStat is published under an MIT License.The presented module is built upon common third-party packages for scientific computing in Python, called

An object-oriented programming approach was chosen for the entire library. SciKit-GStat is designed to interact with the user through a set of classes. Each step in a geostatistical analysis workflow is represented by a class and its methods. Argument names passed to an instance on creation are chosen to be as close as possible to existing and common parameter names from geostatistical literature. The aim is to make the usage of SciKit-GStat as intuitive as possible for geoscientists with only little or no experience with Python.

The main focus of the package is variogram analysis.
Ordinary kriging is also implemented in SciKit-GStat but the main strength is variogram analysis.
Kriging is available as a valuable tool to cross-validate the variogram by interpolating the observation values.
For flexible, feature-rich and fast kriging applications, the variogram can be exported to other libraries with ease.
SciKit-GStat offers an extensible and flexible class that implements common settings out of the box but can be adjusted to rather uncommon problems with ease.
An example variogram is shown in Fig.

Default variogram plot of SciKit-GStat using the matplotlib back end. The variogram was estimated with the pancake dataset using the exponential model (green line) fitted to an experimental variogram (blue dots) resolved to 25 evenly spaced lag classes, up to 500 units (the axis length of the sampled field). The histogram in the upper subplot shows the number of point pairs for each lag class. The histogram shares the

SciKit-GStat contains eight different semi-variance estimators (overview in Table

Overview of all semi-variance estimator functions implemented in SciKit-GStat. Using

Overview of all theoretical variogram model functions implemented in SciKit-GStat.

Overview of all lag class binning methods implemented in SciKit-GStat.

SciKit-GStat offers a multitude of customization options to fit variogram models to experimental data.
The model parameters can be fitted manually or by one of three available optimization algorithms: Levenberg–Marquardt, trust-region reflective and parameter maximum likelihood (see Sect.

Interfaces for a number of other geostatistical packages are provided.
SciKit-GStat defines either an export method or a conversion function to transform objects that can be read by other packages.
Namely,

SciKit-GStat is easily extensible. Many parts of SciKit-GStat were designed to keep the main algorithmic functions clean. Overhead like type checks and function mapping to arrays are outsourced to instance methods wherever possible. This enables the user to implement custom functions with ease, even if they are not too familiar with Python. As an example, implementing a new theoretical model is narrowed down to only implementing the mathematical formula this way.

Documentation provided with SciKit-Gstat is tailored for educational use. The documentation mainly contains a user guide, tutorials and a technical reference. The user guide for SciKit-GStat does not have any prerequisites in geostatistics and guides the reader through the underlying theory while walking through the implementation. Tutorials are provided for users with some experience with Python, geostatistics and other fields of statistics. The tutorials focus on a specific aspect of SciKit-GStat and demonstrate the application of the package. Here, a sound understanding of geostatistics is assumed. Finally, the technical reference only documents the implemented functions and classes from a technical point of view. It is mainly designed for experienced users that need an in-depth understanding of the implementation or for contributors that want to extend SciKit-GStat.

SciKit-GStat is 100 % reproducible through Docker images.
With only the Docker software installed (or any other software that can run Docker containers), it is possible to run the

SciKit-GStat is recognized on GitHub and has a considerable community.
Issues and help requests are submitted frequently and are usually answered in a short amount of time by the author.
At the same time, efforts are made to establish a broader developer community, to foster support and development.
Additionally, the development on SciKit-GStat is closely coordinated with

In geostatistical literature, the terms

At its core, the semi-variogram is a means to express how spatial dependence in observations changes with separating distance.
An observation is here defined to be a sample of a spatial random function.
While these functions are usually two- or three-dimensional functions in geostatistical applications, they can be

Separating distance is calculated for observation point pairs.
For different distance lag classes (e.g., 10 to 20

To model spatial dependencies in a dataset, a formalized mathematical model has to be fitted to the experimental variogram. This step is necessary, to obtain parameters from the model in a formalized manner. These describe spatial statistical properties of the model, which may (hopefully) be generalized to the random field. These parameters are called variogram parameters and include the following:

Closely related to these parameters is the nugget-to-sill ratio. It is interpreted as the share of spatially explainable variance in the sample and is therefore a very important metric to reject the usage of a specific variogram model at all.

The theoretical model is a prerequisite for spatial interpolation.
For this to happen, a number of geostatistical assumptions need to be fulfilled.
Namely, the observations have to be of second-order stationarity, and the intrinsic hypothesis has to hold.
This can be summarized as the requirement that the expected value of the random function and its residuals must not be dependent on the location of observation but solely on the distance to other points.
This assumption has to hold for the full observation space.
Hence, the semi-variance is calculated with the distance lag

Scatterplot of the observation values in the pancake dataset related to only one coordinate dimension.
As the pancake dataset was 2D,

The other requirement for variogram models is that it has to be monotonically increasing. A drop in semi-variance would imply that observations become more similar with increasing distance, which is incompatible with the most fundamental assumption in geostatistics of spatial proximity. This requirement can only be met by a statistical model function and not the experimental variogram, which is often not monotonically increasing in a strict sense. This may happen due to the fact that (spatial) observations are not exhaustive and measurements might be uncertain.

One of the most commonly used applications of geostatistics is kriging.
A sample result is shown in Fig.

Ordinary kriging result of the pancake dataset sample used in Figs.

Kriging estimates the value for an unobserved location

To obtain the weights for one unobserved location, a system of equations called the kriging equation system (KES) is formulated.
By expecting the prediction errors to be zero (Eq.

The standard variogram as described in Sect.

For each directional variogram, only point pairs are considered that are oriented in the direction of the variogram.
For two observation locations

The example data used so far shows a small anisotropy (Fig.

Two directional variograms calculated for the pancake dataset. Both variograms use the same parameters as the instance used to produce Fig.

As long as more than one directional variogram is estimated for a data sample, the difference in the estimated variogram parameters describes the degree of anisotropy.
In a kriging application, the data sample can now be transformed along the main directions at which the directional variograms differ until the directional variograms do not indicate an anisotropy anymore.
The common variogram of the transformed data can be used for kriging, and the interpolated field is finally transformed back.
Transformations are not part of SciKit-GStat. The

At the turn of the millennium, geostatistics had emerged as a major tool in environmental science and geoscience, and the demand for new methods was rising. Datasets collected in nature are usually dynamic in time, which can easily violate the second-order stationarity assumptions underlying classic geostatistics. Hence, substantial progress had been made to incorporate temporal dimensions into variograms.

The classic variogram is modeling the semi-variance of a sample as a function of the separating distance of the underlying point pairs.
For a space-time variogram, this dependence is expanded to time lags.
That means the data are segmented not only in terms of spatial proximity but also temporal proximity.
The resulting model will be capable of identifying covariances over space and time at the same time (Fig.

Default 3D scatterplot of a space-time variogram (blue points), with fitted product-sum model (surface). The variogram is estimated from the in situ soil temperature measurements at 20

Contour plot of an experimental space-time variogram, without theoretical model. The shown variogram is from exactly the same instance as used for Fig.

To build a separable space-time variogram model, the two dimensions are first calculated separately.
Non-separable space-time variogram models are not covered in SciKit-GStat.
The two experimental variograms are called marginal variograms and relate to the temporal or the spatial dimension exclusively, by setting the other dimension's lag to zero.
Finally, these two variograms are combined into a space-time variogram model.
SciKit-GStat implements three models: the sum model, product model and product-sum model.
For each of the marginal experimental variograms, a theoretical model is fitted, as described in Sect.

For the sum model,

This section focuses on the implementation of SciKit-GStat. It aims to foster an understanding of the most fundamental design decisions made during development. Thus, the reader will gain a basic understanding of how the package works, where to get started and how SciKit-GStat can be extended or adjusted.

SciKit-GStat is following an object-oriented programming (OOP) paradigm.
It exports a number of classes, which can be instantiated by the user.
Common geostatistical notions are reflected by class properties and methods to relate the lifetime of each object instance to typical geostatistical analysis workflows.
At the core of SciKit-GStat stands the

The

The second design decision for

To illustrate this as an example, the following is given. When a variogram instance is constructed without further specifying the spatial model that should be used, it will default to the spherical model.
The instance is fitted to this model after construction and can be inspected by the user, i.e., by calling a plot method.
The user wants to check out another semi-variance estimator, such as the Cressie–Hawkins estimator, because there are a lot of outliers in the dataset.
Changing the estimator is as easy as setting the literal estimator name to the estimator property of the variogram.
The experimental variogram will instantly be dropped and recalculated as well as all depending parameters, such as the variogram parameters.
The spherical model is fitted a second time now.
The user might then realize that a spherical model is not suitable and can simply change the model attribute, i.e., to the Matérn model.
As a direct effect, the variogram parameters are dropped again, as they are once again invalidated, and a new fitting procedure is invoked.
This behavior is extremely convenient, as it is easy, interactive, expressive and instant.
But it is also slow, as the theoretical model had been fitted three times before the user even looked into it.
To add some context to

This only tests the estimation of the experimental variogram and does not test any other functionality. That is, kriging implementations in

Benchmark test for estimating an experimental variogram. For each sample size, the mean runtime of 10 repetitions is shown. The experimental variogram was calculated with a native Python implementation (blue),

Although most attributes are mutable, they use common data types in their formulation.
This enables the user to interrupt the calculation at any point using either primitive language types or

Possibly the most crucial step to estimate a suitable variogram is the binning of separating distances into distance lag classes.
In some parts, SciKit-GStat also includes information theory methods. Here, to calculate the basic measure, Shannon entropy

SciKit-GStat implements a large number of methods to form lag classes.
They can be split into two groups. Some are adjusting class edges to fit the requested number of lag classes.
The other group will adjust the number of lag classes to fit other statistical properties of the resulting lag classes.
All methods can be limited by a maximum lag. This is a hyper-parameter that can be specified by the user but is not set by default.
There are various options for the maximum lag. The user can set the parameter by an absolute value, in coordinate units and larger than one.
Alternatively, a number between 0 and 1 can be set.
Then, the

The default behavior is to form a given number of equidistant lag classes, from 0, to the maximum lag distance. This procedure is used in the literature in almost all cases (with different max lags) and is thus a reasonable default method.

Another procedure takes the number of lag classes and forms lag classes of uniform size. That means each lag class will contain the same number of point pairs and thus be of varying width. This procedure can be explicitly useful to avoid empty lag classes, which can easily happen for equidistant lag classes. Another advantage is that the calculation of semi-variance values will always be based on the same sample size, which makes the values statistically more comparable. These advantages come at the cost of less comparable lag classes. Care must be taken when interpreting lag-related variogram properties such as the effective range. There might be lag ranges that are supported by only a very low number of actual lag classes.

The next group of procedures use common methods from histogram estimation to calculate a suitable number of lag classes. This is carried out either directly or by estimating the lag class width and deriving the number of classes needed from this.

The first option is to apply Sturges' rule

Similar to Sturges' rule, the square-root rule estimates the number of lag classes as given in Eq. (

Scott's rule

where

If Scott's rule does, due to outliers, not yield suitable lag classes, the Freedman–Diaconis estimator

The interquartile range (IQR) is robust to outliers, but in turn the Freedman–Diaconis estimator usually estimates way too many lag classes for smaller datasets. The author cannot recommend to use it for distance matrices with less than 1000 entries.

Finally, Doane's rule

All rules that calculate the number of lag classes use the

All histogram estimation methods given above just calculate the number of lag classes. The resulting classes are all equidistant, except for the first lag class, which has 0 as a lower bound instead of

Finally, SciKit-GStat implements two other methods. Both are based on a clustering approach and need the number of lag classes to be set by the user. The distance matrix is clustered by the chosen algorithm. Depending on the clustering algorithm, the cluster centers (centroids) are either estimates of high density or points in the value space, where most neighboring values have the smallest mean distance. Thus, the centroids are taken as a best estimate for lag class centers. Each lag class is then formed by taking half the distance to each sorted neighboring centroid as bounds. This will most likely result in non-equidistant lag classes.

The first option is to use the

The other clustering algorithm is a hierarchical clustering algorithm

The implementation follows

One method of utilizing clustered lag classes is to compare the

Another option available is called

SciKit-GStat implements a number of semi-variance estimators. It includes all semi-variance estimators that are commonly used in the literature.

The

The

The MinMax estimator divides the value range of pairwise differences by their mean value.

Finally, it is possible to use custom, user-defined functions for estimating the semi-variance.
The function has to accept a one-dimensional array of pair-wise differences, as these are already calculated by the

SciKit-GStat implements a number of theoretical variogram models.
The most commonly used models from literature are available.
However, during researching theoretical models, the author brought an almost limitless number of models or variations thereof to light.
Thus, the process of implementing new models was eased as far as possible instead of implementing anything that could be useful.
Any variogram model function (implemented or custom) will receive the

The core design decision for SciKit-GStat's theoretical variogram models was to implement a decorator that wraps any model function. This decorator takes care of handling input data and aligning output data. Thus, the process of implementing new variogram models is simplified to writing a function that maps a single given distance lag to the corresponding semi-variance value.

Each model will receive the three variogram parameter effective range, sill and nugget as function arguments.
The nugget is implemented as an optional argument with a default value of zero, in the case when the user disables the usage of a nugget in the

Note that a harmonized model might not show an effective range, in which cases the library will take the maximum value as the effective range for technical reasons.
Thus, the user has to carefully double-check harmonized models for their geostatistical soundness.
Secondly, the harmonized model cannot be exported to

As soon as an estimated variogram is used in further geostatistical methods, such as kriging or field simulations, it is necessary to describe the experimental, empirical data by a model function of defined mathematical properties.
That is, for kriging, a variogram has to be monotonically increasing and positive definite.
This is assured by fitting a theoretical model to the experimental data.
The models available in SciKit-GStat are described in Sect.

Fitting the theoretical model to the experimental data is crucial, as any uncertainty caused by this procedure will be propagated to any further usage of the variogram.
Almost any geostatistical analysis workflow is based on some kind of variogram; hence, the goodness of fit will influence almost any analysis.
The

When fitting the model, SciKit-GStat implements four main algorithms, each one in different variations. A main challenge of fitting a variogram model function is that closer lag classes result in higher kriging weights and are therefore of higher importance. A variogram model that might show a fair overall goodness of fit but is far off on the first few lag classes will result in poorer kriging results than an overall less well-fitted model that hits the first few lags perfectly. On the other hand, emphasizing the closer lags is mainly done by adjusting the range parameter. The only other degree of freedom for fitting the model is then the sill parameter. Thus, if the modeling of the closer lag classes is put too much into focus, this happens at the cost of missing the experimental sill, which is basically the sample variance, in the case when the nugget is set to zero. If the nugget is not zero, an insufficient sill will change the nugget-to-sill ratio, and one might have to reject the variogram. A kriging interpolation of reasonable range is able to reproduce the spatial structure of a random field, but if the sill is far off, the interpolation is not able to reproduce the value space accordingly, and the estimations will be inaccurate. In the extreme case of a pure nugget variogram model, kriging will only estimate the sample mean (which is the correct behavior but not really useful). Thus, the fitting of a model has to be evaluated carefully by the user, and SciKit-GStat is aiming to support the user with this.

A procedure that is frequently used to find optimal parameters for a given model to fit a data sample is

Another least-squares approach is trust-region reflective (TRF)

The adjustable variogram model parameters are the effective range, sill, nugget (if used), and a shape parameter for the Matèrn and stable models.
The lower bound for all parameters is zero, as all parameters have to be positive by definition.
The upper bounds can also be defined for all parameters. The effective range is bounded to the maximum lag or largest separating distance observed if the maximum lag was not specified by the user.
The sill is bounded by the largest semi-variance value that was estimated for the experimental variogram. As nugget and sill effectively sum up to sample variance, it consequently has to be smaller than any individual semi-variance value.
The same has to hold for the nugget, due to the implementations given in Sect.

The implementation for trust-region reflective least squares is taken from the

The third fitting method is a maximum likelihood approach.
The theoretical model is fitted to the experimental data by minimizing the negative log-likelihood of the variogram parameters.
Each of the parameters samples from a normal distribution with the last parameters predictions mean and standard deviation as first and second moments.
In the current implementation, an unbounded and unconstrained Nelder–Mead solver

The last option is not an algorithm. The

All fitting mechanisms except for the manual fit can be further refined by setting an array of fitting weights.
This enables the user to focus only a few lag classes for fitting and achieve a higher goodness of fit on specific lags.
The weights are, following the logic of

The first option is a linear decrease of weights with increasing lags.
The second option uses the square root of the normalized lag as an approximation.
The third option uses the inverse of the normalized lag squared as a weight.
This results in completely neglecting any lag class except the first two or three, depending on the total number.
The last function applies an exponential function as given by Eq. (

All four distance-dependent weighting functions are compared in Fig.

Red diamonds show a sample experimental variogram (values are made up) with four different spherical variogram models. All four models are fitted using the trust-region reflective fitting procedure and distance-dependent weights.
The weights are

Four random fields generated using the same seed for
randomization, which results in exactly the same field for same
input. The only differing input parameter is the automatic
distance-weighting function that was used for fitting the
theoretical variogram model. All four fields share the same
value range. As the underlying models were made up, neither the
values nor the axis coordinates have any meaning. The two
coordinate axis names correspond to the index of the random field
in matrix form

Another predefined possibility to determine weights for fitting is information theory.
Unlike the other functions, this option is not based on an inverse of weights.
The information-theory-based weighting option calculates the uncertainties directly, by using the Shannon entropy

Directional variograms can be estimated in SciKit-GStat using the

Three new attributes are introduced, which can be set by the user.
For all three parameters, SciKit-GStat retains the name, implementation and usage as close to

The

As the tolerance is given in degrees, the absolute deviations in the unit of the coordinate system can be quite considerable for larger separating distances.
Therefore, it is possible to set a

Apart from the basic hyper-parameters that define a directional variogram, there are different implementations how to apply them.
SciKit-GStat denotes these implementations as

The default

The unbounded version of the

For convenience and to further inspect the point pairs which are actually taken into account, there is an additional auxiliary plotting method.
This plots a network graph for all input locations with an edge for each point pair that will be taken into account for calculation (Fig.

Pair Field plot of two directional variograms. The plot
was created with exactly the same two directional variogram
instances as used in Fig.

For calculating spatiotemporal variograms, SciKit-GStat has a class called

At the core of all implemented theoretical variogram methods for the spatiotemporal variogram is the estimation of two marginal variograms.
The class will estimate a

Finally, the

SciKit-GStat implements three different theoretical spatiotemporal variogram models: the sum, product and sum-product model.
In line with the

In the following equations the marginal variograms represented by

The sum model provides an understanding of the idea and workflow of spatiotemporal models.
However, it should not be used for real data in almost all cases.
It assumes the covariance field to be isotropic across temporal and spatial dimensions, which is a situation which can be considered rarely true. Moreover, it might not be positive definitive, as required for variogram models

SciKit-GStat implements an ordinary kriging algorithm. It is implemented following

It must be noted that the

SciKit-GStat has three interfaces for

The second, major, option is to translate the theoretical model into a fitted covariance model instance of

For the specific case of kriging, a third interface exports the variogram directly into a

Both libraries chose different avenues for how the user may interact with the library.
For

Users are supported by a comprehensive documentation that includes API reference, installation instructions, a getting started guide, a detailed user guide and tutorials. The user guide is written with the example of a lecture script. No geostatistical prior knowledge is necessary. Only some limited experience of Python and basic knowledge of univariate statistics is advantageous. Additionally, the user guide includes a number of technical notes that discuss some specialities of SciKit-GStat in great detail.

SciKit-GStat is managed and hosted on GitHub under an MIT License. For technical problems, questions and feature requests, the GitHub issues ticketing system is used. To date, any issues arising have been processed by the author himself. As some of the raised issues discussed fundamental geostatistical principles and basic applications of SciKit-GStat, these closed issues are also a valuable resource for new users to SciKit-GStat as well as geostatistics. The evaluation of these issues was taken into account for compiling the user guide.

To use SciKit-GStat in production environments and also for rapid installation, a Docker image is offered. The Dockerfile is also included in the SciKit-GStat repository ,and therefore, also distributed under an MIT License, enabling users to adapt and utilize it. The associated Docker image includes an interactive Jupyter Notebook environment, which auto-starts the tutorials. These tutorials are also included in the documentation and accompany the descriptions. In classroom situations, each student can easily start with the interactive tutorials, while the teacher can follow the documentation. The student should implement the core functionality of SciKit-GStat themselves to fully understand geostatistical analysis workflows. This knowledge can then be applied to SciKit-GStat, emphasizing the correct application of the package and geostatistics in general. Finally, the student can easily apply the learned techniques to real problems with a production-ready Python package. The overall aim is to teach geostatistics with the given resources at the example of SciKit-GStat rather than narrowing geostatistics down to the application of SciKit-GStat only.

Contributions to SciKit-GStat are managed via GitHub. Generally, anyone can create a private copy of the full source code. Adaptions, enhancements or corrections to the source code of SciKit-GStat can be merged into the official code base via GitHub. With respect to coding style, technical correctness and overall objective of the library, any possible contribution is reviewed by the author or any other maintainer of the package. To further guarantee technical correctness, SciKit-GStat is covered by unit tests, which test all main functionalities in isolated test cases. Due to technical challenges, most plotting routines are not covered by unit tests. Historically, there have been a number of tests, but they require a lot of maintenance and are, to a specific degree, dependent on the host platform. Thus, it can be doubted that this is actually beneficial for the user. Additionally, a few tests in the style of end-to-end (e2e) tests were added to run a full analysis against an expected result. Such e2e tests also assess the performance, measured as test runtime. However, dropping performance does not cause a test failure but can be used by the author and contributors to assess contributions with respect to their influence on performance. It was also decided to not accept any new contributions that decrease test coverage significantly, by adding automatic coverage reports to new contributions. This can be considered important to assure a specific level of technical correctness for SciKit-GStat, especially because the open-source MIT License does not put any warranties in place that the user could rely on.

The main interface to

Most limitations and notes on applications have already been mentioned in the respective sections, along with implementation details. This section is discussing general comments on SciKit-GStat. SciKit-GStat is a toolbox for variogram estimation, equipped with a large number of methods. Most of these methods and settings do not make sense in every situation. SciKit-GStat is generally leaving any assessment of estimated variograms, beyond numerical goodness of fit values, to the user. From this, it is further clarified that SciKit-GStat is a variogram estimation toolbox, which is used for building geostatistical methods or conducting analyses. It is not an analysis framework itself.

This limitation also applies to preprocessing. While geostatistical prerequisites, like the intrinsic hypothesis, are mentioned and further literature is referenced, SciKit-GStat does not contain any diagnostic tool to, for example, check given input data any further than by offering the presented scatterplots in Fig.

Another general comment concerns spatiotemporal geostatistics.
I want to clearly state here that spatiotemporal variograms cannot be exported to any other Python package, and SciKit-GStat does not include spatiotemporal kriging.
No implementation is planned by the author nor for

With SciKit-GStat, the scientific Python community has gained a flexible, well-documented and well-written package for variogram estimation. SciKit-GStat enables the user to estimate variograms in almost limitless variations in a natural language and efficient manner. Many quality measures and especially plotting routines accompany the library to not only do the hard work but also to help the user understand what was actually done. Such an educational aspect of SciKit-GStat is as important as the technical implementation details. Even the best code can be applied the wrong way to draw incorrect or skewed conclusions. If one does not write the code themselves, this risk might be even higher. With SciKit-GStat the focus is on the variogram. Variograms that are better understood by a user lead to better models, which are beneficial not only in application but also as an educational tool.

Users of SciKit-GStat that relate easier to geoscientific data samples than to pancakes are referred to the tutorial section of SciKit-GStat

Default sample experimental variogram (blue points) with fitted spherical model (green line) of the Meuse dataset

Ordinary kriging application using the theoretical variogram model shown in Fig.

The model was used to interpolate the sample on a

While this example demonstrates the ease of use of SciKit-GStat, as data sources can simply be exchanged, the application by geostatistics can be way more complicated. SciKit-GStat can help with easily approachable methods and algorithms, but the user still needs expert knowledge to estimate useful variograms and set meaningful hyper-parameters.

Using a photograph of a pancake for geostatistics was fun but not only a joke.
When I first saw the browning pattern in the pan, I was just curious if the means of geostatistics work for this example as well.
The application was easy and straightforward, and I actually used the first photograph taken.
I find it striking how well the variogram estimation worked. I have no other geoscientific real-world or even artificial data example at hand that yielded more textbook-like variograms than this pancake did.
Today, I would conclude that while a pancake is not a geoscientific phenomenon, the browning of the dough is largely driven by thermodynamic principles which are universally applicable.
Thus, this artificial dataset was great for development and has become my prime benchmark dataset for geostatistical method development.
I personally prefer artificial datasets over real-world examples here, as sample sizes and locations can be altered.
With real-world datasets I, personally, tend to focus too much on the system that the data actually represents and not the method development.
On the other hand, generating a random field by

To bake your own data, there are a few technical instructions that should help to produce comparable pancakes.
The photograph was taken with a Canon PowerShot SX540 digital camera
at

Finally, my pancake dough is very runny (more like a crêpe and less like an American pancake).
From my experience, runny dough and high temperatures (short time in the pan) are key to spatially structured pancakes.
I would expect a classic American pancake to be way more homogeneously browned.
I used 500

With version 1.0, SciKit-GStat introduced a utility suite that can generate negative log-likelihood functions for any given

Default SciKit-GStat trust-region reflective fit of the pancake dataset (blue line) to the experimental variogram (blue dots) compared to a maximum likelihood approach following

This appendix briefly summarizes the tutorial introducing the utility function.
A prime application for using this function is fitting a theoretical variogram model using a maximum likelihood approach

The source code of SciKit-GStat is available on GitHub (

All data used in this work are part of SciKit-GStat source code

The author has declared that there are no competing interests.

Publisher's note: Copernicus Publications remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

First I want to acknowledge the contributors to SciKit-GStat: Egil Möller, Helge Schneider and Sebastian Müller for their valuable contributions.
I thank Jon Sheppard for proofreading the manuscript and Erwin Zehe for his valuable feedback on general structure, content and data usage.
I also want to emphasize the indirect contributions by Sebastian Müller, the lead developer of

The article processing charges for this open-access publication were covered by the Karlsruhe Institute of Technology (KIT).

This paper was edited by Rohitash Chandra and reviewed by three anonymous referees.