Skip to main content

Differentiable JAX N-body code for modeling nearly-Keplerian orbits

Project description

jnkepler

A differentiable N-body model for multi-planet systems.

jnkepler is a Python package for modeling photometric and radial velocity data of multi-planet systems via N-body integration. Built with JAX, it leverages automatic differentiation for efficient computation of model gradients. This enables seamless integration with gradient-based optimizers and Hamiltonian Monte Carlo methods, including the No-U-Turn Sampler (NUTS) in NumPyro. The package is particularly suited for efficiently sampling from multi-planet posteriors involving a large number of parameters and strong degeneracy.

Subpackages

  • jnkepler.jaxttv: A differentialble N-body model for analyzing transit timing variations (TTVs) and radial velocities (RVs) of multi-planet systems.
  • jnkepler.nbodytransit: A differentialble photodynamical model. jaxoplanet needs to be installed for using this package.
  • jnkepler.nbodyrv: A differentiable RV model taking into account mutual interactions between planets.

See readthedocs for more details.

Installation

pip install jnkepler

CPU performance note

If you use jnkepler on CPU with JAX ≥ 0.4.32, the default thunk runtime in the CPU backend can make computations much slower, especially when computing gradients.

To avoid this, disable the thunk runtime by setting the following environment variable before importing jax:

export XLA_FLAGS="--xla_cpu_use_thunk_runtime=false"

Or inside Python:

import os
os.environ["XLA_FLAGS"] = "--xla_cpu_use_thunk_runtime=false"
import jax

If this is not done, jnkepler will issue a warning on import. Please note that this workaround is intended for JAX < 0.7; this is why jnkepler currently requires jax<0.7.

Note on the transit-finding algorithm (since v0.2.5)

In JaxTTV.get_transit_times_obs, the default transit-time solver is now "fast". This method is optimized for efficient evaluation near the observed transit times, which is typically sufficient for inference because models far from the data have very low likelihood. For models that are substantially offset from the observed transit times, however, the fast method can be less accurate than the Newton-based method. Use transit_time_method="newton" when robust accuracy is needed in that regime.

Examples

Explore example notebooks in the examples/ directory to see jnkepler in action:

  • minimal example: examples/minimal_example.ipynb

    • computing transit times and RVs
    • plotting TTVs
    • adding a non-transiting planet
  • TTV modeling (normal likelihood): examples/kep51_ttv_normal.ipynb

  • TTV modeling (Student's t likelihood):

  • Photodynamical modeling: examples/kep51_photodynamics_gp.ipynb

    • SVI optimization & posterior sampling with NUTS
    • noise modeling using Gaussian Process with tinygp

Applications

  • TOI-1136: TTV modeling of 6-planets in a resonance chain [paper]
  • TOI-2015: Joint TTV & RV modeling of a two-planet system [paper]
  • Kepler-51: Four-planet modeling including JWST data [paper] [repository]
  • K2-19: TTVs confirm 3:2 resonance [paper]
  • TOI-4495: Photodynamical modeling of a pair of near-resonant sub-Neptunes [paper] [repository]
  • V1298 Tau: Four low-density planets transiting a young star [paper] [repository]; see also examples/v1298tau_ttv_student.ipynb in this repo
  • TOI-2076: [paper]

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jnkepler-0.2.6.tar.gz (40.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jnkepler-0.2.6-py3-none-any.whl (257.2 kB view details)

Uploaded Python 3

File details

Details for the file jnkepler-0.2.6.tar.gz.

File metadata

  • Download URL: jnkepler-0.2.6.tar.gz
  • Upload date:
  • Size: 40.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for jnkepler-0.2.6.tar.gz
Algorithm Hash digest
SHA256 2a481018617af62f03ef5d2e87eee3e1a7ac1645a73e4ea9ca0f7d7555f67ea6
MD5 37996295984ee83a91dc6e5e264f990b
BLAKE2b-256 b913715cb6665b3baad6feb81eea72423ed402f9e63ee8ba72e5e2a65126f9c9

See more details on using hashes here.

File details

Details for the file jnkepler-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: jnkepler-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 257.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for jnkepler-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f02d1ad64bbff221aee9371734b5f3f28afe8cbc5bb3bf0f78d93f4f89bba1a1
MD5 82e29f783870027697ae0451c655c179
BLAKE2b-256 9dca8e1edcc9c8ff7d4f7c0ed2f80a7fa20dddaac727a749c4556dc200a04479

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page