redback.utils.UserCosmology

class redback.utils.UserCosmology(H0: ~astropy.cosmology._src.parameter.core.Parameter, Om0: ~astropy.cosmology._src.parameter.core.Parameter, Tcmb0: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=<Quantity 0. K>, derived=False, unit=Unit("K"), equivalencies=[], fvalidate='scalar', doc='Temperature of the CMB at z=0.'), Neff: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=3.04, derived=False, unit=None, equivalencies=[], fvalidate='non-negative', doc='Number of effective neutrino species.'), m_nu: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=<Quantity 0. eV>, derived=False, unit=Unit("eV"), equivalencies=[(Unit("kg"), Unit("J"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>), (Unit("kg / m2"), Unit("J / m2"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>), (Unit("kg / m3"), Unit("J / m3"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>), (Unit("kg / s"), Unit("J / s"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>)], fvalidate=<function FLRW.m_nu>, doc='Mass of neutrino species.'), Ob0: ~astropy.cosmology._src.parameter.core.Parameter = Parameter(default=0.0, derived=False, unit=None, equivalencies=[], fvalidate=<function FLRW.Ob0>, doc='Omega baryon; baryonic matter density/critical density at z=0.'), *, name: ~astropy.cosmology._src.core._NameField = None, meta: ~astropy.utils.metadata.core.MetaData = None)[source]

Bases: FlatLambdaCDM

Dummy cosmology class that behaves like an Astropy cosmology, except that the luminosity distance is fixed to the user‐specified value.

Parameters:
  • dl (astropy.units.Quantity) – The luminosity distance to return (e.g., 100 * u.Mpc).

  • **kwargs – Additional keyword arguments for FlatLambdaCDM (e.g. H0, Om0) if needed.

__init__(**kwargs)[source]
__call__(**kwargs)

Call self as a function.

Methods

H(z)

Hubble parameter at redshift z.

Ob(z)

Return the density parameter for baryonic matter at redshift z.

Ode(z)

Return the density parameter for dark energy at redshift z.

Odm(z)

Return the density parameter for dark matter at redshift z.

Ogamma(z)

Return the density parameter for photons at redshift z.

Ok(z)

Return the equivalent density parameter for curvature at redshift z.

Om(z)

Return the density parameter for non-relativistic matter at redshift z.

Onu(z)

Return the density parameter for neutrinos at redshift z.

Otot(z)

The total density parameter at redshift z.

Tcmb(z)

Compute the CMB temperature at redshift z.

Tnu(z)

Return the neutrino temperature at redshift z.

__init__(**kwargs)

abs_distance_integrand(z)

Integrand of the absorption distance (eq.

absorption_distance(z, /)

Absorption distance at redshift z (eq.

age(z)

Age of the universe in Gyr at redshift z.

angular_diameter_distance(z)

Angular diameter distance in Mpc at a given redshift.

angular_diameter_distance_z1z2(z1, z2)

Angular diameter distance between objects at 2 redshifts.

arcsec_per_kpc_comoving(z)

Angular separation in arcsec equal to a comoving kpc at redshift z.

arcsec_per_kpc_proper(z)

Angular separation in arcsec corresponding to a proper kpc at redshift z.

clone(*[, meta, to_nonflat])

Returns a copy of this object with updated parameters, as specified.

comoving_distance(z[, z2])

Comoving line-of-sight distance \(d_c(z1, z2)\) in Mpc.

comoving_transverse_distance(z)

Comoving transverse distance in Mpc at a given redshift.

comoving_volume(z)

Comoving volume in cubic Mpc at redshift z.

critical_density(z)

Critical density in grams per cubic cm at redshift z.

de_density_scale(z)

Evaluates the redshift dependence of the dark energy density.

differential_comoving_volume(z)

Differential comoving volume at redshift z.

distmod(z)

Distance modulus at redshift z.

efunc(z)

Function used to calculate H(z), the Hubble parameter.

inv_efunc(z)

Function used to calculate \(\frac{1}{H_z}\).

is_equivalent(other, /, *[, format])

Check equivalence between Cosmologies.

kpc_comoving_per_arcmin(z)

Separation in transverse comoving kpc equal to an arcmin at redshift z.

kpc_proper_per_arcmin(z)

Separation in transverse proper kpc equal to an arcminute at redshift z.

lookback_distance(z)

The lookback distance is the light travel time distance to a given redshift.

lookback_time(z)

Lookback time in Gyr to redshift z.

lookback_time_integrand(z)

Integrand of the lookback time (equation 30 of [1]_).

luminosity_distance(redshift)

Return the user-specified luminosity distance, ignoring the redshift.

nu_relative_density(z)

Neutrino density function relative to the energy density in photons.

scale_factor(z)

Compute the scale factor at redshift z.

set_luminosity_distance(dl)

Set (or update) the user-specified luminosity distance.

w(z)

Returns dark energy equation of state at redshift z.

Attributes

H0

Hubble Parameter at redshift 0.

Neff

Number of effective neutrino species.

Ob0

density of baryonic matter in units of the critical density at z=0.

Ode0

Omega dark energy; dark energy density/critical density at z=0.

Odm0

Omega dark matter; dark matter density/critical density at z=0.

Ogamma0

Omega gamma; the density/critical density of photons at z=0.

Ok0

Omega curvature; the effective curvature density/critical density at z=0.

Om0

Omega matter; matter density/critical density at z=0.

Onu0

Omega nu; the density/critical density of neutrinos at z=0.

Otot0

Omega total; the total density/critical density at z=0.

Tcmb0

Temperature of the CMB at z=0.

Tnu0

Temperature of the neutrino background as |Quantity| at z=0.

critical_density0

Critical mass density at z=0.

from_format

h

h = H_0 / 100 [km/sec/Mpc].

has_massive_nu

Does this cosmology have at least one massive neutrino species?

hubble_distance

Hubble distance.

hubble_time

Hubble time.

is_flat

Return True, the cosmology is flat.

m_nu

Mass of neutrino species.

meta

name

The name of the cosmology realization, e.g. 'Planck2018' or None.

nonflat

Return the equivalent non-flat-class instance of this cosmology.

parameters

Immutable mapping of the Parameters.

read

scale_factor0

Scale factor at redshift 0.

to_format

write

H(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Hubble parameter at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) – Input redshift.

Returns:

H – Hubble parameter at each input redshift.

Return type:

Quantity [‘frequency’]

H0: Parameter

Hubble Parameter at redshift 0.

Neff: Parameter

Number of effective neutrino species.

Ob(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Return the density parameter for baryonic matter at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

Ob – The density of baryonic matter relative to the critical density at each redshift.

Return type:

ndarray

Ob0: Parameter

density of baryonic matter in units of the critical density at z=0.

Type:

Omega baryons

Ode(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Return the density parameter for dark energy at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

Ode – The density of dark energy relative to the critical density at each redshift.

Return type:

ndarray

Ode0: Parameter

Omega dark energy; dark energy density/critical density at z=0.

Odm(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Return the density parameter for dark matter at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

Odm – The density of dark matter relative to the critical density at each redshift.

Return type:

ndarray

property Odm0: float

Omega dark matter; dark matter density/critical density at z=0.

Ogamma(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Return the density parameter for photons at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

Ogamma – The energy density of photons relative to the critical density at each redshift.

Return type:

array

property Ogamma0: float

Omega gamma; the density/critical density of photons at z=0.

Ok(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Return the equivalent density parameter for curvature at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

Ok – The equivalent density parameter for curvature at each redshift.

Changed in version 7.2: Always returns a numpy object, never a float.

Return type:

ndarray

Examples

>>> import numpy as np
>>> from astropy.cosmology import Planck18, units as cu
>>> Planck18.Ok(2)
array(0.)
>>> Planck18.Ok([1, 2])
array([0., 0.])
>>> Planck18.Ok(np.array([2]))
array([0.])
>>> Planck18.Ok(2 * cu.redshift)
array(0.)
>>> cosmo = Planck18.clone(Ode0=0.71, to_nonflat=True)
>>> cosmo.Ok0
np.float64(-0.021153694455455927)
>>> cosmo.Ok(100)
np.float64(-0.0006557825253017665)
property Ok0: float | floating

Omega curvature; the effective curvature density/critical density at z=0.

Om(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Return the density parameter for non-relativistic matter at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

Om – The density of non-relativistic matter relative to the critical density at each redshift.

Return type:

ndarray

Notes

This does not include neutrinos, even if non-relativistic at the redshift of interest.

Om0: Parameter

Omega matter; matter density/critical density at z=0.

Onu(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Return the density parameter for neutrinos at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

Onu – The energy density of neutrinos relative to the critical density at each redshift. Note that this includes their kinetic energy (if they have mass), so it is not equal to the commonly used \(\sum \frac{m_{\nu}}{94 eV}\), which does not include kinetic energy.

Return type:

ndarray

property Onu0: float

Omega nu; the density/critical density of neutrinos at z=0.

Otot(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

The total density parameter at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

Otot

Return type:

array

property Otot0: float

Omega total; the total density/critical density at z=0.

Tcmb(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Compute the CMB temperature at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

Tcmb – The temperature of the CMB.

Return type:

Quantity [‘temperature’]

Examples

>>> import astropy.units as u
>>> from astropy.cosmology import Planck18, units as cu
>>> Planck18.Tcmb(u.Quantity([0.5, 1.0], cu.redshift))
<Quantity [4.08825, 5.451  ] K>
>>> Planck18.Tcmb(u.Quantity(0.5, ''))
<Quantity 4.08825 K>
>>> Planck18.Tcmb(0.5)
<Quantity 4.08825 K>
>>> Planck18.Tcmb([0.5, 1.0])
<Quantity [4.08825, 5.451  ] K>
Tcmb0: Parameter

Temperature of the CMB at z=0.

Tnu(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Return the neutrino temperature at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

Tnu – The temperature of the cosmic neutrino background in K.

Return type:

Quantity [‘temperature’]

property Tnu0: Quantity

Temperature of the neutrino background as |Quantity| at z=0.

abs_distance_integrand(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Integrand of the absorption distance (eq. 4, [1]_).

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

dX – The integrand for the absorption distance (dimensionless).

Return type:

array

References

absorption_distance(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], /) ndarray[Any, dtype[floating]]

Absorption distance at redshift z (eq. 4, [1]_).

This is used to calculate the number of objects with some cross section of absorption and number density intersecting a sightline per unit redshift path [1]_.

Parameters:

z (Quantity-like ['redshift'], array-like, positional-only) – Input redshift.

Returns:

X – Absorption distance (dimensionless) at each input redshift.

Return type:

array

References

age(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Age of the universe in Gyr at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

t – The age of the universe in Gyr at each input redshift.

Return type:

Quantity [‘time’]

See also

z_at_value

Find the redshift corresponding to an age.

angular_diameter_distance(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Angular diameter distance in Mpc at a given redshift.

This gives the proper (sometimes called ‘physical’) transverse distance corresponding to an angle of 1 radian for an object at redshift z ([1]_, [2], [3]).

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

d – Angular diameter distance in Mpc at each input redshift.

Return type:

Quantity [‘length’]

References

angular_diameter_distance_z1z2(z1: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], z2: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Angular diameter distance between objects at 2 redshifts.

Useful for gravitational lensing, for example computing the angular diameter distance between a lensed galaxy and the foreground lens.

Parameters:
  • z1 (Quantity-like ['redshift'], array-like) – Input redshifts. For most practical applications such as gravitational lensing, z2 should be larger than z1. The method will work for z2 < z1; however, this will return negative distances.

  • z2 (Quantity-like ['redshift'], array-like) – Input redshifts. For most practical applications such as gravitational lensing, z2 should be larger than z1. The method will work for z2 < z1; however, this will return negative distances.

Returns:

d – The angular diameter distance between each input redshift pair. Returns scalar if input is scalar, array else-wise.

Return type:

Quantity [‘length’]

arcsec_per_kpc_comoving(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Angular separation in arcsec equal to a comoving kpc at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

theta – The angular separation in arcsec corresponding to a comoving kpc at each input redshift.

Return type:

Quantity [‘angle’]

arcsec_per_kpc_proper(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Angular separation in arcsec corresponding to a proper kpc at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

theta – The angular separation in arcsec corresponding to a proper kpc at each input redshift.

Return type:

Quantity [‘angle’]

clone(*, meta: Mapping[Any, Any] | None = None, to_nonflat: bool = False, **kwargs: Any) FLRW

Returns a copy of this object with updated parameters, as specified.

This cannot be used to change the type of the cosmology, except for changing to the non-flat version of this cosmology.

Parameters:
  • meta (mapping or None (optional, keyword-only)) – Metadata that will update the current metadata.

  • to_nonflat (bool, optional keyword-only) – Whether to change to the non-flat version of this cosmology.

  • **kwargs – Cosmology parameter (and name) modifications. If any parameter is changed and a new name is not given, the name will be set to “[old name] (modified)”.

Returns:

newcosmo – A new instance of this (or non-flat equivalent) class with updated parameters as specified. If no arguments are given, then a reference to this object is returned instead of a copy.

Return type:

~astropy.cosmology.Cosmology subclass instance

Examples

To make a copy of the Planck13 cosmology with a different matter density (Om0), and a new name:

>>> from astropy.cosmology import Planck13
>>> Planck13.clone(name="Modified Planck 2013", Om0=0.35)
FlatLambdaCDM(name='Modified Planck 2013', H0=<Quantity 67.77 km / (Mpc s)>,
              Om0=0.35, ...

If no name is specified, the new name will note the modification.

>>> Planck13.clone(Om0=0.35).name
'Planck13 (modified)'

The keyword ‘to_nonflat’ can be used to clone on the non-flat equivalent cosmology. For FLRW cosmologies this means Ode0 can be modified:

>>> Planck13.clone(to_nonflat=True, Ode0=1)
LambdaCDM(name='Planck13 (modified)', H0=<Quantity 67.77 km / (Mpc s)>,
          Om0=0.30712, Ode0=1.0, ...
comoving_distance(z: _InputT, z2: _InputT | None = None) Quantity

Comoving line-of-sight distance \(d_c(z1, z2)\) in Mpc.

The comoving distance along the line-of-sight between two objects remains constant with time for objects in the Hubble flow.

Parameters:
  • z (Quantity ['redshift'], positional-only) –

    Input redshifts. If one argument z is given, the distance \(d_c(0, z)\) is returned. If two arguments z1, z2 are given, the distance \(d_c(z_1, z_2)\) is returned.

    Changed in version 7.0: Passing z as a keyword argument is deprecated.

  • z2 (Quantity ['redshift'], positional-only) –

    Input redshifts. If one argument z is given, the distance \(d_c(0, z)\) is returned. If two arguments z1, z2 are given, the distance \(d_c(z_1, z_2)\) is returned.

    Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

Comoving distance in Mpc between each input redshift.

Return type:

Quantity [‘length’]

comoving_transverse_distance(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Comoving transverse distance in Mpc at a given redshift.

This value is the transverse comoving distance at redshift z corresponding to an angular separation of 1 radian. This is the same as the comoving distance if \(\Omega_k\) is zero (as in the current concordance Lambda-CDM model).

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

d – Comoving transverse distance in Mpc at each input redshift.

Return type:

Quantity [‘length’]

Notes

This quantity is also called the ‘proper motion distance’ in some texts.

comoving_volume(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Comoving volume in cubic Mpc at redshift z.

This is the volume of the universe encompassed by redshifts less than z. For the case of \(\Omega_k = 0\) it is a sphere of radius comoving_distance but it is less intuitive if \(\Omega_k\) is not.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

V – Comoving volume in \(Mpc^3\) at each input redshift.

Return type:

Quantity [‘volume’]

critical_density(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Critical density in grams per cubic cm at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

rho – Critical density at each input redshift.

Return type:

Quantity [‘mass density’]

property critical_density0: Quantity

Critical mass density at z=0.

The critical density is the density of the Universe at which the Universe is flat. It is defined as \(\rho_{\text{crit}} = 3 H_0^2 / (8 \pi G)\).

de_density_scale(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Evaluates the redshift dependence of the dark energy density.

Parameters:

z (Quantity-like ['redshift'] or array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

I – The scaling of the energy density of dark energy with redshift.

Return type:

ndarray

Notes

The scaling factor, I, is defined by \(\rho(z) = \rho_0 I\), and in this case is given by \(I = 1\).

differential_comoving_volume(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Differential comoving volume at redshift z.

Useful for calculating the effective comoving volume. For example, allows for integration over a comoving volume that has a sensitivity function that changes with redshift. The total comoving volume is given by integrating differential_comoving_volume to redshift z and multiplying by a solid angle.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

dV – Differential comoving volume per redshift per steradian at each input redshift.

Return type:

Quantity

distmod(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Distance modulus at redshift z.

The distance modulus is defined as the (apparent magnitude - absolute magnitude) for an object at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

distmod – Distance modulus at each input redshift, in magnitudes.

Return type:

Quantity [‘length’]

See also

z_at_value

Find the redshift corresponding to a distance modulus.

efunc(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Function used to calculate H(z), the Hubble parameter.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

E – The redshift scaling of the Hubble constant. Defined such that \(H(z) = H_0 E(z)\).

Return type:

ndarray

property h: floating

h = H_0 / 100 [km/sec/Mpc].

Type:

Dimensionless Hubble constant

property has_massive_nu: bool

Does this cosmology have at least one massive neutrino species?

property hubble_distance: Quantity

Hubble distance.

property hubble_time: Quantity

Hubble time.

inv_efunc(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Function used to calculate \(\frac{1}{H_z}\).

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

E – The inverse redshift scaling of the Hubble constant. Defined such that \(H_z = H_0 / E\).

Return type:

ndarray

is_equivalent(other: Any, /, *, format: bool | None | str = False) bool

Check equivalence between Cosmologies.

Two cosmologies may be equivalent even if not the same class. For example, an instance of LambdaCDM might have \(\Omega_0=1\) and \(\Omega_k=0\) and therefore be flat, like FlatLambdaCDM.

Parameters:
  • other (~astropy.cosmology.Cosmology subclass instance, positional-only) – The object to which to compare.

  • format (bool or None or str, optional keyword-only) – Whether to allow, before equivalence is checked, the object to be converted to a |Cosmology|. This allows, e.g. a |Table| to be equivalent to a Cosmology. False (default) will not allow conversion. True or None will, and will use the auto-identification to try to infer the correct format. A str is assumed to be the correct format to use when converting. format is broadcast to match the shape of other. Note that the cosmology arguments are not broadcast against format, so it cannot determine the output shape.

Returns:

True if cosmologies are equivalent, False otherwise.

Return type:

bool

Examples

Two cosmologies may be equivalent even if not of the same class. In this examples the LambdaCDM has Ode0 set to the same value calculated in FlatLambdaCDM.

>>> import astropy.units as u
>>> from astropy.cosmology import LambdaCDM, FlatLambdaCDM
>>> cosmo1 = LambdaCDM(70 * (u.km/u.s/u.Mpc), 0.3, 0.7)
>>> cosmo2 = FlatLambdaCDM(70 * (u.km/u.s/u.Mpc), 0.3)
>>> cosmo1.is_equivalent(cosmo2)
True

While in this example, the cosmologies are not equivalent.

>>> cosmo3 = FlatLambdaCDM(70 * (u.km/u.s/u.Mpc), 0.3, Tcmb0=3 * u.K)
>>> cosmo3.is_equivalent(cosmo2)
False

Also, using the keyword argument, the notion of equivalence is extended to any Python object that can be converted to a |Cosmology|.

>>> from astropy.cosmology import Planck18
>>> tbl = Planck18.to_format("astropy.table")
>>> Planck18.is_equivalent(tbl, format=True)
True

The list of valid formats, e.g. the |Table| in this example, may be checked with Cosmology.from_format.list_formats().

As can be seen in the list of formats, not all formats can be auto-identified by Cosmology.from_format.registry. Objects of these kinds can still be checked for equivalence, but the correct format string must be used.

>>> tbl = Planck18.to_format("yaml")
>>> Planck18.is_equivalent(tbl, format="yaml")
True
property is_flat: Literal[True]

Return True, the cosmology is flat.

kpc_comoving_per_arcmin(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Separation in transverse comoving kpc equal to an arcmin at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

d – The distance in comoving kpc corresponding to an arcmin at each input redshift.

Return type:

Quantity [‘length’]

kpc_proper_per_arcmin(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Separation in transverse proper kpc equal to an arcminute at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

d – The distance in proper kpc corresponding to an arcmin at each input redshift.

Return type:

Quantity [‘length’]

lookback_distance(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

The lookback distance is the light travel time distance to a given redshift.

It is simply c * lookback_time. It may be used to calculate the proper distance between two redshifts, e.g. for the mean free path to ionizing radiation.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

d – Lookback distance in Mpc

Return type:

Quantity [‘length’]

lookback_time(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Lookback time in Gyr to redshift z.

The lookback time is the difference between the age of the Universe now and the age at redshift z.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

t – Lookback time in Gyr to each input redshift.

Return type:

Quantity [‘time’]

See also

z_at_value

Find the redshift corresponding to a lookback time.

lookback_time_integrand(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Integrand of the lookback time (equation 30 of [1]_).

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

I – The integrand for the lookback time.

Return type:

array

References

luminosity_distance(redshift)[source]

Return the user-specified luminosity distance, ignoring the redshift.

Parameters:

redshift (float or array-like) – Redshift (ignored).

Returns:

The user-specified luminosity distance.

Return type:

astropy.units.Quantity

m_nu: Parameter

Mass of neutrino species.

name: _NameField = None

The name of the cosmology realization, e.g. ‘Planck2018’ or None.

property nonflat: _FLRWT

Return the equivalent non-flat-class instance of this cosmology.

nu_relative_density(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Neutrino density function relative to the energy density in photons.

Parameters:

z (Quantity-like ['redshift'], array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

f – The neutrino density scaling factor relative to the density in photons at each redshift.

Return type:

array

Notes

The density in neutrinos is given by

\[\rho_{\nu} \left(a\right) = 0.2271 \, N_{eff} \, f\left(m_{\nu} a / T_{\nu 0} \right) \, \rho_{\gamma} \left( a \right)\]

where

\[f \left(y\right) = \frac{120}{7 \pi^4} \int_0^{\infty} \, dx \frac{x^2 \sqrt{x^2 + y^2}} {e^x + 1}\]

assuming that all neutrino species have the same mass. If they have different masses, a similar term is calculated for each one. Note that f has the asymptotic behavior \(f(0) = 1\). This method returns \(0.2271 f\) using an analytical fitting formula given in Komatsu et al. 2011, ApJS 192, 18.

parameters = mappingproxy({'H0': Parameter(derived=False, unit=Unit("km / (Mpc s)"), equivalencies=[], fvalidate='scalar', doc='Hubble constant at z=0.'), 'Om0': Parameter(derived=False, unit=None, equivalencies=[], fvalidate='non-negative', doc='Omega matter; matter density/critical density at z=0.'), 'Tcmb0': Parameter(default=<Quantity 0. K>, derived=False, unit=Unit("K"), equivalencies=[], fvalidate='scalar', doc='Temperature of the CMB at z=0.'), 'Neff': Parameter(default=3.04, derived=False, unit=None, equivalencies=[], fvalidate='non-negative', doc='Number of effective neutrino species.'), 'm_nu': Parameter(default=<Quantity 0. eV>, derived=False, unit=Unit("eV"), equivalencies=[(Unit("kg"), Unit("J"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>), (Unit("kg / m2"), Unit("J / m2"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>), (Unit("kg / m3"), Unit("J / m3"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>), (Unit("kg / s"), Unit("J / s"), <function mass_energy.<locals>.<lambda>>, <function mass_energy.<locals>.<lambda>>)], fvalidate=<function FLRW.m_nu>, doc='Mass of neutrino species.'), 'Ob0': Parameter(default=0.0, derived=False, unit=None, equivalencies=[], fvalidate=<function FLRW.Ob0>, doc='Omega baryon; baryonic matter density/critical density at z=0.')})

Immutable mapping of the Parameters.

If accessed from the class, this returns a mapping of the Parameter objects themselves. If accessed from an instance, this returns a mapping of the values of the Parameters.

scale_factor(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Quantity

Compute the scale factor at redshift z.

The scale factor is defined as \(a = a_0 / (1 + z)\).

Parameters:

z (Quantity-like ['redshift'] | array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

Scale factor at each input redshift.

Return type:

|Quantity|

property scale_factor0: Quantity

Scale factor at redshift 0.

The scale factor is defined as \(a = a_0 / (1 + z)\). The common convention is to set \(a_0 = 1\). However, in some cases, like in some old CMB papers, \(a_0\) is used to normalize a to be a convenient number at the redshift of interest for that paper. Explicitly using \(a_0\) in both calculation and code avoids ambiguity.

set_luminosity_distance(dl)[source]

Set (or update) the user-specified luminosity distance.

Parameters:

dl (astropy.units.Quantity) – The new luminosity distance.

w(z: Quantity | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[Any, dtype[floating]]

Returns dark energy equation of state at redshift z.

Parameters:

z (Quantity-like ['redshift'] or array-like) –

Input redshift.

Changed in version 7.0: Passing z as a keyword argument is deprecated.

Returns:

w – The dark energy equation of state. Returns float if the input is scalar.

Return type:

ndarray or float

Notes

The dark energy equation of state is defined as \(w(z) = P(z)/\rho(z)\), where \(P(z)\) is the pressure at redshift z and \(\rho(z)\) is the density at redshift z, both in units where c=1. Here this is \(w(z) = -1\).