Celestial Coordinates - Solutions

In [1]:
%matplotlib inline

Level 1

Find the coordinates of the Crab Nebula in ICRS coordinates, and convert them to Galactic Coordinates.

In [2]:
from astropy.coordinates import SkyCoord
In [3]:
crab = SkyCoord.from_name('M1')
In [4]:
crab
Out[4]:
<SkyCoord (ICRS): ra=83.633083 deg, dec=22.0145 deg>

There are three ways of converting to Galactic coordinates:

In [5]:
crab.galactic
Out[5]:
<SkyCoord (Galactic): l=184.557518219 deg, b=-5.78433763642 deg>
In [6]:
crab.transform_to('galactic')
Out[6]:
<SkyCoord (Galactic): l=184.557518219 deg, b=-5.78433763642 deg>
In [7]:
from astropy.coordinates import Galactic
crab.transform_to(Galactic)
Out[7]:
<SkyCoord (Galactic): l=184.557518219 deg, b=-5.78433763642 deg>

Level 2

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.

In [8]:
from astropy.table import Table
In [9]:
t = Table.read('data/rosat.vot')
WARNING: W49: None:924:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.exceptions]
WARNING:astropy:W49: None:924:6: W49: Empty cell illegal for integer fields.
WARNING: W49: None:2170:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.exceptions]
WARNING:astropy:W49: None:2170:6: W49: Empty cell illegal for integer fields.
WARNING: W49: None:22470:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.exceptions]
WARNING:astropy:W49: None:22470:6: W49: Empty cell illegal for integer fields.
WARNING: W49: None:23884:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.exceptions]
WARNING:astropy:W49: None:23884:6: W49: Empty cell illegal for integer fields.
WARNING: W49: None:27160:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.exceptions]
WARNING:astropy:W49: None:27160:6: W49: Empty cell illegal for integer fields.
WARNING: W49: None:47362:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.exceptions]
WARNING:astropy:W49: None:47362:6: W49: Empty cell illegal for integer fields.
WARNING: W49: None:48580:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.exceptions]
WARNING:astropy:W49: None:48580:6: W49: Empty cell illegal for integer fields.
WARNING: W49: None:56322:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.exceptions]
WARNING:astropy:W49: None:56322:6: W49: Empty cell illegal for integer fields.
WARNING: W49: None:56784:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.exceptions]
WARNING:astropy:W49: None:56784:6: W49: Empty cell illegal for integer fields.
WARNING: W49: None:58086:6: W49: Empty cell illegal for integer fields. (suppressing further warnings of this type...) [astropy.io.votable.exceptions]
WARNING:astropy:W49: None:58086:6: W49: Empty cell illegal for integer fields. (suppressing further warnings of this type...)

In [10]:
t.columns
Out[10]:
<TableColumns names=('_1RXS','RAJ2000','DEJ2000','PosErr','NewFlag','Count','e_Count','HR1','e_HR1','HR2','e_HR2','Extent')>
In [11]:
from astropy import units as u
from astropy.coordinates import SkyCoord
In [12]:
t['RAJ2000']
Out[12]:
<MaskedColumn name='RAJ2000' unit=u'deg' format=u'%9.5f' description=u'Right ascension (J2000), decimal degrees'>
masked_array(data = [0.0 0.02917 0.04167 ..., 359.92166 359.93625 359.99625],
             mask = [False False False ..., False False False],
       fill_value = 1e+20)
In [13]:
c = SkyCoord(t['RAJ2000'], t['DEJ2000'], frame='fk5')
In [14]:
c_gal = c.galactic
In [15]:
print c_gal.l.degree
[ 340.56245383  101.78669141  312.27873509 ...,  121.29255381  107.38876121
  101.88663123]

In [16]:
print c_gal.b.degree
[-73.66015223 -52.47037436 -52.59268419 ...,  20.41561517 -39.30250463
 -52.19136786]

In [17]:
%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")
Out[17]:
<matplotlib.text.Text at 0x10c0b4fd0>

Level 3

Make an Aitoff projection map of the sources in Galactic coordinates

In [18]:
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
In [19]:
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()