I'm trying to use Skyfield to plot the distance in au from Earth to solar system planets as a function of time. This is super simple and is even given in the front page of the package homepage. However while this works perfectly well for mercury, venus and mars, it doesn't work for other planets. I'm not familiar with JPL ephemeris files but it seems that for example Jupiter has no key entry in the file de421.bsp which would explain the issue.
Here is a minimal example (the one from the homepage):
from skyfield.api import load, now
planets = load('de421.bsp')
earth, planet = planets['earth'], planets['jupiter']
jd = now()
position = earth.at(jd).observe(planet)
ra, dec, distance = position.radec()
print(distance)
The error is the below. Note that if you replace 'jupiter' by 'mars' in the code above, it doesn't crash.
----> earth, planet = planets['earth'], planets['jupiter']
KeyError: "kernel 'de421.bsp' is missing 'JUPITER' - the targets it supports are:
SOLAR SYSTEM BARYCENTER, MERCURY BARYCENTER, VENUS BARYCENTER, EARTH BARYCENTER,
MARS BARYCENTER, JUPITER BARYCENTER, SATURN BARYCENTER, URANUS BARYCENTER,
NEPTUNE BARYCENTER, PLUTO BARYCENTER, SUN, MERCURY, VENUS, MOON, EARTH, MARS"
Am I using the ephemeris file in the wrong way (wrong barycenter ?) or is this just a limitation of the de421.bsp file ? I read the description of the ephemeris file on the Skyfield website (here) but not sure I fully understood it.
Any suggestion of how to perform this simple calculation of Earth-Jupiter distance with Skyfield ?
Thanks !
planets['jupiter barycenter']
? – Daladier