singlens
Differentiable single-lens microlensing in JAX: static and annual-parallax light curves, astrometric centroid shifts, finite sources, limb darkening, and gradient-based inference.
python -m pip install singlens
Requires Python 3.12+ and JAX 0.11.2+. Install singlens[examples] for plotting
and inference dependencies. Enable float64 before constructing models or JAX arrays.
Quickstart
import jax
jax.config.update("jax_enable_x64", True)
import jax.numpy as jnp
from singlens import AnnualParallax, Model, Parameters
times = jnp.linspace(7980., 8020., 501)
geometry = AnnualParallax(ra_deg=266., dec_deg=-29., t_ref=8000.)
model = Model(source="linear", parallax=geometry)
params = Parameters(t0=8000., u0=0.005, t_e=20., rho=0.01, a1=0.5,
pi_e_n=0.2, pi_e_e=-0.1)
A = jax.jit(model.magnification)(times, params)
Model fixes the source profile and geometry; Parameters holds fitted values.
Choose source="point", "uniform", "linear", or "mu2" explicitly.
Results preserve the shape of times. Parallax times are HJD − 2450000 in days.
See finite-source effects for supported
profiles, solver choices, and accuracy.
Differentiate a parameter with JAX:
curve = jax.jit(lambda rho: model.magnification(times, params.replace(rho=rho)))
A = curve(0.01)
dA_drho = jax.jacfwd(curve)(0.01)
Use the same event parameters for the unresolved images' astrometric shift:
A, shift = jax.jit(model.joint)(times, params)
shift_mas = 1.2 * shift # For an angular Einstein radius of 1.2 mas.
The shift is relative to the unlensed source center in the tau + 1j*beta
trajectory frame, for a dark point lens and a circular source.
Documentation
- Getting started: installation, light curves, and autodiff.
- Finite-source effects: source profiles, methods, and accuracy.
- Astrometry: sky coordinates, source motion, and blended light.
- Inference examples: photometry with a GP, flux marginalization, and joint photometry/astrometry.
- API and benchmarks.
For source installation and development, see CONTRIBUTING.
Attribution
Adapted from microJAX. Table generation uses the disk-mixture method of Wang (2026); the FFT backend follows Sugiyama (2022). See attribution, NOTICE, and LICENSES for citations and the MIT, Apache-2.0, and BSD-3-Clause license notices.
Metadata
Release files for singlens 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| singlens-0.2.0.tar.gz | 47.5 MB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| singlens-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.3 MB
Release files / singlens-0.2.0.tar.gz
| Download URL | singlens-0.2.0.tar.gz |
|---|---|
| Size | 47.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e85fb227f69dfb9a9eb74fa9325415b9cb06e1bec8e346e7c7320fec4ce8cb93
|
|
BLAKE2b-256 checksum How to use checksums |
24bc1c4755f72727d374f2a59f437fd30b21036af5f9f81d7c1af1730771d290
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 24, 2026.
Transparency logRelease files / singlens-0.2.0-py3-none-any.whl
| Download URL | singlens-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f120637340bf1c6305f80744d11badb85d5d996b15d62f2e76990c4447ba720
|
|
BLAKE2b-256 checksum How to use checksums |
585da6f9a40e0b119abcea9647ed2f99b9b6477b276b8462db729cb9e426ffbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 24, 2026.
Transparency logSecurity for singlens 0.2.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for singlens-0.2.0.tar.gz
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 Oct 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.