A Cartesian Celestial Coordinate Function in Python
June 26, 2019
As an addendum to my recent post on converting equatorial celestial coordinates to Cartesian coordinates (x, y, z), I wrote a small Python function to demonstrate. It takes right ascension in hours, minutes, and seconds; declination in degrees, hours, and seconds; and distance. It returns x y z coordinates as a tuple (but it would be easy to turn into another data type).
A quick test, again utilizing Aldebaran:
When we run the code, our Python shell spits out
(6.878, 17.899, 5.683)
Next we’ll need to write a program to utilize this function. I have two ideas in mind: a script to parse and reformat a CSV or Excel doc containing star data, and a webapp to allow anyone to convert the coordinates of a star they’re curious about for… fun. But I’ll leave that for another time.