Skyfield: Home • Table of Contents • API Reference
If you are interested in observing the planets, the Jet Propulsion Laboratory (JPL) has prepared long tables that predict the positions of the planets both in the the distant past and out into the future. A table of positions is called an ephemeris and those supplied by the JPL are of very high accuracy.
You can ask Skyfield to download an ephemeris from the JPL
load() a filename.
Or you can load an ephemeris that you’ve already saved to disk
A popular choice of ephemeris is DE421. It is recent, has good precision, was designed for general-purpose use, and is only 17 MB in size:
from skyfield.api import load planets = load('de421.bsp')
Once an ephemeris file has been downloaded to your current directory, re-running your program will simply reuse the copy on disk instead of downloading it all over again.
After you have loaded an ephemeris and have used a statement like:
mars = planets['Mars']
— to retrieve a planet, consult the chapter Positions and Coordinates to learn about all the positions that you can use it to generate.
Several of the ephemeris files listed below are very large. While most programmers will follow the example above and use DE421, if you wish to go beyond its 150-year period you will need a larger ephemeris. And programmers interested in the moons of Jupiter will need JUP310, which weighs in at nearly a gigabyte.
What if you need data from a very large ephemeris, but don’t require its entire time span?
When you installed Skyfield another library named
will have been installed.
When invoked from the command line,
it can build an excerpt of a larger ephemeris
without needing to download the entire file,
thanks to the fact that HTTP supports a
that asks for only specific bytes of a file.
let’s pull two weeks of data for Jupiter’s moons
(using a shell variable
$u for the URL
only to make the command less wide here on the screen
and easier to read):
$ u=https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/satellites/jup310.bsp $ python -m jplephem excerpt 2018/1/1 2018/1/15 $u jup_excerpt.bsp
The resulting file
jup_excerpt.bsp weighs in
at only 0.2 MB instead of 932 MB
but supports all of the same objects as the original JUP310
over the given two-week period:
$ python -m jplephem spk jup_excerpt.bsp File type DAF/SPK and format LTL-IEEE with 13 segments: 2458119.75..2458210.50 Jupiter Barycenter (5) -> Io (501) 2458119.50..2458210.50 Jupiter Barycenter (5) -> Europa (502) 2458119.00..2458210.50 Jupiter Barycenter (5) -> Ganymede (503) 2458119.00..2458210.50 Jupiter Barycenter (5) -> Callisto (504) ...
You can load and use it directly off of disk
Here are several popular ephemerides that you can use with Skyfield.
The filenames matching
predict the positions of many or all of the major planets,
jup310.bsp focuses on Jupiter and its major moons:
|de405.bsp||63 MB||1600 to 2200||May 1997|
|de406.bsp||287 MB||−3000 to 3000||May 1997|
|de421.bsp||17 MB||1900 to 2050||February 2008|
|de422.bsp||623 MB||−3000 to 3000||September 2009|
|de430t.bsp||128 MB||1550 to 2650||February 2010|
|jup310.bsp||932 MB||1900 to 2100||December 2013|
You can think of negative years, as cited in the above table, as being almost like years BC except that they are off by one. Historians invented our calendar back before zero was a counting number, so AD 1 was immediately preceded by 1 BC without a year in between. But astronomers count backwards AD 2, AD 1, 0, −1, −2, and so forth.
So if you are curious about the positions of the planets back in 44 BC, when Julius Caesar was assassinated, be careful to ask an astronomer about the year −43 instead.