kspace.base_field.RandomField#

class kspace.base_field.RandomField(left_edge, right_edge, ddims, seed)[source]#

Bases: BaseField

Base class for fields generated from random realizations, adding a seeded random number generator on top of BaseField’s grid geometry.

Parameters:
  • left_edge (array-like) – The lower edge of the box [kpc] for each of the dimensions.

  • right_edge (array-like) – The upper edge of the box [kpc] for each of the dimensions.

  • ddims (array-like) – The number of grids in each of the axes.

  • seed (int, optional) – Random seed for reproducibility.

__init__(left_edge, right_edge, ddims, seed)[source]#

Methods

__init__(left_edge, right_edge, ddims, seed)

generate_scalar_field_realization([...])

Generate a random realization of the field as a scalar field.

generate_vector_field_realization([...])

Generate a random realization of the field as a vector field.

generate_scalar_field_realization(fourier_space=False)[source]#

Generate a random realization of the field as a scalar field. The shape of the array will be the size of the grid.

Parameters:

fourier_space (boolean, optional) – If True, return the field in Fourier space (i.e., the complex Fourier coefficients). If False, return the field in real space. Default is False.

generate_vector_field_realization(fourier_space=False, divergence_free=False)[source]#

Generate a random realization of the field as a vector field. The first index of the NumPy array will have the size of the dimension of the field (e.g., 3 for a 3D vector field), and the remaining indices will have the size of the grid.

Parameters:
  • fourier_space (boolean, optional) – If True, return the field in Fourier space (i.e., the complex Fourier coefficients). If False, return the field in real space. Default is False.

  • divergence_free (boolean, optional) – If True, generate a divergence-free vector field. Default is False.