import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.table import Table
Find the coordinates of the Crab Nebula in ICRS coordinates, and convert them to Galactic Coordinates.
crab = SkyCoord.from_name('M1')
crab
crab_gal = crab.transform_to('galactic')
crab_gal
Read in the sources, use the RA and Dec columns to instantiate a coordinate object, then convert to Galactic coordinates. Make a plot of latitude versus longitude.
t = Table.read('data/rosat.vot')
t.columns
c = SkyCoord(t['RAJ2000'], t['DEJ2000'], unit=(u.deg, u.deg))
c_gal = c.galactic
c_gal.l.degree
c_gal.b.degree
fig = plt.figure()
ax = fig.add_subplot(1,1,1, aspect='equal')
ax.scatter(c_gal.l.degree, c_gal.b.degree, s=1, color='black', alpha=0.1)
ax.set_xlim(360., 0.)
ax.set_ylim(-90., 90.)
ax.set_xlabel("Galactic Longitude")
ax.set_ylabel("Galactic Latitude")
plt.show()
Make an Aitoff projection map of the sources in Galactic coordinates
l_rad = c_gal.l.radian
l_rad[l_rad > np.pi] -= 2. * np.pi
b_rad = c_gal.b.radian
fig = plt.figure()
ax = fig.add_subplot(1,1,1, projection='aitoff')
ax.scatter(l_rad, b_rad, s=1, color='black', alpha=0.05)
ax.grid()
plt.show()