%matplotlib inline
Find the coordinates of the Crab Nebula in ICRS coordinates, and convert them to Galactic Coordinates.
from astropy.coordinates import SkyCoord
crab = SkyCoord.from_name('M1')
crab
There are three ways of converting to Galactic coordinates:
crab.galactic
crab.transform_to('galactic')
from astropy.coordinates import Galactic
crab.transform_to(Galactic)
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.
from astropy.table import Table
t = Table.read('data/rosat.vot')
t.columns
from astropy import units as u
from astropy.coordinates import SkyCoord
t['RAJ2000']
c = SkyCoord(t['RAJ2000'], t['DEJ2000'], frame='fk5')
c_gal = c.galactic
print c_gal.l.degree
print c_gal.b.degree
%matplotlib inline
from matplotlib import pyplot as plt
fig = plt.figure(figsize=(8,5))
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")
Make an Aitoff projection map of the sources in Galactic coordinates
import numpy as np
l_rad = c_gal.l.radian
l_rad[l_rad > np.pi] -= 2. * np.pi
b_rad = c_gal.b.radian
fig = plt.figure(figsize=(8,5))
ax = fig.add_subplot(1,1,1, projection='aitoff')
ax.scatter(l_rad, b_rad, s=1, color='black', alpha=0.05)
ax.grid()