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.

For this reason, when using the fast method in NUTS, initialize the sampler from a good solution, such as a least-squares optimum as in the example notebooks, rather than from a diffuse or poor initial guess. If multimodality is a major concern, consider a preliminary grid/global search before running NUTS, rather than relying on NUTS alone to discover all modes.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: jnkepler-0.2.7.tar.gz
  • Upload date:
  • Size: 40.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jnkepler-0.2.7.tar.gz
Algorithm Hash digest
SHA256 8287dfecda016ae8a011415c09fce9e5b6f9d19cd3460e9802ca2fb6fce88cef
MD5 095dc44fdd4371fd783e54142917bb77
BLAKE2b-256 f2f7d223ededaf6f5770c964f508801bad5f9f19ba6609abf5bb76f859a59b7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for jnkepler-0.2.7.tar.gz:

Publisher: release.yml on kemasuda/jnkepler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: jnkepler-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 245.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jnkepler-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 2cfcfb72b43d66fe68ac068937aabdbdd15529cbd5496bbddf26b04e2da431e1
MD5 df121829febe10ecfe97e506b59cce29
BLAKE2b-256 a96a1bbe04f16ec1d629265806dce1109abc1a3c539cac3e49cae89c53d375fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for jnkepler-0.2.7-py3-none-any.whl:

Publisher: release.yml on kemasuda/jnkepler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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