gwkokab.cosmology¶

Cosmology module for GWKokab, adapted from code written by Reed Essick included in the gw-distributions package at source.

Classes¶

Cosmology

Flat \(\Lambda\mathrm{CDM}\) cosmology in Mpc-based units.

Functions¶

PLANCK_2013_Cosmology(...)

Planck 2013 cosmology, with \(\Omega_m\) from astropy's Planck13.

PLANCK_2015_Cosmology(...)

Planck 2015 cosmology.

PLANCK_2018_Cosmology(...)

Planck 2018 cosmology.

default_cosmology(→ gwkokab.cosmology._cosmology.Cosmology)

Build the default cosmology named by GWKOKAB_DEFAULT_COSMOLOGY.

Package Contents¶

class gwkokab.cosmology.Cosmology(Ho: jaxtyping.ArrayLike, omega_matter: jaxtyping.ArrayLike, omega_radiation: jaxtyping.ArrayLike, omega_lambda: jaxtyping.ArrayLike, max_z: float = 4.0, dz: float = 0.001)[source]¶

Bases: equinox.Module

Flat \(\Lambda\mathrm{CDM}\) cosmology in Mpc-based units.

The dimensionless expansion rate is

\[E(z) = \sqrt{\Omega_\Lambda + \Omega_\kappa (1+z)^2 + \Omega_m (1+z)^3 + \Omega_r (1+z)^4}\]

with the curvature density fixed by closure, \(\Omega_\kappa = 1 - (\Omega_m + \Omega_r + \Omega_\Lambda)\). Comoving distance and comoving volume are integrated once on a uniform redshift grid at construction time and thereafter interpolated.

Parameters:
  • Ho (ArrayLike) – Hubble constant, in m/s/Mpc.

  • omega_matter (ArrayLike) – Matter density parameter \(\Omega_m\).

  • omega_radiation (ArrayLike) – Radiation density parameter \(\Omega_r\).

  • omega_lambda (ArrayLike) – Dark energy density parameter \(\Omega_\Lambda\).

  • max_z (float, optional) – Upper end of the precomputed redshift grid. Defaults to 4.0; conversions beyond it are clamped by jax.numpy.interp().

  • dz (float, optional) – Spacing of the precomputed redshift grid. Defaults to 1e-3.

DL_to_z(DL: jaxtyping.ArrayLike) → jaxtyping.ArrayLike[source]¶

Redshift at a given luminosity distance.

Inverted by interpolating the precomputed \(D_L(z)\) grid, which is monotone, so the inversion is well defined up to the grid resolution.

Parameters:

DL (ArrayLike) – Luminosity distance, in Mpc.

Returns:

Redshift.

Return type:

ArrayLike

dDLdz(z: jaxtyping.ArrayLike) → jaxtyping.ArrayLike[source]¶

Derivative of luminosity distance with respect to redshift.

\[\frac{\mathrm{d}D_L}{\mathrm{d}z} = (1+z)\frac{\mathrm{d}D_c}{\mathrm{d}z} + D_c(z)\]
Parameters:

z (ArrayLike) – Redshift.

Returns:

\(\mathrm{d}D_L/\mathrm{d}z\), in Mpc.

Return type:

ArrayLike

dDcdz(z: jaxtyping.ArrayLike) → jaxtyping.ArrayLike[source]¶

Derivative of comoving distance with respect to redshift.

\[\frac{\mathrm{d}D_c}{\mathrm{d}z} = \frac{c}{H_0 E(z)}\]
Parameters:

z (ArrayLike) – Redshift.

Returns:

\(\mathrm{d}D_c/\mathrm{d}z\), in Mpc.

Return type:

ArrayLike

dVcdz(z: jaxtyping.ArrayLike, Dc: jaxtyping.ArrayLike | None = None) → jaxtyping.ArrayLike[source]¶

Differential comoving volume, integrated over the sky.

Parameters:
  • z (ArrayLike) – Redshift.

  • Dc (Optional[ArrayLike]) – Comoving distance at z, in Mpc. Defaults to None, in which case it is interpolated with z_to_Dc().

Returns:

\(\mathrm{d}V_c/\mathrm{d}z\), in \(\mathrm{Gpc}^3\).

Return type:

ArrayLike

logdVcdz(z: jaxtyping.ArrayLike, Dc: jaxtyping.ArrayLike | None = None) → jaxtyping.ArrayLike[source]¶

Log differential comoving volume, integrated over the sky.

\[\log\frac{\mathrm{d}V_c}{\mathrm{d}z} = \log 4\pi + 2\log D_c(z) + \log\frac{\mathrm{d}D_c}{\mathrm{d}z} - 9\log 10\]

The final term converts from \(\mathrm{Mpc}^3\) to \(\mathrm{Gpc}^3\).

Parameters:
  • z (ArrayLike) – Redshift.

  • Dc (Optional[ArrayLike]) – Comoving distance at z, in Mpc. Defaults to None, in which case it is interpolated with z_to_Dc(). Pass it explicitly to avoid a redundant lookup, or to break the circularity during __init__.

Returns:

\(\log(\mathrm{d}V_c/\mathrm{d}z)\), with the volume in \(\mathrm{Gpc}^3\).

Return type:

ArrayLike

z_to_DL(z: jaxtyping.ArrayLike) → jaxtyping.ArrayLike[source]¶

Luminosity distance at a given redshift.

Parameters:

z (ArrayLike) – Redshift.

Returns:

Luminosity distance, in Mpc.

Return type:

ArrayLike

z_to_Dc(z: jaxtyping.ArrayLike) → jaxtyping.ArrayLike[source]¶

Comoving distance at a given redshift.

Interpolated on the precomputed grid, so it is JAX-safe and differentiable.

Parameters:

z (ArrayLike) – Redshift.

Returns:

Comoving distance, in Mpc.

Return type:

ArrayLike

z_to_E(z: jaxtyping.ArrayLike) → jaxtyping.ArrayLike[source]¶

Dimensionless expansion rate \(E(z) = H(z)/H_0\).

Parameters:

z (ArrayLike) – Redshift.

Returns:

The expansion rate \(E(z)\).

Return type:

ArrayLike

property DL: jaxtyping.ArrayLike¶

Luminosity distance on the precomputed redshift grid, in Mpc.

Returns:

\(D_L = (1 + z) D_c\) evaluated on z.

Return type:

ArrayLike

property Dc: jaxtyping.ArrayLike¶

Comoving distance on the precomputed redshift grid, in Mpc.

Returns:

\(D_c\) evaluated on z.

Return type:

ArrayLike

Ho: jaxtyping.ArrayLike¶
OmegaKappa: jaxtyping.ArrayLike¶

Curvature density parameter, derived from the other three.

OmegaLambda: jaxtyping.ArrayLike¶
OmegaMatter: jaxtyping.ArrayLike¶
OmegaRadiation: jaxtyping.ArrayLike¶
Vc: jaxtyping.ArrayLike¶

Comoving volume on the redshift grid, in \(\mathrm{Gpc}^3\).

property z: jaxtyping.ArrayLike¶

The precomputed redshift grid.

Returns:

Redshifts from 0 to max_z in steps of dz.

Return type:

ArrayLike

gwkokab.cosmology.PLANCK_2013_Cosmology() → gwkokab.cosmology._cosmology.Cosmology[source]¶

Planck 2013 cosmology, with \(\Omega_m\) from astropy’s Planck13.

Returns:

A flat \(\Lambda\mathrm{CDM}\) cosmology with \(H_0 = 67.77\) km/s/Mpc and \(\Omega_m = 0.30712\).

Return type:

Cosmology

gwkokab.cosmology.PLANCK_2015_Cosmology() → gwkokab.cosmology._cosmology.Cosmology[source]¶

Planck 2015 cosmology.

See Table 4 in arXiv:1502.01589; \(\Omega_m\) is taken from astropy’s Planck15.

Returns:

A flat \(\Lambda\mathrm{CDM}\) cosmology with \(H_0 = 67.74\) km/s/Mpc and \(\Omega_m = 0.3075\).

Return type:

Cosmology

gwkokab.cosmology.PLANCK_2018_Cosmology() → gwkokab.cosmology._cosmology.Cosmology[source]¶

Planck 2018 cosmology.

See Table 1 in arXiv:1807.06209.

Returns:

A flat \(\Lambda\mathrm{CDM}\) cosmology with \(H_0 = 67.66\) km/s/Mpc and \(\Omega_m = 0.30966\).

Return type:

Cosmology

gwkokab.cosmology.default_cosmology() → gwkokab.cosmology._cosmology.Cosmology[source]¶

Build the default cosmology named by GWKOKAB_DEFAULT_COSMOLOGY.

The environment variable is validated once, at import time; this function looks the validated name up in COSMOLOGY_REGISTRY and constructs a fresh instance.

Returns:

The default cosmology, Planck15 unless overridden.

Return type:

Cosmology