astropy.cosmology.units.redshift_distance(cosmology=None, kind='comoving', **atzkw)[source]#

Convert quantities between redshift and distance.

Care should be taken to not misinterpret a relativistic, gravitational, etc redshift as a cosmological one.

cosmologyCosmology, str, or None, optional

A cosmology realization or built-in cosmology’s name (e.g. ‘Planck18’). If None, will use the default cosmology (controlled by default_cosmology).

kind{‘comoving’, ‘lookback’, ‘luminosity’}, optional

The distance type for the Equivalency. Note this does NOT include the angular diameter distance as this distance measure is not monotonic.


keyword arguments for z_at_value(), which is used to convert distance to redshift.


Equivalency between redshift and temperature.


If the distance corresponds to a redshift that is larger than zmax.


See z_at_value() for possible exceptions, e.g. if the distance maps to a redshift that is larger than zmax, the maximum redshift.


>>> import astropy.units as u
>>> import astropy.cosmology.units as cu
>>> from astropy.cosmology import WMAP9
>>> z = 1100 * cu.redshift
>>> d =, cu.redshift_distance(WMAP9, kind="comoving"))
>>> d  
<Quantity 14004.03157418 Mpc>

The reverse operation is also possible, though not always as simple. To convert a very large distance to a redshift it might be necessary to specify a large enough zmax value. See z_at_value() for details.

>>>, cu.redshift_distance(WMAP9, kind="comoving", zmax=1200))  
<Quantity 1100.000 redshift>