Astropy: Celestial Coordinates - Solutions

In [1]:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
In [2]:
from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.table import Table

Level 1

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

In [3]:
crab = SkyCoord.from_name('M1')
In [4]:
crab
Out[4]:
<SkyCoord (ICRS): (ra, dec) in deg
    (83.633083, 22.0145)>
In [5]:
crab_gal = crab.transform_to('galactic')
In [6]:
crab_gal
Out[6]:
<SkyCoord (Galactic): (l, b) in deg
    (184.55745771, -5.78435696)>

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 [7]:
t = Table.read('data/rosat.vot')
WARNING: W49: None:924:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.converters]
WARNING: W49: None:2170:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.converters]
WARNING: W49: None:22470:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.converters]
WARNING: W49: None:23884:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.converters]
WARNING: W49: None:27160:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.converters]
WARNING: W49: None:47362:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.converters]
WARNING: W49: None:48580:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.converters]
WARNING: W49: None:56322:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.converters]
WARNING: W49: None:56784:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.converters]
WARNING: W49: None:58086:6: W49: Empty cell illegal for integer fields. (suppressing further warnings of this type...) [astropy.io.votable.converters]
In [8]:
t.columns
Out[8]:
TableColumns([('_1RXS',
               <MaskedColumn name='_1RXS' dtype='bytes16' description='ROSAT All-Sky Survey Catalogue source name (1)' length=18806>
               J000000.0-392902
               J000007.0+081653
               J000010.0-633543
               J000011.9+052318
               J000012.6+014621
               J000013.5+575628
               J000019.5-261032
               J000035.5-280553
               J000038.4+794037
               J000042.5+621034
               J000044.2-260521
               J000044.6-255030
                            ...
               J235908.7+572355
               J235910.6-040737
               J235912.1-144320
               J235919.5+065140
               J235919.6-204758
               J235929.2-255851
               J235929.3+334329
               J235930.9-401541
               J235940.9-314342
               J235941.2+830719
               J235944.7+220014
               J235959.1+083355),
              ('RAJ2000',
               <MaskedColumn name='RAJ2000' dtype='float64' unit='deg' format='%9.5f' description='Right ascension (J2000), decimal degrees' length=18806>
                 0.00000
                 0.02917
                 0.04167
                 0.04958
                 0.05250
                 0.05625
                 0.08125
                 0.14792
                 0.16000
                 0.17708
                 0.18417
                 0.18583
                     ...
               359.78625
               359.79419
               359.80042
               359.83127
               359.83167
               359.87164
               359.87207
               359.87875
               359.92041
               359.92166
               359.93625
               359.99625),
              ('DEJ2000',
               <MaskedColumn name='DEJ2000' dtype='float64' unit='deg' format='%9.5f' description='Declination (J2000), decimal degrees' length=18806>
               -39.48403
                 8.28153
               -63.59528
                 5.38833
                 1.77250
                57.94125
               -26.17556
               -28.09819
                79.67694
                62.17611
               -26.08931
               -25.84181
                     ...
                57.39861
                -4.12694
               -14.72222
                 6.86125
               -20.79958
               -25.98083
                33.72472
               -40.26139
               -31.72847
                83.12195
                22.00389
                 8.56528),
              ('PosErr',
               <MaskedColumn name='PosErr' dtype='int16' unit='arcs' description='? Total positional error (including 6" systematic error)' length=18806>
                19
                10
                11
                 7
                11
                 8
                12
                29
                 8
                 8
                15
                15
               ...
                 9
                 8
                12
                12
                10
                10
                11
                18
                19
                10
                17
                10),
              ('NewFlag',
               <MaskedColumn name='NewFlag' dtype='bytes4' description="[T._] 'new data' flags (3)" length=18806>
               __..
               TT..
               __..
               __..
               __..
               __..
               __..
               __..
               __..
               __..
               __..
               __..
                ...
               __..
               __..
               __..
               __..
               __..
               _T..
               __..
               __..
               __..
               __..
               __..
               __..),
              ('Count',
               <MaskedColumn name='Count' dtype='float32' unit='ct / s' format='%9.2g' description='? Source countrate (4)' length=18806>
                    0.13
                    0.19
                    0.19
                    0.26
                   0.081
                    0.12
                    0.12
                   0.072
                     0.1
                    0.16
                    0.12
                    0.05
                     ...
                    0.07
                    0.39
                   0.054
                   0.067
                   0.097
                    0.23
                    0.16
                    0.13
                   0.058
                   0.066
                   0.052
                    0.12),
              ('e_Count',
               <MaskedColumn name='e_Count' dtype='float32' unit='ct / s' format='%9.2g' description='? Error on Count (4)' length=18806>
                   0.035
                   0.021
                   0.031
                   0.026
                   0.016
                   0.017
                   0.022
                   0.018
                   0.013
                   0.019
                   0.022
                   0.015
                     ...
                   0.013
                   0.036
                   0.015
                   0.015
                   0.021
                   0.028
                   0.024
                   0.037
                   0.017
                   0.011
                   0.015
                   0.018),
              ('HR1',
               <MaskedColumn name='HR1' dtype='float32' format='%5.2f' description='[-1/1]? Hardness ratio 1 (5)' length=18806>
                0.69
                0.89
               -0.36
                0.24
                0.05
                0.57
               -0.26
                0.17
                0.09
               -0.03
               -0.11
               -0.16
                 ...
                0.80
                0.05
               -0.43
               -0.43
               -0.29
               -0.43
               -0.62
               -0.73
                0.17
                0.72
               -0.01
                0.54),
              ('e_HR1',
               <MaskedColumn name='e_HR1' dtype='float32' format='%5.2f' description='? Error on HR1 (6)' length=18806>
                0.25
                0.10
                0.13
                0.10
                0.20
                0.12
                0.17
                0.27
                0.11
                0.11
                0.18
                0.27
                 ...
                0.12
                0.08
                0.24
                0.21
                0.19
                0.11
                0.12
                0.18
                0.30
                0.14
                0.27
                0.13),
              ('HR2',
               <MaskedColumn name='HR2' dtype='float32' format='%5.2f' description='[-1/1]? hardness ratio 2 (5)' length=18806>
                0.28
                0.24
               -0.35
                0.00
                0.00
                0.32
                0.19
                0.29
                0.12
               -0.23
                0.45
               -0.09
                 ...
                0.10
               -0.03
                0.47
               -0.89
                0.07
               -0.30
               -0.56
                0.02
                0.33
                0.19
                0.37
                0.10),
              ('e_HR2',
               <MaskedColumn name='e_HR2' dtype='float32' format='%5.2f' description='? Error on HR2 (6)' length=18806>
                0.24
                0.13
                0.23
                0.13
                0.26
                0.14
                0.29
                0.51
                0.15
                0.16
                0.24
                0.41
                 ...
                0.19
                0.12
                0.48
                0.66
                0.34
                0.26
                0.66
                0.82
                0.34
                0.17
                0.35
                0.17),
              ('Extent',
               <MaskedColumn name='Extent' dtype='int16' unit='arcs' description='Source extent, by which the source image exceeds the point spread\n     function.' length=18806>
                 0
                 0
                13
                 0
                14
                 0
                 0
                59
                 0
                 0
                 0
                 9
               ...
                 0
                20
                 0
                 8
                 0
                13
                12
                 0
                 0
                 0
                 0
                 9)])
In [9]:
c = SkyCoord(t['RAJ2000'], t['DEJ2000'], unit=(u.deg, u.deg))
In [10]:
c_gal = c.galactic
In [11]:
c_gal.l.degree
Out[11]:
array([ 340.56214636,  101.78662367,  312.27862175, ...,  121.29248372,
        107.38870299,  101.88656375])
In [12]:
c_gal.b.degree
Out[12]:
array([-73.66010239, -52.47046199, -52.59260607, ...,  20.41553086,
       -39.30259234, -52.19145549])
In [13]:
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()

Level 3

Make an Aitoff projection map of the sources in Galactic coordinates

In [14]:
l_rad = c_gal.l.radian
l_rad[l_rad > np.pi] -= 2. * np.pi
b_rad = c_gal.b.radian
In [15]:
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()