# Kriging

The subpackage gstools.krige provides routines for Gaussian process regression, also known as kriging. Kriging is a method of data interpolation based on predefined covariance models.

The aim of kriging is to derive the value of a field at some point , when there are fixed observed values at given points .

The resluting value at is calculated as a weighted mean:

The weights depent on the given covariance model and the location of the target point.

The different kriging approaches provide different ways of calculating .

The Krige class provides everything in one place and you can switch on/off the features you want:

• unbiased: the weights have to sum up to 1. If true, this results in Ordinary kriging, where the mean is estimated, otherwise it will result in Simple kriging, where the mean has to be given.

• drift_functions: you can give a polynomial order or a list of self defined functions representing the internal drift of the given values. This drift will be fitted internally during the kriging interpolation. This results in Universal kriging.

• ext_drift: You can also give an external drift per point to the routine. In contrast to the internal drift, that is evaluated at the desired points with the given functions, the external drift has to given for each point form an “external” source. This results in ExtDrift kriging.

• trend, mean, normalizer: These are used to pre- and post-process data. If you already have fitted a trend model that is provided as a callable function, you can give it to the kriging routine. Normalizer are power-transformations to gain normality. mean behaves similar to trend but is applied at another position:

1. conditioning data is de-trended (substracting trend)

2. detrended conditioning data is then normalized (in order to follow a normal distribution)

3. normalized conditioning data is set to zero mean (subtracting mean)

Cosequently, when there is no normalizer given, trend and mean are the same thing and only one should be used. Detrended kriging is a shortcut to provide only a trend and simple kriging with normal data.

• exact and cond_err: To incorporate the nugget effect and/or measurement errors, one can set exact to False and provide either individual measurement errors for each point or set the nugget as a constant measurement error everywhere.

• pseudo_inv: Sometimes the inversion of the kriging matrix can be numerically unstable. This occurs for examples in cases of redundant input values. In this case we provide a switch to use the pseudo-inverse of the matrix. Then redundant conditional values will automatically be averaged.

Note

All mentioned features can be combined within the Krige class. All other kriging classes are just shortcuts to this class with a limited list of input parameters.

The routines for kriging are almost identical to the routines for spatial random fields, with regard to their handling. First you define a covariance model, as described in The Covariance Model, then you initialize the kriging class with this model:

import gstools as gs
# condtions
cond_pos = [...]
cond_val = [...]
model = gs.Gaussian(dim=1, var=0.5, len_scale=2)
krig = gs.krige.Simple(model, cond_pos=cond_pos, cond_val=cond_val, mean=1)


The resulting field instance krig has the same methods as the SRF class. You can call it to evaluate the kriged field at different points, you can plot the latest field or you can export the field and so on.

## Provided Kriging Methods

The following kriging methods are provided within the submodule gstools.krige.

 Krige(model, cond_pos, cond_val[, ...]) A Swiss Army knife for kriging. Simple(model, cond_pos, cond_val[, mean, ...]) Simple kriging. Ordinary(model, cond_pos, cond_val[, ...]) Ordinary kriging. Universal(model, cond_pos, cond_val, ...[, ...]) Universal kriging. ExtDrift(model, cond_pos, cond_val, ext_drift) External drift kriging (EDK). Detrended(model, cond_pos, cond_val, trend) Detrended simple kriging.

## Examples

Simple Kriging

Simple Kriging

Ordinary Kriging

Ordinary Kriging

Interface to PyKrige

Interface to PyKrige

Compare Kriging

Compare Kriging

External Drift Kriging

External Drift Kriging

Universal Kriging

Universal Kriging

Detrended Kriging

Detrended Kriging

Detrended Ordinary Kriging

Detrended Ordinary Kriging

Incorporating measurement errors

Incorporating measurement errors

Redundant data and pseudo-inverse

Redundant data and pseudo-inverse

Gallery generated by Sphinx-Gallery