1

I am experimenting with the PyEphem library for astronomy, and trying to recreate/understand some of the basic calculations there.

There is a function called separation that, given two planets and a date/time, it calculates the separation (angle) between those 2 planets with respect to their "x" projection in a plane.

So for 2018/1/1 for planets Mercury and Mars, we have:

import ephem
import math 

mercury = ephem.Mercury('2018/1/1')
mars = ephem.Mars('2018/1/1')

s1 = ephem.separation(mercury, mars)
print(math.degrees(s1))

Which returns

33.792384499568264

But if I wanted to calculate this without the separation function, then the calculation would be as simple as the "right ascension" of 1 minus the "right ascension" of the other:

math.degrees(mercury.ra) - math.degrees(mars.ra)

Which returns

35.114532008671574

Why are the angles different? Since I am not including a latitude and longitude of the observer, all the calculations are supposed to be geo-centric, according to PyEphem.

Is anybody familiar with the calculations going on behind PyEphem, or another library with built-in ephemeris that can produce consistent results for separation?

Luis Miguel
  • 5,057
  • 8
  • 42
  • 75

1 Answers1

3

Good question! You will want to consult a textbook on spherical trigonometry. Just as you cannot predict the number of miles between two locations simply from their longitudes — because they might both be on the equator and far apart, or up near the North Pole and sitting just a few feet from each other — so you cannot predict the separation between two objects from Right Ascension (= "sky longitude") alone, but will have to add in (a) the two objects' declinations, and (b) use a special formula that computes the arc between the two positions on the sphere along a great circle route.

Brandon Rhodes
  • 83,755
  • 16
  • 106
  • 147