While Copernicus rightly observed that the planets revolve around the Sun, it was Kepler who correctly defined their orbits. At the age of 27, Kepler became the assistant of a wealthy astronomer, Tycho Brahe, who asked him to define the orbit of Mars. Kepler’s third law states that the square of the period is proportional to the cube of the semi-major axis of the orbit. In Satellite Orbits and Energy, we derived Kepler’s third law for the special case of a circular orbit. Kepler 186f orbits around its host star at a distance of around 37 million miles (60 million km), the same distance as Mercury orbits the sun, and takes 130 days to make one complete orbit. Kepler 186f Mass and Radius.
Skyfield:Home • Table of Contents • Changelog • API Reference
Skyfield now offers basic support for computing the positionof a comet or minor planetwhose elliptical, parabolic, or hyperbolic orbitis provided as Kepler orbital elements.
Beware that the internal routines supporting Kepler orbitsare rudimentary and subject to change —only the interface documented hereis guaranteed to work in future Skyfield versions.
Skyfield loads orbital elements from text files using the Pandas library.Install it before trying any of the the examples below:
Comets¶
The IAU Minor Planet Centerdistributes a CometEls.txt fileof orbital elements for predicting comet positions.The file is plain text,so feel free to open it with a text editorto see the comets for which it offers orbital elements.To build a dataframe of comets:
Since the comets file has no explicit expiration date,load.open() will only download the file once.Subsequent calls re-open the copy of the file already on your filesystem.To force a fresh download and receive updated orbits and new comets,pass reload=True.

Kepler Orbit Equation
To generate a comet’s position,first select its row from dataframe.There are several Pandas techniques for selecting rows,but most Skyfield users will simply index their dataframe by comet designation.
When computing the position of a comet from Earth,there is a complication:cometary orbits are not measured from the Solar System barycenterbut are instead centered on the Sun.You will therefore need to add the barycenter→Sun vectorto the Sun→comet vectorto produce a position that you can pass to the observe() method,which always measures positions from the Solar System barycenter.
Hopefully Skyfield will in the future support generating positionsfor whole arrays of comets in a single efficient operation,but for now your code should expect to operate on one comet at a time.
Minor Planets¶
There are nearly a million minor planetsin the IAU Minor Planet Center’sdatabase of orbital elements,thanks to the prodigious output of automated sky surveysover the past few decades.
The database can be downloaded as a single MPCORB —“Minor Planet Center orbits” —file that offers each minor planet’s orbital elements as plain text.But the raw file requires a bit of preprocessingbefore Skyfield is ready to load it:
- The first 43 lines of the file are paragraphs that explain its contents,state the terms under which software programs may include the data,and provide links to documentation.Skyfield will need these non-data lines ignored or removed.
- While an uncompressed version of the file is available for download,most users opt to download the 55 MB compressed versionfrom the Minor Planet Centerto save bandwidth and storage.Decompressing the full 190 MB of data stored insidecan require more than 1 second of computing timedepending on your platform and processing speed.
- The complete catalog lists nearly 1 million objects,which can take several seconds to load and index.
For all of these reasons,it usually makes the most sense to download, uncompress, and filter the filebefore starting your application.
If your operating system provides tools for pattern matching,they might be the fastest tool for selecting specific orbits.Here’s how to extract the orbitsfor the first four asteroids to be discovered —(1) Ceres, (2) Pallas, (3) Juno, and (4) Vesta —on a Linux system:
If your operating system lacks such tools,you can build them yourself using Python.Note that mass operations that Python implements in C,like reading an entire file’s contents with read()and scanning the full contents with a regular expression findall(),will be much faster than using a Python loop to read every line.Here’s an example script for performing the same searchas the zgrep command shown above:
The same four asteroid orbits could then be extracted with:
Note that the minor planets file has no explicit expiration date,so load.open() in the above scriptwill only download the file once.Subsequent calls re-open the copy of the file already on your filesystem.To force a fresh download, pass reload=True.

In either case, the resulting file — shorn of its text header,and containing only minor planet orbits —is ready for Skyfield to load.
Some Skyfield users have encountered Minor Planet Center fileswith bodies whose orbital elements are incomplete,presumably because their orbits are still being determined.To avoid receiving an EphemerisRangeError exceptionwhen Skyfield tries to compute a position for these bodies,you can ask Pandas to filter them out of your dataframe:
As was demonstrated in the previous section on comets,you can ask Pandas to index the dataframe by minor planet designationfor quick lookup.
Finally,generating a position involves the same maneuver necessary for comets:since minor planet orbits are centered on the Sun,the Sun’s position vector must be added to theirsto build a complete position.
Click on the 'RADIUS' button, enter the time and mass, click on 'CALCULATE' and the answer is 4.2244 x107 meters or 42,244 kilometers or 26,249 miles. (This is the distance as measured from the Earth's center). r3 = (6.674x10-11 • 5.9736x1024 • 86,4002) / 39.4784 r3 = 2.976x1024 / 39.4784 r3 = 7.53922 radius = 42,244,000 meters 2) The Moon orbits the Earth at a center-to-center distance of 3.86 x105 kilometers (3.86 x108 meters). Now that you have this information, how long does it take the Moon to make one revolution around the Earth? Click on the 'TIME' button. Enter the radius and mass data. Click on 'CALCULATE' and the answer is 2,371,900 seconds or 27.453 days. t2 = (4 • π2 • 386,000,0003) / (6.674x10-11 • 6.0471x1024) t2 = 2.27x1027 / 4.0414 t2 = 5,626,000,000,000 time = 2,372,000 seconds 3) Every 152,850 seconds, Io orbits Jupiter at an average orbital radius of 421,700 kilometers (4.21x108 meters). What is Jupiter's Mass? m = (39.4784 • 421,700,0003) / (6.674x10-11 • 152,8502) m = 2.961x1027 / 1.559 mass = 1.899x1027 kilograms Numbers larger than 1,000 will be displayed in scientific notation and with the same number of significant figures specified. You may change the significant figures displayed by changing the number in the box above. Internet Explorer and most other browsers, will display the answers properly but there are a few browsers that will show no output whatsoever. If so, enter a zero in the box above. This eliminates all formatting but it is better than seeing no output at all. | ||
Kepler Orbit Engine
Return To Home PageKepler Telescope Orbit
Copyright © 1999 - 1728 Software Systems
