Plotting the brightest 200 stars

Here we try to replicate what we did previously in the Jupyter notebook?

import pandas as pd
import matplotlib.pyplot as plt
from math import pi
plt.style.use('seaborn-v0_8-darkgrid')

Then we can load in our data:

stars = pd.read_csv(
    './brightest_200.csv',
    header=None,
    names=['Official', 'Common', 'RA', 'DEC'])
stars
Official Common RA DEC
0 Alpha Canis Majoris Sirius 06h45m -16.7
1 Alpha Carinae Canopus 06h24m -52.7
2 Alpha Centauri Rigil Kentaurus 14h40m -60.8
3 Alpha Bo�tis Arcturus 14h16m 19.2
4 Alpha Lyrae Vega 18h37m 38.8
... ... ... ... ...
195 Delta Herculis Sarin 17h15m 24.8
196 Kappa Centauri Ke Kwan 14h59m -42.1
197 Alpha Lyncis NaN 09h21m 34.4
198 N Velorum NaN 09h31m -57.0
199 Pi Herculis NaN 17h15m 36.8

200 rows × 4 columns

Our main task here is to get the Right Ascension values into a decimal form, so that we can meaningfully plot them. Writing a quick function to handle a single RA value:

def to_ra_deg(ra_str):
    hours = float(ra_str[:2])
    minutes = float(ra_str[3:5])
    return (hours + minutes/60) * 15 #15 deg per hour

Then we can apply it to create a new column:

stars['RA_deg'] = stars.RA.apply(to_ra_deg)
stars
Official Common RA DEC RA_deg
0 Alpha Canis Majoris Sirius 06h45m -16.7 101.25
1 Alpha Carinae Canopus 06h24m -52.7 96.00
2 Alpha Centauri Rigil Kentaurus 14h40m -60.8 220.00
3 Alpha Bo�tis Arcturus 14h16m 19.2 214.00
4 Alpha Lyrae Vega 18h37m 38.8 279.25
... ... ... ... ... ...
195 Delta Herculis Sarin 17h15m 24.8 258.75
196 Kappa Centauri Ke Kwan 14h59m -42.1 224.75
197 Alpha Lyncis NaN 09h21m 34.4 140.25
198 N Velorum NaN 09h31m -57.0 142.75
199 Pi Herculis NaN 17h15m 36.8 258.75

200 rows × 5 columns

And finally we can plot it up:

Suppose I wanted to highlight the star Betelgeuse:

b = stars[stars.Common == 'Betelgeuse']
b
Official Common RA DEC RA_deg
9 Alpha Orionis Betelgeuse 05h55m 7.4 88.75

And it was at this point that I realized that the projection is NOT working as I’d have expected. Turns out it wants radian values between -\(\pi\) and \(\pi\). Fair enough.

def convert(deg):
    rad = deg * pi / 180
    if rad > pi:
        rad -= 2 * pi
    return rad


plt.subplot(111, projection='aitoff')
plt.plot(
    stars.RA_deg.apply(convert), 
    stars.DEC.apply(convert), '.')
plt.plot(
    b.RA_deg.apply(convert), 
    b.DEC.apply(convert), '.')
plt.show()

Still kinda hard to see Orion, as it is mirrored, but it is at least visible in the correct region now.