gstools.field.generator

GStools subpackage providing generators for spatial random fields.

The following classes are provided

RandMeth(model[, mode_no, seed, …]) Randomization method for calculating isotropic spatial random fields.
class gstools.field.generator.RandMeth(model, mode_no=1000, seed=None, chunk_tmp_size=10000000.0, verbose=False, **kwargs)[source]

Randomization method for calculating isotropic spatial random fields.

Parameters:
  • model (CovModel) – covariance model
  • mode_no (int, optional) – number of Fourier modes. Default: 1000
  • seed (int or None, optional) – the seed of the random number generator. If “None”, a random seed is used. Default: None
  • chunk_tmp_size (int, optional) – Number of points (number of coordinates * mode_no) to be handled by one chunk while creating the fild. This is used to prevent memory overflows while generating the field. Default: 1e7
  • verbose (bool, optional) – State if there should be output during the generation. Default: False
  • **kwargs – Placeholder for keyword-args

Notes

The Randomization method is used to generate isotropic spatial random fields characterized by a given covariance model. The calculation looks like:

u\left(x\right)=
\sqrt{\frac{\sigma^{2}}{N}}\cdot
\sum_{i=1}^{N}\left(
Z_{1,i}\cdot\cos\left(\left\langle k_{i},x\right\rangle \right)+
Z_{2,i}\cdot\sin\left(\left\langle k_{i},x\right\rangle \right)
\right)

where:

  • N : fourier mode number
  • Z_{j,i} : random samples from a normal distribution
  • k_i : samples from the spectral density distribution of the covariance model
Attributes:
chunk_tmp_size

int: temporary chunk size

mode_no

int: The number of modes in the randomization method.

model

CovModel: The covariance model of the spatial random field.

name

str: The name of the generator

seed

int: the seed of the master RNG

verbose

bool: verbosity of the generator

Methods

__call__(x[, y, z]) Calculates the random modes for the randomization method.
reset_seed([seed]) Recalculate the random amplitudes and wave numbers with the given seed.
update([model, seed]) Update the model and the seed.
__call__(x, y=None, z=None)[source]

Calculates the random modes for the randomization method.

Parameters:
  • x (float, numpy.ndarray) – the x components of the position tuple, the shape has to be (len(x), 1, 1) for 3d and accordingly shorter for lower dimensions
  • y (float, numpy.ndarray, optional) – the y components of the pos. tupls
  • z (float, numpy.ndarray, optional) – the z components of the pos. tuple
Returns:

the random modes

Return type:

numpy.ndarray

reset_seed(seed=nan)[source]

Recalculate the random amplitudes and wave numbers with the given seed.

Parameters:seed (int or None or numpy.nan, optional) – the seed of the random number generator. If None, a random seed is used. If numpy.nan, the actual seed will be kept. Default: numpy.nan

Notes

Even if the given seed is the present one, modes will be racalculated.

update(model=None, seed=nan)[source]

Update the model and the seed.

If model and seed are not different, nothing will be done.

Parameters:
chunk_tmp_size

temporary chunk size

Type:int
mode_no

The number of modes in the randomization method.

Type:int
model

The covariance model of the spatial random field.

Type:CovModel
name

The name of the generator

Type:str
seed

the seed of the master RNG

Notes

If a new seed is given, the setter property not only saves the new seed, but also creates new random modes with the new seed.

Type:int
verbose

verbosity of the generator

Type:bool