Distance

class astropy.coordinates.distances.Distance(*args, **kwargs) [edit on github][source]

Bases: object

A one-dimensional distance.

This can be initialized in one of two ways, using either a distance and a unit, or a redshift and (optionally) a cosmology. value and unit may be provided as positional arguments, but z and cosmology are only valid as keyword arguments (see examples).

Parameters :

value : scalar

The value of this distance

unit : UnitBase

The units for this distance. 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.

cosmology : Cosmology or None

A cosmology that will be used to compute the distance from z. If None, the current cosmology will be used (see astropy.cosmology for details).

Raises :

UnitsError :

If the unit is not a distance.

Examples

>>> from astropy import units as u
>>> from astropy.cosmology import WMAP3
>>> 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=WMAP3)

Attributes Summary

Mpc The value of this distance in megaparsecs
pc The value of this distance in parsecs
m The value of this distance in meters
km The value of this distance in kilometers
kpc The value of this distance in kiloparsecs
au The value of this distance in astronomical units
lightyear The value of this distance in light years
z The redshift for this distance assuming its physical distance is a luminosity distance.

Methods Summary

compute_z([cosmology]) The redshift for this distance assuming its physical distance is a luminosity distance.

Attributes Documentation

Mpc[source]

The value of this distance in megaparsecs

pc[source]

The value of this distance in parsecs

m[source]

The value of this distance in meters

km[source]

The value of this distance in kilometers

kpc[source]

The value of this distance in kiloparsecs

au[source]

The value of this distance in astronomical units

lightyear[source]

The value of this distance in light years

z[source]

The redshift for this distance assuming its physical distance is a luminosity distance.

Note

This uses the “current” cosmology to determine the appropriate distance to redshift conversions. See astropy.cosmology for details on how to change this.

Methods Documentation

compute_z(cosmology=None) [edit on github][source]

The redshift for this distance assuming its physical distance is a luminosity distance.

Parameters :

cosmology : cosmology or None

The cosmology to assume for this calculation, or None to use the current cosmology.

Page Contents