API Reference¶
cloelib¶
cosmology
¶
Cosmology package of cloelib.
The package provides interface with external Boltzmann solvers or emulators via Python Protocols following the cosmology.API. Core structure enables defining Background & Perturbation models.
Supported External Codes:
- Background:
camb,class - Perturbations:
camb,class,HMCode2020emu,euclidemu2,baccoemu
EE2_cosmology
¶
Implementation of Background and Perturbation cosmology using EuclidEmulator2.
EE2NonLinearPerturbations
¶
EE2NonLinearPerturbations(background: Background, linearperturbations: Perturbations, redshifts: ndarray)
Class for nonlinear perturbations using EE2, compatible with the Perturbations protocol.
matter_power_spectrum
¶
matter_power_spectrum_cb
¶
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
.. math:: D(z, k) =\sqrt{P_{\rm \delta\delta}(z, k)\ /P_{\rm \delta\delta}(z=0, k)}\
and normalizes as for :math:D(z)/D(0).
We use here the growth from the fluctuations without baryons.
Parameters:¶
zs : array_like Redshifts at which to calculate the growth factor. ks : array_like Wavenumbers at which to calculate the growth factor.
Returns:¶
np.ndarray The growth factor as a function of redshift and wavenumber.
HMcode2020Emu_cosmology
¶
Implementation of Background and Perturbation cosmology using HMcode2020Emu.
HMemuLinearPerturbations
¶
HMemuLinearPerturbations(background: Background, redshifts: ndarray)
Class for perturbations cosmology using HMemu, compatibly with the Perturbations protocol.
matter_power_spectrum
¶
matter_power_spectrum(zs, ks, hubble_units=False, k_hunit=False) -> ndarray
Compute the linear matter power spectrum.
Parameters:
-
(ks¶ndarray) –Wave number in h Mpc^{-1}
-
(zs¶ndarray) –redshifts
-
(hubble_units¶Optional[bool], default:False) –Flag to specify if output in h units
-
(k_hunit¶Optional[bool], default:False) –Flag to specify if wavenumber in h units
Returns:
-
pk(ndarray) –Linear matter power spectrum at the specified scale and redshift
matter_power_spectrum_cb
¶
matter_power_spectrum_cb(zs, ks, hubble_units=False, k_hunit=False) -> ndarray
Compute the linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters:
-
(ks¶ndarray) –Wave number in h Mpc^{-1}
-
(zs¶ndarray) –redshifts
-
(hubble_units¶Optional[bool], default:False) –Flag to specify if output in h units
-
(k_hunit¶Optional[bool], default:False) –Flag to specify if wavenumber in h units
Returns:
-
pk(ndarray) –Linear matter power spectrum at the specified scale and redshift
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The growth factor as a function of redshift and wavenumber.
growth_factor_cb
¶
Calculate the growth factor for cb for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The growth factor as a function of redshift and wavenumber.
growth_rate
¶
Calculate the growth rate for given redshifts and wavenumbers.
Returns:
-
ndarray–The growth rate as a function of redshift and wavenumber.
HMemuNonLinearPerturbations
¶
HMemuNonLinearPerturbations(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Class for non linear perturbations cosmology using HMemu, compatibly with the Perturbations protocol.
matter_power_spectrum
¶
matter_power_spectrum_cb
¶
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The growth factor as a function of redshift and wavenumber.
growth_factor_cb
¶
Calculate the growth factor for cb for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The growth factor as a function of redshift and wavenumber.
growth_rate
¶
Calculate the growth rate for given redshifts and wavenumbers.
Returns:
-
ndarray–The growth rate as a function of redshift and wavenumber.
ReACTEmu_cosmology
¶
MGemuNonlinearBoost
¶
MGemuNonlinearBoost(background: Background, linearperturbations: Perturbations, zs: ndarray, gravity_model: str, mgpars: dict, high_z_policy: str = 'taper', z_decay: float = 0.75)
These emulators were created based on training data produced using ReACT (https://arxiv.org/abs/2005.12184)
This class allows for f(R), DGP, IDE and other parameterized gravity models
See https://github.com/nebblu/MGEmus/tree/main for more details
Parameters¶
background : Background A cosmological background instance containing parameters such as Omega_b0, Omega_cdm0, H0, ns, mnu, w0, and wa. Note w0 and wa are assumed to be LCDM values for some modified gravity models.
Perturbations
A standard linear perturbation object (e.g. from CAMB) used as the LCDM baseline.
np.ndarray
Array of redshifts at which to compute the MG corrections.
str, optional
Name of the gravity model or dark energy model to use. Examples: 'fr', 'dgp', 'ide', 'wCDM', 'w0waCDM', 'gamma', 'mu' etc.
dict
Dictionary of the extended MG parameters. Examples: fR0 for f(R), omegarc for DGP, gamma0/gamma1 for Linder models, mu0/Sigma0 or binned values for mu-Sigma, xi for IDE, etc.
string (default taper)
Gives the high redshift extrapolation policy. Can choose from the following: options: "power_law", "freeze", "one", "taper"
float
Gives the decay rate after emulator max redshift going back to LCDM (boost=1)
BoostedPerturbations
¶
Parameters¶
Parameters¶
base_lin_perturbations : object
An object representing the linear perturbations, which may include methods
like sigma_lensing for lensing calculations.
object
An object with a matter_power_spectrum(z, k) method that provides the
nonlinear matter power spectrum for the ΛCDM model.
callable
A function or interpolator B(z, k) that returns the nonlinear boost to be applied to the ΛCDM
matter_power_spectrum
¶
Return the boosted nonlinear matter power spectrum.
Parameters¶
z : float or np.ndarray Redshift value or array of redshifts. k : float or np.ndarray Wavenumber value or array of wavenumbers in 1/Mpc.
Returns¶
float or np.ndarray Boosted matter power spectrum. The output is squeezed so scalar inputs return a scalar, while array inputs return the corresponding one- or two-dimensional array.
growth_factor
¶
Calculate the growth factor.
If ks is provided:
D(z,k) = sqrt( P(z,k) / P(0,k) )
If ks is None (linear growth via boost on large scales):
D(z) = sqrt( B(z,k_lin) / B(0,k_lin) ), with a sensible default k_lin.
Parameters¶
zs : array_like Redshifts. ks : array_like or None Wavenumbers. If None, returns linear-growth estimate from the boost at k_lin.
Returns¶
np.ndarray If ks is None or scalar -> shape (len(zs),) If z and k arrays -> shape (len(zs), len(ks))
TabulatedBoost_cosmology
¶
Tabulated nonlinear boost module.
This module provides a lightweight interface for using simulation-based nonlinear matter power spectrum boosts B(k, z). It reads a text file containing a common k-grid and boost values for a set of snapshot redshifts, constructs a 2D spline interpolator B(z, k), and exposes it in the required format.
TabulatedNonlinearBoost
¶
TabulatedNonlinearBoost(background: Background, linearperturbations: Perturbations, zs: ndarray, boost_file: str, z_cols: Sequence[float], high_z_policy: str = 'taper', z_decay: float = 0.75)
Nonlinear matter power spectrum boost from a tabulated file B(k; z).
The boost file is expected to have
- column 1: k values (same k-grid used for all redshifts)
- columns 2..N: boost values B(k; z_i) for each snapshot/redshift
Parameters¶
background : Background A cosmological background instance containing parameters such as Omega_b0, Omega_cdm0, H0, ns, mnu, w0, and wa. Note w0 and wa are assumed to be LCDM values for some modified gravity models.
Perturbations
A standard linear perturbation object (e.g. from CAMB) used as the LCDM baseline.
np.ndarray
Array of redshifts at which to compute the MG corrections.
str
Path to the text file containing [k, B(z1), B(z2), ..., B(zN)]. Commented header lines starting with '#' are allowed.
Sequence[float]
1D array or list of redshifts corresponding to columns 2..N in the boost file (same order). Length must match the number of boost columns.
string (default taper)
Gives the high redshift extrapolation policy. Can choose from the following: options: "power_law", "freeze", "one", "taper"
float
Gives the decay rate after emulator max redshift going back to LCDM (boost=1)
Notes¶
This class simply builds a RectBivariateSpline over (z, k) so that you can
pass self.boost_interp into BoostedPerturbations in exactly the same
way as the ReACT emulator-based version.
TabulatedBoostedPerturbations
¶
Parameters¶
base_lin_perturbations : object
An object representing the linear perturbations, which may include methods
like sigma_lensing for lensing calculations. Must have the same background
as in the modified theory of gravity or dark energy (not ΛCDM for CPL-backgrounds!).
object
An object with a matter_power_spectrum(z, k) method that provides the
nonlinear matter power spectrum for the ΛCDM model.
callable
A function or interpolator B(z, k) that returns the nonlinear boost to be applied to the ΛCDM spectrum.
matter_power_spectrum
¶
Return the boosted nonlinear matter power spectrum.
Parameters¶
z : float or np.ndarray Redshift value or array of redshifts. k : float or np.ndarray Wavenumber value or array of wavenumbers in 1/Mpc.
Returns¶
float or np.ndarray Boosted matter power spectrum. The output is squeezed so scalar inputs return a scalar, while array inputs return the corresponding one- or two-dimensional array.
growth_factor
¶
Calculate the growth factor.
If ks is provided:
D(z,k) = sqrt( P(z,k) / P(0,k) )
If ks is None (linear growth via boost on large scales):
D(z) = sqrt( B(z,k_lin) / B(0,k_lin) ), with a sensible default k_lin.
Parameters¶
zs : array_like Redshifts. ks : array_like or None Wavenumbers. If None, returns linear-growth estimate from the boost at k_lin.
Returns¶
np.ndarray If ks is None or scalar -> shape (len(zs),) If z and k arrays -> shape (len(zs), len(ks))
baccoemu_cosmology
¶
Implementation of Background and Perturbation cosmology using BACCOemu (similarly to what done with HMcode2020emu).
BACCOemuLinearPerturbations
¶
BACCOemuLinearPerturbations(background: Background, redshifts: ndarray)
Class for perturbations cosmology using BACCOemu, compatibly with the Perturbations protocol.
matter_power_spectrum
¶
matter_power_spectrum_cb
¶
growth_factor
¶
Calculate the total (dark matter + baryons + neutrinos) growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The growth factor as a function of redshift and wavenumber.
growth_rate
¶
Calculate the total (dark matter + baryons + neutrinos) linear growth rate for given redshifts and wavenumbers.
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The linear growth rate as a function of redshift and wavenumber.
growth_factor_cb
¶
Calculate the cold (dark matter + baryons) growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The growth factor as a function of redshift and wavenumber.
growth_rate_cb
¶
Calculate the cold (dark matter + baryons) linear growth rate for given redshifts and wavenumbers.
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The linear cold growth rate as a function of redshift and wavenumber.
sigma8_0
¶
Calculate the total (dark matter + baryons + neutrinos) linear sigma8 value for the current cosmology.
Returns:¶
float The sigma8 value.
sigma12_0
¶
Calculate the total (dark matter + baryons + neutrinos) linear sigma12 value for the current cosmology.
Returns:¶
float The sigma8 value.
BACCOemuNonLinearPerturbations
¶
BACCOemuNonLinearPerturbations(background: Background, linearperturbations: Perturbations, redshifts: ndarray, nonlinear_model_name: Optional[str] = 'Arico2023', baryonic_boost: Optional[str] = None, baryonic_model_name: Optional[str] = 'Burger2025', M_c: Optional[float] = None, eta: Optional[float] = None, beta: Optional[float] = None, M1_z0_cen: Optional[float] = None, theta_out: Optional[float] = None, theta_inn: Optional[float] = None, M_inn: Optional[float] = None)
Class for non linear perturbations cosmology using BACCOemu, compatibly with the Perturbations protocol.
matter_power_spectrum
¶
matter_power_spectrum_cb
¶
growth_factor
¶
Calculate the total (dark matter + baryons + neutrinos) linear growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The linear growth factor as a function of redshift and wavenumber.
growth_rate
¶
Calculate the total (dark matter + baryons + neutrinos) linear growth rate for given redshifts and wavenumbers.
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The linear growth rate as a function of redshift and wavenumber.
growth_factor_cb
¶
Calculate the cold (dark matter + baryons) linear growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The linear growth factor as a function of redshift and wavenumber.
growth_rate_cb
¶
Calculate the cold (dark matter + baryons) linear growth rate for given redshifts and wavenumbers.
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The linear cold growth rate as a function of redshift and wavenumber.
sigma8_0
¶
Calculate the total (dark matter + baryons + neutrinos) linear sigma8 value for the current cosmology.
Returns:¶
float The sigma8 value.
sigma12_0
¶
Calculate the total (dark matter + baryons + neutrinos) linear sigma12 value for the current cosmology.
Returns:¶
float The sigma8 value.
camb_cosmology
¶
Implementation of Background and Perturbation cosmology using CAMB.
CAMBBackground
¶
CAMBBackground(H0: float, Omega_b0: float, Omega_cdm0: float, Omega_k0: float, As: float, ns: float, mnu: Union[float, Sequence[float], ndarray], w0: float, wa: float, gamma_MG: float, N_mnu: int, N_ur: Optional[float] = None, alpha_s: float = 0.0)
A wrapper for CAMB background cosmological calculations.
Parameters:
-
(H0¶float) –Hubble parameter in [km/s/Mpc].
-
(Omega_b0¶float) –Baryonic matter density parameter.
-
(Omega_cdm0¶float) –Cold dark matter density parameter.
-
(Omega_k0¶float) –Curvature density parameter.
-
(As¶float) –Scalar amplitude of primordial fluctuations.
-
(ns¶float) –Scalar spectral index.
-
(alpha_s¶float, default:0.0) –Running of the scalar spectral index (d ns / d ln k).
-
(mnu¶Union[float, Sequence[float]], np.ndarray]) –Total neutrino mass in eV. Can be a single float for degenerate masses, an array (or a sequence of floats) for individual species.
-
(w0¶float) –Equation of state parameter for dark energy.
-
(wa¶float) –Time evolution of the dark energy equation of state.
-
(gamma_MG¶float) –Modified gravity growth parameter.
-
(N_mnu¶int) –Number of massive neutrino species.
-
(N_ur¶Optional[float], default:None) –Extra number of ultra-relativistic species. If not provided, it will be inferred from N_mnu such that N_eff = 3.044.
N_ur
property
¶
Effective number of ultra-relativistic species.
If the user gave one, return it; otherwise infer from other parameters such that N_eff = 3.044 for the standard model of cosmology.
N_eff
property
¶
Return the effective number of relativistic species.
Assumes a standard value of T_ncdm = 0.71611 for neutrinos.
hubble_parameter
¶
comoving_distance
¶
comoving_distance(zs: ndarray) -> ndarray
Return the comoving distance as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Comoving distance values.
transverse_comoving_distance
¶
transverse_comoving_distance(zs: ndarray) -> ndarray
Return the transverse comoving distance between two redshifts.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Transverse comoving distance values.
angular_diameter_distance
¶
angular_diameter_distance(zs: ndarray) -> ndarray
Return the angular diameter distance as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Angular diameter distance values.
Omega_cb
¶
Omega_cb(zs: ndarray) -> ndarray
Return the cold dark matter + baryons (no neutrinos) as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–np.ndarray: Matter density values (no neutrinos).
CAMBLinearPerturbations
¶
CAMBLinearPerturbations(background: Background, redshifts: ndarray)
A wrapper for CAMB linear perturbation calculations.
Parameters:
-
(background¶Background) –A CAMBBackground instance.
-
(redshifts¶ndarray) –Array of redshifts for the calculations.
matter_power_spectrum
¶
matter_power_spectrum(zs: ndarray, ks: ndarray, hubble_units=False, k_hunit=False) -> ndarray
Compute the linear matter power spectrum.
Parameters:
-
(zs¶ndarray) –redshifts
-
(ks¶ndarray) –wavenumber
-
(hubble_units¶Optional[bool], default:False) –Flag to specify if output in h units
-
(k_hunit¶Optional[bool], default:False) –Flag to specify if wavenumber in h units
Returns:
-
pk(ndarray) –Linear matter power spectrum at the specified scale and redshift
matter_power_spectrum_cb
¶
Computes the linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Args zs (numpy.ndarray): redshifts ks (numpy.ndarray): wavenumber
Returns:
-
ndarray–The growth factor at the specified redshift and wavenumber.
growth_factor_cb
¶
Calculate the growth factor for cb for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Args zs (numpy.ndarray): redshifts ks (numpy.ndarray): wavenumber
Returns:
-
ndarray–The growth factor at the specified redshift and wavenumber.
CAMBNonLinearPerturbations
¶
CAMBNonLinearPerturbations(background: Background, linearperturbations: Optional[object], redshifts: ndarray, nonlinear_model: Optional[str] = None, log10TAGN: Optional[float] = None)
A wrapper for CAMB nonlinear perturbation calculations.
Parameters:
-
(self¶LinearPerturbations) –An instance of the LinearPerturbations class.
-
(linearperturbations¶Optional[object]) –Linear perturbations object (unused by CAMB, which computes nonlinear corrections internally; accepted for interface compatibility with emulator-based NonLinPerturbations classes).
-
(redshifts¶ndarray) –Array of redshifts for the calculations.
-
(nonlinear_model¶Optional[str], default:None) –The nonlinear model to use (e.g., "takahashi"). Defaults to None, which uses the CAMB default model.
matter_power_spectrum
¶
matter_power_spectrum(zs: ndarray, ks: ndarray, hubble_units=False, k_hunit=False) -> ndarray
Compute the nonlinear matter power spectrum.
Parameters:
-
(zs¶ndarray) –redshifts
-
(ks¶ndarray) –wavenumber
-
(hubble_units¶Optional[bool], default:False) –Flag to specify if output in h units
-
(k_hunit¶Optional[bool], default:False) –Flag to specify if wavenumber in h units
Returns:
-
pk(ndarray) –Nonlinear matter power spectrum at the specified scale and redshift
matter_power_spectrum_cb
¶
Compute the nonlinear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
Returns:
-
ndarray–The growth factor at the specified redshift and wavenumber.
growth_factor_cb
¶
Calculate the growth factor for cb for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
Returns:
-
ndarray–The growth factor at the specified redshift and wavenumber.
class_cosmology
¶
Implementation of Background and Perturbation cosmology using CLASS.
CLASSBackground
¶
CLASSBackground(H0: float, Omega_b0: float, Omega_cdm0: float, Omega_k0: float, As: float, ns: float, mnu: Union[float, Sequence[float], ndarray], w0: float, wa: float, gamma_MG: float, N_mnu: int, N_ur: Optional[float] = None, alpha_s: float = 0.0, **kwargs)
A wrapper for CLASS background cosmological calculations.
Parameters:
-
(H0¶float) –Hubble parameter at z=0 in km/s/Mpc.
-
(Omega_b0¶float) –Baryonic matter density parameter.
-
(Omega_cdm0¶float) –Cold dark matter density parameter.
-
(Omega_k0¶float) –Curvature density parameter.
-
(As¶float) –Scalar amplitude of primordial fluctuations.
-
(ns¶float) –Scalar spectral index.
-
(alpha_s¶float, default:0.0) –Running of the scalar spectral index (d ns / d ln k).
-
(mnu¶Union[float, Sequence[float], ndarray]) –Total neutrino mass in eV. Can be a single float for degenerate masses, an array (or a sequence of floats) for individual species.
-
(w0¶float) –Equation of state parameter for dark energy.
-
(wa¶float) –Time evolution of the equation of state.
-
(gamma_MG¶float) –Modified gravity growth parameter (not directly used in CLASS, but kept for protocol compliance).
-
(N_mnu¶int) –Number of massive neutrino species.
-
(N_ur¶Optional[float], default:None) –Effective number of ultra-relativistic species. If not provided, it will be inferred from N_mnu such that N_eff = 3.044.
N_ur
property
¶
Effective number of ultra-relativistic species.
If the user gave one, return it; otherwise infer from other parameters such that N_eff = 3.044 for the standard model of cosmology.
N_eff
property
¶
Return the effective number of relativistic species.
Assumes a standard value of T_ncdm = 0.71611 K for neutrinos.
hubble_parameter
¶
comoving_distance
¶
comoving_distance(zs: ndarray) -> ndarray
Return the comoving distance as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Comoving distance values.
transverse_comoving_distance
¶
transverse_comoving_distance(zs: ndarray) -> ndarray
Return the transverse comoving distance between two redshifts.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Transverse comoving distance values.
angular_diameter_distance
¶
angular_diameter_distance(zs: ndarray) -> ndarray
Return the angular diameter distance as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Angular diameter distance values.
Omega_cb
¶
Omega_cb(zs: ndarray) -> ndarray
Return the cold dark matter + baryons (no neutrinos) as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–np.ndarray: Matter density values (no neutrinos).
CLASSLinearPerturbations
¶
CLASSLinearPerturbations(background: Background, redshifts: ndarray)
Class for perturbations cosmology using CLASS, inheriting from Perturbations parent class.
matter_power_spectrum
¶
matter_power_spectrum(zs, ks, hubble_units=False, k_hunit=False) -> ndarray
Calculate the CLASS linear matter power spectrum.
Parameters:
-
(zs¶ndarray) –redshifts
-
(ks¶ndarray) –wavenumber
-
(hubble_units¶Optional[bool], default:False) –Flag to specify if output in h units
-
(k_hunit¶Optional[bool], default:False) –Flag to specify if wavenumber in h units
Returns:
-
pk(ndarray) –Linear matter power spectrum at the specified scale
-
ndarray–and redshift
matter_power_spectrum_cb
¶
Computes the linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
Returns:
-
ndarray–The growth factor at the specified redshift and wavenumber.
growth_rate
¶
Calculate the growth rate f(z).
Returns:
-
ndarray–Scale-independent growth rate f(z)
CLASSNonLinearPerturbations
¶
CLASSNonLinearPerturbations(background: Background, linearperturbations: Optional[object], redshifts: ndarray, nonlinear_model: Optional[str] = None, hmcode_version: Optional[str] = None)
Class for non-linear perturbations cosmology using CLASS, inheriting from Perturbations parent class.
Parameters:
-
(background¶Background) –Background cosmology object.
-
(linearperturbations¶Optional[object]) –Linear perturbations object (unused by CLASS, which computes nonlinear corrections internally; accepted for interface compatibility with emulator-based NonLinPerturbations classes).
-
(redshifts¶ndarray) –Array of redshifts for the calculations.
-
(nonlinear_model¶Optional[str], default:None) –The nonlinear model to use. Defaults to None (no nonlinear).
-
(hmcode_version¶Optional[str], default:None) –The HMcode version to use. Defaults to None.
matter_power_spectrum
¶
matter_power_spectrum(zs, ks, hubble_units=False, k_hunit=False) -> ndarray
Calculate the CLASS non-linear matter power spectrum.
Parameters:
-
(zs¶ndarray) –redshifts
-
(ks¶ndarray) –wavenumber
-
(hubble_units¶Optional[bool], default:False) –Flag to specify if output in h units
-
(k_hunit¶Optional[bool], default:False) –Flag to specify if wavenumber in h units
Returns:
-
pk(ndarray) –Non-linear matter power spectrum at the specified scale
-
ndarray–and redshift
matter_power_spectrum_cb
¶
Calculate the CLASS non-linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
Returns:
-
ndarray–The growth factor at the specified redshift and wavenumber.
growth_rate
¶
Calculate the growth rate f(z).
Returns:
-
ndarray–Scale-independent growth rate f(z)
cosmology
¶
Protocols for Background and Perturbation cosmology classes.
Notes:¶
-
Refactored cosmology.py from the original CLOE to provide a more flexible framework, enabling seamless integration with external cosmological codes while removing dependency on Cobaya.
-
Introduced the use of protocols to standardize external code interfaces, providing a unified and extensible template for interaction.
Background
¶
flowchart TD
cloelib.cosmology.cosmology.Background[Background]
click cloelib.cosmology.cosmology.Background href "" "cloelib.cosmology.cosmology.Background"
Protocol for Background cosmology class.
Omega_cdm0
property
¶
Omega cold dark matter; the cold dark matter density/critical density at z=0.
mnu
property
¶
Total neutrino mass in eV (float) or an array of individual neutrino masses in eV.
Omega_k0
property
¶
Omega curvature; the effective curvature density/critical density at z=0.
interface_args
property
¶
Save internal structure format of possible interface codes.
Omega_cb
¶
Computes the cold dark matter + baryons (no neutrinos) as a function of redshift.
hubble_parameter
¶
Retrieve the hubble parameter as a function of redshift.
comoving_distance
¶
Calculate the comoving distance for given redshifts.
transverse_comoving_distance
¶
Calculate the transverse comoving distance for given redshifts.
angular_diameter_distance
¶
Calculate the angular diameter distance for given redshifts.
Perturbations
¶
flowchart TD
cloelib.cosmology.cosmology.Perturbations[Perturbations]
click cloelib.cosmology.cosmology.Perturbations href "" "cloelib.cosmology.cosmology.Perturbations"
Protocol for Perturbation cosmology class.
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
growth_rate
¶
Calculate the growth rate for given redshifts and wavenumbers.
matter_power_spectrum
¶
Retrieve the matter power spectrum.
matter_power_spectrum_cb
¶
Retrieves matter power spectrum of cold dark matter + baryons (no neutrinos).
cosmopower_jax_cosmology
¶
This module provides CosmoPower-JAX-based emulators for linear and nonlinear matter power spectra.
Uses cosmopower_jax instead of tensorflow-based cosmopower for faster JAX-accelerated predictions.
Supported models include: - w0waCDM with mass of the neutrino 0 - w0waCDM with one massive neutrino - w0waCDM with 2 massive neutrinos - w0waCDM with three degenerate massive neutrinos - wCDM with mass of the neutrino 0 - wCDM with one massive neutrino - wCDM with 2 massive neutrinos - wCDM with three massive neutrinos - LCDM with mass of the neutrinos 0 - LCDM with one massive neutrino - LCDM with 2 massive neutrinos - LCDM with three massive neutrinos
- LCDM with curvature
- LCDM with running of the spectral index
CosmoPowerJAXw0waCDMPerturbations
¶
Class for w0waCDM cosmology perturbations using CosmoPower-JAX emulators.
Linear
¶
Linear(background: Background, redshifts: ndarray)
Emulator for the linear matter power spectrum in the w0waCDM cosmology.
Uses CosmoPower-JAX for fast JAX-accelerated predictions.
Parameters¶
background : Background Background cosmology object. redshifts : np.ndarray Array of redshift values.
matter_power_spectrum
¶
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
.. math:: D(z, k) =\sqrt{P_{\rm \delta\delta}(z, k)\ /P_{\rm \delta\delta}(z=0, k)}\
and normalizes as for :math:D(z)/D(0).
Parameters:¶
zs : array_like Redshifts at which to calculate the growth factor. ks : array_like Wavenumbers at which to calculate the growth factor.
Returns:¶
np.ndarray The growth factor as a function of redshift and wavenumber.
LinearCB
¶
LinearCB(background: Background, redshifts: ndarray)
Emulator for the cb [cold dark matter (c) + baryon (b)] linear matter power spectrum in the w0waCDM cosmology.
This class uses a Cosmopower-JAX neural network to emulate the cb linear power spectrum for a w0waCDM cosmology. Automatically selects the appropriate emulator based on neutrino configuration.
matter_power_spectrum
¶
Compute the cb linear matter power spectrum P_cb(k, z).
NonLinear
¶
NonLinear(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the nonlinear matter power spectrum in the w0waCDM cosmology.
This class uses a Cosmopower-JAX neural network to emulate the nonlinear power spectrum
for a w0waCDM cosmology. Automatically selects the appropriate emulator based on neutrino configuration.
Nonlinear corrections are applied using the mead2020 model in CAMB, with baryonic feedback
regulated using the log10TAGN parameter.
matter_power_spectrum
¶
Compute the nonlinear matter power spectrum P(k, z).
NonLinearCB
¶
NonLinearCB(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the cb [cold dark matter (c) + baryon (b)] nonlinear matter power spectrum in the w0waCDM cosmology.
This class uses a Cosmopower-JAX neural network to emulate the cb nonlinear power spectrum
for a w0waCDM cosmology. Automatically selects the appropriate emulator based on neutrino configuration.
Nonlinear corrections are applied using the mead2020 model in CAMB, with baryonic feedback
regulated using the log10TAGN parameter.
matter_power_spectrum
¶
Compute the cb nonlinear matter power spectrum P_cb(k, z).
CosmoPowerJAXwCDMPerturbations
¶
Class for wCDM cosmology perturbations using CosmoPower-JAX emulators.
Linear
¶
Linear(background: Background, redshifts: ndarray)
Emulator for the linear matter power spectrum in the wCDM cosmology.
This class uses a Cosmopower-JAX neural network to emulate the linear power spectrum for a wCDM cosmology. Automatically selects the appropriate emulator based on neutrino configuration.
matter_power_spectrum
¶
Compute the linear matter power spectrum P(k, z).
LinearCB
¶
LinearCB(background: Background, redshifts: ndarray)
Emulator for the cb [cold dark matter (c) + baryon (b)] linear matter power spectrum in the wCDM cosmology.
This class uses a Cosmopower-JAX neural network to emulate the cb linear power spectrum for a wCDM cosmology. Automatically selects the appropriate emulator based on neutrino configuration.
NonLinear
¶
NonLinear(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the nonlinear matter power spectrum in wCDM cosmology.
NonLinearCB
¶
NonLinearCB(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the cb nonlinear matter power spectrum in wCDM cosmology.
CosmoPowerJAXLCDMPerturbations
¶
Class for LCDM cosmology perturbations using CosmoPower-JAX emulators.
Linear
¶
Linear(background: Background, redshifts: ndarray)
Emulator for the linear matter power spectrum in LCDM cosmology.
LinearCB
¶
LinearCB(background: Background, redshifts: ndarray)
Emulator for the cb linear matter power spectrum in LCDM cosmology.
NonLinear
¶
NonLinear(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the nonlinear matter power spectrum in LCDM cosmology.
NonLinearCB
¶
NonLinearCB(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the cb nonlinear matter power spectrum in LCDM cosmology.
CosmoPowerJAXCurvaturePerturbations
¶
Class for LCDM+curvature cosmology perturbations using CosmoPower-JAX emulators.
Supports non-zero spatial curvature (Omega_k0 != 0). Neutrino mass is fixed at mnu=0.06 eV during training and is not a free parameter of these emulators. Uses a dedicated k-mode grid (curvature-kmodes.txt) and emulator files: - lcdm-curvature-linear.npz - lcdm-curvature-nonlinear.npz - lcdm-curvature-s8-fs8.npz
Emulator parameter ranges
ombh2 in [0.019, 0.025] omch2 in [0.09, 0.15] H0 in [60, 80] ns in [0.8, 1.2] lnAs in [1.6, 4.0] z in [0, 5] logT_AGN in [7.3, 8.5] (nonlinear and sigma8/fsigma8 emulators only) omk in [-0.1, 0.1]
Linear
¶
Linear(background: Background, redshifts: ndarray)
Emulator for the linear matter power spectrum in LCDM+curvature cosmology.
NonLinear
¶
NonLinear(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the nonlinear matter power spectrum in LCDM+curvature cosmology.
LinearCB
¶
LinearCB(background: Background, redshifts: ndarray)
Emulator for the cb linear matter power spectrum in LCDM+curvature cosmology.
NonLinearCB
¶
NonLinearCB(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the cb nonlinear matter power spectrum in LCDM+curvature cosmology.
CosmoPowerJAXRunningIndexPerturbations
¶
Class for LCDM+running spectral index cosmology perturbations using CosmoPower-JAX emulators.
Supports a running spectral index alpha_s = d ns / d ln k. Neutrino mass is fixed at mnu=0.06 eV during training and is not a free parameter of these emulators. Uses the standard k-mode grid (k-modes.txt) and emulator files: - lcdm-running-linear.npz - lcdm-running-nonlinear.npz - lcdm-running-s8-fs8.npz
Emulator parameter ranges
ombh2 in [0.019, 0.025] omch2 in [0.09, 0.15] H0 in [60, 80] ns in [0.8, 1.2] lnAs in [1.6, 4.0] z in [0, 5] alpha_s in [-0.1, 0.1] logT_AGN in [7.3, 8.5] (nonlinear and sigma8/fsigma8 emulators only)
Linear
¶
Linear(background: Background, redshifts: ndarray)
Emulator for the linear matter power spectrum in LCDM+running spectral index cosmology.
NonLinear
¶
NonLinear(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the nonlinear matter power spectrum in LCDM+running spectral index cosmology.
LinearCB
¶
LinearCB(background: Background, redshifts: ndarray)
Emulator for the cb linear matter power spectrum in LCDM+running spectral index cosmology.
NonLinearCB
¶
NonLinearCB(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the cb nonlinear matter power spectrum in LCDM+running spectral index cosmology.
emulator_data
¶
load_pk_emulator
¶
load_sigma_emulator
¶
derived_cosmology
¶
Common cosmology derived functions.
rho_crit
¶
rho_crit(background, zs: ndarray) -> ndarray
dV_dzdO
¶
Return the volume element per redshit per solid angle at the redshift requested.
Parameters¶
background: Background Background class containing cosmology zs :np.ndarray Redshifts. hubble_units: (Optional) bool Flag to specify if output in h units, defaults to False
Returns:
-
ndarray–volume element in Mpc^3 h^{-3}
rdrag_fitting_function
¶
rdrag_fitting_function(background, neff=3.046)
emantis_cosmology
¶
Implementation of nonlinear Perturbation cosmology for f(R) gravity using the e-MANTIS emulator.
EmantisFofrNonLinearPerturbations
¶
EmantisFofrNonLinearPerturbations(background: Background, linearperturbations: Perturbations, nonlinearperturbations_lcdm: Perturbations, fR0: float, redshifts: ndarray, verbose: bool = False, emu_version: int = 2, extrapolate_cosmo: bool = True)
Nonlinear perturbations in f(R) gravity.
The nonlinear matter power spectrum boost, i.e. P_f(R)(k) / P_LCDM(k), is computed with the e-MANTIS emulator. The boost is then combined with an external nonlinear LCDM matter power spectrum prediction in order to obtain the full nonlinear matter power spectrum in f(R) gravity.
Parameters¶
background : Background A background cosmology object, providing all the standard cosmological parameters. linearperturbations : Perturbations A linear perturbations object, providing linear perturbations in f(R) gravity. nonlinearperturbations_lcdm : Perturbations A nonlinear perturbations object, providing the nonlinear matter power spectrum in LCDM. fR0 : float The modified gravity parameter fR0. redshifts : np.ndarray An array of redshifts used to compute the matter power spectrum. verbose : float, optional (default=False) Activate or not verbose output from the emantis emulator. emu_version : int, optional (default=2) The version of the emantis emulator to use. Version 2 (the default) has an extended cosmological parameter and redshift range. extrapolate_cosmo : bool optional (default=True) Activate or not constant extrapolation of cosmological parameters. The extrapolation is done only for the LCDM cosmological parameters. There is no extrapolation for fR0.
hi_class_cosmology
¶
Implementation of Background and Perturbation cosmology using hi_class.
hi_classBackground
¶
hi_classBackground(H0: float, Omega_b0: float, Omega_cdm0: float, Omega_k0: float, As: float, ns: float, mnu: Union[float, Sequence[float], ndarray], w0: float, wa: float, gamma_MG: float, N_mnu: int, N_ur: Optional[float] = None, alpha_s: float = 0.0, params_smg: Optional[dict] = None, **kwargs)
A wrapper for hi_class background cosmological calculations.
Parameters:
-
(H0¶float) –Hubble parameter at z=0 in km/s/Mpc.
-
(Omega_b0¶float) –Baryonic matter density parameter.
-
(Omega_cdm0¶float) –Cold dark matter density parameter.
-
(Omega_k0¶float) –Curvature density parameter.
-
(As¶float) –Scalar amplitude of primordial fluctuations.
-
(ns¶float) –Scalar spectral index.
-
(alpha_s¶float, default:0.0) –Running of the scalar spectral index (d ns / d ln k).
-
(mnu¶Union[float, Sequence[float], ndarray]) –Total neutrino mass in eV. Can be a single float for degenerate masses, an array (or a sequence of floats) for individual species.
-
(w0¶float) –Equation of state parameter for dark energy.
-
(wa¶float) –Time evolution of the equation of state.
-
(gamma_MG¶float) –Modified gravity growth parameter (not directly used in hi_class, but kept for protocol compliance).
-
(N_mnu¶int) –Number of massive neutrino species.
-
(N_ur¶Optional[float], default:None) –Effective number of ultra-relativistic species. If not provided, it will be inferred from N_mnu such that N_eff = 3.044.
-
(params_smg¶Optional[dict], default:None) –Modified gravity parameters, or other extra parameters not passed by default.
N_ur
property
¶
Effective number of ultra-relativistic species.
If the user gave one, return it; otherwise infer from other parameters such that N_eff = 3.044 for the standard model of cosmology.
N_eff
property
¶
Return the effective number of relativistic species.
Assumes a standard value of T_ncdm = 0.71611 K for neutrinos.
hubble_parameter
¶
comoving_distance
¶
comoving_distance(zs: ndarray) -> ndarray
Return the comoving distance as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–np.ndarray: Comoving distance values.
transverse_comoving_distance
¶
transverse_comoving_distance(zs: ndarray) -> ndarray
Return the transverse comoving distance between two redshifts.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–np.ndarray: Transverse comoving distance values.
angular_diameter_distance
¶
angular_diameter_distance(zs: ndarray) -> ndarray
Return the angular diameter distance as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–np.ndarray: Angular diameter distance values.
Omega_cb
¶
Omega_cb(zs: ndarray) -> ndarray
Return the cold dark matter + baryons (no neutrinos) as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–np.ndarray: Matter density values (no neutrinos).
Omega_m
¶
Omega_m(zs: ndarray) -> ndarray
Return the matter density as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–np.ndarray: Matter density values.
Omega_b
¶
Omega_b(zs: ndarray) -> ndarray
Return the baryon density as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–np.ndarray: Matter density values.
get_background
¶
Return all background quantities
Return a dictionary of background quantities at all times. The name and list of quantities in the returned dictionary are defined in hi_class, in background_output_titles() and background_output_data(). The keys of the dictionary refer to redshift 'z', proper time 'proper time [Gyr]', conformal time 'conf. time [Mpc]', and many quantities such as the Hubble rate, distances, densities, pressures, or growth factors. For each key, the dictionary contains an array of values corresponding to each sampled value of time.
This function works for whatever request in the 'output' field, and even if 'output' was not passed or left blank.
Parameters¶
None
Returns¶
background : dict Dictionary of all background quantities at each time
hi_classLinearPerturbations
¶
hi_classLinearPerturbations(background: Background, redshifts: ndarray)
Class for perturbations cosmology using hi_class, inheriting from Perturbations parent class.
matter_power_spectrum
¶
Calculate the hi_class linear matter power spectrum.
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
matter_power_spectrum_cb
¶
Computes the linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
.. math:: D(z, k) =\sqrt{P_{\rm \delta\delta}(z, k)\ /P_{\rm \delta\delta}(z=0, k)}\
and normalizes as for :math:D(z)/D(0).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
Returns:¶
np.ndarray The growth factor at the specified redshift and wavenumber.
hi_classNonLinearPerturbations
¶
hi_classNonLinearPerturbations(background: Background, linearperturbations: Optional[object], redshifts: ndarray, nonlinear_model: Optional[str] = None)
Class for non-linear perturbations cosmology using hi_class, inheriting from Perturbations parent class.
Parameters:
-
(background¶Background) –Background cosmology object.
-
(linearperturbations¶Optional[object]) –Linear perturbations object (unused by hi_class, which computes nonlinear corrections internally; accepted for interface compatibility with emulator-based NonLinPerturbations classes).
-
(redshifts¶ndarray) –Array of redshifts for the calculations.
-
(nonlinear_model¶Optional[str], default:None) –The nonlinear model to use. Defaults to None (no nonlinear).
matter_power_spectrum
¶
Calculate the hi_class non-linear matter power spectrum.
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Non-linear matter power spectrum at the specified scale and redshift
matter_power_spectrum_cb
¶
Calculate the hi_class non-linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
.. math:: D(z, k) =\sqrt{P_{\rm \delta\delta}(z, k)\ /P_{\rm \delta\delta}(z=0, k)}\
and normalizes as for :math:D(z)/D(0).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
Returns:¶
np.ndarray The growth factor at the specified redshift and wavenumber.
jax_cosmology
¶
Implementation of Background and Perturbation cosmology using JAX.
The module enables automatic differentiation. All of the functions are completely differentiable.
JAXBackground
¶
JAXBackground(H0: float, Omega_b0: float, Omega_cdm0: float, Omega_k0: float, As: float, ns: float, mnu: Union[float, Sequence[float], ndarray], w0: float, wa: float, gamma_MG: float, N_mnu: int, N_ur: Optional[float] = None, alpha_s: float = 0.0, **kwargs)
Class to define background cosmology using JAX,inheriting from Cosmology parent class.
Parameters:
-
(H0¶float) –Hubble parameter in [km/s/Mpc].
-
(Omega_b0¶float) –Baryonic matter density parameter.
-
(Omega_cdm0¶float) –Cold dark matter density parameter.
-
(Omega_k0¶float) –Curvature density parameter.
-
(As¶float) –Scalar amplitude of primordial fluctuations.
-
(ns¶float) –Scalar spectral index.
-
(alpha_s¶float, default:0.0) –Running of the scalar spectral index (d ns / d ln k). Note: JAXBackground does not use alpha_s (emulator not trained with it).
-
(mnu¶Union[float, Sequence[float], ndarray]) –Total neutrino mass in eV. Can be a single float for degenerate masses, an array (or a sequence of floats) for individual species.
-
(w0¶float) –Equation of state parameter for dark energy.
-
(wa¶float) –Time evolution of the dark energy equation of state.
-
(gamma_MG¶float) –Modified gravity growth parameter.
-
(N_mnu¶int) –Number of massive neutrino species. Note that JaxBackground does not support N_mnu != 0.
-
(N_ur¶Optional[float], default:None) –Effective number of ultra-relativistic species. If not provided, it will be inferred from N_mnu such that N_eff = 3.044.
N_ur
property
¶
Effective number of ultra-relativistic species.
Checks if N_ur is provided and raises an error if so. FIXME: Not implemented, so this will always return None.
N_eff
property
¶
Effective number of relativistic species.
FIXME: Not implemented, so this will always return the default 3.044.
hubble_parameter
¶
comoving_distance
¶
comoving_distance(zs: ndarray) -> ndarray
Calculate the comoving distance for given redshifts.
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the comoving distance.
Returns:
-
ndarray–The comoving distance as a function of redshift.
transverse_comoving_distance
¶
transverse_comoving_distance(zs: ndarray) -> ndarray
Return the transverse comoving distance between two redshifts.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Transverse comoving distance values.
angular_diameter_distance
¶
angular_diameter_distance(zs: ndarray) -> ndarray
Calculate the angular diameter distance for given redshifts.
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the angular diameter distance.
Returns:
-
ndarray–The angular diameter distance as a function of redshift.
Omega_b
¶
Omega_b(zs: ndarray) -> ndarray
Return the baryon density as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Matter density values.
Omega_m
¶
Omega_m(zs: ndarray) -> ndarray
Return the matter density as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Matter density values.
JAXLinearPerturbations
¶
JAXLinearPerturbations(background: Background)
A wrapper for JAX linear perturbation calculations.
Parameters:
-
(background¶Background) –A Background instance.
transfer_Eisenstein_Hu
¶
transfer_Eisenstein_Hu(ks)
Compute the Eisenstein & Hu matter transfer function.
Parameters:
-
(ks¶array_like) –Wave number in h Mpc^{-1}
Returns:
-
T(array_like) –Value of the transfer function at the requested wave number
Notes
The Eisenstein & Hu transfer functions are computed using the fitting
formulae of :cite:1998:EisensteinHu
sigmasqr
¶
Compute the energy of the fluctuations within a sphere of R h^{-1} Mpc.
where
sigma8sqr
¶
Compute the energy of the fluctuations within a sphere of R h^{-1} Mpc.
where
matter_power_spectrum
¶
matter_power_spectrum_cb
¶
Computes the linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: array_like, optional Redshifts
array_like
Wave number in h Mpc^{-1}
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: array_like Linear matter power spectrum at the specified scale and redshift
JAXNonLinearPerturbations
¶
JAXNonLinearPerturbations(background: Background)
Class for perturbations cosmology using JAX, inheriting from Cosmology parent class.
growth_factor
¶
Return the linear growth factor.
matter_power_spectrum
¶
Compute the non-linear matter power spectrum.
This function is just a wrapper over several nonlinear power spectra.
nonlinear_matter_power_spectrum_limber_grid
¶
Write documentation (TODO).
matter_power_spectrum_cb
¶
Compute the non-linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
interp
¶
Compute a linear interpolation (equivalent of jnp.interp).
We are not doing any checks, so make sure your query points are lying inside the array.
TODO: Implement proper interpolation, like in interpolations.jl
x, xp, fp need to be 1d arrays
romb
¶
Romberg integration of a callable function or method.
Returns the integral of function (a function of one variable)
over the interval (a, b).
If show is 1, the triangular array of the intermediate results
will be printed. If vec_func is True (default is False), then
function is assumed to support vector arguments.
Parameters:
-
(function¶callable) –Function to be integrated.
-
(a¶float) –Lower limit of integration.
-
(b¶float) –Upper limit of integration.
-
(args¶optional[tuple], default:()) –Extra arguments to pass to function. Each element of
argswill be passed as a single argument tofunc. Default is to pass no extra arguments. -
(divmax¶optional[int], default:6) –Maximum order of extrapolation. Default is 10.
Returns:
-
results(float) –Result of the integration.
See Also¶
fixed_quad : Fixed-order Gaussian quadrature. quad : Adaptive quadrature using QUADPACK. dblquad : Double integrals. tplquad : Triple integrals. romb : Integrators for sampled data. simps : Integrators for sampled data. cumtrapz : Cumulative integration for sampled data. ode : ODE integrator. odeint : ODE integrator. References
.. [1] 'Romberg's method' http://en.wikipedia.org/wiki/Romberg%27s_method Examples
Integrate a gaussian from 0 to 1 and compare to the error function.
from scipy import integrate from scipy.special import erf gaussian = lambda x: 1/np.sqrt(np.pi) * jnp.exp(-x*2) result = integrate.romberg(gaussian, 0, 1, show=True) Romberg integration of
from [0, 1] :: Steps StepSize Results 1 1.000000 0.385872 2 0.500000 0.412631 0.421551 4 0.250000 0.419184 0.421368 0.421356 8 0.125000 0.420810 0.421352 0.421350 0.421350 16 0.062500 0.421215 0.421350 0.421350 0.421350 0.421350 32 0.031250 0.421317 0.421350 0.421350 0.421350 0.421350 0.421350 The final result is 0.421350396475 after 33 function evaluations. print("%g %g" % (2 result, erf(1))) 0.842701 0.842701
As_to_sigma8_max_precision
¶
Compute the emulated conversion As -> sigma8, using the most accurate expression.
Parameters:
-
(As¶float) –10^9 times the amplitude of the primordial P(k)
-
(Om¶float) –The z=0 total matter density parameter, Om
-
(Ob¶float) –The z=0 baryonic density parameter, Ob
-
(h¶float) –Hubble constant, H0, divided by 100 km/s/Mpc
-
(ns¶float) –Spectral tilt of primordial power spectrum
-
(mnu¶float) –Sum of neutrino masses [eV / c^2]
-
(w0¶float) –Time independent part of the dark energy EoS
-
(wa¶float) –Time dependent part of the dark energy EoS
Returns:
-
sigma8(float) –Root-mean-square density fluctuation when the linearly evolved field is smoothed with a top-hat filter of radius 8 Mpc/h
options: show_root_toc_entry: true show_root_heading: true members: false
cosmology
¶
Protocols for Background and Perturbation cosmology classes.
Notes:¶
-
Refactored cosmology.py from the original CLOE to provide a more flexible framework, enabling seamless integration with external cosmological codes while removing dependency on Cobaya.
-
Introduced the use of protocols to standardize external code interfaces, providing a unified and extensible template for interaction.
Background
¶
flowchart TD
cloelib.cosmology.cosmology.Background[Background]
click cloelib.cosmology.cosmology.Background href "" "cloelib.cosmology.cosmology.Background"
Protocol for Background cosmology class.
Omega_cdm0
property
¶
Omega cold dark matter; the cold dark matter density/critical density at z=0.
mnu
property
¶
Total neutrino mass in eV (float) or an array of individual neutrino masses in eV.
Omega_k0
property
¶
Omega curvature; the effective curvature density/critical density at z=0.
interface_args
property
¶
Save internal structure format of possible interface codes.
Omega_cb
¶
Computes the cold dark matter + baryons (no neutrinos) as a function of redshift.
hubble_parameter
¶
Retrieve the hubble parameter as a function of redshift.
comoving_distance
¶
Calculate the comoving distance for given redshifts.
transverse_comoving_distance
¶
Calculate the transverse comoving distance for given redshifts.
angular_diameter_distance
¶
Calculate the angular diameter distance for given redshifts.
Perturbations
¶
flowchart TD
cloelib.cosmology.cosmology.Perturbations[Perturbations]
click cloelib.cosmology.cosmology.Perturbations href "" "cloelib.cosmology.cosmology.Perturbations"
Protocol for Perturbation cosmology class.
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
growth_rate
¶
Calculate the growth rate for given redshifts and wavenumbers.
matter_power_spectrum
¶
Retrieve the matter power spectrum.
matter_power_spectrum_cb
¶
Retrieves matter power spectrum of cold dark matter + baryons (no neutrinos).
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
derived_cosmology
¶
Common cosmology derived functions.
rho_crit
¶
rho_crit(background, zs: ndarray) -> ndarray
dV_dzdO
¶
Return the volume element per redshit per solid angle at the redshift requested.
Parameters¶
background: Background Background class containing cosmology zs :np.ndarray Redshifts. hubble_units: (Optional) bool Flag to specify if output in h units, defaults to False
Returns:
-
ndarray–volume element in Mpc^3 h^{-3}
rdrag_fitting_function
¶
rdrag_fitting_function(background, neff=3.046)
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
camb_cosmology
¶
Implementation of Background and Perturbation cosmology using CAMB.
CAMBBackground
¶
CAMBBackground(H0: float, Omega_b0: float, Omega_cdm0: float, Omega_k0: float, As: float, ns: float, mnu: Union[float, Sequence[float], ndarray], w0: float, wa: float, gamma_MG: float, N_mnu: int, N_ur: Optional[float] = None, alpha_s: float = 0.0)
A wrapper for CAMB background cosmological calculations.
Parameters:
-
(H0¶float) –Hubble parameter in [km/s/Mpc].
-
(Omega_b0¶float) –Baryonic matter density parameter.
-
(Omega_cdm0¶float) –Cold dark matter density parameter.
-
(Omega_k0¶float) –Curvature density parameter.
-
(As¶float) –Scalar amplitude of primordial fluctuations.
-
(ns¶float) –Scalar spectral index.
-
(alpha_s¶float, default:0.0) –Running of the scalar spectral index (d ns / d ln k).
-
(mnu¶Union[float, Sequence[float]], np.ndarray]) –Total neutrino mass in eV. Can be a single float for degenerate masses, an array (or a sequence of floats) for individual species.
-
(w0¶float) –Equation of state parameter for dark energy.
-
(wa¶float) –Time evolution of the dark energy equation of state.
-
(gamma_MG¶float) –Modified gravity growth parameter.
-
(N_mnu¶int) –Number of massive neutrino species.
-
(N_ur¶Optional[float], default:None) –Extra number of ultra-relativistic species. If not provided, it will be inferred from N_mnu such that N_eff = 3.044.
N_ur
property
¶
Effective number of ultra-relativistic species.
If the user gave one, return it; otherwise infer from other parameters such that N_eff = 3.044 for the standard model of cosmology.
N_eff
property
¶
Return the effective number of relativistic species.
Assumes a standard value of T_ncdm = 0.71611 for neutrinos.
hubble_parameter
¶
comoving_distance
¶
comoving_distance(zs: ndarray) -> ndarray
Return the comoving distance as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Comoving distance values.
transverse_comoving_distance
¶
transverse_comoving_distance(zs: ndarray) -> ndarray
Return the transverse comoving distance between two redshifts.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Transverse comoving distance values.
angular_diameter_distance
¶
angular_diameter_distance(zs: ndarray) -> ndarray
Return the angular diameter distance as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Angular diameter distance values.
Omega_cb
¶
Omega_cb(zs: ndarray) -> ndarray
Return the cold dark matter + baryons (no neutrinos) as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–np.ndarray: Matter density values (no neutrinos).
CAMBLinearPerturbations
¶
CAMBLinearPerturbations(background: Background, redshifts: ndarray)
A wrapper for CAMB linear perturbation calculations.
Parameters:
-
(background¶Background) –A CAMBBackground instance.
-
(redshifts¶ndarray) –Array of redshifts for the calculations.
matter_power_spectrum
¶
matter_power_spectrum(zs: ndarray, ks: ndarray, hubble_units=False, k_hunit=False) -> ndarray
Compute the linear matter power spectrum.
Parameters:
-
(zs¶ndarray) –redshifts
-
(ks¶ndarray) –wavenumber
-
(hubble_units¶Optional[bool], default:False) –Flag to specify if output in h units
-
(k_hunit¶Optional[bool], default:False) –Flag to specify if wavenumber in h units
Returns:
-
pk(ndarray) –Linear matter power spectrum at the specified scale and redshift
matter_power_spectrum_cb
¶
Computes the linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Args zs (numpy.ndarray): redshifts ks (numpy.ndarray): wavenumber
Returns:
-
ndarray–The growth factor at the specified redshift and wavenumber.
growth_factor_cb
¶
Calculate the growth factor for cb for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Args zs (numpy.ndarray): redshifts ks (numpy.ndarray): wavenumber
Returns:
-
ndarray–The growth factor at the specified redshift and wavenumber.
CAMBNonLinearPerturbations
¶
CAMBNonLinearPerturbations(background: Background, linearperturbations: Optional[object], redshifts: ndarray, nonlinear_model: Optional[str] = None, log10TAGN: Optional[float] = None)
A wrapper for CAMB nonlinear perturbation calculations.
Parameters:
-
(self¶LinearPerturbations) –An instance of the LinearPerturbations class.
-
(linearperturbations¶Optional[object]) –Linear perturbations object (unused by CAMB, which computes nonlinear corrections internally; accepted for interface compatibility with emulator-based NonLinPerturbations classes).
-
(redshifts¶ndarray) –Array of redshifts for the calculations.
-
(nonlinear_model¶Optional[str], default:None) –The nonlinear model to use (e.g., "takahashi"). Defaults to None, which uses the CAMB default model.
matter_power_spectrum
¶
matter_power_spectrum(zs: ndarray, ks: ndarray, hubble_units=False, k_hunit=False) -> ndarray
Compute the nonlinear matter power spectrum.
Parameters:
-
(zs¶ndarray) –redshifts
-
(ks¶ndarray) –wavenumber
-
(hubble_units¶Optional[bool], default:False) –Flag to specify if output in h units
-
(k_hunit¶Optional[bool], default:False) –Flag to specify if wavenumber in h units
Returns:
-
pk(ndarray) –Nonlinear matter power spectrum at the specified scale and redshift
matter_power_spectrum_cb
¶
Compute the nonlinear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
Returns:
-
ndarray–The growth factor at the specified redshift and wavenumber.
growth_factor_cb
¶
Calculate the growth factor for cb for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
Returns:
-
ndarray–The growth factor at the specified redshift and wavenumber.
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
class_cosmology
¶
Implementation of Background and Perturbation cosmology using CLASS.
CLASSBackground
¶
CLASSBackground(H0: float, Omega_b0: float, Omega_cdm0: float, Omega_k0: float, As: float, ns: float, mnu: Union[float, Sequence[float], ndarray], w0: float, wa: float, gamma_MG: float, N_mnu: int, N_ur: Optional[float] = None, alpha_s: float = 0.0, **kwargs)
A wrapper for CLASS background cosmological calculations.
Parameters:
-
(H0¶float) –Hubble parameter at z=0 in km/s/Mpc.
-
(Omega_b0¶float) –Baryonic matter density parameter.
-
(Omega_cdm0¶float) –Cold dark matter density parameter.
-
(Omega_k0¶float) –Curvature density parameter.
-
(As¶float) –Scalar amplitude of primordial fluctuations.
-
(ns¶float) –Scalar spectral index.
-
(alpha_s¶float, default:0.0) –Running of the scalar spectral index (d ns / d ln k).
-
(mnu¶Union[float, Sequence[float], ndarray]) –Total neutrino mass in eV. Can be a single float for degenerate masses, an array (or a sequence of floats) for individual species.
-
(w0¶float) –Equation of state parameter for dark energy.
-
(wa¶float) –Time evolution of the equation of state.
-
(gamma_MG¶float) –Modified gravity growth parameter (not directly used in CLASS, but kept for protocol compliance).
-
(N_mnu¶int) –Number of massive neutrino species.
-
(N_ur¶Optional[float], default:None) –Effective number of ultra-relativistic species. If not provided, it will be inferred from N_mnu such that N_eff = 3.044.
N_ur
property
¶
Effective number of ultra-relativistic species.
If the user gave one, return it; otherwise infer from other parameters such that N_eff = 3.044 for the standard model of cosmology.
N_eff
property
¶
Return the effective number of relativistic species.
Assumes a standard value of T_ncdm = 0.71611 K for neutrinos.
hubble_parameter
¶
comoving_distance
¶
comoving_distance(zs: ndarray) -> ndarray
Return the comoving distance as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Comoving distance values.
transverse_comoving_distance
¶
transverse_comoving_distance(zs: ndarray) -> ndarray
Return the transverse comoving distance between two redshifts.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Transverse comoving distance values.
angular_diameter_distance
¶
angular_diameter_distance(zs: ndarray) -> ndarray
Return the angular diameter distance as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Angular diameter distance values.
Omega_cb
¶
Omega_cb(zs: ndarray) -> ndarray
Return the cold dark matter + baryons (no neutrinos) as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–np.ndarray: Matter density values (no neutrinos).
CLASSLinearPerturbations
¶
CLASSLinearPerturbations(background: Background, redshifts: ndarray)
Class for perturbations cosmology using CLASS, inheriting from Perturbations parent class.
matter_power_spectrum
¶
matter_power_spectrum(zs, ks, hubble_units=False, k_hunit=False) -> ndarray
Calculate the CLASS linear matter power spectrum.
Parameters:
-
(zs¶ndarray) –redshifts
-
(ks¶ndarray) –wavenumber
-
(hubble_units¶Optional[bool], default:False) –Flag to specify if output in h units
-
(k_hunit¶Optional[bool], default:False) –Flag to specify if wavenumber in h units
Returns:
-
pk(ndarray) –Linear matter power spectrum at the specified scale
-
ndarray–and redshift
matter_power_spectrum_cb
¶
Computes the linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
Returns:
-
ndarray–The growth factor at the specified redshift and wavenumber.
growth_rate
¶
Calculate the growth rate f(z).
Returns:
-
ndarray–Scale-independent growth rate f(z)
CLASSNonLinearPerturbations
¶
CLASSNonLinearPerturbations(background: Background, linearperturbations: Optional[object], redshifts: ndarray, nonlinear_model: Optional[str] = None, hmcode_version: Optional[str] = None)
Class for non-linear perturbations cosmology using CLASS, inheriting from Perturbations parent class.
Parameters:
-
(background¶Background) –Background cosmology object.
-
(linearperturbations¶Optional[object]) –Linear perturbations object (unused by CLASS, which computes nonlinear corrections internally; accepted for interface compatibility with emulator-based NonLinPerturbations classes).
-
(redshifts¶ndarray) –Array of redshifts for the calculations.
-
(nonlinear_model¶Optional[str], default:None) –The nonlinear model to use. Defaults to None (no nonlinear).
-
(hmcode_version¶Optional[str], default:None) –The HMcode version to use. Defaults to None.
matter_power_spectrum
¶
matter_power_spectrum(zs, ks, hubble_units=False, k_hunit=False) -> ndarray
Calculate the CLASS non-linear matter power spectrum.
Parameters:
-
(zs¶ndarray) –redshifts
-
(ks¶ndarray) –wavenumber
-
(hubble_units¶Optional[bool], default:False) –Flag to specify if output in h units
-
(k_hunit¶Optional[bool], default:False) –Flag to specify if wavenumber in h units
Returns:
-
pk(ndarray) –Non-linear matter power spectrum at the specified scale
-
ndarray–and redshift
matter_power_spectrum_cb
¶
Calculate the CLASS non-linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
Returns:
-
ndarray–The growth factor at the specified redshift and wavenumber.
growth_rate
¶
Calculate the growth rate f(z).
Returns:
-
ndarray–Scale-independent growth rate f(z)
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
jax_cosmology
¶
Implementation of Background and Perturbation cosmology using JAX.
The module enables automatic differentiation. All of the functions are completely differentiable.
JAXBackground
¶
JAXBackground(H0: float, Omega_b0: float, Omega_cdm0: float, Omega_k0: float, As: float, ns: float, mnu: Union[float, Sequence[float], ndarray], w0: float, wa: float, gamma_MG: float, N_mnu: int, N_ur: Optional[float] = None, alpha_s: float = 0.0, **kwargs)
Class to define background cosmology using JAX,inheriting from Cosmology parent class.
Parameters:
-
(H0¶float) –Hubble parameter in [km/s/Mpc].
-
(Omega_b0¶float) –Baryonic matter density parameter.
-
(Omega_cdm0¶float) –Cold dark matter density parameter.
-
(Omega_k0¶float) –Curvature density parameter.
-
(As¶float) –Scalar amplitude of primordial fluctuations.
-
(ns¶float) –Scalar spectral index.
-
(alpha_s¶float, default:0.0) –Running of the scalar spectral index (d ns / d ln k). Note: JAXBackground does not use alpha_s (emulator not trained with it).
-
(mnu¶Union[float, Sequence[float], ndarray]) –Total neutrino mass in eV. Can be a single float for degenerate masses, an array (or a sequence of floats) for individual species.
-
(w0¶float) –Equation of state parameter for dark energy.
-
(wa¶float) –Time evolution of the dark energy equation of state.
-
(gamma_MG¶float) –Modified gravity growth parameter.
-
(N_mnu¶int) –Number of massive neutrino species. Note that JaxBackground does not support N_mnu != 0.
-
(N_ur¶Optional[float], default:None) –Effective number of ultra-relativistic species. If not provided, it will be inferred from N_mnu such that N_eff = 3.044.
N_ur
property
¶
Effective number of ultra-relativistic species.
Checks if N_ur is provided and raises an error if so. FIXME: Not implemented, so this will always return None.
N_eff
property
¶
Effective number of relativistic species.
FIXME: Not implemented, so this will always return the default 3.044.
hubble_parameter
¶
comoving_distance
¶
comoving_distance(zs: ndarray) -> ndarray
Calculate the comoving distance for given redshifts.
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the comoving distance.
Returns:
-
ndarray–The comoving distance as a function of redshift.
transverse_comoving_distance
¶
transverse_comoving_distance(zs: ndarray) -> ndarray
Return the transverse comoving distance between two redshifts.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Transverse comoving distance values.
angular_diameter_distance
¶
angular_diameter_distance(zs: ndarray) -> ndarray
Calculate the angular diameter distance for given redshifts.
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the angular diameter distance.
Returns:
-
ndarray–The angular diameter distance as a function of redshift.
Omega_b
¶
Omega_b(zs: ndarray) -> ndarray
Return the baryon density as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Matter density values.
Omega_m
¶
Omega_m(zs: ndarray) -> ndarray
Return the matter density as a function of redshift.
Parameters:
-
(zs¶ndarray) –Array of redshifts.
Returns:
-
ndarray–Matter density values.
JAXLinearPerturbations
¶
JAXLinearPerturbations(background: Background)
A wrapper for JAX linear perturbation calculations.
Parameters:
-
(background¶Background) –A Background instance.
transfer_Eisenstein_Hu
¶
transfer_Eisenstein_Hu(ks)
Compute the Eisenstein & Hu matter transfer function.
Parameters:
-
(ks¶array_like) –Wave number in h Mpc^{-1}
Returns:
-
T(array_like) –Value of the transfer function at the requested wave number
Notes
The Eisenstein & Hu transfer functions are computed using the fitting
formulae of :cite:1998:EisensteinHu
sigmasqr
¶
Compute the energy of the fluctuations within a sphere of R h^{-1} Mpc.
where
sigma8sqr
¶
Compute the energy of the fluctuations within a sphere of R h^{-1} Mpc.
where
matter_power_spectrum
¶
matter_power_spectrum_cb
¶
Computes the linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: array_like, optional Redshifts
array_like
Wave number in h Mpc^{-1}
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: array_like Linear matter power spectrum at the specified scale and redshift
JAXNonLinearPerturbations
¶
JAXNonLinearPerturbations(background: Background)
Class for perturbations cosmology using JAX, inheriting from Cosmology parent class.
growth_factor
¶
Return the linear growth factor.
matter_power_spectrum
¶
Compute the non-linear matter power spectrum.
This function is just a wrapper over several nonlinear power spectra.
nonlinear_matter_power_spectrum_limber_grid
¶
Write documentation (TODO).
matter_power_spectrum_cb
¶
Compute the non-linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters¶
zs: numpy.ndarray redshifts
numpy.ndarray
wavenumber
(Optional) bool
Flag to specify if output in h units, defaults to False
(Optional) bool
Flag to specify if wavenumber in h units, defaults to False
Returns¶
pk: numpy.ndarray Linear matter power spectrum at the specified scale and redshift
interp
¶
Compute a linear interpolation (equivalent of jnp.interp).
We are not doing any checks, so make sure your query points are lying inside the array.
TODO: Implement proper interpolation, like in interpolations.jl
x, xp, fp need to be 1d arrays
romb
¶
Romberg integration of a callable function or method.
Returns the integral of function (a function of one variable)
over the interval (a, b).
If show is 1, the triangular array of the intermediate results
will be printed. If vec_func is True (default is False), then
function is assumed to support vector arguments.
Parameters:
-
(function¶callable) –Function to be integrated.
-
(a¶float) –Lower limit of integration.
-
(b¶float) –Upper limit of integration.
-
(args¶optional[tuple], default:()) –Extra arguments to pass to function. Each element of
argswill be passed as a single argument tofunc. Default is to pass no extra arguments. -
(divmax¶optional[int], default:6) –Maximum order of extrapolation. Default is 10.
Returns:
-
results(float) –Result of the integration.
See Also¶
fixed_quad : Fixed-order Gaussian quadrature. quad : Adaptive quadrature using QUADPACK. dblquad : Double integrals. tplquad : Triple integrals. romb : Integrators for sampled data. simps : Integrators for sampled data. cumtrapz : Cumulative integration for sampled data. ode : ODE integrator. odeint : ODE integrator. References
.. [1] 'Romberg's method' http://en.wikipedia.org/wiki/Romberg%27s_method Examples
Integrate a gaussian from 0 to 1 and compare to the error function.
from scipy import integrate from scipy.special import erf gaussian = lambda x: 1/np.sqrt(np.pi) * jnp.exp(-x*2) result = integrate.romberg(gaussian, 0, 1, show=True) Romberg integration of
from [0, 1] :: Steps StepSize Results 1 1.000000 0.385872 2 0.500000 0.412631 0.421551 4 0.250000 0.419184 0.421368 0.421356 8 0.125000 0.420810 0.421352 0.421350 0.421350 16 0.062500 0.421215 0.421350 0.421350 0.421350 0.421350 32 0.031250 0.421317 0.421350 0.421350 0.421350 0.421350 0.421350 The final result is 0.421350396475 after 33 function evaluations. print("%g %g" % (2 result, erf(1))) 0.842701 0.842701
As_to_sigma8_max_precision
¶
Compute the emulated conversion As -> sigma8, using the most accurate expression.
Parameters:
-
(As¶float) –10^9 times the amplitude of the primordial P(k)
-
(Om¶float) –The z=0 total matter density parameter, Om
-
(Ob¶float) –The z=0 baryonic density parameter, Ob
-
(h¶float) –Hubble constant, H0, divided by 100 km/s/Mpc
-
(ns¶float) –Spectral tilt of primordial power spectrum
-
(mnu¶float) –Sum of neutrino masses [eV / c^2]
-
(w0¶float) –Time independent part of the dark energy EoS
-
(wa¶float) –Time dependent part of the dark energy EoS
Returns:
-
sigma8(float) –Root-mean-square density fluctuation when the linearly evolved field is smoothed with a top-hat filter of radius 8 Mpc/h
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
cosmopower_jax_cosmology
¶
This module provides CosmoPower-JAX-based emulators for linear and nonlinear matter power spectra.
Uses cosmopower_jax instead of tensorflow-based cosmopower for faster JAX-accelerated predictions.
Supported models include: - w0waCDM with mass of the neutrino 0 - w0waCDM with one massive neutrino - w0waCDM with 2 massive neutrinos - w0waCDM with three degenerate massive neutrinos - wCDM with mass of the neutrino 0 - wCDM with one massive neutrino - wCDM with 2 massive neutrinos - wCDM with three massive neutrinos - LCDM with mass of the neutrinos 0 - LCDM with one massive neutrino - LCDM with 2 massive neutrinos - LCDM with three massive neutrinos
- LCDM with curvature
- LCDM with running of the spectral index
CosmoPowerJAXw0waCDMPerturbations
¶
Class for w0waCDM cosmology perturbations using CosmoPower-JAX emulators.
Linear
¶
Linear(background: Background, redshifts: ndarray)
Emulator for the linear matter power spectrum in the w0waCDM cosmology.
Uses CosmoPower-JAX for fast JAX-accelerated predictions.
Parameters¶
background : Background Background cosmology object. redshifts : np.ndarray Array of redshift values.
matter_power_spectrum
¶
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
.. math:: D(z, k) =\sqrt{P_{\rm \delta\delta}(z, k)\ /P_{\rm \delta\delta}(z=0, k)}\
and normalizes as for :math:D(z)/D(0).
Parameters:¶
zs : array_like Redshifts at which to calculate the growth factor. ks : array_like Wavenumbers at which to calculate the growth factor.
Returns:¶
np.ndarray The growth factor as a function of redshift and wavenumber.
LinearCB
¶
LinearCB(background: Background, redshifts: ndarray)
Emulator for the cb [cold dark matter (c) + baryon (b)] linear matter power spectrum in the w0waCDM cosmology.
This class uses a Cosmopower-JAX neural network to emulate the cb linear power spectrum for a w0waCDM cosmology. Automatically selects the appropriate emulator based on neutrino configuration.
matter_power_spectrum
¶
Compute the cb linear matter power spectrum P_cb(k, z).
NonLinear
¶
NonLinear(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the nonlinear matter power spectrum in the w0waCDM cosmology.
This class uses a Cosmopower-JAX neural network to emulate the nonlinear power spectrum
for a w0waCDM cosmology. Automatically selects the appropriate emulator based on neutrino configuration.
Nonlinear corrections are applied using the mead2020 model in CAMB, with baryonic feedback
regulated using the log10TAGN parameter.
matter_power_spectrum
¶
Compute the nonlinear matter power spectrum P(k, z).
NonLinearCB
¶
NonLinearCB(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the cb [cold dark matter (c) + baryon (b)] nonlinear matter power spectrum in the w0waCDM cosmology.
This class uses a Cosmopower-JAX neural network to emulate the cb nonlinear power spectrum
for a w0waCDM cosmology. Automatically selects the appropriate emulator based on neutrino configuration.
Nonlinear corrections are applied using the mead2020 model in CAMB, with baryonic feedback
regulated using the log10TAGN parameter.
matter_power_spectrum
¶
Compute the cb nonlinear matter power spectrum P_cb(k, z).
CosmoPowerJAXwCDMPerturbations
¶
Class for wCDM cosmology perturbations using CosmoPower-JAX emulators.
Linear
¶
Linear(background: Background, redshifts: ndarray)
Emulator for the linear matter power spectrum in the wCDM cosmology.
This class uses a Cosmopower-JAX neural network to emulate the linear power spectrum for a wCDM cosmology. Automatically selects the appropriate emulator based on neutrino configuration.
matter_power_spectrum
¶
Compute the linear matter power spectrum P(k, z).
LinearCB
¶
LinearCB(background: Background, redshifts: ndarray)
Emulator for the cb [cold dark matter (c) + baryon (b)] linear matter power spectrum in the wCDM cosmology.
This class uses a Cosmopower-JAX neural network to emulate the cb linear power spectrum for a wCDM cosmology. Automatically selects the appropriate emulator based on neutrino configuration.
NonLinear
¶
NonLinear(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the nonlinear matter power spectrum in wCDM cosmology.
NonLinearCB
¶
NonLinearCB(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the cb nonlinear matter power spectrum in wCDM cosmology.
CosmoPowerJAXLCDMPerturbations
¶
Class for LCDM cosmology perturbations using CosmoPower-JAX emulators.
Linear
¶
Linear(background: Background, redshifts: ndarray)
Emulator for the linear matter power spectrum in LCDM cosmology.
LinearCB
¶
LinearCB(background: Background, redshifts: ndarray)
Emulator for the cb linear matter power spectrum in LCDM cosmology.
NonLinear
¶
NonLinear(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the nonlinear matter power spectrum in LCDM cosmology.
NonLinearCB
¶
NonLinearCB(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the cb nonlinear matter power spectrum in LCDM cosmology.
CosmoPowerJAXCurvaturePerturbations
¶
Class for LCDM+curvature cosmology perturbations using CosmoPower-JAX emulators.
Supports non-zero spatial curvature (Omega_k0 != 0). Neutrino mass is fixed at mnu=0.06 eV during training and is not a free parameter of these emulators. Uses a dedicated k-mode grid (curvature-kmodes.txt) and emulator files: - lcdm-curvature-linear.npz - lcdm-curvature-nonlinear.npz - lcdm-curvature-s8-fs8.npz
Emulator parameter ranges
ombh2 in [0.019, 0.025] omch2 in [0.09, 0.15] H0 in [60, 80] ns in [0.8, 1.2] lnAs in [1.6, 4.0] z in [0, 5] logT_AGN in [7.3, 8.5] (nonlinear and sigma8/fsigma8 emulators only) omk in [-0.1, 0.1]
Linear
¶
Linear(background: Background, redshifts: ndarray)
Emulator for the linear matter power spectrum in LCDM+curvature cosmology.
NonLinear
¶
NonLinear(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the nonlinear matter power spectrum in LCDM+curvature cosmology.
LinearCB
¶
LinearCB(background: Background, redshifts: ndarray)
Emulator for the cb linear matter power spectrum in LCDM+curvature cosmology.
NonLinearCB
¶
NonLinearCB(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the cb nonlinear matter power spectrum in LCDM+curvature cosmology.
CosmoPowerJAXRunningIndexPerturbations
¶
Class for LCDM+running spectral index cosmology perturbations using CosmoPower-JAX emulators.
Supports a running spectral index alpha_s = d ns / d ln k. Neutrino mass is fixed at mnu=0.06 eV during training and is not a free parameter of these emulators. Uses the standard k-mode grid (k-modes.txt) and emulator files: - lcdm-running-linear.npz - lcdm-running-nonlinear.npz - lcdm-running-s8-fs8.npz
Emulator parameter ranges
ombh2 in [0.019, 0.025] omch2 in [0.09, 0.15] H0 in [60, 80] ns in [0.8, 1.2] lnAs in [1.6, 4.0] z in [0, 5] alpha_s in [-0.1, 0.1] logT_AGN in [7.3, 8.5] (nonlinear and sigma8/fsigma8 emulators only)
Linear
¶
Linear(background: Background, redshifts: ndarray)
Emulator for the linear matter power spectrum in LCDM+running spectral index cosmology.
NonLinear
¶
NonLinear(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the nonlinear matter power spectrum in LCDM+running spectral index cosmology.
LinearCB
¶
LinearCB(background: Background, redshifts: ndarray)
Emulator for the cb linear matter power spectrum in LCDM+running spectral index cosmology.
NonLinearCB
¶
NonLinearCB(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Emulator for the cb nonlinear matter power spectrum in LCDM+running spectral index cosmology.
emulator_data
¶
load_pk_emulator
¶
load_sigma_emulator
¶
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
HMcode2020Emu_cosmology
¶
Implementation of Background and Perturbation cosmology using HMcode2020Emu.
HMemuLinearPerturbations
¶
HMemuLinearPerturbations(background: Background, redshifts: ndarray)
Class for perturbations cosmology using HMemu, compatibly with the Perturbations protocol.
matter_power_spectrum
¶
matter_power_spectrum(zs, ks, hubble_units=False, k_hunit=False) -> ndarray
Compute the linear matter power spectrum.
Parameters:
-
(ks¶ndarray) –Wave number in h Mpc^{-1}
-
(zs¶ndarray) –redshifts
-
(hubble_units¶Optional[bool], default:False) –Flag to specify if output in h units
-
(k_hunit¶Optional[bool], default:False) –Flag to specify if wavenumber in h units
Returns:
-
pk(ndarray) –Linear matter power spectrum at the specified scale and redshift
matter_power_spectrum_cb
¶
matter_power_spectrum_cb(zs, ks, hubble_units=False, k_hunit=False) -> ndarray
Compute the linear matter power spectrum of cold dark matter + baryons (no neutrinos).
Parameters:
-
(ks¶ndarray) –Wave number in h Mpc^{-1}
-
(zs¶ndarray) –redshifts
-
(hubble_units¶Optional[bool], default:False) –Flag to specify if output in h units
-
(k_hunit¶Optional[bool], default:False) –Flag to specify if wavenumber in h units
Returns:
-
pk(ndarray) –Linear matter power spectrum at the specified scale and redshift
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The growth factor as a function of redshift and wavenumber.
growth_factor_cb
¶
Calculate the growth factor for cb for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The growth factor as a function of redshift and wavenumber.
growth_rate
¶
Calculate the growth rate for given redshifts and wavenumbers.
Returns:
-
ndarray–The growth rate as a function of redshift and wavenumber.
HMemuNonLinearPerturbations
¶
HMemuNonLinearPerturbations(background: Background, linearperturbations: Perturbations, redshifts: ndarray, log10TAGN: Optional[float] = None)
Class for non linear perturbations cosmology using HMemu, compatibly with the Perturbations protocol.
matter_power_spectrum
¶
matter_power_spectrum_cb
¶
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The growth factor as a function of redshift and wavenumber.
growth_factor_cb
¶
Calculate the growth factor for cb for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The growth factor as a function of redshift and wavenumber.
growth_rate
¶
Calculate the growth rate for given redshifts and wavenumbers.
Returns:
-
ndarray–The growth rate as a function of redshift and wavenumber.
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
EE2_cosmology
¶
Implementation of Background and Perturbation cosmology using EuclidEmulator2.
EE2NonLinearPerturbations
¶
EE2NonLinearPerturbations(background: Background, linearperturbations: Perturbations, redshifts: ndarray)
Class for nonlinear perturbations using EE2, compatible with the Perturbations protocol.
matter_power_spectrum
¶
matter_power_spectrum_cb
¶
growth_factor
¶
Calculate the growth factor for given redshifts and wavenumbers.
.. math:: D(z, k) =\sqrt{P_{\rm \delta\delta}(z, k)\ /P_{\rm \delta\delta}(z=0, k)}\
and normalizes as for :math:D(z)/D(0).
We use here the growth from the fluctuations without baryons.
Parameters:¶
zs : array_like Redshifts at which to calculate the growth factor. ks : array_like Wavenumbers at which to calculate the growth factor.
Returns:¶
np.ndarray The growth factor as a function of redshift and wavenumber.
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
baccoemu_cosmology
¶
Implementation of Background and Perturbation cosmology using BACCOemu (similarly to what done with HMcode2020emu).
BACCOemuLinearPerturbations
¶
BACCOemuLinearPerturbations(background: Background, redshifts: ndarray)
Class for perturbations cosmology using BACCOemu, compatibly with the Perturbations protocol.
matter_power_spectrum
¶
matter_power_spectrum_cb
¶
growth_factor
¶
Calculate the total (dark matter + baryons + neutrinos) growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The growth factor as a function of redshift and wavenumber.
growth_rate
¶
Calculate the total (dark matter + baryons + neutrinos) linear growth rate for given redshifts and wavenumbers.
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The linear growth rate as a function of redshift and wavenumber.
growth_factor_cb
¶
Calculate the cold (dark matter + baryons) growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The growth factor as a function of redshift and wavenumber.
growth_rate_cb
¶
Calculate the cold (dark matter + baryons) linear growth rate for given redshifts and wavenumbers.
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The linear cold growth rate as a function of redshift and wavenumber.
sigma8_0
¶
Calculate the total (dark matter + baryons + neutrinos) linear sigma8 value for the current cosmology.
Returns:¶
float The sigma8 value.
sigma12_0
¶
Calculate the total (dark matter + baryons + neutrinos) linear sigma12 value for the current cosmology.
Returns:¶
float The sigma8 value.
BACCOemuNonLinearPerturbations
¶
BACCOemuNonLinearPerturbations(background: Background, linearperturbations: Perturbations, redshifts: ndarray, nonlinear_model_name: Optional[str] = 'Arico2023', baryonic_boost: Optional[str] = None, baryonic_model_name: Optional[str] = 'Burger2025', M_c: Optional[float] = None, eta: Optional[float] = None, beta: Optional[float] = None, M1_z0_cen: Optional[float] = None, theta_out: Optional[float] = None, theta_inn: Optional[float] = None, M_inn: Optional[float] = None)
Class for non linear perturbations cosmology using BACCOemu, compatibly with the Perturbations protocol.
matter_power_spectrum
¶
matter_power_spectrum_cb
¶
growth_factor
¶
Calculate the total (dark matter + baryons + neutrinos) linear growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The linear growth factor as a function of redshift and wavenumber.
growth_rate
¶
Calculate the total (dark matter + baryons + neutrinos) linear growth rate for given redshifts and wavenumbers.
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The linear growth rate as a function of redshift and wavenumber.
growth_factor_cb
¶
Calculate the cold (dark matter + baryons) linear growth factor for given redshifts and wavenumbers.
and normalizes as for \(D(z)/D(0)\).
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The linear growth factor as a function of redshift and wavenumber.
growth_rate_cb
¶
Calculate the cold (dark matter + baryons) linear growth rate for given redshifts and wavenumbers.
Parameters:
-
(zs¶array_like) –Redshifts at which to calculate the growth factor.
-
(ks¶array_like) –Wavenumbers at which to calculate the growth factor.
Returns:
-
ndarray–The linear cold growth rate as a function of redshift and wavenumber.
sigma8_0
¶
Calculate the total (dark matter + baryons + neutrinos) linear sigma8 value for the current cosmology.
Returns:¶
float The sigma8 value.
sigma12_0
¶
Calculate the total (dark matter + baryons + neutrinos) linear sigma12 value for the current cosmology.
Returns:¶
float The sigma8 value.
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
emantis_cosmology
¶
Implementation of nonlinear Perturbation cosmology for f(R) gravity using the e-MANTIS emulator.
EmantisFofrNonLinearPerturbations
¶
EmantisFofrNonLinearPerturbations(background: Background, linearperturbations: Perturbations, nonlinearperturbations_lcdm: Perturbations, fR0: float, redshifts: ndarray, verbose: bool = False, emu_version: int = 2, extrapolate_cosmo: bool = True)
Nonlinear perturbations in f(R) gravity.
The nonlinear matter power spectrum boost, i.e. P_f(R)(k) / P_LCDM(k), is computed with the e-MANTIS emulator. The boost is then combined with an external nonlinear LCDM matter power spectrum prediction in order to obtain the full nonlinear matter power spectrum in f(R) gravity.
Parameters¶
background : Background A background cosmology object, providing all the standard cosmological parameters. linearperturbations : Perturbations A linear perturbations object, providing linear perturbations in f(R) gravity. nonlinearperturbations_lcdm : Perturbations A nonlinear perturbations object, providing the nonlinear matter power spectrum in LCDM. fR0 : float The modified gravity parameter fR0. redshifts : np.ndarray An array of redshifts used to compute the matter power spectrum. verbose : float, optional (default=False) Activate or not verbose output from the emantis emulator. emu_version : int, optional (default=2) The version of the emantis emulator to use. Version 2 (the default) has an extended cosmological parameter and redshift range. extrapolate_cosmo : bool optional (default=True) Activate or not constant extrapolation of cosmological parameters. The extrapolation is done only for the LCDM cosmological parameters. There is no extrapolation for fR0.
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
observables
¶
Observable package of cloelib.
The package provides photometric and spectroscopic observables. The Tracer protocol is used to define Photometric observables. The SpectroPower protocol is used to define Spectroscopic observables.
Supported External Codes:
- SpectroPower: comet-emu, PBJ
- Tracers: ShearTracer, PositionsTracer
CometEFT_spectro
¶
Interface of Legendre Multiples with Comet.
CometEFT_SpectroPower
¶
CometEFT_SpectroPower(background: Background, RSD_parameters: dict, redshift: float)
Class to retrieve \(P(k,\mu)\) (including RSD) with the EFT model from COMET.
Parameters:
-
(background¶Background) –Background class containing cosmology and background distances
-
(RSD_parameters¶dict) –Dictionary containing bias and counterterm parameters
-
(redshift¶float) –Redshift at which to evaluate \(P(k,\mu)\)
CometVDG_spectro
¶
Interface of Legendre Multiples with Comet.
CometVDG_SpectroPower
¶
CometVDG_SpectroPower(background: Background, RSD_parameters: dict, redshift: float)
Class to retrieve \(P(k,\mu)\) (including RSD) with the VDG model from COMET.
Parameters:
-
(background¶Background) –Background class containing cosmology and background distances
-
(RSD_parameters¶dict) –Dictionary containing bias and counterterm parameters
-
(redshift¶float) –Redshift at which to evaluate \(P(k,\mu)\)
PBJ_spectro
¶
Interface of Legendre Multipoles with PBJ.
PBJSpectroPower
¶
PBJSpectroPower(linear_perturbations: Perturbations, nuisance_parameters: dict, redshift: float)
Class to retrieve \(P(k,\mu)\) with the EFT model from PBJ.
Parameters:
-
(linear_perturbations¶Perturbations) –Perturbations object containing cosmology, linear power spectrum, and growth functions
-
(nuisance_parameters¶dict) –Dictionary containing bias and counterterm parameters
-
(redshift¶float) –single redshift in which to evaluate PBJ
Pk2d_rsd
¶
Pk2d_term_rsd
¶
2D power spectrum for a subset of specific diagrams of the loop expansion, corresponding to linear parameters that can be analytically marginalised over.
Parameters¶
k: np.ndarray Wavenumber mu: np.ndarray Angle (cosinus) to the line of sight term_list: list Identifiers of loop diagrams. Available options: 'bG3', 'c0', 'c2', 'c4', 'ck4'
Returns¶
Pk2d: np.ndarray 2D power spectrum of specific terms
cmb
¶
Module implementing CMB lensing.
This class is compatible with the Tracer protocol.
CMBLensingTracer
¶
CMBLensingTracer(perturbations: Perturbations, z: ndarray)
Class for the kernel for CMB Lensing convergence.
Parameters¶
perturbations : object An object from NonLinearPerturbations class z : np.ndarray A 1-dimensional array used to perform line-of-sight integration.
get_window
¶
Compute the Window.
Computes CMB lensing window function
.. math:: W^{\kappa}(\ell, z, k) = \frac{3}{2}\left ( \frac{H_0}{c}\right )^2 \Omega_{{\rm m},0} (1 + z) f_K\left[\tilde{r}(z)\right] \frac{f_K\left[\tilde{r}(z_) - \tilde{r}(z)\right]} {f_K\left[\tilde{r}(z_)\right]}\
Parameters¶
z: float Redshift at which window kernel is being evaluated
Returns¶
window: np.ndarray
photo
¶
Module with two classes for each observable tracer type: shear and galaxy positions.
Both classes are compatible with the Tracer protocol.
ShearTracer
¶
ShearTracer(perturbations: Perturbations, dndz: ndarray, z: ndarray, nuisance_params: dict)
Class for the kernel for Cosmic Shear.
Parameters:
-
(perturbations¶object) –An object from NonLinearPerturbations class
-
(dndz¶ndarray) –A n-dimensional array representing the number density distribution of galaxies as a function of redshift. It is expected to be normalised.
-
(z¶ndarray) –A 1-dimensional array representing the redshift values corresponding to the
dndzarray.
get_window_IA
¶
get_window_IA(z)
Window integrand.
Calculates IA window
Parameters:
-
(z¶float) –Redshift at which kernel is being evaluated
Returns:
-
window_IA(ndarray) –
get_lensing_efficiency_bin
¶
Compute the lensing efficiency in a redshift bin.
get_lensing_efficiency
¶
get_lensing_efficiency(z)
Compute the lensing efficiency kernel for each redshift bin.
This function calculates the geometric lensing kernel W(χ), which weights the contribution
of matter at different redshifts to the weak lensing signal, for a given redshift grid z.
Parameters:
-
(z¶ndarray) –1D array of redshift values (must be evenly spaced). Used to compute comoving distances and define integration domain.
Returns:
-
ndarray–2D array of shape (N_bins, len(z)) representing the lensing efficiency kernel W(z) for each redshift bin over the evaluation grid.
Notes¶
- Assumes
zis evenly spaced; spacing is inferred asz[1] - z[0]. - Uses a precomputed Simpson rule weight matrix (
cached_stacked_simpson) for integration. self.dndzis expected to have shape (N_bins, len(z)) and be normalized.- Efficiency is evaluated using
np.einsum.
get_window_lensing
¶
get_window_lensing(z)
Weak Lensing shear kernel.
Calculates the weak lensing shear kernel for a given tomographic bin
distribution.
Uses broadcasting to compute a 2D-array of integrands and then applies
np.trapz on the array along one axis.
Parameters:
-
(z¶ndarray) –Redshift at which weight is evaluated (
floattype).
Returns:
-
ndarray–1-D Numpy array of shear kernel values for specified bin at specified scale for the redshifts defined in z
PositionsTracer
¶
PositionsTracer(perturbations: Perturbations, dndz: ndarray, z: ndarray, galaxy_bias_model: str, nuisance_params: dict, include_rsd: bool = False)
Class to define the kernel for angular (galaxy) clustering.
This docstring should be checked. I replaced LinearPerturbations or NonLinearPerturbations with Perturbations as the type of perturbations in the parameters list doc.¶
Parameters:
-
(perturbations¶Perturbations) –An object from NonLinearPerturbations class
-
(dndz¶ndarray) –A n-dimensional array representing the number density distribution of galaxies as a function of redshift. It is expected to be normalised.
-
(z¶ndarray) –A 1-dimensional array representing the redshift values corresponding to the
dndzarray. -
(galaxy_bias_model¶str) –A string specifying the model used to describe the galaxy bias
-
(nuisance_params¶dict) –A dictionary containing additional parameters that are not directly related to the cosmological model but may affect the observations.
get_window_positions
¶
get_window_positions(z) -> ndarray
Galaxy Positions window function.
Implements the galaxy clustering photometric window function.
Parameters:
-
(z¶ndarray | float) –Redshift at which to evaluate distribution (array of
floatorfloat)
Returns:
-
window_positions(ndarray) –Window function for angular photometric galaxy clustering
get_window_rsd
¶
Linear photo-RSD window :math:W^{\rm RSD}_i(\ell,z) tabulated on the internal z-grid.
We use the shifted-distance (extended Limber) approximation, where the RSD contribution is written as a linear combination of the source term evaluated at shifted redshifts:
with $$ S_i(z)=\frac{H(z)\,f(z)}{c}\,n_i(z), $$
and the shifted redshifts defined implicitly via comoving distance (here :math:\chi \equiv r):
$$
\chi!\left(z_m(\ell,z)\right)=
\frac{\ell+m+\tfrac12}{\ell+\tfrac12}\,\chi(z),
\qquad m\in{-2,+2}.
$$
The coefficients are $$ A_\ell=\frac{2\ell^2+2\ell-1}{(2\ell-1)(2\ell+3)},\quad B_\ell=-\frac{\ell(\ell-1)}{(2\ell-1)(2\ell+1)},\quad C_\ell=-\frac{(\ell+1)(\ell+2)}{(2\ell+1)(2\ell+3)}. $$
Notes¶
chiis used purely as an interpolation coordinate soget_photo_rsdcan evaluate the shifted arguments efficiently.
Parameters¶
ells : array_like
Multipoles ell.
H, f : array_like
H(z) and growth rate f(z), sampled on the same z-grid as self.dndz_shifted.
chi : array_like
Comoving distance χ(z)=r(z), sampled on the same z-grid.
Returns¶
ndarray
The RSD window sampled on the z-grid (shape as returned by get_photo_rsd).
get_magnification_efficiency
¶
get_magnification_efficiency(z)
Compute the magnification efficiency kernel for each redshift bin.
This function calculates the geometric lensing kernel W(χ), which weights the contribution
of matter at different redshifts to the weak lensing signal, for a given redshift grid z.
Parameters:
-
(z¶ndarray) –1D array of redshift values (must be evenly spaced). Used to compute comoving distances and define integration domain.
Returns:
-
ndarray–2D array of shape (N_bins, len(z)) representing the lensing efficiency kernel W(z) for each redshift bin over the evaluation grid.
Notes¶
- Assumes
zis evenly spaced; spacing is inferred asz[1] - z[0]. - Uses a precomputed Simpson rule weight matrix (
cached_stacked_simpson) for integration. self.dndzis expected to have shape (N_bins, len(z)) and be normalized.- Efficiency is evaluated using
np.einsum.
get_window_magnification
¶
get_window_magnification(z)
Magnification photometric galaxy kernel.
Calculates the weak lensing shear kernel for a given tomographic bin
distribution.
Uses broadcasting to compute a 2D-array of integrands and then applies
np.trapz on the array along one axis.
Parameters:
-
(z¶ndarray) –Redshift at which weight is evaluated (array of
float).
Returns:
-
ndarray–1-D Numpy array of shear kernel values for specified bin at specified scale for the redshifts defined in z
get_window
¶
get_window(z) -> ndarray
Compute the angular photometric galaxy clustering window function.
This function combines the galaxy clustering window and the magnification bias window to produce the final window function.
Parameters:
-
(z¶float) –Redshift at which window kernel is being evaluated
Returns:
-
window(ndarray) –
spectro
¶
SpectroPower protocol.
SpectroPower
¶
flowchart TD
cloelib.observables.spectro.SpectroPower[SpectroPower]
click cloelib.observables.spectro.SpectroPower href "" "cloelib.observables.spectro.SpectroPower"
Protocol to define the \(P(k,\mu)\) interface.
Pk2d_rsd
¶
2D power spectrum from couplings of density and velocity fields.
Parameters:
-
(k¶ndarray) –Wavenumber. Can be NumPy (
numpy.ndarray) or JAX (jax.numpy.ndarray) ndarray. -
(mu¶ndarray | ndarray) –Angle (cosinus) to the line of sight. Can be NumPy (
numpy.ndarray) or JAX (jax.numpy.ndarray) ndarray.
Returns:
-
Pk2d_rsd(ndarray | ndarray) –2D power spectrum from couplings of density and velocity fields
Pk2d_term_rsd
¶
2D power spectrum for a subset of specific term of the loop expansion.
Parameters:
-
(k¶ndarray | ndarray) –Wavenumber. Can be NumPy (
numpy.ndarray) or JAX (jax.numpy.ndarray) ndarray. -
(mu¶ndarray | ndarray) –Angle (cosinus) to the line of sight. Can be NumPy (
numpy.ndarray) or JAX (jax.numpy.ndarray) ndarray.
Returns:
-
Pk2d_term_rsd(ndarray | ndarray) –2D power spectrum of specific terms. Can be NumPy (
numpy.ndarray) or JAX (jax.numpy.ndarray) ndarray.
options: show_root_toc_entry: true show_root_heading: true members: false
photo
¶
Module with two classes for each observable tracer type: shear and galaxy positions.
Both classes are compatible with the Tracer protocol.
ShearTracer
¶
ShearTracer(perturbations: Perturbations, dndz: ndarray, z: ndarray, nuisance_params: dict)
Class for the kernel for Cosmic Shear.
Parameters:
-
(perturbations¶object) –An object from NonLinearPerturbations class
-
(dndz¶ndarray) –A n-dimensional array representing the number density distribution of galaxies as a function of redshift. It is expected to be normalised.
-
(z¶ndarray) –A 1-dimensional array representing the redshift values corresponding to the
dndzarray.
get_window_IA
¶
get_window_IA(z)
Window integrand.
Calculates IA window
Parameters:
-
(z¶float) –Redshift at which kernel is being evaluated
Returns:
-
window_IA(ndarray) –
get_lensing_efficiency_bin
¶
Compute the lensing efficiency in a redshift bin.
get_lensing_efficiency
¶
get_lensing_efficiency(z)
Compute the lensing efficiency kernel for each redshift bin.
This function calculates the geometric lensing kernel W(χ), which weights the contribution
of matter at different redshifts to the weak lensing signal, for a given redshift grid z.
Parameters:
-
(z¶ndarray) –1D array of redshift values (must be evenly spaced). Used to compute comoving distances and define integration domain.
Returns:
-
ndarray–2D array of shape (N_bins, len(z)) representing the lensing efficiency kernel W(z) for each redshift bin over the evaluation grid.
Notes¶
- Assumes
zis evenly spaced; spacing is inferred asz[1] - z[0]. - Uses a precomputed Simpson rule weight matrix (
cached_stacked_simpson) for integration. self.dndzis expected to have shape (N_bins, len(z)) and be normalized.- Efficiency is evaluated using
np.einsum.
get_window_lensing
¶
get_window_lensing(z)
Weak Lensing shear kernel.
Calculates the weak lensing shear kernel for a given tomographic bin
distribution.
Uses broadcasting to compute a 2D-array of integrands and then applies
np.trapz on the array along one axis.
Parameters:
-
(z¶ndarray) –Redshift at which weight is evaluated (
floattype).
Returns:
-
ndarray–1-D Numpy array of shear kernel values for specified bin at specified scale for the redshifts defined in z
PositionsTracer
¶
PositionsTracer(perturbations: Perturbations, dndz: ndarray, z: ndarray, galaxy_bias_model: str, nuisance_params: dict, include_rsd: bool = False)
Class to define the kernel for angular (galaxy) clustering.
This docstring should be checked. I replaced LinearPerturbations or NonLinearPerturbations with Perturbations as the type of perturbations in the parameters list doc.¶
Parameters:
-
(perturbations¶Perturbations) –An object from NonLinearPerturbations class
-
(dndz¶ndarray) –A n-dimensional array representing the number density distribution of galaxies as a function of redshift. It is expected to be normalised.
-
(z¶ndarray) –A 1-dimensional array representing the redshift values corresponding to the
dndzarray. -
(galaxy_bias_model¶str) –A string specifying the model used to describe the galaxy bias
-
(nuisance_params¶dict) –A dictionary containing additional parameters that are not directly related to the cosmological model but may affect the observations.
get_window_positions
¶
get_window_positions(z) -> ndarray
Galaxy Positions window function.
Implements the galaxy clustering photometric window function.
Parameters:
-
(z¶ndarray | float) –Redshift at which to evaluate distribution (array of
floatorfloat)
Returns:
-
window_positions(ndarray) –Window function for angular photometric galaxy clustering
get_window_rsd
¶
Linear photo-RSD window :math:W^{\rm RSD}_i(\ell,z) tabulated on the internal z-grid.
We use the shifted-distance (extended Limber) approximation, where the RSD contribution is written as a linear combination of the source term evaluated at shifted redshifts:
with $$ S_i(z)=\frac{H(z)\,f(z)}{c}\,n_i(z), $$
and the shifted redshifts defined implicitly via comoving distance (here :math:\chi \equiv r):
$$
\chi!\left(z_m(\ell,z)\right)=
\frac{\ell+m+\tfrac12}{\ell+\tfrac12}\,\chi(z),
\qquad m\in{-2,+2}.
$$
The coefficients are $$ A_\ell=\frac{2\ell^2+2\ell-1}{(2\ell-1)(2\ell+3)},\quad B_\ell=-\frac{\ell(\ell-1)}{(2\ell-1)(2\ell+1)},\quad C_\ell=-\frac{(\ell+1)(\ell+2)}{(2\ell+1)(2\ell+3)}. $$
Notes¶
chiis used purely as an interpolation coordinate soget_photo_rsdcan evaluate the shifted arguments efficiently.
Parameters¶
ells : array_like
Multipoles ell.
H, f : array_like
H(z) and growth rate f(z), sampled on the same z-grid as self.dndz_shifted.
chi : array_like
Comoving distance χ(z)=r(z), sampled on the same z-grid.
Returns¶
ndarray
The RSD window sampled on the z-grid (shape as returned by get_photo_rsd).
get_magnification_efficiency
¶
get_magnification_efficiency(z)
Compute the magnification efficiency kernel for each redshift bin.
This function calculates the geometric lensing kernel W(χ), which weights the contribution
of matter at different redshifts to the weak lensing signal, for a given redshift grid z.
Parameters:
-
(z¶ndarray) –1D array of redshift values (must be evenly spaced). Used to compute comoving distances and define integration domain.
Returns:
-
ndarray–2D array of shape (N_bins, len(z)) representing the lensing efficiency kernel W(z) for each redshift bin over the evaluation grid.
Notes¶
- Assumes
zis evenly spaced; spacing is inferred asz[1] - z[0]. - Uses a precomputed Simpson rule weight matrix (
cached_stacked_simpson) for integration. self.dndzis expected to have shape (N_bins, len(z)) and be normalized.- Efficiency is evaluated using
np.einsum.
get_window_magnification
¶
get_window_magnification(z)
Magnification photometric galaxy kernel.
Calculates the weak lensing shear kernel for a given tomographic bin
distribution.
Uses broadcasting to compute a 2D-array of integrands and then applies
np.trapz on the array along one axis.
Parameters:
-
(z¶ndarray) –Redshift at which weight is evaluated (array of
float).
Returns:
-
ndarray–1-D Numpy array of shear kernel values for specified bin at specified scale for the redshifts defined in z
get_window
¶
get_window(z) -> ndarray
Compute the angular photometric galaxy clustering window function.
This function combines the galaxy clustering window and the magnification bias window to produce the final window function.
Parameters:
-
(z¶float) –Redshift at which window kernel is being evaluated
Returns:
-
window(ndarray) –
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
spectro
¶
SpectroPower protocol.
SpectroPower
¶
flowchart TD
cloelib.observables.spectro.SpectroPower[SpectroPower]
click cloelib.observables.spectro.SpectroPower href "" "cloelib.observables.spectro.SpectroPower"
Protocol to define the \(P(k,\mu)\) interface.
Pk2d_rsd
¶
2D power spectrum from couplings of density and velocity fields.
Parameters:
-
(k¶ndarray) –Wavenumber. Can be NumPy (
numpy.ndarray) or JAX (jax.numpy.ndarray) ndarray. -
(mu¶ndarray | ndarray) –Angle (cosinus) to the line of sight. Can be NumPy (
numpy.ndarray) or JAX (jax.numpy.ndarray) ndarray.
Returns:
-
Pk2d_rsd(ndarray | ndarray) –2D power spectrum from couplings of density and velocity fields
Pk2d_term_rsd
¶
2D power spectrum for a subset of specific term of the loop expansion.
Parameters:
-
(k¶ndarray | ndarray) –Wavenumber. Can be NumPy (
numpy.ndarray) or JAX (jax.numpy.ndarray) ndarray. -
(mu¶ndarray | ndarray) –Angle (cosinus) to the line of sight. Can be NumPy (
numpy.ndarray) or JAX (jax.numpy.ndarray) ndarray.
Returns:
-
Pk2d_term_rsd(ndarray | ndarray) –2D power spectrum of specific terms. Can be NumPy (
numpy.ndarray) or JAX (jax.numpy.ndarray) ndarray.
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
tracer
¶
Tracer protocol for different window functions.
Tracer
¶
flowchart TD
cloelib.observables.tracer.Tracer[Tracer]
click cloelib.observables.tracer.Tracer href "" "cloelib.observables.tracer.Tracer"
Tracer protocol to implement window functions.
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
CometEFT_spectro
¶
Interface of Legendre Multiples with Comet.
CometEFT_SpectroPower
¶
CometEFT_SpectroPower(background: Background, RSD_parameters: dict, redshift: float)
Class to retrieve \(P(k,\mu)\) (including RSD) with the EFT model from COMET.
Parameters:
-
(background¶Background) –Background class containing cosmology and background distances
-
(RSD_parameters¶dict) –Dictionary containing bias and counterterm parameters
-
(redshift¶float) –Redshift at which to evaluate \(P(k,\mu)\)
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
CometVDG_spectro
¶
Interface of Legendre Multiples with Comet.
CometVDG_SpectroPower
¶
CometVDG_SpectroPower(background: Background, RSD_parameters: dict, redshift: float)
Class to retrieve \(P(k,\mu)\) (including RSD) with the VDG model from COMET.
Parameters:
-
(background¶Background) –Background class containing cosmology and background distances
-
(RSD_parameters¶dict) –Dictionary containing bias and counterterm parameters
-
(redshift¶float) –Redshift at which to evaluate \(P(k,\mu)\)
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
PBJ_spectro
¶
Interface of Legendre Multipoles with PBJ.
PBJSpectroPower
¶
PBJSpectroPower(linear_perturbations: Perturbations, nuisance_parameters: dict, redshift: float)
Class to retrieve \(P(k,\mu)\) with the EFT model from PBJ.
Parameters:
-
(linear_perturbations¶Perturbations) –Perturbations object containing cosmology, linear power spectrum, and growth functions
-
(nuisance_parameters¶dict) –Dictionary containing bias and counterterm parameters
-
(redshift¶float) –single redshift in which to evaluate PBJ
Pk2d_rsd
¶
Pk2d_term_rsd
¶
2D power spectrum for a subset of specific diagrams of the loop expansion, corresponding to linear parameters that can be analytically marginalised over.
Parameters¶
k: np.ndarray Wavenumber mu: np.ndarray Angle (cosinus) to the line of sight term_list: list Identifiers of loop diagrams. Available options: 'bG3', 'c0', 'c2', 'c4', 'ck4'
Returns¶
Pk2d: np.ndarray 2D power spectrum of specific terms
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
profiling
¶
Time profiling package of cloelib.
The package provides modules to time profile the library functions
profile_function
¶
Define the decorator to profile a function's runtime using pyinstrument.
options: show_root_toc_entry: true show_root_heading: true members: false
profiling
¶
Profiling utilities for cloelib.
Provides decorators and helpers for runtime profiling using pyinstrument.
profile_function
¶
Define the decorator to profile a function's runtime using pyinstrument.
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
summary_statistics
¶
Summary Statistics package of cloelib.
The package provides modules to compute the final summary statistics, such as angular power spectra or Legendre multipoles.
APDistortion
¶
Module to compute Alcock-Paczynski (AP) distortions parameters.
APDistortion
¶
APDistortion(background: Background, background_fiducial: Background)
Class to compute AP distortion parameters from cosmological background quantities.
Parameters:
-
(background¶Background) –Background class for computing background distances
-
(background_fiducial¶Background) –Background class for computing fiducial background distances
angular_correlation_function
¶
Protocol for angular correlation function classes.
This protocol defines a standard interface for computing real-space two-point correlation functions xi(theta). Implementing classes are expected to encapsulate any internal information needed to evaluate the correlation function, such as multipole grids (ells), wavenumber grids (ks), and angular power spectra (Cl).
Notes¶
Implementations may return a single correlation function xi(theta) (e.g., galaxy clustering or galaxy-galaxy lensing) or a tuple (xi_plus, xi_minus) for spin-2 tracers (e.g., cosmic shear).
AngularCorrelationFunction
¶
flowchart TD
cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction[AngularCorrelationFunction]
click cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction href "" "cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction"
angular_correlation_function_wigner
¶
AngularCorrelationFunctionWigner
¶
AngularCorrelationFunctionWigner(angular_two_point, ells, ks)
flowchart TD
cloelib.summary_statistics.angular_correlation_function_wigner.AngularCorrelationFunctionWigner[AngularCorrelationFunctionWigner]
cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction[AngularCorrelationFunction]
cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction --> cloelib.summary_statistics.angular_correlation_function_wigner.AngularCorrelationFunctionWigner
click cloelib.summary_statistics.angular_correlation_function_wigner.AngularCorrelationFunctionWigner href "" "cloelib.summary_statistics.angular_correlation_function_wigner.AngularCorrelationFunctionWigner"
click cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction href "" "cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction"
Correlation function implementation using Wigner small-d matrices.
The real-space angular correlation functions are computed from angular power spectra Cl via spherical harmonic projection. The spin configuration is inferred from the types of tracers in the provided AngularTwoPoint object.
Parameters:
-
(angular_two_point¶AngularTwoPoint) –Object providing Cl evaluation and tracers.
-
(ells¶ndarray) –Multipole moments at which the Cl spectrum is evaluated.
-
(ks¶ndarray) –Wavenumber grid (only needed for computing Cl via angular_two_point).
build_xi_dict
¶
Return a dictionary of TwoPointCorrelationFunction objects.
get_xi
¶
get_xi(theta)
Compute the angular correlation function xi(theta) using the Wigner d-matrices.
TODO: Also implement FFTLog which is likely faster WARNING: Currently assumes B-modes are zero, as they are not passed on from AngularTwoPoint
Parameters:
-
(theta¶ndarray) –Angles in radians. Should be JAX (
jax.numpy.ndarray) ndarray.
Returns:
-
ndarray | (ndarray, ndarray)–Computed xi(theta) if at least one tracer is spin 0 (clustering or GGL) (
jax.numpy.ndarray) or Computed xi_+(theta) and xi_-(theta) (jax.numpy.ndarray,jax.numpy.ndarray) if both tracers are spin 2 (cosmic shear)
angular_two_point
¶
Module for angular two-point functions.
AngularTwoPoint
¶
Two point asbtract class to compute two point functions.
Checks if the tracers are compatible and sets the two tracers as instance attributes.
Parameters:
-
(tracer1¶Tracer, default:None) –The first tracer for the two-point function. Defaults to None.
-
(tracer2¶Tracer, default:None) –The second tracer for the two-point function. Defaults to None.
get_Cl
¶
Compute the angular power spectrum Cl using Limber approximation.
Combines the window functions of the tracers, interpolated matter power spectrum, Hubble parameter, and comoving distances to calculate the two-point angular statistics.
Parameters:
-
(ells¶ndarray) –Multipole moments for the angular power spectrum.
-
(nl¶ndarray) –Noise power spectrum (not used yet, reserved for future use).
-
(ks¶ndarray) –Wavenumber grid of the matter power spectrum.
Returns:
-
ndarray–Angular power spectrum Cl for the given multipoles.
get_pseudo_Cl
¶
Compute the pseudo angular power spectrum Cl convolved with the mixing matrices.
Parameters: - nl (jax.numpy.ndarray): Noise power spectrum (not used yet). - ks (jax.numpy.ndarray): Wavenumber grid of the matter power spectrum. - mixing_matrix (dict): Mixing matrices in the euclidlib internal format.
Returns: - dict: Pseudo angular power spectrum Cl for the multipoles specified by the mixing matrix.
get_cosebis
¶
Compute EE and BB COSEBIs from angular power spectra.
Delegates to the module-level :func:get_cosebis_from_cl. See that
function for full parameter documentation.
Cl_integration
¶
Perform the integration to compute the angular power spectrum Cl.
The integration is done using the unnormalized trapezoidal rule, utilizing the window functions, power spectrum, Hubble parameter, and comoving distance squared.
Parameters:
-
(WT1¶ndarray) –Window function for the first tracer.
-
(WT2¶ndarray) –Window function for the second tracer.
-
(Pkl¶ndarray) –Matter power spectrum interpolated on Limber grid.
-
(H¶ndarray) –Hubble parameter evaluated at redshifts.
-
(chi2¶ndarray) –Square of comoving distances at redshifts.
-
(weights¶ndarray) –Array of weights used for the fixed nodes integration.
Returns:
-
ndarray–Angular power spectrum Cl with shape (len(ells), len(ells), len(ells)).
Pkl_interp
¶
Interpolate the matter power spectrum on a Limber grid.
Utilizes interpax's 2D interpolation with Akima method to handle non-uniform grids in logarithmic space. Extrapolation is enabled for values outside the given grid.
Parameters:
-
(k_l¶ndarray) –Wavenumbers corresponding to (ells + 0.5) / chi.
-
(z_l¶ndarray) –Redshift grid for Limber integration.
-
(ks¶ndarray) –Original wavenumber grid of the matter power spectrum.
-
(zs¶ndarray) –Original redshift grid of the matter power spectrum.
-
(Pk¶ndarray) –Matter power spectrum values on (ks, zs) grid.
Returns:
-
ndarray–Interpolated power spectrum on the Limber grid.
get_cosebis_from_cl
¶
Compute EE and BB COSEBIs for all SHE-SHE keys in cells.
Can be used as a standalone function without instantiating AngularTwoPoint
if angular power spectra are already available.
Parameters¶
cells : dict Angular power spectra in cosmolib format. All SHE-SHE bin pairs present in the dict are processed automatically. ells : jax.numpy.ndarray Multipoles at which the integration is performed. w_ell : dict Harmonic-space COSEBIs kernels. Two layouts are accepted:
* **Global** — a single dict ``{n: array, ..., "metadata": {...}}``
(as returned by ``get_W_ell``). The same kernels are used for
every bin pair.
* **Per-bin** — a dict ``{(i, j): {n: array, ..., "metadata": {...}},
...}`` supplying independent kernels per bin pair. A ``None`` key
may be included as a global fallback for pairs without an explicit
entry.
ns : array-like
Mode indices selecting kernels from w_ell.
software : str, optional
Software provenance tag stored in the output COSEBI objects.
Defaults to 'get_cosebis_from_cl (cloelib)'.
Returns¶
dict
Dictionary keyed like the SHE-SHE entries of cells with COSEBI
values of shape (2, 2, n_modes).
get_cosebis_from_2pcf
¶
Compute EE and BB COSEBIs for all SHE-SHE keys in twopcf.
Can be used as a standalone function without instantiating AngularTwoPoint
if two-point correlation functions are already available.
Parameters¶
twopcf : dict
Two-point correlation functions in cosmolib format.
Keys should be tuples like ('SHE', 'SHE', i, j).
theta : jax.numpy.ndarray
Angular scales in radians.
T_plus : array-like
Real-space T_+ kernel functions.
T_minus : array-like
Real-space T_- kernel functions.
ns : jax.numpy.ndarray
Mode indices selecting kernels from T_plus/T_minus.
software : str, optional
Software provenance tag stored in the output COSEBI objects.
Defaults to 'get_cosebis_from_2pcf (cloelib)'.
Returns¶
dict
COSEBIs with EE and BB modes, keyed like twopcf.
bao_alphas
¶
Module to compute alpha parameters for the BAO analysis.
BaryonAcousticOscillations
¶
BaryonAcousticOscillations(background: Background, background_fiducial: Background, redshifts: ndarray)
Class to compute alpha parameters for the BAO analysis.
Parameters:
-
(background¶Background) –Object following the Background protocol; used to compute background quantities needed for the alphas in a given cosmology
-
(background_fiducial¶Background) –Object following the Background protocol; used to compute background quantities in the fiducial cosmology
-
(redshifts¶ndarray) –Array of redshifts at which the alphas are output
alpha_par
¶
alpha_par(zs: T) -> T
Alpha_parallel.
Dilation parameter along the line of sight
Parameters:
-
(zs¶array) –redshift
Returns:
-
alpha_par(array) –alpha_parallel at requested redshifts
alpha_perp
¶
alpha_perp(zs: T) -> T
Alpha_perpendicular.
Dilation parameter perpendicular to the line of sight
Parameters:
-
(zs¶array) –redshift
Returns:
-
alpha_perp(array) –alpha_perpendicular at requested redshifts
alpha_iso
¶
alpha_iso(alpha_par: T, alpha_perp: T) -> T
Alpha_iso.
Geometrical mean of alpha_parallel and alpha_perpendicular
Parameters:
Returns:
-
alpha_iso(array) –alpha_iso computed from alpha_par, alpha_perp
alpha_AP
¶
alpha_AP(alpha_par: ndarray, alpha_perp: ndarray) -> ndarray
Alpha_AP.
Ratio of alpha_parallel and alpha_perpendicular
Parameters:
Returns:
-
alpha_AP(array) –alpha_AP computed from alpha_par, alpha_perp
set_alphas
¶
Construct a dictionary with values for the BAO alphas.
The alphas are alpha_par, alpha_perp, alpha_iso and alpha_AP. The alphas are evaluated at the redshifts requested at initialisation.
Returns:
-
alphas(dict) –Dictionary containing values for the BAO alphas
legendre_multipoles
¶
Module to compute Legendre multipoles.
LegendreMultipoles
¶
LegendreMultipoles(spectro_power: SpectroPower, background_fiducial: Background, parameters: dict, nbar: float)
Class to compute spectroscopic Legendre multipoles of the galaxy power spectrum.
Parameters:
-
(spectro_power¶SpectroPower) –Class returning the anisotropic power spectrum (only density and velocity field couplings; noise and systematics are included directly here)
-
(background_fiducial¶Background) –Background class for computing fiducial background distances
-
(parameters¶dict) –Dictionary containing shot noise and parameters related to observational systematics
-
(nbar¶float) –Mean number denisty of the sample
power_multipoles
¶
power_multipoles(k: ndarray, ells: Optional[ndarray] = None, use_AP: Optional[bool] = True, format_type: Optional[str] = None) -> dict
Power spectrum Legendre multipoles.
Parameters:
-
(k¶ndarray) –Wavenumber
-
(ells¶ndarray, default:None) –Legendre multipole order
-
(use_AP¶bool, default:True) –Flag to switch between with and without AP corrections
-
(format_type¶str, default:None) –Type of output format
Returns: multipoles (dict): Power spectrum Legendre multipoles
power_term_multipoles
¶
power_term_multipoles(k: ndarray, term_list: list, ells: Optional[ndarray] = None, use_AP: Optional[bool] = True) -> dict
Power spectrum Legendre multipoles of specified terms.
Parameters:
-
(k¶ndarray) –Wavenumber
-
(term_list¶list) –List of terms to compute
-
(ells¶ndarray, default:None) –Legendre multipole order
-
(use_AP¶bool, default:True) –Flag to switch between with and without AP corrections
Returns:
-
multipoles(dict) –Power spectrum Legendre multipoles of specified terms
convolved_power_multipoles
¶
convolved_power_multipoles(mixing_matrix: PowerSpectrumMultipolesMixingMatrix, ells: Optional[ndarray] = None, use_AP: Optional[bool] = True, format_type: Optional[str] = None) -> dict
Power spectrum Legendre multipoles convolved with the mixing matrix.
Parameters:
-
(mixing_matrix¶PowerSpectrumMultipolesMixingMatrix) –Dicitonary containing the mixing matrix
-
(ells¶ndarray, default:None) –Legendre multipole order
-
(use_AP¶bool, default:True) –Flag to switch between with and without AP corrections
-
(format_type¶str, default:None) –Type of output format
Returns:
-
multipoles_out(dict) –Convolved power spectrum Legendre multipoles
convolved_power_term_multipoles
¶
convolved_power_term_multipoles(mixing_matrix: PowerSpectrumMultipolesMixingMatrix, term_list: list, ells: Optional[ndarray] = None, use_AP: Optional[bool] = True) -> dict
Convolved power spectrum multipoles of specified terms.
Parameters:
-
(mixing_matrix¶PowerSpectrumMultipolesMixingMatrix) –Dicitonary containing the mixing matrix
-
(term_list¶list) –List of terms to compute
-
(ells¶ndarray, default:None) –Legendre multipole order
-
(use_AP¶bool, default:True) –Flag to switch between with and without AP corrections
Returns:
-
multipoles_out(dict) –Convolved power spectrum Legendre multipoles of specified terms
two_point_correlation_multipoles
¶
two_point_correlation_multipoles(s: ndarray, ells: Optional[ndarray] = None, use_AP: Optional[bool] = True, logkmin: Optional[float] = -5.0, logkmax: Optional[float] = 2.0, nk: Optional[int] = 2048, kcut: Optional[float] = 0.4, pow: Optional[float] = 2.0, format_type: Optional[str] = None) -> dict
Two-point correlation function Legendre multipoles.
Parameters¶
s: np.ndarray Comoving separations ells: np.ndarray Legendre multipole order use_AP: bool Flag to switch between with and without AP corrections logkmin: float Left logarithmic edge of input wave mode array logkmax: float Right logarithmic edge of input wave mode array nk: int Number of logarithmic wave mode bins kcut: float Cutoff scale for exponential damping pow: float Power index for exponential damping format_type: str Type of output format Returns
multipoles: dict Two-point correlation function Legendre multipoles
two_point_correlation_polar
¶
two_point_correlation_polar(s: ndarray, mu: ndarray, use_AP: Optional[bool] = True, logkmin: Optional[float] = -5.0, logkmax: Optional[float] = 2.0, nk: Optional[int] = 2048, kcut: Optional[float] = 0.4, pow: Optional[float] = 2.0, format_type: Optional[str] = None) -> dict
Polar two-point correlation function.
Parameters¶
s: np.ndarray Comoving separations mu: np.ndarray Cosinus of the angle between the pair separation and the line of sight use_AP: bool Flag to switch between with and without AP corrections logkmin: float Left logarithmic edge of input wave mode array logkmax: float Right logarithmic edge of input wave mode array nk: int Number of logarithmic wave mode bins kcut: float Cutoff scale for exponential damping pow: float Power index for exponential damping format_type: str Type of output format Returns
xi_polar: np.ndarray Polar two-point correlation function
two_point_correlation_term_multipoles
¶
two_point_correlation_term_multipoles(s: ndarray, term_list: list, ells: Optional[ndarray] = None, use_AP: Optional[bool] = True, logkmin: Optional[float] = -5.0, logkmax: Optional[float] = 2.0, nk: Optional[int] = 2048, kcut: Optional[float] = 0.4, pow: Optional[float] = 2.0) -> dict
Two-point correlation function Legendre multipoles of specified terms.
Parameters¶
s: np.ndarray Comoving separations term_list: list List of terms to compute ells: np.ndarray Legendre multipole order use_AP: bool Flag to switch between with and without AP corrections logkmin: float Left logarithmic edge of input wave mode array logkmax: float Right logarithmic edge of input wave mode array nk: int Number of logarithmic wave mode bins kcut: float Cutoff scale for exponential damping pow: float Power index for exponential damping Returns
multipoles: dict Two-point correlation function Legendre multipoles of specified terms
options: show_root_toc_entry: true show_root_heading: true members: false
angular_correlation_function_wigner
¶
AngularCorrelationFunctionWigner
¶
AngularCorrelationFunctionWigner(angular_two_point, ells, ks)
flowchart TD
cloelib.summary_statistics.angular_correlation_function_wigner.AngularCorrelationFunctionWigner[AngularCorrelationFunctionWigner]
cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction[AngularCorrelationFunction]
cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction --> cloelib.summary_statistics.angular_correlation_function_wigner.AngularCorrelationFunctionWigner
click cloelib.summary_statistics.angular_correlation_function_wigner.AngularCorrelationFunctionWigner href "" "cloelib.summary_statistics.angular_correlation_function_wigner.AngularCorrelationFunctionWigner"
click cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction href "" "cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction"
Correlation function implementation using Wigner small-d matrices.
The real-space angular correlation functions are computed from angular power spectra Cl via spherical harmonic projection. The spin configuration is inferred from the types of tracers in the provided AngularTwoPoint object.
Parameters:
-
(angular_two_point¶AngularTwoPoint) –Object providing Cl evaluation and tracers.
-
(ells¶ndarray) –Multipole moments at which the Cl spectrum is evaluated.
-
(ks¶ndarray) –Wavenumber grid (only needed for computing Cl via angular_two_point).
build_xi_dict
¶
Return a dictionary of TwoPointCorrelationFunction objects.
get_xi
¶
get_xi(theta)
Compute the angular correlation function xi(theta) using the Wigner d-matrices.
TODO: Also implement FFTLog which is likely faster WARNING: Currently assumes B-modes are zero, as they are not passed on from AngularTwoPoint
Parameters:
-
(theta¶ndarray) –Angles in radians. Should be JAX (
jax.numpy.ndarray) ndarray.
Returns:
-
ndarray | (ndarray, ndarray)–Computed xi(theta) if at least one tracer is spin 0 (clustering or GGL) (
jax.numpy.ndarray) or Computed xi_+(theta) and xi_-(theta) (jax.numpy.ndarray,jax.numpy.ndarray) if both tracers are spin 2 (cosmic shear)
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
angular_correlation_function
¶
Protocol for angular correlation function classes.
This protocol defines a standard interface for computing real-space two-point correlation functions xi(theta). Implementing classes are expected to encapsulate any internal information needed to evaluate the correlation function, such as multipole grids (ells), wavenumber grids (ks), and angular power spectra (Cl).
Notes¶
Implementations may return a single correlation function xi(theta) (e.g., galaxy clustering or galaxy-galaxy lensing) or a tuple (xi_plus, xi_minus) for spin-2 tracers (e.g., cosmic shear).
AngularCorrelationFunction
¶
flowchart TD
cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction[AngularCorrelationFunction]
click cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction href "" "cloelib.summary_statistics.angular_correlation_function.AngularCorrelationFunction"
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
angular_two_point
¶
Module for angular two-point functions.
AngularTwoPoint
¶
Two point asbtract class to compute two point functions.
Checks if the tracers are compatible and sets the two tracers as instance attributes.
Parameters:
-
(tracer1¶Tracer, default:None) –The first tracer for the two-point function. Defaults to None.
-
(tracer2¶Tracer, default:None) –The second tracer for the two-point function. Defaults to None.
get_Cl
¶
Compute the angular power spectrum Cl using Limber approximation.
Combines the window functions of the tracers, interpolated matter power spectrum, Hubble parameter, and comoving distances to calculate the two-point angular statistics.
Parameters:
-
(ells¶ndarray) –Multipole moments for the angular power spectrum.
-
(nl¶ndarray) –Noise power spectrum (not used yet, reserved for future use).
-
(ks¶ndarray) –Wavenumber grid of the matter power spectrum.
Returns:
-
ndarray–Angular power spectrum Cl for the given multipoles.
get_pseudo_Cl
¶
Compute the pseudo angular power spectrum Cl convolved with the mixing matrices.
Parameters: - nl (jax.numpy.ndarray): Noise power spectrum (not used yet). - ks (jax.numpy.ndarray): Wavenumber grid of the matter power spectrum. - mixing_matrix (dict): Mixing matrices in the euclidlib internal format.
Returns: - dict: Pseudo angular power spectrum Cl for the multipoles specified by the mixing matrix.
get_cosebis
¶
Compute EE and BB COSEBIs from angular power spectra.
Delegates to the module-level :func:get_cosebis_from_cl. See that
function for full parameter documentation.
Cl_integration
¶
Perform the integration to compute the angular power spectrum Cl.
The integration is done using the unnormalized trapezoidal rule, utilizing the window functions, power spectrum, Hubble parameter, and comoving distance squared.
Parameters:
-
(WT1¶ndarray) –Window function for the first tracer.
-
(WT2¶ndarray) –Window function for the second tracer.
-
(Pkl¶ndarray) –Matter power spectrum interpolated on Limber grid.
-
(H¶ndarray) –Hubble parameter evaluated at redshifts.
-
(chi2¶ndarray) –Square of comoving distances at redshifts.
-
(weights¶ndarray) –Array of weights used for the fixed nodes integration.
Returns:
-
ndarray–Angular power spectrum Cl with shape (len(ells), len(ells), len(ells)).
Pkl_interp
¶
Interpolate the matter power spectrum on a Limber grid.
Utilizes interpax's 2D interpolation with Akima method to handle non-uniform grids in logarithmic space. Extrapolation is enabled for values outside the given grid.
Parameters:
-
(k_l¶ndarray) –Wavenumbers corresponding to (ells + 0.5) / chi.
-
(z_l¶ndarray) –Redshift grid for Limber integration.
-
(ks¶ndarray) –Original wavenumber grid of the matter power spectrum.
-
(zs¶ndarray) –Original redshift grid of the matter power spectrum.
-
(Pk¶ndarray) –Matter power spectrum values on (ks, zs) grid.
Returns:
-
ndarray–Interpolated power spectrum on the Limber grid.
get_cosebis_from_cl
¶
Compute EE and BB COSEBIs for all SHE-SHE keys in cells.
Can be used as a standalone function without instantiating AngularTwoPoint
if angular power spectra are already available.
Parameters¶
cells : dict Angular power spectra in cosmolib format. All SHE-SHE bin pairs present in the dict are processed automatically. ells : jax.numpy.ndarray Multipoles at which the integration is performed. w_ell : dict Harmonic-space COSEBIs kernels. Two layouts are accepted:
* **Global** — a single dict ``{n: array, ..., "metadata": {...}}``
(as returned by ``get_W_ell``). The same kernels are used for
every bin pair.
* **Per-bin** — a dict ``{(i, j): {n: array, ..., "metadata": {...}},
...}`` supplying independent kernels per bin pair. A ``None`` key
may be included as a global fallback for pairs without an explicit
entry.
ns : array-like
Mode indices selecting kernels from w_ell.
software : str, optional
Software provenance tag stored in the output COSEBI objects.
Defaults to 'get_cosebis_from_cl (cloelib)'.
Returns¶
dict
Dictionary keyed like the SHE-SHE entries of cells with COSEBI
values of shape (2, 2, n_modes).
get_cosebis_from_2pcf
¶
Compute EE and BB COSEBIs for all SHE-SHE keys in twopcf.
Can be used as a standalone function without instantiating AngularTwoPoint
if two-point correlation functions are already available.
Parameters¶
twopcf : dict
Two-point correlation functions in cosmolib format.
Keys should be tuples like ('SHE', 'SHE', i, j).
theta : jax.numpy.ndarray
Angular scales in radians.
T_plus : array-like
Real-space T_+ kernel functions.
T_minus : array-like
Real-space T_- kernel functions.
ns : jax.numpy.ndarray
Mode indices selecting kernels from T_plus/T_minus.
software : str, optional
Software provenance tag stored in the output COSEBI objects.
Defaults to 'get_cosebis_from_2pcf (cloelib)'.
Returns¶
dict
COSEBIs with EE and BB modes, keyed like twopcf.
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
bao_alphas
¶
Module to compute alpha parameters for the BAO analysis.
BaryonAcousticOscillations
¶
BaryonAcousticOscillations(background: Background, background_fiducial: Background, redshifts: ndarray)
Class to compute alpha parameters for the BAO analysis.
Parameters:
-
(background¶Background) –Object following the Background protocol; used to compute background quantities needed for the alphas in a given cosmology
-
(background_fiducial¶Background) –Object following the Background protocol; used to compute background quantities in the fiducial cosmology
-
(redshifts¶ndarray) –Array of redshifts at which the alphas are output
alpha_par
¶
alpha_par(zs: T) -> T
Alpha_parallel.
Dilation parameter along the line of sight
Parameters:
-
(zs¶array) –redshift
Returns:
-
alpha_par(array) –alpha_parallel at requested redshifts
alpha_perp
¶
alpha_perp(zs: T) -> T
Alpha_perpendicular.
Dilation parameter perpendicular to the line of sight
Parameters:
-
(zs¶array) –redshift
Returns:
-
alpha_perp(array) –alpha_perpendicular at requested redshifts
alpha_iso
¶
alpha_iso(alpha_par: T, alpha_perp: T) -> T
Alpha_iso.
Geometrical mean of alpha_parallel and alpha_perpendicular
Parameters:
Returns:
-
alpha_iso(array) –alpha_iso computed from alpha_par, alpha_perp
alpha_AP
¶
alpha_AP(alpha_par: ndarray, alpha_perp: ndarray) -> ndarray
Alpha_AP.
Ratio of alpha_parallel and alpha_perpendicular
Parameters:
Returns:
-
alpha_AP(array) –alpha_AP computed from alpha_par, alpha_perp
set_alphas
¶
Construct a dictionary with values for the BAO alphas.
The alphas are alpha_par, alpha_perp, alpha_iso and alpha_AP. The alphas are evaluated at the redshifts requested at initialisation.
Returns:
-
alphas(dict) –Dictionary containing values for the BAO alphas
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
legendre_multipoles
¶
Module to compute Legendre multipoles.
LegendreMultipoles
¶
LegendreMultipoles(spectro_power: SpectroPower, background_fiducial: Background, parameters: dict, nbar: float)
Class to compute spectroscopic Legendre multipoles of the galaxy power spectrum.
Parameters:
-
(spectro_power¶SpectroPower) –Class returning the anisotropic power spectrum (only density and velocity field couplings; noise and systematics are included directly here)
-
(background_fiducial¶Background) –Background class for computing fiducial background distances
-
(parameters¶dict) –Dictionary containing shot noise and parameters related to observational systematics
-
(nbar¶float) –Mean number denisty of the sample
power_multipoles
¶
power_multipoles(k: ndarray, ells: Optional[ndarray] = None, use_AP: Optional[bool] = True, format_type: Optional[str] = None) -> dict
Power spectrum Legendre multipoles.
Parameters:
-
(k¶ndarray) –Wavenumber
-
(ells¶ndarray, default:None) –Legendre multipole order
-
(use_AP¶bool, default:True) –Flag to switch between with and without AP corrections
-
(format_type¶str, default:None) –Type of output format
Returns: multipoles (dict): Power spectrum Legendre multipoles
power_term_multipoles
¶
power_term_multipoles(k: ndarray, term_list: list, ells: Optional[ndarray] = None, use_AP: Optional[bool] = True) -> dict
Power spectrum Legendre multipoles of specified terms.
Parameters:
-
(k¶ndarray) –Wavenumber
-
(term_list¶list) –List of terms to compute
-
(ells¶ndarray, default:None) –Legendre multipole order
-
(use_AP¶bool, default:True) –Flag to switch between with and without AP corrections
Returns:
-
multipoles(dict) –Power spectrum Legendre multipoles of specified terms
convolved_power_multipoles
¶
convolved_power_multipoles(mixing_matrix: PowerSpectrumMultipolesMixingMatrix, ells: Optional[ndarray] = None, use_AP: Optional[bool] = True, format_type: Optional[str] = None) -> dict
Power spectrum Legendre multipoles convolved with the mixing matrix.
Parameters:
-
(mixing_matrix¶PowerSpectrumMultipolesMixingMatrix) –Dicitonary containing the mixing matrix
-
(ells¶ndarray, default:None) –Legendre multipole order
-
(use_AP¶bool, default:True) –Flag to switch between with and without AP corrections
-
(format_type¶str, default:None) –Type of output format
Returns:
-
multipoles_out(dict) –Convolved power spectrum Legendre multipoles
convolved_power_term_multipoles
¶
convolved_power_term_multipoles(mixing_matrix: PowerSpectrumMultipolesMixingMatrix, term_list: list, ells: Optional[ndarray] = None, use_AP: Optional[bool] = True) -> dict
Convolved power spectrum multipoles of specified terms.
Parameters:
-
(mixing_matrix¶PowerSpectrumMultipolesMixingMatrix) –Dicitonary containing the mixing matrix
-
(term_list¶list) –List of terms to compute
-
(ells¶ndarray, default:None) –Legendre multipole order
-
(use_AP¶bool, default:True) –Flag to switch between with and without AP corrections
Returns:
-
multipoles_out(dict) –Convolved power spectrum Legendre multipoles of specified terms
two_point_correlation_multipoles
¶
two_point_correlation_multipoles(s: ndarray, ells: Optional[ndarray] = None, use_AP: Optional[bool] = True, logkmin: Optional[float] = -5.0, logkmax: Optional[float] = 2.0, nk: Optional[int] = 2048, kcut: Optional[float] = 0.4, pow: Optional[float] = 2.0, format_type: Optional[str] = None) -> dict
Two-point correlation function Legendre multipoles.
Parameters¶
s: np.ndarray Comoving separations ells: np.ndarray Legendre multipole order use_AP: bool Flag to switch between with and without AP corrections logkmin: float Left logarithmic edge of input wave mode array logkmax: float Right logarithmic edge of input wave mode array nk: int Number of logarithmic wave mode bins kcut: float Cutoff scale for exponential damping pow: float Power index for exponential damping format_type: str Type of output format Returns
multipoles: dict Two-point correlation function Legendre multipoles
two_point_correlation_polar
¶
two_point_correlation_polar(s: ndarray, mu: ndarray, use_AP: Optional[bool] = True, logkmin: Optional[float] = -5.0, logkmax: Optional[float] = 2.0, nk: Optional[int] = 2048, kcut: Optional[float] = 0.4, pow: Optional[float] = 2.0, format_type: Optional[str] = None) -> dict
Polar two-point correlation function.
Parameters¶
s: np.ndarray Comoving separations mu: np.ndarray Cosinus of the angle between the pair separation and the line of sight use_AP: bool Flag to switch between with and without AP corrections logkmin: float Left logarithmic edge of input wave mode array logkmax: float Right logarithmic edge of input wave mode array nk: int Number of logarithmic wave mode bins kcut: float Cutoff scale for exponential damping pow: float Power index for exponential damping format_type: str Type of output format Returns
xi_polar: np.ndarray Polar two-point correlation function
two_point_correlation_term_multipoles
¶
two_point_correlation_term_multipoles(s: ndarray, term_list: list, ells: Optional[ndarray] = None, use_AP: Optional[bool] = True, logkmin: Optional[float] = -5.0, logkmax: Optional[float] = 2.0, nk: Optional[int] = 2048, kcut: Optional[float] = 0.4, pow: Optional[float] = 2.0) -> dict
Two-point correlation function Legendre multipoles of specified terms.
Parameters¶
s: np.ndarray Comoving separations term_list: list List of terms to compute ells: np.ndarray Legendre multipole order use_AP: bool Flag to switch between with and without AP corrections logkmin: float Left logarithmic edge of input wave mode array logkmax: float Right logarithmic edge of input wave mode array nk: int Number of logarithmic wave mode bins kcut: float Cutoff scale for exponential damping pow: float Power index for exponential damping Returns
multipoles: dict Two-point correlation function Legendre multipoles of specified terms
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3
APDistortion
¶
Module to compute Alcock-Paczynski (AP) distortions parameters.
APDistortion
¶
APDistortion(background: Background, background_fiducial: Background)
Class to compute AP distortion parameters from cosmological background quantities.
Parameters:
-
(background¶Background) –Background class for computing background distances
-
(background_fiducial¶Background) –Background class for computing fiducial background distances
options: show_root_toc_entry: true show_root_heading: true show_submodules: false heading_level: 3