skyfielders / python-skyfield

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

Use earth satellites as observer location #949

Open Borlaff opened 6 months ago

Borlaff commented 6 months ago

Hi,

I am trying to generate ephemeris for astronomical observations from Hubble Space Telescope (LEO) and the Euclid Space Telescope (Lagrangian point 2). As far as I understand from the documentation, skyfield does not currently support to use Earth satellites as Observer location, would that be correct? This feature is supported in the JPL/Horizons system (https://ssd.jpl.nasa.gov/horizons/app.html#/) but I am unsure if there is an built-in way in current Skyfield to replicate that.

Thank you! Alex

brandon-rhodes commented 6 months ago

Good question! To use a satellite sat as an observer of objects out in the Solar System, load an ephemeris — let's call it eph as shown in the documentation several places — and do something like this:

observer = eph['earth'] + sat
pos = observer.at(t).observe(star_or_whatever).apparent()

I should update the documentation to show how, since it hadn't occurred to me to cover the case of satellites looking outward; almost all questions from users are instead about Earth-bound locations trying to aim antennae at Earth satellites! Before I write up docs, try out this code and see if it works in your case. If it does, then I'll plan to resolve this issue by updating the Earth Satellite docs to include this idea.

Thanks for the question!