import of the Astropy library's coordinates management module
#!pip install astropy
from astropy.coordinates import SkyCoord
A SkyCoords object represents an ICRS position (Right ascension [RA], Declination [Dec]) in the sky.
It is thus possible to retrieve the position of our target, by calling the from_name method which takes the name of the object as a parameter, then we display its value .
from astropy.coordinates import SkyCoord
gam_cas_coords = SkyCoord.from_name("HD5394")
print(f"Objet SkyCoords : {gam_cas_coords}")
From this variable, which is a SkyCoord object, it is possible to access the separate values for right ascent and declination. Depending on the methods used, different data formats and fineness are accessible.
print(f" - Position RA/DEC (hms & dms / ep=J2000): {gam_cas_coords.to_string('hmsdms')}")
print(f" - Position RA et DEC - Détail (ep=J2000) : {gam_cas_coords.ra.hms, gam_cas_coords.dec.dms}")
print(f" - RA (min) : {gam_cas_coords.ra.hms.m}")
In the other direction, we can also create a SkyCoord object from the known coordinates and their format.
from astropy import units as u
c = SkyCoord(14.184, 60.7249, frame='icrs', unit='deg')
c = SkyCoord('00h56m44.16s', '+60d43m29.64s', frame='icrs')
c = SkyCoord('00 56 44.16 +60 43 29.64', unit=(u.hourangle, u.deg))
c