RandomField#
- class pisces.math_utils.random_fields.RandomField(domain_dimensions: ndarray, bounding_box: ndarray, **kwargs)[source]#
Abstract base class for defining random fields in arbitrary dimensions.
This class provides a general framework for representing random fields on uniform grids. It encapsulates domain geometry, spatial and Fourier space utilities, and a standard interface for generating random field realizations.
Subclasses should implement
generate()
, which constructs a particular type of random field (e.g. Gaussian random field with a specified power spectrum).- Parameters:
domain_dimensions (
numpy.ndarray
ofint
) – Number of grid points along each axis of the domain. Must be a 1D array of length equal to the spatial dimensionality.bounding_box (
numpy.ndarray
) – The lower and upper bounds of the domain in each dimension. For example,[[x_min, y_min], [x_max, y_max]]
in 2D. The shape must be(2, ndim)
.rng (
numpy.random.Generator
, optional) – Random number generator instance. Defaults tonp.random.default_rng()
.
Notes
The class provides convenience methods to compute real-space grids (
compute_spatial_mgrid()
) and Fourier-space grids (compute_wavenumber_mgrid()
).This base class does not implement the actual random field generation logic; see
GaussianRandomField
for an example subclass.
Methods
__init__
(domain_dimensions, bounding_box, ...)Compute the meshgrid of spatial coordinates for the random field.
compute_spatial_mgrid
(**kwargs)Compute the meshgrid of spatial coordinates for the random field.
compute_wavenumber_arrays
([fft_type])Compute the 1D wavenumber arrays for each axis of the domain.
compute_wavenumber_mgrid
([fft_type])Compute the meshgrid of wavenumber arrays for the random field.
generate
(*args, **kwargs)Generate a realization of the random field.
Attributes
Bounding box of the random field.
Domain dimensions of the random field.
Alias for
grid_spacing
.Range of the grid in each dimension.
Spacing of the grid in each dimension.
Number of dimensions of the random field.