Simulation#

This module compute quantities from data of simulations.

pyexshalos.simulation.Compute_Abundance(Mh: ndarray, Mmin: float | None = None, Mmax: float | None = None, Nm: int = 25, Lc: float = 2.0, nd: int = 256, ndx: int | None = None, ndy: int | None = None, ndz: int | None = None, verbose: bool = False) Dict[str, ndarray]#

Compute the abundance from an array of masses.

Parameters:
  • Mh (numpy.ndarray) – Mass of each halo.

  • Mmin (Optional[float]) – Minimum mass used to construct the mass bins. Fiducial value: None

  • Mmax (Optional[float]) – Maximum mass used to construct the mass bins. Fiducial value: None

  • Nm (int) – Number of mass bins. Fiducial value: 25

  • Lc (float) – Size of each cell in Mpc/h. Fiducial value: 2.0

  • nd (int) – Number of cells in each direction. Fiducial value: 256

  • ndx (Optional[int]) – Number of cells in the x direction. Fiducial value: None

  • ndy (Optional[int]) – Number of cells in the y direction. Fiducial value: None

  • ndz (Optional[int]) – Number of cells in the z direction. Fiducial value: None

  • verbose (bool) – Whether to output information in the C code. Fiducial value: False

Returns:

Dictionary with the following keys:

  • ”Mh”: Ndarray with the mean mass in the bin

  • ”dn”: Ndarray with differential abundance in the bin

  • ”dn_err”: Ndarray with the error in the differential abundance in the bin

Return type:

dict

pyexshalos.simulation.Compute_BiSpectrum(grid: ndarray, L: float = 1000.0, window: str | int = 'CIC', R: float = 4.0, Nk: int = 25, k_min: float | None = None, k_max: float | None = None, folds: int = 1, verbose: bool = False, nthreads: int = 1, ntypes: int = 1) Dict[str, ndarray]#

Compute the bispectrum from a density grid.

Parameters:
  • grid (numpy.ndarray) – Density grid for all tracers.

  • L (float) – Size of the box in Mpc/h. Fiducial value: 1000.0

  • window (Union[str, int]) – Density assignment method used to construct the density grid. Fiducial value: “CIC” (Options: “NGP” = 0, “CIC” = 1, “SPHERICAL” = 2, “EXPONENTIAL” = 3)

  • R (float) – Smoothing length used in the spherical and exponential windows. Fiducial value: 4.0

  • Nk (int) – Number of bins in k to compute the tri-spectra. Fiducial value: 25

  • k_min (Optional[float]) – Minimum value of k to compute the tri-spectra. Fiducial value: None

  • k_max (Optional[float]) – Maximum value of k to compute the tri-spectra. Fiducial value: None

  • folds (int) – Number of times that the box was folded in each direction. Fiducial value: 1

  • verbose (bool) – Whether to output information in the C code. Fiducial value: False

  • nthreads (int) – Number of threads used by OpenMP. Fiducial value: 1

  • ntypes (int) – Number of different types of tracers. Fiducial value: 1

Returns:

Dictionary with the following keys:

  • ”kP”: Ndarray with the mean wavenumbers

  • ”Pk”: Ndarray with all possible power spectra

  • ”Nk”: Ndarray with the number of independent modes per bin

  • ”kB”: Ndarray with the mean tripets of k for the bispectra

  • ”Bk”: Ndarray with all possible bispectra

  • ”Ntri”: Number of independent triangles in each bin

Return type:

dict

pyexshalos.simulation.Compute_Bias_Jens(grid: ndarray, Mh: ndarray, flag: ndarray, Mmin: float | None = None, Mmax: float | None = None, Nm: int = 20, dmin: float = -1.0, dmax: float = 1.0, Nbins: int = 200, Lambda: float | None = None, Lc: float = 2.0, Central: bool = True, Normalized: bool = False) Dict[str, ndarray]#

Compute the bias of halos using Jens’ method.

Parameters:
  • grid (numpy.ndarray) – Linear (initial) density grid.

  • Mh (numpy.ndarray) – Mass of all halos.

  • flag (numpy.ndarray) – Flag of all grid cells as being part of a trace or not.

  • Mmin (Optional[float]) – Minimum halo mass to be considered. Fiducial value: None

  • Mmax (Optional[float]) – Maximum halo mass to be considered. Fiducial value: None

  • Nm (int) – Number of bins in mass. Fiducial value: 20

  • dmin (float) – Minimum density to be used in the construction of the histograms in delta. Fiducial value: -1.0

  • dmax (float) – Maximum density to be used in the construction of the histograms in delta. Fiducial value: 1.0

  • Nbins (int) – Number of bins to be used in the construction of the histograms in delta. Fiducial value: 200

  • Lambda (Optional[float]) – Scale used to smooth the density field. Fiducial value: None

  • Lc (float) – Size of the cells of the grid. Fiducial value: 2.0

  • Central (bool) – Whether to use only the central particle of the halo. Fiducial value: True

  • Normalized (bool) – Whether to output the normalized PDF. Fiducial value: False

Returns:

Dictionay with the following keys:

  • ”delta”: Ndarray

  • ”Mh”: Ndarray

  • ”Unmasked”: Ndarray

  • ”Masked”: Ndarray

Return type:

dict

pyexshalos.simulation.Compute_Density_Grid(pos: ndarray, vel: ndarray | None = None, mass: ndarray | None = None, types: ndarray | None = None, nd: int = 256, L: float = 1000.0, Om0: float = 0.31, z: float = 0.0, direction: int | None = None, window: str | int = 'CIC', R: float = 4.0, R_times: float = 5.0, interlacing: bool = False, folds: int = 1, verbose: bool = False, nthreads: int = 1) ndarray#

Compute the density grid of a set of tracers.

Parameters:
  • pos (numpy.ndarray) – Position of the tracers.

  • vel (Optional[numpy.ndarray]) – Velocities of the particles in the given direction. Fiducial value: None

  • mass (Optional[numpy.ndarray]) – Weight of each tracer. Fiducial value: None

  • types (Optional[numpy.ndarray]) – Type of each tracer. Fiducial value: None

  • nd (int) – Number of cells per dimension. Fiducial value: 256

  • L (float) – Size of the box in Mpc/h. Fiducial value: 1000.0

  • Om0 (float) – Value of the matter overdensity today. Fiducial value: 0.31

  • z (float) – Redshift of the density grid. Fiducial value: 0.0

  • direction (Optional[int]) – Direction to use to put the particles in redshift space. Fiducial value: None

  • window (Union[str, int]) – Density assignment method used to construct the density grid. Fiducial value: “CIC” (Options: “NGP” = 0, “CIC” = 1, “SPHERICAL” = 2, “EXPONENTIAL” = 3)

  • R (float) – Smoothing length used in the spherical and exponential windows. Fiducial value: 4.0

  • R_times (float) – Scale considered to account for particles (used in the exponential window) in units of R. Fiducial value: 5.0

  • interlacing (bool) – Whether to use or do not use the interlacing technique. Fiducial value: False

  • folds (int) – Number of times that the box will be folded in each direction. Fiducial value: 1

  • verbose (bool) – Whether to output information in the C code. Fiducial value: False

  • nthreads (int) – Number of threads used by OpenMP. Fiducial value: 1

Returns:

The density grid for each type of tracer and for the grids with and without interlacing (if interlacing is True).

Return type:

numpy.ndarray

pyexshalos.simulation.Compute_Power_Spectrum(grid: ndarray, L: float = 1000.0, window: str | int = 'CIC', R: float = 4.0, Nk: int = 25, k_min: float | None = None, k_max: float | None = None, l_max: int = 0, direction: str | int | None = None, folds: int = 1, verbose: bool = False, nthreads: int = 1, ntypes: int = 1) Dict[str, ndarray]#

Compute the power spectrum from a density grid.

Parameters:
  • grid (numpy.ndarray) – Density grid for all tracers.

  • L (float) – Size of the box in Mpc/h. Fiducial value: 1000.0

  • window (Union[str, int]) – Density assignment method used to construct the density grid. Fiducial value: “CIC” (Options: “NGP” = 0, “CIC” = 1, “SPHERICAL” = 2, “EXPONENTIAL” = 3)

  • R (float) – Smoothing length used in the spherical and exponential windows. Fiducial value: 4.0

  • Nk (int) – Number of bins in k to compute the power spectra. Fiducial value: 25

  • k_min (Optional[float]) – Minimum value of k to compute the power spectra. Fiducial value: None

  • k_max (Optional[float]) – Maximum value of k to compute the power spectra. Fiducial value: None

  • l_max (int) – Maximum multipole computed. Fiducial value: 0

  • direction (Optional[Union[str, int]]) – Direction to use to put the particles in redshift space. Fiducial value: None

  • folds (int) – Number of times that the box was folded in each direction. Fiducial value: 1

  • verbose (bool) – Whether to output information in the C code. Fiducial value: False

  • nthreads (int) – Number of threads used by OpenMP. Fiducial value: 1

  • ntypes (int) – Number of different types of tracers. Fiducial value: 1

Returns:

Dictionary with the following keys:

  • ”k”: Ndarray with the mean wavenumbers

  • ”Pk”: Ndarray with all possible power spectra

  • ”Nk”: Ndarray with the number of independent modes per bin

Return type:

dict

pyexshalos.simulation.Compute_Power_Spectrum_individual(grid: ndarray, pos: ndarray, L: float = 1000.0, window: str | int = 'CIC', R: float = 4.0, Nk: int = 25, k_min: float | None = None, k_max: float | None = None, l_max: int = 0, direction: str | int | None = None, folds: int = 1, verbose: bool = False, nthreads: int = 1, ntypes: int = 1) Dict[str, ndarray]#

Compute the power spectrum for individual tracers from a density grid.

Parameters:
  • grid (numpy.ndarray) – Density grid for all tracers.

  • pos (numpy.ndarray) – Position of the tracers.

  • L (float) – Size of the box in Mpc/h. Fiducial value: 1000.0

  • window (Union[str, int]) – Density assignment method used to construct the density grid. Fiducial value: “CIC” (Options: “NGP” = 0, “CIC” = 1, “SPHERICAL” = 2, “EXPONENTIAL” = 3)

  • R (float) – Smoothing length used in the spherical and exponential windows. Fiducial value: 4.0

  • Nk (int) – Number of bins in k to compute the power spectra. Fiducial value: 25

  • k_min (Optional[float]) – Minimum value of k to compute the power spectra. Fiducial value: None

  • k_max (Optional[float]) – Maximum value of k to compute the power spectra. Fiducial value: None

  • l_max (int) – Maximum multipole computed. Fiducial value: 0

  • direction (Optional[Union[str, int]]) – Direction to use to put the particles in redshift space. Fiducial value: None

  • folds (int) – Number of times that the box will be folded in each direction. Fiducial value: 1

  • verbose (bool) – Whether to output information in the C code. Fiducial value: False

  • nthreads (int) – Number of threads used by OpenMP. Fiducial value: 1

  • ntypes (int) – Number of different types of tracers. Fiducial value: 1

Returns:

Dictionary with the following keys:

  • ”k”: Ndarray with the mean wavenumbers

  • ”Pk”: Ndarray with all possible power spectra

  • ”Nk”: Ndarray with the number of independent modes per bin

Return type:

dict

pyexshalos.simulation.Compute_TriSpectrum(grid: ndarray, L: float = 1000.0, window: str | int = 'CIC', R: float = 4.0, Nk: int = 25, k_min: float | None = None, k_max: float | None = None, folds: int = 1, verbose: bool = False, nthreads: int = 1, ntypes: int = 1) Dict[str, ndarray]#

Compute the trispectrum from a density grid.

Parameters:
  • grid (numpy.ndarray) – Density grid for all tracers.

  • L (float) – Size of the box in Mpc/h. Fiducial value: 1000.0

  • window (Union[str, int]) – Density assignment method used to construct the density grid. Fiducial value: “CIC” (Options: “NGP” = 0, “CIC” = 1, “SPHERICAL” = 2, “EXPONENTIAL” = 3)

  • R (float) – Smoothing length used in the spherical and exponential windows. Fiducial value: 4.0

  • Nk (int) – Number of bins in k to compute the tri-spectra. Fiducial value: 25

  • k_min (Optional[float]) – Minimum value of k to compute the tri-spectra. Fiducial value: None

  • k_max (Optional[float]) – Maximum value of k to compute the tri-spectra. Fiducial value: None

  • folds (int) – Number of times that the box was folded in each direction. Fiducial value: 1

  • verbose (bool) – Whether to utput information in the C code. Fiducial value: False

  • nthreads (int) – Number of threads used by OpenMP. Fiducial value: 1

  • ntypes (int) – Number of different types of tracers. Fiducial value: 1

Returns:

Dictionary with the following keys:

  • ”kP”: Ndarray with the mean wavenumbers

  • ”Pk”: Ndarray with all possible power spectra

  • ”Nk”: Ndarray with the number of independent modes per bin

  • ”kT”: Ndarray with the mean duplets of k for the trispectra

  • ”Tk”: Ndarray with all possible trispectra

  • ”Tuk”: Ndarray with all possible unconnected trispectr

  • ”Nsq”: Number of independent tetrahedra in each bin

Return type:

dict