redshift_distance¶
- 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.
- Parameters:
- cosmology
Cosmology,str, orNone, 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.
- **atzkw
keyword arguments for
z_at_value(), which is used to convert distance to redshift.
- cosmology
- Returns:
EquivalencyEquivalency between redshift and temperature.
- Raises:
CosmologyErrorIf the distance corresponds to a redshift that is larger than
zmax.ExceptionSee
z_at_value()for possible exceptions, e.g. if the distance maps to a redshift that is larger thanzmax, the maximum redshift.
Examples
>>> import astropy.units as u >>> import astropy.cosmology.units as cu >>> from astropy.cosmology import WMAP9
>>> z = 1100 * cu.redshift >>> d = z.to(u.Mpc, 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
zmaxvalue. Seez_at_value()for details.>>> d.to(cu.redshift, cu.redshift_distance(WMAP9, kind="comoving", zmax=1200)) <Quantity 1100.000 redshift>