Skip to main content
lenscape

lenscape

Fast, high-resolution Δχ² maps of binary-lens microlensing events.

Planetary microlensing light curves often admit several degenerate binary-lens interpretations. To find them, analyses compute Δχ² maps over the binary-lens separation s and mass ratio q: at every point of the map, the remaining parameters (t0, u0, tE, α, ρ) are fitted to the light curve, with finite-source magnifications near the caustics. These maps decide how many solutions an analysis reports and how wide its mass-ratio constraints are, and they are often the most expensive step of the modelling. Standard analyses therefore use coarse grids of independent point-by-point fits, which get stuck in local minima.

lenscape is an open-source Python package that computes these maps quickly and suppresses local-minimum artefacts with staged neighbour propagation and adaptive refinement. For the planetary event MOA-2022-BLG-091, it reproduces the published 50 × 50 map in 14 minutes and computes a 400 × 400 map in under two hours on a 16-core desktop computer (AMD Ryzen 9 7950X): 14 minutes for the 50 × 50 lattice, then 8, 23 and 74 minutes for the 100 × 100, 200 × 200 and 400 × 400 refinements. It recovers the event's four published solutions and their χ² to within 1.

Published and lenscape maps of MOA-2022-BLG-091

MOA-2022-BLG-091. (a, c) The published 50 × 50 maps (Han et al. 2025, Fig. 2), in bands of Δχ² < 4, 8, 12, 16 and 20. (b, d) The continuous Δχ² surfaces of lenscape at 400 × 400. Top: the (log s, log q) plane. Bottom: the trajectory angle α against log s, with χ² minimised over all other parameters, including q, at every point.

Why it is fast

  • Compiled magnifications. Pure Python, compiled with numba. Point-source magnifications use the root solver of VBMicrolensing (Bozza 2010; Bozza et al. 2018; Skowron & Gould 2012). Near caustics, quadrupole and hexadecapole approximations (Gould 2008; Pejcha & Heyrovský 2009; Cassan 2017) are evaluated on images tracked from the point-source roots; full contour integration is reserved for sources on or inside a caustic.
  • Fluxes solved, not searched. The source and blend fluxes of every data set are solved by linear least squares at each step, so the fits search only the nonlinear parameters.
  • Fits in the timescales a light curve measures. The fits use teff = u0tE and t⋆ = ρtE, which straightens the narrow curved valleys of the likelihood. A short Nelder–Mead search finds the valley floor, and Levenberg–Marquardt steps converge to the minimum.
  • Warm starts from the neighbours. Most fits start from the solutions of neighbouring cells and lattice points, near their minimum, instead of from a sweep over trajectory angles.
  • Hierarchical densification. Fine maps are built from coarser ones: each new point starts from the solutions around it, so doubling the resolution costs a fraction of a new map. Refinement can be restricted to the cells that a Δχ² contour runs through.

Why it is complete

Fitting every lattice point independently leaves many fits in local minima and gives speckled maps. lenscape computes a map in stages:

  1. Cell fits. The best fit anywhere inside each lattice cell (s and q free within the cell), so that a narrow valley between two lattice points is not missed. A coarse seed grid provides starting points, and neighbouring cells exchange their solutions.
  2. Lattice-point fits at fixed (s, q), started from the cell solutions nearby.
  3. Neighbour refinement. Solutions propagate from point to point, for both the resolved and the unresolved source branch, until no point improves by more than 1.
  4. Outlier recalculation. Points worse than their neighbours get a deep search with many starts.
  5. Densification (optional) to finer lattices, or finer cells only where a Δχ² band edge runs between cells.

The same stages at fixed (log s, α), with q free, give the profile of the trajectory angle. Each stage prints a numbered header and a progress bar.

Installation

pip install lenscape

Latest development version:

pip install git+https://github.com/hippke/lenscape

Requirements: Python ≥ 3.10, NumPy, numba, tqdm; matplotlib for figures (pip install lenscape[plot]). The first call compiles the kernels (about a minute); they are cached on disk afterwards.

Examples

The example notebooks run from public data to finished maps and figures. Start with the quickstart; tutorial_first_map_research_note computes the map of the research note step by step.

Documentation

  • Method: magnifications, fits, the stages of a map, accuracy.
  • API reference: all public functions.
  • Validation: comparisons with VBBinaryLensing and with a published map.

Contributing

All my repositories embrace collaboration between humans and AI. Contributions are welcome, whether they are written by you, by an AI assistant, or by both together, and they will be handled promptly. Please open an issue or a pull request.

Citing

If you use lenscape, please cite the accompanying research note (in preparation). See CITATION.cff.

Metadata

Release files for lenscape 1.0

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

Source distribution (sdist)

Source distribution for lenscape 1.0
File Size Uploaded Provenance Actions
lenscape-1.0.tar.gz 193.3 kB Without provenance Details for lenscape-1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lenscape 1.0
File Interpreter ABI Platform Actions
lenscape-1.0-py3-none-any.whl Python 3 none any Details for lenscape-1.0-py3-none-any.whl

Total release size: 307.7 kB

Release files / lenscape-1.0.tar.gz

Download URL lenscape-1.0.tar.gz
Size 193.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2dd1d002eefa09b3f3b87621c7d5341a8e6fedd12533a5b750264e694a844598
BLAKE2b-256 checksum
How to use checksums
fc429cc04dd5b58081b35d38b750944d93b90d7adaded4c94f7a6ca97505ea9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Release files / lenscape-1.0-py3-none-any.whl

Download URL lenscape-1.0-py3-none-any.whl
Size 114.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b385a21d0a6c262536fc4576a0a618a0da09701765228f8d619cce977e12359
BLAKE2b-256 checksum
How to use checksums
211029473c7ba35736930315c1c0d2c04b1c2674c2a18fca9cbbc53ef8d1664b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Security for lenscape 1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files No provenance

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