gstools.field.Field¶
- class gstools.field.Field(model, value_type='scalar', mean=None, normalizer=None, trend=None)[source]¶
Bases:
objectA base class for random fields, kriging fields, etc.
- Parameters
model (
CovModel) – Covariance Model related to the field.value_type (
str, optional) – Value type of the field. Either “scalar” or “vector”. The default is “scalar”.mean (
Noneorfloatorcallable, optional) – Mean of the field if wanted. Could also be a callable. The default is None.normalizer (
NoneorNormalizer, optional) – Normalizer to be applied to the field. The default is None.trend (
Noneorfloatorcallable, optional) – Trend of the denormalized fields. If no normalizer is applied, this behaves equal to ‘mean’. The default is None.
- Attributes
dimint: Dimension of the field.meanmodelCovModel: The covariance model of the field.namestr: The name of the class.normalizerNormalizer: Normalizer of the field.trendvalue_typestr: Type of the field values (scalar, vector).
Methods
__call__(*args, **kwargs)Generate the 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.
post_field(field[, name, process, save])Postprocessing field values.
pre_pos(pos[, mesh_type])Preprocessing positions and mesh_type.
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.
- mesh(mesh, points='centroids', direction='all', name='field', **kwargs)[source]¶
Generate a field on a given meshio or ogs5py mesh.
- Parameters
mesh (meshio.Mesh or ogs5py.MSH or PyVista mesh) – The given meshio, ogs5py, or PyVista 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 (
strorlist, 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”. By default, all directions are used. One can also pass a list of indices. Default: “all”name (
strorlistofstr, optional) – Name(s) to store the field(s) in the given mesh as point_data or cell_data. If to few names are given, digits will be appended. 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 or PyVista mesh was given.
See: https://github.com/nschloe/meshio See: https://github.com/pyvista/pyvista
See:
Field.__call__
- plot(field='field', fig=None, ax=None, **kwargs)[source]¶
Plot the spatial random field.
- Parameters
field (
str, optional) – Field that should be plotted. Default: “field”fig (
FigureorNone) – Figure to plot the axes on. If None, a new one will be created. Default: Noneax (
AxesorNone) – Axes to plot on. If None, a new one will be added to the figure. Default: None**kwargs – Forwarded to the plotting routine.
- post_field(field, name='field', process=True, save=True)[source]¶
Postprocessing field values.
- Parameters
field (
numpy.ndarray) – Field values.name (
str, optional) – Name. to store the field. The default is “field”.process (
bool, optional) – Whether to process field to apply mean, normalizer and trend. The default is True.save (
bool, optional) – Whether to store the field under the given name. The default is True.
- Returns
field – Processed field values.
- Return type
- pre_pos(pos, mesh_type='unstructured')[source]¶
Preprocessing positions and mesh_type.
- Parameters
- Returns
iso_pos ((d, n),
numpy.ndarray) – the isometrized position tupleshape (
tuple) – Shape of the resulting field.
- structured(*args, **kwargs)[source]¶
Generate a field on a structured mesh.
See
Field.__call__
- to_pyvista(field_select='field', fieldname='field')[source]¶
Create a VTK/PyVista grid of the stored field.
- unstructured(*args, **kwargs)[source]¶
Generate a field on an unstructured mesh.
See
Field.__call__
- vtk_export(filename, field_select='field', fieldname='field')[source]¶
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”
- property normalizer¶
Normalizer of the field.
- Type