Note
This is an old version of the documentation. See http://docs.astropy.org/en/stable for the latest version.
Bases: astropy.units.quantity.Quantity
A onedimensional distance.
This can be initialized in one of four ways:
Parameters:  value : scalar or Quantity.
unit : UnitBase
z : float
cosmology : Cosmology or None
distmod : float or Quantity
dtype : dtype, optional
copy : bool, optional
order : {‘C’, ‘F’, ‘A’}, optional
subok : bool, optional
ndmin : int, optional
allow_negative : bool, optional


Raises:  `~astropy.units.UnitsError`
ValueError

Examples
>>> from astropy import units as u
>>> from astropy import cosmology
>>> from astropy.cosmology import WMAP5, WMAP7
>>> cosmology.set_current(WMAP7)
>>> d1 = Distance(10, u.Mpc)
>>> d2 = Distance(40, unit=u.au)
>>> d3 = Distance(value=5, unit=u.kpc)
>>> d4 = Distance(z=0.23)
>>> d5 = Distance(z=0.23, cosmology=WMAP5)
>>> d6 = Distance(distmod=24.47)
>>> d7 = Distance(Distance(10 * u.Mpc))
Attributes Summary
distmod  The distance modulus as a Quantity 
z  Short for self.compute_z() 
Methods Summary
compute_z([cosmology])  The redshift for this distance assuming its physical distance is a luminosity distance. 
Attributes Documentation
Short for self.compute_z()
Methods Documentation
The redshift for this distance assuming its physical distance is a luminosity distance.
Parameters:  cosmology : Cosmology or None


Returns:  z : float
