#!/bin/env python3

import math as m
import numpy as np
import matplotlib.pyplot as plt

r2d = m.degrees(1)
d2r = 1.0/r2d

# Read columns 2-4 from the input file, skipping the first 11 lines:
hip = np.loadtxt('BrightStars-1.1.csv', skiprows=11, delimiter=',',
                 usecols=(1,2,3))

# Use comprehensible array names:
mag   = hip[:,0]
ra    = hip[:,1]
dec   = hip[:,2]
limMag = 7.0
sizes = 30*(0.5 + (limMag-mag)/3.0)**2

# Set the plot boundaries:
raMin  = 26.0*d2r
raMax  = 50.0*d2r
decMin = 10.0*d2r
decMax = 30.0*d2r

# Select the stars within the boundaries:
sel = (ra > raMin) & (ra < raMax) & (dec > decMin) & (dec < decMax)
# sel = ra < 1e6  # Select all stars

plt.figure(figsize=(9,7))                  # Set png size to 900x700 (dpi=100)

# Make a scatter plot.  s contains the *surface areas* of the circles:
plt.scatter(ra[sel]*r2d, dec[sel]*r2d, s=sizes[sel])

plt.axis('scaled')
plt.axis([raMax*r2d,raMin*r2d, decMin*r2d,decMax*r2d])
plt.xlabel(r'$\alpha_{2000}$ ($^\circ$)')
plt.ylabel(r'$\delta_{2000}$ ($^\circ$)')

plt.tight_layout()
plt.show()
# plt.savefig("hipparcos.pdf")
plt.close()
