cosmo_functions#

class cosmicjellyfish.cosmology.cosmology.cosmo_functions(cosmopars, input=None, *, configuration=None)[source]#

Bases: object

Hubble(z, physical=False)[source]#

Hubble function

Parameters:
  • z (float) – redshift

  • physical (bool) – Default False, if True, return H(z) in (km/s/Mpc).

Returns:

Hubble function values (Mpc^-1) at the redshifts of the input redshift

Return type:

float

E_hubble(z)[source]#

E(z) dimensionless Hubble function

Parameters:

z (float) – redshift

Returns:

Dimensionless E(z) Hubble function values at the redshifts of the input redshift

Return type:

float

angdist(z)[source]#

Angular diameter distance

Parameters:

z (float) – redshift

Returns:

Angular diameter distance values at the redshifts of the input redshift

Return type:

float

matpow(z, k, nonlinear=False, tracer='matter')[source]#

Calculates the power spectrum of a given tracer quantity at a specific redshift and wavenumber.

Parameters:
  • z (float) – The redshift of interest.

  • k (array_like) – An array of wavenumbers at which to compute the power spectrum. These must be in units of 1/Mpc and should be sorted in increasing order.

  • nonlinear (bool, optional) – A boolean indicating whether or not to include nonlinear corrections to the matter power spectrum. The default value is False.

  • tracer (str, optional) – A string indicating which trace quantity to use for computing the power spectrum. If this argument is “matter” or anything other than “clustering”, the power spectrum functions Pmm will be used to compute the power spectrum. If the argument is “clustering”, the power spectrum function Pcb will be used instead. The default value is “matter”.

Returns:

Array containing the calculated power spectrum values.

Return type:

np.ndarray

Warning

If tracer is not “matter” or “clustering”, a warning message is printed to the console saying the provided tracer was not recognized and the function defaults to using Pmm to calculate the power spectrum of matter.

Pmm(z, k, nonlinear=False)[source]#

Compute the power spectrum of the total matter species (MM) at a given redshift and wavenumber.

Parameters:
  • self – An instance of the current class.

  • z – The redshift at which to compute the MM power spectrum.

  • k – The wavenumber at which to compute the MM power spectrum in 1/Mpc.

  • nonlinear (bool, optional) – If True, include nonlinear effects in the computation. Default is False.

Returns:

The value of the MM power spectrum at the given redshift and wavenumber.

Return type:

float

Pcb(z, k, nonlinear=False)[source]#

Compute the power spectrum of the clustering matter species (CB) at a given redshift and wavenumber.

Parameters:
  • self – An instance of the current class.

  • z – The redshift at which to compute the CB power spectrum.

  • k – The wavenumber at which to compute the CB power spectrum in 1/Mpc.

  • nonlinear (bool, optional) – If True, include nonlinear effects in the computation. Default is False.

Returns:

The value of the CB power spectrum at the given redshift and wavenumber.

nonwiggle_pow(z, k, nonlinear=False, tracer='matter')[source]#

Calculate the power spectrum at a specific redshift and wavenumber, after smoothing to remove baryonic acoustic oscillations (BAO).

Parameters:
  • z – The redshift of interest.

  • k – An array of wavenumbers at which to compute the power spectrum. Must be in units of Mpc^-1/h. Should be sorted in increasing order.

  • nonlinear (default: False) – Whether to include nonlinear corrections to the matter power spectrum. Default is False.

  • tracer (default: 'matter') – Which perturbations to use for computing the power spectrum. Options are ‘matter’ or ‘clustering’. Default is ‘matter’.

Returns:

An array of power spectrum values corresponding to the input wavenumbers. Units are (Mpc/h)^3.

Note

This function computes the power spectrum of a given tracer quantity at a specific redshift, using the matter power spectrum function matpow. It then applies a Savitzky-Golay filter to smooth out the BAO features in the power spectrum. This is done by first taking the natural logarithm of the power spectrum values at a set of logarithmic wavenumbers spanning from kmin_loc to kmax_loc. The smoothed power spectrum is then returned on a linear (not logarithmic) grid of wavenumbers given by the input array k.

comoving(z)[source]#

Comoving distance

Parameters:

z (float) – redshift

Returns:

Comoving distance values at the redshifts of the input redshift

Return type:

float

sigma8_of_z(z, tracer='matter')[source]#

sigma_8

Parameters:
  • z (float) – redshift

  • tracer (String) – either ‘matter’ if you want sigma_8 calculated from the total matter power spectrum or ‘clustering’ if you want it from the Powerspectrum with massive neutrinos substracted

Returns:

The Variance of the matter perturbation smoothed over a scale of 8 Mpc/h

Return type:

float

growth(z, k=None)[source]#

Growth factor

Parameters:

z (float) – redshift

Returns:

Growth factor values at the redshifts of the input redshift

Return type:

float

Omegam_of_z(z)[source]#

Omega matter fraction as a function of redshift

Parameters:

z (float) – redshift

Returns:

Omega matter (total) at the redshifts of the input redshift z

Return type:

float

Note

Assumes standard matter evolution Implements the following equation:

\[Omega_m(z) = Omega_{m,0}*(1+z)^3 / E^2(z)\]
f_growthrate(z, k=None, gamma=False, tracer='matter')[source]#

Growth rate in LCDM gamma approximation

Parameters:

z (float) – redshift

Returns:

Growth rate values at the redshifts of the input redshift, using self.gamma as gamma value.

Return type:

float

Note

Implements the following equation:

\[f(z) = Omega_m(z)^{\gamma}\]
fsigma8_of_z(z, k=None, gamma=False, tracer='matter')[source]#

Growth rate in LCDM gamma approximation

Parameters:

z (float) – redshift

Returns:

Growth rate values at the redshifts of the input redshift, using self.gamma as gamma value.

Return type:

float

Note

Implements the following equation:

\[f(z) = Omega_m(z)^{\gamma}\]
SigmaMG(z, k)[source]#

Compute the modified growth rate Sigma for modified gravity models.

Parameters:
Returns:

Modified growth rate Sigma

Return type:

float

cmb_power(lmin, lmax, obs1, obs2)[source]#

Compute the CMB power spectrum.

Parameters:
  • lmin (int) – Minimum multipole moment

  • lmax (int) – Maximum multipole moment

  • obs1 (str) – First observable (e.g., ‘CMB_TCMB_T’)

  • obs2 (str) – Second observable (e.g., ‘CMB_ECMB_E’)

Returns:

Array of CMB power spectrum values

Return type:

np.ndarray

static scale_factor(z)[source]#

Compute the scale factor a from redshift z.

Parameters:

z (float or array-like) – Redshift

Returns:

Scale factor a

Return type:

float or array-like