gstools.krige

GStools subpackage providing kriging.

Kriging Classes

Simple(model, mean, cond_pos, cond_val) A class for simple kriging.
Ordinary(model, cond_pos, cond_val) A class for ordinary kriging.

class gstools.krige.Simple(model, mean, cond_pos, cond_val)[source]

Bases: gstools.field.base.Field

A class for simple kriging.

Parameters:
  • model (CovModel) – Covariance Model used for kriging.
  • mean (float, optional) – mean value of the kriging field
  • cond_pos (list) – tuple, containing the given condition positions (x, [y, z])
  • cond_val (numpy.ndarray) – the values of the conditions
Attributes:
cond_pos

list: The position tuple of the conditions.

cond_val

list: The values of the conditions.

mean

float: The mean of the field.

model

CovModel: The covariance model of the field.

value_type

str: Type of the field values (scalar, vector).

Methods

__call__(pos[, mesh_type]) Generate the simple kriging field.
mesh(mesh[, points, direction, name]) Generate a field on a given meshio or ogs5py mesh.
plot([field, fig, ax]) Plot the spatial random field.
set_condition(cond_pos, cond_val) Set the conditions for kriging.
structured(*args, **kwargs) Generate a field on a structured mesh.
to_pyvista([field_select, fieldname]) Create a VTK/PyVista grid of the stored field.
unstructured(*args, **kwargs) Generate a field on an unstructured mesh.
vtk_export(filename[, field_select, fieldname]) Export the stored field to vtk.
__call__(pos, mesh_type='unstructured')[source]

Generate the simple kriging field.

The field is saved as self.field and is also returned.

Parameters:
  • pos (list) – the position tuple, containing main direction and transversal directions (x, [y, z])
  • mesh_type (str) – ‘structured’ / ‘unstructured’
Returns:

mesh(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.

See: https://github.com/nschloe/meshio

See: Field.__call__

plot(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(cond_pos, cond_val)[source]

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
structured(*args, **kwargs)

Generate a field on a structured mesh.

See Field.__call__

to_pyvista(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(*args, **kwargs)

Generate a field on an unstructured mesh.

See Field.__call__

vtk_export(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_pos

The position tuple of the conditions.

Type:list
cond_val

The values of the conditions.

Type:list
mean

The mean of the field.

Type:float
model

The covariance model of the field.

Type:CovModel
value_type

Type of the field values (scalar, vector).

Type:str
class gstools.krige.Ordinary(model, cond_pos, cond_val)[source]

Bases: gstools.field.base.Field

A class for ordinary kriging.

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
Attributes:
cond_pos

list: The position tuple of the conditions.

cond_val

list: The values of the conditions.

mean

float: The mean of the field.

model

CovModel: The covariance model of the field.

value_type

str: Type of the field values (scalar, vector).

Methods

__call__(pos[, mesh_type]) Generate the ordinary kriging field.
mesh(mesh[, points, direction, name]) Generate a field on a given meshio or ogs5py mesh.
plot([field, fig, ax]) Plot the spatial random field.
set_condition(cond_pos, cond_val) Set the conditions for kriging.
structured(*args, **kwargs) Generate a field on a structured mesh.
to_pyvista([field_select, fieldname]) Create a VTK/PyVista grid of the stored field.
unstructured(*args, **kwargs) Generate a field on an unstructured mesh.
vtk_export(filename[, field_select, fieldname]) Export the stored field to vtk.
__call__(pos, mesh_type='unstructured')[source]

Generate the ordinary kriging field.

The field is saved as self.field and is also returned.

Parameters:
  • pos (list) – the position tuple, containing main direction and transversal directions (x, [y, z])
  • mesh_type (str) – ‘structured’ / ‘unstructured’
Returns:

mesh(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.

See: https://github.com/nschloe/meshio

See: Field.__call__

plot(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(cond_pos, cond_val)[source]

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
structured(*args, **kwargs)

Generate a field on a structured mesh.

See Field.__call__

to_pyvista(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(*args, **kwargs)

Generate a field on an unstructured mesh.

See Field.__call__

vtk_export(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_pos

The position tuple of the conditions.

Type:list
cond_val

The values of the conditions.

Type:list
mean

The mean of the field.

Type:float
model

The covariance model of the field.

Type:CovModel
value_type

Type of the field values (scalar, vector).

Type:str