skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.41k stars 211 forks source link

Planet rise/set #226

Closed Bernmeister closed 4 years ago

Bernmeister commented 5 years ago

It is possible in PyEphem to compute the rise/set of a planet with respect to a point on Earth.

Is this possible in Skyfield? All I have managed to find is documentation of sun rise/set.

brandon-rhodes commented 5 years ago

Yes, the PyEphem documentation describes how to run sunrise and sunset with respect to planets:

https://rhodesmill.org/pyephem/rise-set.html

Skyfield at the moment only has a routine for the Sun. To do planets, you'd take the sunrise_sunset routine and generalize it to not use sun but some other planet, by making your own copy of the routine:

https://github.com/skyfielders/python-skyfield/blob/e83d751c0b80d2dbb14dcc0038c574ed2b43f69c/skyfield/almanac.py#L178

brandon-rhodes commented 4 years ago

The skyfield.almanac module now has a function risings_and_settings() that does this. Enjoy!