gstools.field.generator.Fourier

class gstools.field.generator.Fourier(model, period, mode_no=32, seed=None, **kwargs)[source]

Bases: Generator

Fourier method for calculating periodic, isotropic random fields.

Parameters:
  • model (CovModel) – Covariance model

  • period (list or float) – The spatial periodicity of the field, is often the domain size.

  • mode_no (list or float, optional) – Number of Fourier modes per dimension.

  • seed (int, optional) – The seed of the random number generator. If “None”, a random seed is used. Default: None

  • **kwargs – Placeholder for keyword-args

Notes

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

\[u\left(x\right)= \sum_{i=1}^{N}\sqrt{2S(k_{i})\Delta k}\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:

  • \(S\) : spectrum of the covariance model

  • \(Z_{j,i}\) : random samples from a normal distribution

  • \(k_i\) : the equidistant Fourier grid

Attributes:
mode_no

numpy.ndarray: Number of modes per dimension.

model

CovModel: Covariance model of the spatial random field.

modes

numpy.ndarray: Modes on which the spectrum is calculated.

name

str: Name of the generator.

period

numpy.ndarray: Period length of the spatial random field.

seed

int: Seed of the master RNG.

value_type

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

Methods

__call__(pos[, add_nugget])

Calculate the modes for the Fourier method.

get_nugget(shape)

Generate normal distributed values for the nugget simulation.

reset_seed([seed])

Recalculate the random values with the given seed.

update([model, seed, period, mode_no])

Update the model and the seed.

__call__(pos, add_nugget=True)[source]

Calculate the modes for the Fourier method.

This method calls the summate_fourier Cython method, which is the heart of the Fourier method.

Parameters:
  • pos ((d, n), numpy.ndarray) – the position tuple with d dimensions and n points.

  • add_nugget (bool) – Whether to add nugget noise to the field.

Returns:

the random modes

Return type:

numpy.ndarray

get_nugget(shape)[source]

Generate normal distributed values for the nugget simulation.

Parameters:

shape (tuple) – the shape of the summed modes

Returns:

nugget – the nugget in the same shape as the summed modes

Return type:

numpy.ndarray

reset_seed(seed=nan)[source]

Recalculate the random values 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 recalculated.

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

Update the model and the seed.

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

Parameters:
  • model (CovModel or None, optional) – covariance model. Default: None

  • 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

  • period (list or :any:`None, optional) – The spatial periodicity of the field, is often the domain size.

  • mode_no (list or None, optional) – Number of Fourier modes per dimension.

property mode_no

Number of modes per dimension.

Type:

numpy.ndarray

property model

Covariance model of the spatial random field.

Type:

CovModel

property modes

Modes on which the spectrum is calculated.

Type:

numpy.ndarray

property name

Name of the generator.

Type:

str

property period

Period length of the spatial random field.

Type:

numpy.ndarray

property seed

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

property value_type

Type of the field values (scalar, vector).

Type:

str