Learning Scientific Programming with Python (2nd edition)

P4.6.3: The Yale Bright Star catalog

Question P4.6.3

Write a program to create an image of a constellation using the data from the Yale Bright Star Catalog.

Create a class, Star, to represent a star with attributes for its name, magnitude and position in the sky, parsed from the file bsc5.dat which forms part of the catalog. Implement a method for this class which converts the star's position on the celestial sphere as (Right Ascension: $\alpha$, Declination: $\delta$) to a point in a plane, $(x,y)$, for example using the orthographic projection about a central point $(\alpha_0, \delta_0)$:

$$ \begin{align*} \Delta\alpha &= \alpha - \alpha_0\\ x &= \cos\delta \sin\Delta\alpha\\ y &= \sin\delta \cos\delta_0 - \cos\delta\cos\Delta\alpha\sin\delta_0 \end{align*} $$

Suitably-scaled projected, star positions can be output to an SVG image as circles (with a larger radius for brighter stars). For example, the line

<circle cx="200" cy="150" r="5" stroke="none" fill="#ffffff"/>

represents a white circle of radius 5 pixels, centred on the canvas at (200, 150).

Hints: You will need to convert the right ascension from (hr, min, sec) and the declination from (deg, min, sec) to radians - use the data corresponding to "equinox J2000, epoch 2000.0" in each line of bsc5.dat. Let the user select the constellation from the command line using its three-letter abbreviation (e.g. 'Ori' for Orion): this is given as part of the star name in the catalog. Don't forget that star magnitudes are smaller for brighter stars. If you are using the orthographic projection suggested above, choose $(\alpha_0, \delta_0)$ to be the mean of $(\alpha, \delta)$ for stars in the constellation.