from astropy.coordinates import SkyCoord # Initializing a coordinate object for the Galactic center in ICRS frame galactic_center = SkyCoord.from_name('Galactic Center') # Initializing a coordinate object for the star Sirius in ICRS frame sirius = SkyCoord.from_name('Sirius')
from astropy.coordinates import Angle, SkyCoord from astropy.coordinates import FK5, Galactic # Initializing a coordinate object for the star Sirius in FK5 frame sirius_fk5 = SkyCoord.from_name('Sirius', frame=FK5) # Initializing a coordinate object for the Galactic center in Galactic frame galactic_center_gal = SkyCoord.from_name('Galactic Center', frame=Galactic) # Converting a FK5 coordinate to Galactic frame sirius_gal = sirius_fk5.transform_to(Galactic) # Printing the RA, Dec and GLON, GLAT for Sirius print('Sirius RA:', Angle(sirius_fk5.ra).to_string(unit='hourangle')) print('Sirius Dec:', Angle(sirius_fk5.dec).to_string(unit='deg')) print('Sirius GLON:', Angle(sirius_gal.l).to_string(unit='deg')) print('Sirius GLAT:', Angle(sirius_gal.b).to_string(unit='deg')) # Printing the galactic coordinates of the Galactic center print(galactic_center_gal.l, galactic_center_gal.b)In this example, we initialize two SkyCoord objects for the star Sirius and the Galactic center in different frames, FK5 and Galactic. We then convert the coordinates of the Sirius object from FK5 to Galactic frame and print the RA, Dec and GLON, GLAT values. Lastly, we print the galactic coordinates of the Galactic center.