We'll use astropy to unburden us from common calculations (and equally common mistakes when doing them by hand).
astropy has a fair amount of packages, so check of the docs: http://docs.astropy.org/en/latest/
In [1]:
kpc_to_km = 3.086E16
distance = 1. # kpc
distance * kpc_to_km
Out[1]:
In [2]:
type(distance)
Out[2]:
In [3]:
import astropy.units as u
distance_q = 1 * u.kpc
type(distance_q)
Out[3]:
In [4]:
distance_q.to(u.km)
Out[4]:
In [5]:
distance_q.to(u.jupiterRad)
Out[5]:
In [6]:
distance_M = 1 * u.Mpc
distance_q + distance_M
Out[6]:
Coordinates in astronomy often come in equatorial coordinates, specified by right ascension (RA) and declination (DEC).
In [7]:
import astropy.coordinates as coord
In [8]:
c1 = coord.SkyCoord(ra=150*u.degree, dec=-17*u.degree)
c2 = coord.SkyCoord(ra='21:15:32.141', dec=-17*u.degree, unit=(u.hourangle,u.degree))
If we wanted this coordinate on the celestial sphere to another system (of the celestial sphere), which is tied to our Galaxy, we can do this:
In [9]:
c1.transform_to(coord.Galactic)
Out[9]: