Skip to main content

Kete

Predict orbits of asteroids and comets at large scales.

See the arXiv paper.

Github Actions DOI arXiv

The kete tools are intended to enable the simulation of all-sky surveys of minor planets. This includes multi-body physics orbital dynamics, orbit determination and fitting, thermal and optical modeling of the objects, as well as field of view and light delay corrections. These tools in conjunction with the Minor Planet Centers (MPC) and JPL's databases of known asteroids can be used to not only plan surveys but can also be used to predict what objects are visible for existing or past surveys.

The primary goal for kete is to enable a set of tools that can operate on the entire MPC catalog at once, without having to do queries on specific objects. It has been used to simulate over 10 years of survey time for the NEO Surveyor mission using 10 million main-belt and near-Earth asteroids.

Documentation

https://github.com/user-attachments/assets/a48491d8-9c15-4659-9022-1767a3aa1e94

Here is a simulation of what the ZTF survey would observe during the entirety of 2023. This is every position of every numbered asteroid, along with a calculation of the expected V-band magnitudes. If the expected magnitude is less than ZTF's reported magnitude limit for the specific frame, then the object will flash light grey.

This took about 50 minutes on a desktop computer to compute, and about 40 minutes to generate the movie.

Kete can be used to answer many questions, for example, identifying all known asteroids inside of a given image.

Kete can also be used as a backend for more fun visualizations, such as:

Ketev - Solar System Visualizer in your browser

Installation

Kete may be installed using pip:

pip install kete

Example of Code

Here is a small example showing off what programming with kete looks like. This calculates the closest distance that the asteroid Apophis will be at during its very close approach to Earth in April of 2029.

A more in-depth look at this example can be found here.

import kete
import numpy as np

# Date of impact +- 1 day in Julian Date
jd_center = kete.Time.from_ymd(2029, 4, 13.9066).jd

# Step the orbit every 1 minute for +- 1 day.
step_size = 1 / 24 / 60
jd_range = np.arange(-1, 1, step_size) + jd_center

# load Apophis from JPL Horizons
obj = kete.HorizonsProperties.fetch("Apophis")
cur_state = obj.state

# keep track the the closest approach
closest_approach = [np.inf, 0]
for jd in jd_range:
    # propagate the object, and include the massive main belt asteroids
    cur_state = kete.propagate_n_body(cur_state, jd, include_asteroids=True)

    # calculate position relative to earth
    earth_vec = cur_state.pos - kete.spice.get_state("Earth", cur_state.jd).pos
    earth_dist = earth_vec.r * kete.constants.AU_KM
    if earth_dist < closest_approach[0]:
        closest_approach = [earth_dist, cur_state.jd]

print("Closest approach is on:")
print(kete.Time(closest_approach[1]).iso)
print(f"At a distance of about {closest_approach[0]:0.0f} km")
#  Closest approach is on:
#  2029-04-13T21:45:30.239+00:00
#  At a distance of about 38015 km

Name

'Kete' comes from ancient greek mythology, meaning sea monsters, and is the root word for Cetaceans (Whales).

Licensing:

The original version of this code was developed while the original author (Dar Dahlen) was working at Caltech IPAC. This is a fork of that repo where the work will continue as a personal project. Difference between this fork and previous code is licensed as BSD 3-Clause but copyright to Dar Dahlen & future collaborators.

Units and Reference Frame

Kete uses the ICRF Reference frame as the base coordinate frame, with units of AU, with time in JD with Barycentric Dynamical Time (TDB) scaling. Internally this frame converted to an Ecliptic coordinate system which is defined by the Obliquity Angle definition used by JPL Horizons, which is the defined IAU76/80 model in the J2000 frame.

  - https://en.wikipedia.org/wiki/Axial_tilt#Short_term
  - https://ssd.jpl.nasa.gov/horizons/manual.html#defs

Both JPL Horizons and the Minor Planet Center (MPC) use this coordinate frame, which is essentially equivalent to J2000 Ecliptic coordinates. Conversion tools are available in kete which enable conversion to the Equatorial frame and to various flavors of time.

Cache directory

Many operations in kete result in downloading various files. These files are cached automatically, the directory where this cache is stored may be set by setting the environment variable KETE_CACHE_DIR. The default directory is ~/.kete/.

export KETE_CACHE_DIR="~/.kete/"

Use with Containers - Docker/Podman

Be aware that kete downloads several large SPICE kernel files on first use, which are saved to a cache directory.

Important for Docker/Podman:

  • If you trigger the download during the Docker build (e.g., RUN python -c "import kete"), the files will be baked into the image.
  • If you skip this step, the files will download on first container run but will be lost when the container stops unless you use a volume mount for the cache directory.

Recommended Dockerfile approach:

RUN pip install kete && \
    python -c "import kete"  # Triggers kernel downloads during build

This ensures the SPICE kernels are part of your image and don't need re-downloading.

Developer information:

Information below is aimed for developers, and is not necessary for end users.

Installation - From Source

If kete is built from source, the rust compiler must be installed. Installation instructions may be found here:

https://www.rust-lang.org/learn/get-started

Ensure that your Python is up to date, this code runs on Python 3.9+.

python --version

Ensure that your pip is up to date, this should be at least version 22.0.0.

pip --version

This can be updated using:

python -m pip install "pip>=22.0.0" --upgrade
pip install setuptools --upgrade

Development

If you plan on doing development, it is recommended to install with the following:

pip install '.[dev]'

The [dev] in that line has pip install a number of optional dependencies which are useful for development. Including pytest and documentation tools.

Building Documentation

In order for documentation to be built, some additional Python libraries are needed. These can be installed with:

pip install sphinx sphinx_gallery autodoc

After this has been installed, the documentation can be built by running inside the kete directory.

(cd docs && make html && open html/index.html&)

Once this has completed running, open the file kete/docs/html/index.html for access to the HTML documentation.

To clean the previous docs build:

(cd docs && make clean)

Documentation tests may be run with:

(cd docs && make doctest)

Running tests

Running tests require that the pytest and pytest-cov packages be installed.

Open a terminal in the base of this folder and run the following command:

pytest --cov-report term-missing --cov=kete   

Another coverage report type is HTML, this will generate a folder called htmlcov in the directory where the command was run, then you can open the htmlcov/index.html file. This is a user-friendly website representation of the code coverage.

pytest --cov-report html --cov=kete   

Running Tutorials

Tutorials are computationally expensive examples which are more indicative of typical expected use. Since these examples are so expensive to run, they are not run unless manually performed. A convenience python script has been provided to do just this.

cd docs
python utils.py

Running Benchmarks

There are a test suite of micro-benchmarks in the rust backend of kete. These require gnuplot to be installed, and may be run using the following command:

cargo bench
open target/criterion/report/index.html

Additionally, Flamegraphs may be produced using the following:

cargo bench --bench propagation -- --profile-time=5
cargo bench --bench spice -- --profile-time=5
cargo bench --bench thermal -- --profile-time=5

These flamegraphs will be put in target/criterion/*/profile/flamegraph.svg. Opening these files in a web browser will show what functions are being used during the bench.

Release files for kete 3.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kete 3.2.3
File Size Uploaded
kete-3.2.3.tar.gz 81.4 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for kete 3.2.3
File
kete-3.2.3-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
kete-3.2.3-cp39-abi3-manylinux_2_35_x86_64.whl CPython 3.9 abi3 Linux glibc 2.35+ x86-64 Details
kete-3.2.3-cp39-abi3-manylinux_2_35_aarch64.whl CPython 3.9 abi3 Linux glibc 2.35+ ARM64 Details
kete-3.2.3-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
kete-3.2.3-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 137.8 MB

Release files / kete-3.2.3.tar.gz

Download URL kete-3.2.3.tar.gz
Size 81.4 MB
Tags Source
SHA-256 checksum
How to use checksums
973e85feaf5feda4bcad853fecfe4a86564470d933eac68ff16ccca817e7ca3f
BLAKE2b-256 checksum
How to use checksums
66c31aea763e99e86fd266d35de1ef779b406a7dec2be0a8b5d2bf7493217bb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / kete-3.2.3-cp39-abi3-win_amd64.whl

Download URL kete-3.2.3-cp39-abi3-win_amd64.whl
Size 10.7 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e5098362bb06c6ba84d75621ca8e65b097b20bb7f0d0aaf1ffb8ee550eb0fe9e
BLAKE2b-256 checksum
How to use checksums
15a9df9b3738994092fd722ffc2ccb7dce0d054cd6736f639b064717a8059c55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / kete-3.2.3-cp39-abi3-manylinux_2_35_x86_64.whl

Download URL kete-3.2.3-cp39-abi3-manylinux_2_35_x86_64.whl
Size 12.0 MB
Tags CPython 3.9 Linux glibc 2.35+ x86-64 abi3
SHA-256 checksum
How to use checksums
d2076d0eeb8504a1bfba4a0d14051c4477de53eec767c3956da5f31dc4fbdbf9
BLAKE2b-256 checksum
How to use checksums
e48258de46f6ebf812e718cf09c98f037069157c6311956dd75b0cf048074583
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / kete-3.2.3-cp39-abi3-manylinux_2_35_aarch64.whl

Download URL kete-3.2.3-cp39-abi3-manylinux_2_35_aarch64.whl
Size 12.2 MB
Tags CPython 3.9 Linux glibc 2.35+ ARM64 abi3
SHA-256 checksum
How to use checksums
8e1d02e882b8f977a9fb49da18d22b822102520d36bc901a0aeffe413c293b0c
BLAKE2b-256 checksum
How to use checksums
0afc9e311fdc9cccedcf56d48136b3bf87d9aa33deb95a0841e4cfb165a3390d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / kete-3.2.3-cp39-abi3-macosx_11_0_arm64.whl

Download URL kete-3.2.3-cp39-abi3-macosx_11_0_arm64.whl
Size 10.4 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
243a6945f601aaa653c5e775aac29edbf59dc0a35468f1fdb2dc6675906b1ca8
BLAKE2b-256 checksum
How to use checksums
2bce8a20cd413b1db5957016a4a671c8d54f155637bcfb39a66d85dde0bba1cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / kete-3.2.3-cp39-abi3-macosx_10_12_x86_64.whl

Download URL kete-3.2.3-cp39-abi3-macosx_10_12_x86_64.whl
Size 11.0 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
4a36fb06962554a64fc76013b7537139b5b9da889be7b2f50589615e927c40ee
BLAKE2b-256 checksum
How to use checksums
0463892129ebe5603ba6373eb95bd6d267dba70b9e7f8b9a80080f0993a0294a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

3.2.3 This release

6 release files

3.2.2

6 release files

3.2.1

6 release files

3.2.0

6 release files

3.1.0

6 release files

3.0.1

6 release files

3.0.0

6 release files

2.1.6

6 release files

2.1.5

5 release files

2.1.4

4 release files

2.1.3

4 release files

2.1.2

4 release files

2.1.1

3 release files

2.1.0

3 release files

2.0.0

3 release files

1.1.0

15 release files

1.0.8

6 release files

1.0.7

15 release files

1.0.6

15 release files

1.0.0

8 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page