skyfielders / python-skyfield

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

Sunrise and sunset at a location on the Moon #258

Closed mhsundstrom closed 4 years ago

mhsundstrom commented 5 years ago

I have zero knowledge of how (or even if) this calculation could be accomplished in Skyfield, but as I read about the Chinese Change-4 lander the past several months, waking up at its local sunrise and shutting down at its local sunset (plus shutting down around its local noon thanks to the heat), I wonder if these times could be calculated via Skyfield. Thanks...

brandon-rhodes commented 5 years ago

Skyfield does not currently have direct support, I don't think, for any of the NASA data files that provide orientation (and thus rotation) data for the Moon — so I think that would have to be added, or accomplished in a separate program, before sunrise and sunset on the Moon could be calculated? Or a much simpler equation for the Moon's orientation could be used. Oh: or, maybe libration information could be combined with knowledge of the Earth-Moon vector’s direction and Earth-Sun vector’s direction to determine where the sun is overhead on the Moon?

brandon-rhodes commented 4 years ago

I have just released Skyfield 1.16 which implements support for lunar latitude/longitude locations. Try it out, and let me know if you run into any snags or problems with the implementation!

https://rhodesmill.org/skyfield/planetary.html

You should be able to combine this feature with the logic in almanac.py to find the time of sunrise and sunset — just take a look at how it’s implemented there for the earth, and write your own routine that does sunrise and sunset for the Moon. Let me know if you run into any snags!

mhsundstrom commented 4 years ago

Thank you! This looks like it's working fine. Will be doing some more experimentation.