Navigation

astropy.coordinates can calculate the SkyCoord of some of the major solar
system objects. By default, it uses approximate orbital elements calculated
using built-in ERFA routines, but it can
also use more precise ones using the JPL ephemerides (which are derived from
dynamical models). The default JPL ephemerides (DE430) provide predictions
valid roughly for years between 1550 and 2650. The file is 115 MB and will need
to be downloaded the first time you use this functionality, but will be cached
after that.

Note

Using JPL ephemerides requires that the jplephem package be installed. This is
most easily achieved via pipinstalljplephem, although whatever
package management system you use might have it as well.

Above, we used solar_system_ephemeris as a context, which sets the default
ephemeris while in the with clause, and resets it at the end.

To get more precise positions, one could use the de430 ephemeris mentioned
above, but between 1950 and 2050 one could also opt for the de432s
ephemeris, which is stored in a smaller, ~10 MB, file (which will be
downloaded and cached when the ephemeris is set):

While the sun is included in the these ephemerides, it is important to
recognize that get_sun always uses the built-in,
polynomial model (as this requires no special download). So it is not safe
to assume that get_body(time,'sun') and get_sun(time) will give
the same result.