Astropy: Tables

Level 1

Try and find a way to make a table of the ROSAT point source catalog that contains only the RA, Dec, and count rate.

In [1]:
from astropy.table import Table
In [2]:
t = Table.read('data/rosat.vot')
WARNING: W49: None:924:6: W49: Empty cell illegal for integer fields. [astropy.io.votable.converters]
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.converters]
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.converters]
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.converters]
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.converters]
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.converters]
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.converters]
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.converters]
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.converters]
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.converters]
WARNING:astropy:W49: None:58086:6: W49: Empty cell illegal for integer fields. (suppressing further warnings of this type...)

In [3]:
t.keep_columns(['RAJ2000', 'DEJ2000', 'Count'])
t
Out[3]:
<Table masked=True length=18806>
RAJ2000DEJ2000Count
degdegct / s
float64float64float32
0.00000-39.484030.13
0.029178.281530.19
0.04167-63.595280.19
0.049585.388330.26
0.052501.772500.081
0.0562557.941250.12
0.08125-26.175560.12
0.14792-28.098190.072
0.1600079.676940.1
.........
359.80042-14.722220.054
359.831276.861250.067
359.83167-20.799580.097
359.87164-25.980830.23
359.8720733.724720.16
359.87875-40.261390.13
359.92041-31.728470.058
359.9216683.121950.066
359.9362522.003890.052
359.996258.565280.12

Note that you can also do this with:

In [4]:
t_new = t['RAJ2000', 'DEJ2000', 'Count']
t_new
Out[4]:
<Table masked=True length=18806>
RAJ2000DEJ2000Count
degdegct / s
float64float64float32
0.00000-39.484030.13
0.029178.281530.19
0.04167-63.595280.19
0.049585.388330.26
0.052501.772500.081
0.0562557.941250.12
0.08125-26.175560.12
0.14792-28.098190.072
0.1600079.676940.1
.........
359.80042-14.722220.054
359.831276.861250.067
359.83167-20.799580.097
359.87164-25.980830.23
359.8720733.724720.16
359.87875-40.261390.13
359.92041-31.728470.058
359.9216683.121950.066
359.9362522.003890.052
359.996258.565280.12

Level 2

Make an all-sky equatorial plot of the ROSAT sources, with all sources shown in black, and only the sources with a count rate larger than 2. shown in red.

In [5]:
from astropy.table import Table
from matplotlib import pyplot as plt
In [6]:
t = Table.read('data/rosat.vot')
In [7]:
t_bright = t[t['Count'] > 2.]
-c:1: RuntimeWarning: invalid value encountered in greater

In [8]:
fig = plt.figure()
ax = fig.add_subplot(1,1,1, aspect='equal')
ax.scatter(t['RAJ2000'], t['DEJ2000'], s=1, color='black')
ax.scatter(t_bright['RAJ2000'], t_bright['DEJ2000'], color='red')
ax.set_xlim(360., 0.)
ax.set_ylim(-90., 90.)
ax.set_xlabel("Right Ascension")
ax.set_ylabel("Declination")
Out[8]:
<matplotlib.text.Text at 0x10a757860>

Level 3

Try and write out the ROSAT catalog into a format that you can read into another software package.

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

In [11]:
t.write('rosat2.csv', format='ascii', delimiter=',')