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 modelperiod (
list
orfloat
) – The spatial periodicity of the field, is often the domain size.mode_no (
list
orfloat
, 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:
- 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:
- reset_seed(seed=nan)[source]
Recalculate the random values with the given seed.
- Parameters:
seed (
int
orNone
ornumpy.nan
, optional) – the seed of the random number generator. IfNone
, a random seed is used. Ifnumpy.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
orNone
, optional) – covariance model. Default:None
seed (
int
orNone
ornumpy.nan
, optional) – the seed of the random number generator. IfNone
, a random seed is used. Ifnumpy.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
orNone
, optional) – Number of Fourier modes per dimension.
- property mode_no
Number of modes per dimension.
- Type:
- property modes
Modes on which the spectrum is calculated.
- Type:
- property period
Period length of the spatial random field.
- Type:
- 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: