# gstools.krige.Ordinary¶

class `gstools.krige.``Ordinary`(model, cond_pos, cond_val, trend_function=None)[source]

Bases: `gstools.krige.base.Krige`

Ordinary kriging.

Ordinary kriging is used to interpolate data and estimate a proper mean.

Parameters: model (`CovModel`) – Covariance Model used for kriging. cond_pos (`list`) – tuple, containing the given condition positions (x, [y, z]) cond_val (`numpy.ndarray`) – the values of the conditions trend_function (`callable`, optional) – A callable trend function. Should have the signiture: f(x, [y, z]) This is used for detrended kriging, where the trended is subtracted from the conditions before kriging is applied. This can be used for regression kriging, where the trend function is determined by an external regression algorithm. `cond_ext_drift` `numpy.ndarray`: The ext. drift at the conditions. `cond_no` `int`: The number of the conditions. `cond_pos` `list`: The position tuple of the conditions. `cond_trend` `numpy.ndarray`: Trend at the conditions. `cond_val` `list`: The values of the conditions. `drift_functions` `list` of `callable`: The drift functions. `drift_no` `int`: Number of drift values per point. `mean` `float`: The mean of the field. `model` `CovModel`: The covariance model of the field. `trend_function` `callable`: The trend function. `unbiased` `bool`: Whether the kriging is unbiased or not. `value_type` `str`: Type of the field values (scalar, vector).

Methods

 `__call__`(self, pos[, mesh_type, ext_drift, …]) Generate the kriging field. `get_mean`(self) Calculate the estimated mean. `mesh`(self, mesh[, points, direction, name]) Generate a field on a given meshio or ogs5py mesh. `plot`(self[, field, fig, ax]) Plot the spatial random field. `set_condition`(self, cond_pos, cond_val[, …]) Set the conditions for kriging. `set_drift_functions`(self[, drift_functions]) Set the drift functions for universal kriging. `structured`(self, \*args, \*\*kwargs) Generate a field on a structured mesh. `to_pyvista`(self[, field_select, fieldname]) Create a VTK/PyVista grid of the stored field. `unstructured`(self, \*args, \*\*kwargs) Generate a field on an unstructured mesh. `update`(self) Update the kriging settings. `vtk_export`(self, filename[, field_select, …]) Export the stored field to vtk.
`__call__`(self, pos, mesh_type='unstructured', ext_drift=None, chunk_size=None)

Generate the kriging field.

The field is saved as self.field and is also returned. The error variance is saved as self.krige_var and is also returned.

Parameters: pos (`list`) – the position tuple, containing main direction and transversal directions (x, [y, z]) mesh_type (`str`, optional) – ‘structured’ / ‘unstructured’ ext_drift (`numpy.ndarray` or `None`, optional) – the external drift values at the given positions (only for EDK) chunk_size (`int`, optional) – Chunk size to cut down the size of the kriging system to prevent memory errors. Default: None field (`numpy.ndarray`) – the kriged field krige_var (`numpy.ndarray`) – the kriging error variance
`get_mean`(self)[source]

Calculate the estimated mean.

`mesh`(self, mesh, points='centroids', direction='xyz', name='field', **kwargs)

Generate a field on a given meshio or ogs5py mesh.

Parameters: mesh (meshio.Mesh or ogs5py.MSH) – The given meshio or ogs5py mesh points (`str`, optional) – The points to evaluate the field at. Either the “centroids” of the mesh cells (calculated as mean of the cell vertices) or the “points” of the given mesh. Default: “centroids” direction (`str`, optional) – Here you can state which direction should be choosen for lower dimension. For example, if you got a 2D mesh in xz direction, you have to pass “xz” Default: “xyz” name (`str`, optional) – Name to store the field in the given mesh as point_data or cell_data. Default: “field” **kwargs – Keyword arguments forwareded to Field.__call__.

Notes

This will store the field in the given mesh under the given name, if a meshio mesh was given.

`plot`(self, field='field', fig=None, ax=None)

Plot the spatial random field.

Parameters: field (`str`, optional) – Field that should be plotted. Can be: “field”, “raw_field”, “krige_field”, “err_field” or “krige_var”. Default: “field” fig (`Figure` or `None`) – Figure to plot the axes on. If None, a new one will be created. Default: None ax (`Axes` or `None`) – Axes to plot on. If None, a new one will be added to the figure. Default: None
`set_condition`(self, cond_pos, cond_val, ext_drift=None)

Set the conditions for kriging.

Parameters: cond_pos (`list`) – the position tuple of the conditions (x, [y, z]) cond_val (`numpy.ndarray`) – the values of the conditions ext_drift (`numpy.ndarray` or `None`, optional) – the external drift values at the given conditions (only for EDK) For multiple external drifts, the first dimension should be the index of the drift term.
`set_drift_functions`(self, drift_functions=None)

Set the drift functions for universal kriging.

Parameters: drift_functions (`list` of `callable`, `str` or `int`) – Either a list of callable functions, an integer representing the polynomial order of the drift or one of the following strings: ”linear” : regional linear drift (equals order=1) ”quadratic” : regional quadratic drift (equals order=2) `ValueError` – If the given drift functions are not callable.
`structured`(self, *args, **kwargs)

Generate a field on a structured mesh.

`to_pyvista`(self, field_select='field', fieldname='field')

Create a VTK/PyVista grid of the stored field.

Parameters: field_select (`str`, optional) – Field that should be stored. Can be: “field”, “raw_field”, “krige_field”, “err_field” or “krige_var”. Default: “field” fieldname (`str`, optional) – Name of the field in the VTK file. Default: “field”
`unstructured`(self, *args, **kwargs)

Generate a field on an unstructured mesh.

`update`(self)

Update the kriging settings.

`vtk_export`(self, filename, field_select='field', fieldname='field')

Export the stored field to vtk.

Parameters: filename (`str`) – Filename of the file to be saved, including the path. Note that an ending (.vtr or .vtu) will be added to the name. field_select (`str`, optional) – Field that should be stored. Can be: “field”, “raw_field”, “krige_field”, “err_field” or “krige_var”. Default: “field” fieldname (`str`, optional) – Name of the field in the VTK file. Default: “field”
`cond_ext_drift`

The ext. drift at the conditions.

`cond_no`

The number of the conditions.

Type: `int`
`cond_pos`

The position tuple of the conditions.

Type: `list`
`cond_trend`

Trend at the conditions.

`cond_val`

The values of the conditions.

Type: `list`
`drift_functions`

The drift functions.

Type: `list` of `callable`
`drift_no`

Number of drift values per point.

Type: `int`
`mean`

The mean of the field.

Type: `float`
`model`

The covariance model of the field.

Type: `CovModel`
`trend_function`

The trend function.

Type: `callable`
`unbiased`

Whether the kriging is unbiased or not.

Type: `bool`
`value_type`

Type of the field values (scalar, vector).

Type: `str`