Distance¶
-
class
astropy.coordinates.Distance[source]¶ Bases:
astropy.units.quantity.SpecificTypeQuantityA one-dimensional distance.
This can be initialized in one of four ways:
- A distance
value(array or float) and aunit - A
Quantityobject - A redshift and (optionally) a cosmology.
- Providing a distance modulus
Parameters: - value : scalar or
Quantity. The value of this distance.
- unit :
UnitBase The units for this distance, if
valueis not aQuantity. Must have dimensions of distance.- z : float
A redshift for this distance. It will be converted to a distance by computing the luminosity distance for this redshift given the cosmology specified by
cosmology. Must be given as a keyword argument.- cosmology :
CosmologyorNone A cosmology that will be used to compute the distance from
z. IfNone, the current cosmology will be used (seeastropy.cosmologyfor details).- distmod : float or
Quantity The distance modulus for this distance. Note that if
unitis not provided, a guess will be made at the unit between AU, pc, kpc, and Mpc.- parallax :
QuantityorAngle The parallax in angular units.
- dtype :
dtype, optional See
Quantity.- copy : bool, optional
See
Quantity.- order : {‘C’, ‘F’, ‘A’}, optional
See
Quantity.- subok : bool, optional
See
Quantity.- ndmin : int, optional
See
Quantity.- allow_negative : bool, optional
Whether to allow negative distances (which are possible is some cosmologies). Default:
False.
Raises: - `~astropy.units.UnitsError`
If the
unitis not a distance.- ValueError
If value specified is less than 0 and
allow_negative=False.If
zis provided with aunitorcosmologyis provided whenzis not given, orvalueis given as well asz.
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)) >>> d8 = Distance(parallax=21.34*u.mas)
Attributes Summary
distmodThe distance modulus as a QuantityparallaxThe parallax angle as an AngleobjectzShort for self.compute_z()Methods Summary
compute_z([cosmology])The redshift for this distance assuming its physical distance is a luminosity distance. Attributes Documentation
-
z¶ Short for
self.compute_z()
Methods Documentation
-
compute_z(cosmology=None)[source]¶ The redshift for this distance assuming its physical distance is a luminosity distance.
Parameters: - cosmology :
CosmologyorNone The cosmology to assume for this calculation, or
Noneto use the current cosmology (seeastropy.cosmologyfor details).
Returns: - z : float
The redshift of this distance given the provided
cosmology.
- cosmology :
- A distance