Gaussian Random Field Generation#

See

class drdmannturb.GaussianRandomField(Covariance: Covariance, grid_level: ndarray, grid_shape: ndarray | None = None, grid_dimensions: ndarray = [1.0, 1.0, 1.0], ndim: int = 3, sampling_method: str = 'fft')[source]#

Generator for a discrete Gaussian random field: a random Gaussian variable at each point in a domain. Several sampling methods are provided by default:

  1. fft - usual Fast Fourier Transform

  2. fftw - “Fastest Fourier Transform in the West”

  3. vf_fftw - vector field version of Fastest Fourier Transform in the West

  4. dst - Discrete Sine Transform

  5. dct - Discrete Cosine Transform

Please refer to the sampling methods documentation for more details on each of these methods.

Parameters:
  • Covariance (Covariance) – An instantiation of one of the Covariance classes (VonKarman, Mann, or NN) provided in the package that subclass from the Covariance metaclass.

  • grid_level (np.ndarray) – Numpy array denoting the grid levels; number of discretization points used in each dimension, which evaluates as 2^k for each dimension for FFT-based sampling methods.

  • grid_shape (np.ndarray, optional) – _description_, by default None

  • grid_dimensions (np.ndarray, optional) – Numpy array denoting the grid size; the real dimensions of the domain of interest, by default [1.0, 1.0, 1.0]

  • ndim (int, optional) – Number of dimensions of the random field, by default 3, which is currently forced (only 3D field generation is implemented).

  • sampling_method (str, optional) – Sampling method to be used in correlating with field generated from underlying distribution (Gaussian), by default “fft”

Raises:

ValueErrorgrid_level and grid_shape must have the same dimensions.

reseed(seed=None)[source]#

Sets a new seed for the class’s PRNG.

Parameters:

seed (Seed value for PRNG, following ``np.RandomState()` conventions,`) – by default None

sample(noise: ndarray | None = None) ndarray[source]#

Samples the Gaussian Random Field with specified sampling method. Note this is not just what is sampled from the distribution; this field is also correlated with the covariance kernel provided during construction.

Parameters:

noise (Optional[np.ndarray], optional) – Random field from underlying distribution, by default None, which results in an additional sampling of the domain from the distribution.

Returns:

np.ndarray – Sampled grid from distribution.

Raises:

Exception – If Sampling method has not been set already.

Return type:

ndarray

sample_noise(grid_shape: ndarray | None = None) ndarray[source]#

Samples random grid from specified distribution (currently only a Gaussian).

Parameters:

grid_shape (Optional[np.ndarray], optional) – Number of grid points in each dimension, by default None, which results in a field over the grid determined during construction of this object.

Returns:

np.ndarray – Sampled random values from underlying distribution of size matching the given grid shape.

Return type:

ndarray

setSamplingMethod(method: str)[source]#

Initialize the sampling method

Parameters:

method (str) – One of “fft”, “dst”, “dct”, “fftw”, “vf_fftw”; see Sampling methods.

Raises:

Exception – If method is not one of the above.

class drdmannturb.VectorGaussianRandomField(vdim=3, **kwargs)[source]#

Gaussian random vector field generator

Constructor for vector of GRFs in specified number of dimensions (presently only 3). kwargs must contain all information required by GaussianRandomField.

Parameters:

vdim (int, optional) – Dimension count of vector of GRF, by default 3