Before we start:
Premise: the sky is not flat ... => Dealing with R.A & Dec. can be "frustrating", i.e.:
SkyCoord class:
Cost:
Benefits:
# Import the packages
from astropy import units as u
from astropy.coordinates import SkyCoord
# Lots of flexibility to define coordinates ...
a = SkyCoord('00h42m30s', '+41d12m00s', frame='icrs')
b = SkyCoord('00 42 30 +41 12 00', unit=(u.hourangle, u.deg))
c = SkyCoord(ra=10.625*u.degree, dec=41.2*u.degree, frame='icrs')
# ... that are all equivalent
print('a:',a.to_string('hmsdms'))
print('b:',b.to_string('hmsdms'))
print('c:',c.to_string('hmsdms'))
# It's then easy to access the different class parameters
print(type(a.ra), a.ra.deg, a.ra.hour)
print(type(a.dec), a.dec.deg)
# Create 2 different coordinates
a = SkyCoord('00h42m30s', '+41d12m00s', frame='icrs')
b = SkyCoord('00h42m30s', '+41d11m00s', frame='icrs')
# Get the separationg between the two
sep = a.separation(b)
print(sep.to(u.arcsec))
# Blind offset
c = a.directional_offset_by(180*u.deg,1*u.arcmin)
print(c.to_string('hmsdms'))
# Change between galactic and sky coordinates
a = SkyCoord('00h00m00s', '+00d00m00s', frame='galactic', equinox='J2000')
print('ICRS:',a.icrs.to_string('hmsdms'))
# Deal with "proper motions"
from astropy.time import Time
a = SkyCoord('00h00m00s', '00d00m00s', frame='icrs',
pm_ra_cosdec=0*u.mas/u.yr, pm_dec=5*u.arcsec/u.yr,
distance=100*u.pc,
obstime=Time('2000-01-01 00:00:00.0'))
b = a.apply_space_motion(new_obstime = Time('2010-01-01 00:00:00.0'))
print(b.to_string('hmsdms'))
sep = a.separation(b)
print('Angular offset:', sep.to(u.arcsec)/10)
from astropy.coordinates import EarthLocation
VLT = EarthLocation.of_site('Paranal Observatory')
print(VLT.lat,VLT.lon,VLT.height)