lfkit.cosmo.cosmology module#
Cosmology utilities for LFKit.
This module provides wrappers around PyCCL cosmology objects and background calculations.
It standardizes how cosmology instances are created and how lookback time is computed, ensuring consistent behavior across LFKit.
All returned quantities are NumPy arrays of dtype float.
- lfkit.cosmo.cosmology.comoving_distance_mpc(cosmo_obj, z)[source]#
Compute comoving radial distance in megaparsecs.
This follows the same explicit
c / H(z)integral structure used in the old code, rather than relying on a compact shortcut.- Parameters:
cosmo_obj (object) – A PyCCL cosmology object.
z (ArrayLike) – Redshift value or array-like of redshift values.
- Returns:
NumPy array of comoving radial distances in Mpc.
- Return type:
ndarray[tuple[Any, …], dtype[float64]]
- lfkit.cosmo.cosmology.cosmo_object(*, instance=None, **params)[source]#
Return a PyCCL cosmology object.
This function provides a standardized way to obtain a
pyccl.Cosmologyinstance within LFKit.- Behavior:
If
instanceis provided, it is returned unchanged.Else if cosmological parameters are provided, a new
ccl.Cosmologyis constructed using those parameters.Else, a default
ccl.CosmologyVanillaLCDMis returned.
- Parameters:
instance (object | None) – Pre-built
ccl.Cosmologyobject.**params (Any) – Cosmological parameters passed directly to
ccl.Cosmology(**params).
- Returns:
A PyCCL cosmology object.
- Raises:
ValueError – If both
instanceand cosmological parameters are provided.- Return type:
object
- lfkit.cosmo.cosmology.differential_comoving_volume(cosmo_obj, z, frac_sky=1.0)[source]#
Compute differential comoving volume per unit redshift.
This follows the same structure as the old code:
dV/dz = 4 pi f_sky chi(z)^2 c / H(z)- Parameters:
cosmo_obj (object) – A PyCCL cosmology object.
z (ArrayLike) – Redshift value or array-like of redshift values.
frac_sky (float) – Fraction of sky covered by the survey.
- Returns:
NumPy array of differential comoving volume values in Mpc^3 per unit redshift.
- Return type:
ndarray[tuple[Any, …], dtype[float64]]
- lfkit.cosmo.cosmology.distance_modulus(cosmo_obj, z, h=None)[source]#
Compute distance modulus.
If
his provided, this uses the same convention as the old code:mu = 5 log10(d_L * h) + 25- Parameters:
cosmo_obj (object) – A PyCCL cosmology object.
z (ArrayLike) – Redshift value or array-like of redshift values.
h (float | None) – Optional dimensionless Hubble parameter used to rescale the luminosity distance before computing the modulus.
- Returns:
NumPy array of distance modulus values.
- Return type:
ndarray[tuple[Any, …], dtype[float64]]
- lfkit.cosmo.cosmology.lookback_time_gyr(cosmo_obj, z)[source]#
Compute lookback time in gigayears.
This function evaluates the cosmological lookback time using PyCCL background calculations.
- Parameters:
cosmo_obj (object) – A PyCCL cosmology object.
z (ArrayLike) – Redshift value or array-like of redshift values.
- Returns:
NumPy array of lookback time values in gigayears.
- Return type:
ndarray[tuple[Any, …], dtype[float64]]
- lfkit.cosmo.cosmology.luminosity_distance_mpc(cosmo_obj, z)[source]#
Compute luminosity distance in megaparsecs.
- Parameters:
cosmo_obj (object) – A PyCCL cosmology object.
z (ArrayLike) – Redshift value or array-like of redshift values.
- Returns:
NumPy array of luminosity distances in Mpc.
- Return type:
ndarray[tuple[Any, …], dtype[float64]]