gwforge.GWForge.cosmology¶
Attributes¶
Classes¶
Flat dark-energy background with analytic parameter derivatives. |
Functions¶
|
Resolve a GWForge cosmology specification to an |
|
Full-sky |
|
Luminosity distance in Mpc for either cosmology flavour. |
Module Contents¶
- gwforge.GWForge.cosmology.astropy_cosmology(name='Planck18', H0=None, Om0=None, Ode0=None, Tcmb0=2.725, Ob0=None)[source]¶
Resolve a GWForge cosmology specification to an
astropycosmology.Setting
Tcmb0 = 0removes radiation and massive neutrinos, which makes the result identical toFlatwCDM(H0, Om0, w0=-1)whenOde0 = 1 - Om0.- Parameters:
name (str) – An
astropy.cosmologyrealization name, or anything else (e.g."custom") to request an explicitLambdaCDM.H0 (float or None) – Hubble constant in km/s/Mpc. Required if
nameis not a realization.Om0 (float or None) – Present-day matter and dark-energy density parameters.
Ode0 (float or None) – Present-day matter and dark-energy density parameters.
Tcmb0 (float) – CMB temperature in K.
0disables radiation and neutrinos.Ob0 (float or None) – Baryon density parameter.
- Return type:
astropy.cosmology.FLRW
- Raises:
ValueError – If
nameis not a realization and the explicit parameters are incomplete.
- class gwforge.GWForge.cosmology.FlatwCDM(H0=67.66, Om0=0.3111, w0=-1.0)[source]¶
Flat dark-energy background with analytic parameter derivatives.
\[E(z)^2 = \Omega_{m,0}(1 + z)^3 + (1 - \Omega_{m,0})(1 + z)^{3(1 + w_0)}\]Usage¶
>>> cosmology = FlatwCDM(H0=67.66, Om0=0.3111) >>> cosmology.luminosity_distance(1.0) # Mpc >>> cosmology.derivatives(1.0)["Om0"]["luminosity_distance"]
- classmethod from_astropy(cosmology, w0=-1.0, fold_neutrinos=True)[source]¶
Build a
FlatwCDMmatching anastropycosmology.astropyrealizations carry radiation and massive neutrinos, which this two-component background does not have.fold_neutrinosaddsOnu0toOm0, treating neutrinos as cold matter – a good approximation at the redshifts gravitational-wave catalogues reach, and the convention this module documents its residuals against.- Parameters:
cosmology (astropy.cosmology.FLRW)
w0 (float) – Equation of state to give the result.
fold_neutrinos (bool) – Add
Onu0toOm0.
- Return type:
- to_astropy()[source]¶
The exactly equivalent
astropycosmology (no radiation, no neutrinos).- Return type:
astropy.cosmology.FlatLambdaCDM or astropy.cosmology.FlatwCDM
- defunc_dz(redshift)[source]¶
\(dE/dz\).
Carries the dark-energy term. The LCDM expression \(1.5\,\Omega_{m,0}(1+z)^2 / E\) is the \(w_0 = -1\) special case only, and using it under wCDM is wrong by 26% at \(w_0 = -0.8\).
- _quadrature_nodes(redshift)[source]¶
Gauss-Legendre nodes and half-width for
[0, z], broadcast overz.Returns
(sample_redshifts, half)with shapes(..., order)and(..., 1), so the integral offis(half * (weights * f).sum(-1)).
- differential_comoving_volume(redshift)[source]¶
Full-sky \(dV_c/dz = 4\pi D_C^2 D_H / E\), Mpc^3.
Note the \(4\pi\):
astropy’s method of the same name is per steradian.
- redshift_of_distance(distance)[source]¶
Invert \(d_L(z)\), by table-seeded Newton on the exact derivative.
- Parameters:
distance (array_like) – Luminosity distance in Mpc.
- Return type:
numpy.ndarray
- _dinv_efunc(redshift)[source]¶
d(1/E)/dLambdafor each cosmology parameter, as a dict of arrays.These are the closed-form integrands that make
derivatives()exact: the same Gauss-Legendre weights that build \(D_C\) also build \(\partial D_C/\partial\Lambda\).
- derivatives(redshift, parameters=COSMOLOGY_PARAMETERS)[source]¶
Analytic derivatives of the background quantities at fixed
z.- Parameters:
redshift (array_like)
parameters (sequence of str) – Any subset of
COSMOLOGY_PARAMETERS.
- Returns:
{parameter: {"comoving_distance": ..., "luminosity_distance": ..., "ddL_dz": ..., "differential_comoving_volume": ...}}, every entry an array shaped likeredshift.- Return type:
dict
Notes
H0enters only through \(D_H = c/H_0\), because \(E(z)\) is dimensionless and carries no \(H_0\). Hence \(\partial_{H_0} D_C = -D_C/H_0\), \(\partial_{H_0}(dV_c/dz) = -3 (dV_c/dz)/H_0\) and \(\partial_{H_0}(dd_L/dz) = -(dd_L/dz)/H_0\) – the \(-3/H_0 + 1/H_0 = -2/H_0\) that the spectral-siren measure term reduces to.
- dredshift_dparameter(redshift, parameters=COSMOLOGY_PARAMETERS)[source]¶
dz/dLambdaat fixed luminosity distance.Implicit differentiation of \(d_L(z;\Lambda) = \mathrm{const}\):
\[\frac{\partial z}{\partial\Lambda} = -\left(\frac{\partial d_L}{\partial\Lambda}\right)_{\!z} \Big/ \frac{d d_L}{d z}.\]This is the chain that carries cosmology into the spectral-siren score: a trial cosmology moves the redshift assigned to a measured distance, which moves the source-frame masses and the merger-rate shape.
- Parameters:
redshift (array_like) – Redshift at the fiducial cosmology.
parameters (sequence of str)
- Returns:
{parameter: array}.- Return type:
dict
- gwforge.GWForge.cosmology.differential_comoving_volume(cosmology, redshift)[source]¶
Full-sky
dV_c/dzin Mpc^3 for either cosmology flavour.astropy’sdifferential_comoving_volumeis per steradian and carries units;FlatwCDM’s is already full-sky and unitless. Population code wants one number either way, so it goes through here.- Parameters:
cosmology (FlatwCDM or astropy.cosmology.FLRW)
redshift (array_like)
- Return type:
numpy.ndarray