skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.43k stars 213 forks source link

Add method "is_moonlit" #1002

Open Borlaff opened 1 month ago

Borlaff commented 1 month ago

Hi!

I am working in a project using extensively SkyField and I would like to find out not only if a certain position is illuminated by the sun (as the is_sunlit method does very efficiently) but also it would be critical to know if the position is illuminated by the Moon (regardless of the Moon phase). Is there any possibility to do this in skyfield in an elegant way, like is_sunlit does?

Thank you, Alex

Borlaff commented 1 month ago

Update:

I added and tested the solution in the following fork:

https://github.com/Borlaff/python-skyfield

https://github.com/Borlaff/python-skyfield/commit/be4d267824eef042373c8c3c37e5d250abeb85d5

In that fork, ICRF(object) contains the is_moonlit method, which is a direct copy of is_sunlit.

Perhaps in the future it should become a more general method, that accepts any celestial object as "illuminating" source.