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.5.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.5-py3-none-any.whl (257.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jnkepler-0.2.5.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.5.tar.gz
Algorithm Hash digest
SHA256 4a68c2de1fa715c405604471f97516995262a4645e0e8bcbb26d79e6d16af916
MD5 54088236bf9b2f288044718f925726e4
BLAKE2b-256 952870ecc643ea9f3d9ce1b888ed487d708fbb0057df3b5e5224acfdb0b5001c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jnkepler-0.2.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 694efd13447b5882db34ab54f6e44114019d59e5ec1f0c007f14b99fab3e5aad
MD5 c4352b546493ff4e7d50e79a37ac793e
BLAKE2b-256 3f55001368d3996db3c61122228eda96063539a42c08110e1400c91d33c673d1

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