gstools.field.generator¶
GStools subpackage providing generators for spatial random fields.
The following classes are provided
RandMeth (model[, mode_no, seed, verbose]) |
Randomization method for calculating isotropic spatial random fields. |
IncomprRandMeth (model[, mean_velocity, …]) |
RandMeth for incompressible random vector fields. |
-
class
gstools.field.generator.
RandMeth
(model, mode_no=1000, seed=None, verbose=False, **kwargs)[source]¶ Bases:
object
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
orNone
, optional) – The seed of the random number generator. If “None”, a random seed is used. Default:None
- verbose (
bool
, optional) – Be chatty 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:
where:
- : fourier mode number
- : random samples from a normal distribution
- : samples from the spectral density distribution of the covariance model
Attributes: Methods
__call__
(x[, y, z, mesh_type])Calculate 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, mesh_type='unstructured')[source]¶ Calculate the random modes for the randomization method.
This method calls the summate_* Cython methods, which are the heart of the randomization method.
Parameters: - x (
float
,numpy.ndarray
) – The x components of the pos. tuple. - y (
float
,numpy.ndarray
, optional) – The y components of the pos. tuple. - z (
float
,numpy.ndarray
, optional) – The z components of the pos. tuple. - mesh_type (
str
, optional) – ‘structured’ / ‘unstructured’
Returns: the random modes
Return type: - x (
-
reset_seed
(seed=nan)[source]¶ Recalculate the random amplitudes and wave numbers 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)[source]¶ Update the model and the seed.
If model and seed are not different, nothing will be done.
Parameters:
- model (
-
class
gstools.field.generator.
IncomprRandMeth
(model, mean_velocity=1.0, mode_no=1000, seed=None, verbose=False, **kwargs)[source]¶ Bases:
gstools.field.generator.RandMeth
RandMeth for incompressible random vector fields.
Parameters: - model (
CovModel
) – covariance model - mean_velocity (
float
, optional) – the mean velocity in x-direction - mode_no (
int
, optional) – number of Fourier modes. Default:1000
- seed (
int
orNone
, optional) – the seed of the random number generator. If “None”, a random seed is used. Default:None
- 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 incompressible random vector fields characterized by a given covariance model. The equation is:
where:
- : mean velocity in direction
- : fourier mode number
- : random samples from a normal distribution
- : samples from the spectral density distribution of the covariance model
- : the projector ensuring the incompressibility
Attributes: Methods
__call__
(x[, y, z, mesh_type])Calculate 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, mesh_type='unstructured')[source]¶ Calculate the random modes for the randomization method.
This method calls the summate_incompr_* Cython methods, which are the heart of the randomization method. In this class the method contains a projector to ensure the incompressibility of the vector field.
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. tuples. Default:None
- z (
float
,numpy.ndarray
, optional) – the z components of the pos. tuple. Default:None
- mesh_type (
str
, optional) – ‘structured’ / ‘unstructured’
Returns: the random modes
Return type: - x (
-
reset_seed
(seed=nan)¶ Recalculate the random amplitudes and wave numbers 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)¶ Update the model and the seed.
If model and seed are not different, nothing will be done.
Parameters:
- model (