gstools.field

GStools subpackage providing tools for spatial random fields.

Subpackages

generator GStools subpackage providing generators for spatial random fields.
upscaling GStools subpackage providing upscaling routines for the spatial random field.

Spatial Random Field

SRF(model[, mean, upscaling, generator]) A class to generate spatial random fields (SRF).

class gstools.field.SRF(model, mean=0.0, upscaling='no_scaling', generator='RandMeth', **generator_kwargs)[source]

A class to generate spatial random fields (SRF).

Parameters:
  • model (CovModel) – Covariance Model to use for the field.
  • mean (float, optional) – mean value of the SRF
  • var_upscaling (str, optional) –

    Method to be used for upscaling the variance at each point depending on the related element volume. See the point_volumes keyword in the SRF.__call__ routine. At the moment, the following upscaling methods are provided:

    • ”no_scaling” : No upscaling is applied to the variance. See: var_no_scaling
    • ”coarse_graining” : A volume depended variance is calculated by the upscaling technique coarse graining. See: var_coarse_graining

    Default: “no_scaling”

  • generator (str, optional) –

    Name of the generator to use for field generation. At the moment, the following generators are provided:

    • ”RandMeth” : The Randomization Methode. See: RandMeth

    Default: “RandMeth”

  • **generator_kwargs – keyword arguments that are forwarded to the generator in use. Have a look at the provided generators for further information.
Attributes:
do_rotation

bool: State if a rotation should be performed

generator

callable: The generator of the field.

model

CovModel: The covariance model of the spatial random field.

upscaling

str: Name of the upscaling method for the variance at each

Methods

__call__(pos[, seed, force_moments, …]) Generate the spatial random field.
set_generator(generator, **generator_kwargs) Set the generator for the field
structured(*args, **kwargs) Generate an SRF on a structured mesh
unstructured(*args, **kwargs) Generate an SRF on an unstructured mesh
upscaling_func(*args, **kwargs) The upscaling method applied to the field variance
__call__(pos, seed=nan, force_moments=False, point_volumes=0.0, mesh_type='unstructured')[source]

Generate the spatial random field.

Parameters:
  • pos (list) – the position tuple, containing main direction and transversal directions
  • seed (int, optional) – seed for RNG for reseting. Default: keep seed from generator
  • force_moments (bool) – Force the generator to exactly match mean and variance. Default: False
  • point_volumes (float or numpy.ndarray) – If your evaluation points for the field are coming from a mesh, they are probably representing a certain element volume. This volumes can be passed by point_volumes to apply the given variance upscaling. If point_volumes is 0 nothing is changed. Default: 0
  • mesh_type (str) – ‘structured’ / ‘unstructured’
Returns:

field – the SRF

Return type:

numpy.ndarray

set_generator(generator, **generator_kwargs)[source]

Set the generator for the field

Parameters:
  • generator (str, optional) – Name of the generator to use for field generation. Default: “RandMeth”
  • **generator_kwargs – keyword arguments that are forwarded to the generator in use.
structured(*args, **kwargs)[source]

Generate an SRF on a structured mesh

See SRF.__call__

unstructured(*args, **kwargs)[source]

Generate an SRF on an unstructured mesh

See SRF.__call__

upscaling_func(*args, **kwargs)[source]

The upscaling method applied to the field variance

do_rotation

State if a rotation should be performed depending on the model.

Type:bool
generator

The generator of the field.

Default: RandMeth

Type:callable
model

The covariance model of the spatial random field.

Type:CovModel
upscaling

Name of the upscaling method for the variance at each point depending on the related element volume.

See the point_volumes keyword in the SRF.__call__ routine. Default: “no_scaling”

Type:str