zeus21.cosmology
Cosmology functions and helper tools related with cosmology.
- Authors: zeus21 v2 collaboration - June 2026
Emily Bregou ; Hector Afonso G. Cruz ; Sarah Libanore ; Julian B. Muñoz ; Yonny Sklansky ; Emilie Thélie ; Alessandra Venditti
arXiv:2302.08506, arXiv:2306.09403, arXiv:2407.18294, Sklansky et al. (in prep)
Classes
Class that builds an interpolator of the HMF as function of the halo mass and redshift. |
Functions
|
Returns the age of the Universe (in Gyrs) corresponding to a given redshift. |
|
Returns the redshift corresponding to a given age of the Universe (in Gyrs). |
|
Hubble parameter H(z). |
|
Converts Hubble parameter H(z) in inverse length units (1/Mpc). |
|
Converts Hubble parameter H(z) in inverse time units (1/yr). |
|
Baryon density rho_baryon(z). |
|
Number density of hydrogen nuclei (including both neutral or ionized). |
|
CMB temperature T(z). |
|
Returns T_adiabatic as a function of z from thermodynamics in CLASS. |
|
Electron fraction x_e(z) without any sources. |
Returns adiabatic index (delta_Tad/delta) as a function of z. Fit from 1506.04152. to ~3% on z = 6 − 50). |
|
|
Convert input comoving Radius to virial Mass. |
|
Convert input virial Mass to comoving Radius. |
|
Sheth-Tormen Halo Mass Function. |
|
Tinker 2008 Halo Mass Function. |
|
Fit in eq A2 in Yung+23 (2309.14408) to z < 20. |
|
Unnormalized Press-Schechter HMF. |
|
Interpolator to find the scale-independent growth factor. |
|
Derivative of growth factor w.r.t. z. |
|
Redshift associated with the given comoving distance in the input cosmology. |
|
Comoving distance associated with given redshift in the input cosmology. |
|
Prefactor in mK to T21 that only depends on cosmological parameters and z. See Eq.(21) in 2110.13919 |
|
Bias of halos in the Sheth-Tormen model. |
|
Bias of halos in the Tinker model. See https://arxiv.org/pdf/1001.3162.pdf for Delta = 200 |
Module Contents
- zeus21.cosmology.time_at_redshift(ClassyCosmo, z)[source]
Returns the age of the Universe (in Gyrs) corresponding to a given redshift.
- Parameters:
ClassyCosmo (zeus21.runclass class) – Sets up Class cosmology.
z (float) – Redshift.
- Returns:
Age of the Universe in Gyrs.
- Return type:
float
- zeus21.cosmology.redshift_at_time(ClassyCosmo, t)[source]
Returns the redshift corresponding to a given age of the Universe (in Gyrs).
- Parameters:
ClassyCosmo (zeus21.runclass class) – Sets up Class cosmology.
t (float) – Age in Gyrs.
- Returns:
Redshift corresponding to the given age of the Universe.
- Return type:
float
- zeus21.cosmology.Hub(CosmoParams, z)[source]
Hubble parameter H(z).
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters.
z (float) – Redshift.
- Returns:
Hubble parameter H(z) in km/s/Mpc.
- Return type:
float
- zeus21.cosmology.HubinvMpc(CosmoParams, z)[source]
Converts Hubble parameter H(z) in inverse length units (1/Mpc).
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters.
z (float) – Redshift.
- Returns:
Hubble parameter H(z) in 1/Mpc.
- Return type:
float
- zeus21.cosmology.Hubinvyr(CosmoParams, z)[source]
Converts Hubble parameter H(z) in inverse time units (1/yr).
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters.
z (float) – Redshift.
- Returns:
Hubble parameter H(z) in 1/yr.
- Return type:
float
- zeus21.cosmology.rho_baryon(CosmoParams, z)[source]
Baryon density rho_baryon(z).
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters.
z (float) – Redshift.
- Returns:
Baryon density rho_baryon(z) in Msun/Mpc^3.
- Return type:
float
- zeus21.cosmology.n_H(CosmoParams, z)[source]
Number density of hydrogen nuclei (including both neutral or ionized).
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters.
z (float) – Redshift.
- Returns:
Number density of hydrogen nuclei in 1/cm^3.
- Return type:
float
- zeus21.cosmology.Tcmb(ClassCosmo, z)[source]
CMB temperature T(z).
- Parameters:
ClassCosmo (ClassCosmo) – CLASS cosmology object.
z (float) – Redshift.
- Returns:
CMB temperature T(z) in K.
- Return type:
float
- zeus21.cosmology.Tadiabatic(CosmoParams, z)[source]
Returns T_adiabatic as a function of z from thermodynamics in CLASS.
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters.
z (float) – Redshift.
- Returns:
Adiabatic temperature T_adiabatic(z).
- Return type:
float
- zeus21.cosmology.xefid(CosmoParams, z)[source]
Electron fraction x_e(z) without any sources. Uses thermodynamics in CLASS for z>15, and fixed below to avoid the tanh approximation.
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters.
z (float) – Redshift.
- Returns:
Fiducial x_e(z).
- Return type:
float
- zeus21.cosmology.adiabatic_index(z)[source]
Returns adiabatic index (delta_Tad/delta) as a function of z. Fit from 1506.04152. to ~3% on z = 6 − 50).
- Parameters:
z (float) – Redshift.
- Returns:
Adiabatic index (delta_Tad/delta).
- Return type:
float
- zeus21.cosmology.MhofRad(CosmoParams, R)[source]
Convert input comoving Radius to virial Mass.
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters.
R (float) – Comoving radius in cMpc.
- Returns:
Mass in Msun.
- Return type:
float
- zeus21.cosmology.RadofMh(CosmoParams, M)[source]
Convert input virial Mass to comoving Radius.
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters.
M (float) – Virial mass in Msun.
- Returns:
Comoving radius in cMpc.
- Return type:
float
- zeus21.cosmology.ST_HMF(CosmoParams, Mass, sigmaM, dsigmadM)[source]
Sheth-Tormen Halo Mass Function.
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters.
Mass (float) – Halo mass in Msun.
sigmaM (float) – Variance of the density field on the scale of the halo mass.
dsigmadM (float) – Derivative of sigmaM with respect to Mass.
- Returns:
HMF value in 1/Mpc^3/Msun.
- Return type:
float
- zeus21.cosmology.Tink_HMF(CosmoParams, Mass, sigmaM, dsigmadM, z)[source]
Tinker 2008 Halo Mass Function. All in physical (no h) units. Form from App.A of Yung+23 (2309.14408).
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters.
Mass (float) – Halo mass in Msun.
sigmaM (float) – Variance of the density field on the scale of the halo mass at redshift z.
dsigmadM (float) – Derivative of sigmaM with respect to Mass at redshift z.
z (float) – Redshift.
- Returns:
HMF value in 1/Mpc^3/Msun.
- Return type:
float
- zeus21.cosmology.f_GUREFT_physical(sigmaM, z)[source]
Fit in eq A2 in Yung+23 (2309.14408) to z < 20. Required by the Tinker 2008 HMF; all in physical units (no h). Implementation thanks to Aaron Yung.
- Parameters:
sigmaM (float) – Variance of the density field on the scale of the halo mass at redshift z.
z (float) – Redshift.
- Returns:
HMF value in 1/Mpc^3/Msun.
- Return type:
float
- zeus21.cosmology.PS_HMF_unnorm(CosmoParams, Mass, nu, dlogSdM)[source]
Unnormalized Press-Schechter HMF. Used to emulate 21cmFAST.
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters.
Mass (float) – Halo mass in Msun.
nu (float) – Peak height, defined as nu = delta_tilde/S_tilde, with delta_tilde = delta_crit - delta_R, and variance S = sigma(M)^2 - sigma(R)^2.
dlogSdM (float) – Derivative of log(S) with respect to Mass, where S = sigma(M)^2 - sigma(R)^2.
- Returns:
HMF value in 1/Mpc^3/Msun.
- Return type:
float
- class zeus21.cosmology.HMF_interpolator(UserParams, CosmoParams)[source]
Class that builds an interpolator of the HMF as function of the halo mass and redshift.
- Parameters:
UserParams (UserParams) – User parameters, used to set the resolution of the HMF table.
CosmoParams (CosmoParams) – Cosmological parameters, used to compute the HMF table with CLASS.
- HMF_int[source]
Interpolator for HMF value, takes (Mass, z) as arguments
- Type:
RegularGridInterpolator
- sigma_int[source]
Interpolator for sigma value, takes (Mass, z) as arguments
- Type:
RegularGridInterpolator
- sigmaR_int[source]
Interpolator for sigma(R) value, takes (R, z) as arguments
- Type:
RegularGridInterpolator
- dsigmadM_int[source]
Interpolator for dsigma/dM value, takes (Mass, z) as arguments
- Type:
RegularGridInterpolator
- HMF_int(Mh, z)[source]
Interpolator to find HMF(M,z).
- Parameters:
Mh (float or array) – Halo mass in Msun. Can be a single value or an array of values.
z (float)
- Returns:
Interpolator for HMF value, takes (Mass, z) as arguments.
- Return type:
float
- sigma_int(Mh, z)[source]
Interpolator to find sigma(M,z).
- Parameters:
Mh (float or array) – Halo mass in Msun. Can be a single value or an array of values.
z (float)
- Returns:
Interpolator for sigma value, takes (Mass, z) as arguments.
- Return type:
float
- zeus21.cosmology.growth(CosmoParams, z)[source]
Interpolator to find the scale-independent growth factor.
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters, used to compute the growth factor with CLASS.
z (float) – Redshift.
- Returns:
Interpolator for the scale-independent growth factor, takes z as argument.
- Return type:
float
- zeus21.cosmology.dgrowth_dz(CosmoParams, z)[source]
Derivative of growth factor w.r.t. z.
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters, used to compute the growth factor with CLASS.
z (float) – Redshift.
- Returns:
dgrowth/dz
- Return type:
float
- zeus21.cosmology.redshift_of_chi(CosmoParams, chi)[source]
- Redshift associated with the given comoving distance in the input cosmology.
This function is not used inside the code but is provided for users
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters, used to compute the growth factor with CLASS.
chi (float) – Comoving distance from today in Mpc
- Returns:
z – Redshift
- Return type:
float
- zeus21.cosmology.chi_of_redshift(CosmoParams, z)[source]
Comoving distance associated with given redshift in the input cosmology. This function is not used inside the code but is provided for users
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters, used to compute the growth factor with CLASS.
z (float) – Redshift
- Returns:
chi – Comoving distance from today in Mpc
- Return type:
float
- zeus21.cosmology.T021(CosmoParams, z)[source]
Prefactor in mK to T21 that only depends on cosmological parameters and z. See Eq.(21) in 2110.13919
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters, used to compute the growth factor with CLASS.
z (float) – Redshift.
- Returns:
Prefactor in mK to T21
- Return type:
float
- zeus21.cosmology.bias_ST(CosmoParams, sigmaM)[source]
Bias of halos in the Sheth-Tormen model. See https://arxiv.org/pdf/1007.4201.pdf Table 1
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters, used to compute the growth factor with CLASS.
sigmaM (float) – Variance of the matter density field smoothed on a scale corresponding to the halo mass.
- Returns:
Halo bias
- Return type:
float
- zeus21.cosmology.bias_Tinker(CosmoParams, sigmaM)[source]
Bias of halos in the Tinker model. See https://arxiv.org/pdf/1001.3162.pdf for Delta = 200
- Parameters:
CosmoParams (CosmoParams) – Cosmological parameters, used to compute the growth factor with CLASS.
sigmaM (float) – Variance of the matter density field smoothed on a scale corresponding to the halo mass.
- Returns:
Halo bias
- Return type:
float