Search code examples
pythonpyephem

Pyephem: how to calculate time of entering into next constellation


Pyephem docs have example how to calculate constellation in which planet is in certain time.

>>> m = ephem.Moon('1980/6/1')
>>> print(ephem.constellation(m))
('Sgr', 'Sagittarius')

But how to calculate time when the planet will change constellation?


Solution

  • Because planets can change direction and speed across the sky, there is no way to predict ahead of time exactly when a planet will cross the boundary to another constellation. The simplest approach would be to step forward in time by one day (or more? or less?) until the output of constellation() changes for the planet, and then back up and determine at exactly what time of day the transition occurred.