Auto-differentiable strong lens modelling
Project description
Herculens: differentiable gravitational lensing
Analysis of strong lensing imaging data
The primary purpose of Herculens is to provide flexible modeling methods to model current and future observations of strong gravitational lenses. Currently, it supports various degrees of model complexity, ranging from standard smooth analytical profiles to pixelated models combined with machine learning approaches.
Currently, Herculens supports several of the most widely-used analytical profiles, as well as multi-scale pixelated models regularized with wavelets. Future updates will include the support of point source modeling, new regularization techniques, and more expressive models based on neural networks.
JAX-based automatic differentiation and code compilation
Herculens is based on the powerful framework of differentiable programming. The code is entirely based on the automatic differentiation and compilation features of JAX. This simply means that you have access, analytically, to all partial derivatives of your model with respect to any of its parameters. This enables faster convergence to the solution, more efficient exploration of the parameter space including the sampling of posterior distributions, and new ways to mitigate degeneracies that affect gravitational lensing.
This highly modular framework offers a way to merge all modeling paradigms explored in the literature, into a single tool:
- analytical: model components are described by analytical functions with few parameters and clear physical meaning, but that may be insufficient to fit all observations;
- pixelated: regular or irregular grid of pixels are used as individual parameters, which offer higher flexibility, but requires well-motivated regularization strategies;
- deep learning: neural networks (among others) are by construction fully differentiable, regardless of being pre-trained or not. It is therefore effortless to plug-in any deep learning-based model component to
Herculens.
Being based on JAX means that Herculens runs effortlessly on CPUs, GPUs and TPUs with no changes to the code.
Works using Herculens
You can find a list of analyses that used Herculens, as well as their ADS bibtex entries, on this page.
Example notebooks
Several examples to run Herculens in many different situations are available in the herculens_workspace repository.
Installation
Manual installation
The package will be soon available through PyPi directly, but it is as easy to install it manually. It has been texted against Python 3.7, but should work with Python 3.8 or more recent versions.
Good practice is to create a new python environment:
conda create -n herculens-env python=3.12
conda activate herculens-env
Download the package cd into the directory. Then install the local Herculens package (or use -e for a development install) as follows:
pip install (-e) .
The mandatory dependencies will be installed automatically.
Package requirements
The requirements.txt file lists all required and optional package dependencies, along with their specific versions. IMPORTANT NOTE: do not only install blindly the required packages; please also have a look at the content of the file itself to learn more about additional optional packages, depending on your goals.
Attribution
Citation
If you make use of Herculens, please cite Galan et al. 2022. If you use the CorrelatedField model, please also cite Galan et al. 2024. You will find in this file the related bibtex entries.
Special mention regarding Lenstronomy
Part of the Herculens code originates from the open-source lens modeling software package lenstronomy, described in Birrer et al. 2021 (and references therein). In every source file, proper credits are given to the specific developers and contributors to both the original lenstronomy (up to version 1.9.3) and Herculens.
Contributors
The list of people that contributed to Herculens and credits to original lenstronomy contributors, is in this document.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file herculens-0.2.3.tar.gz.
File metadata
- Download URL: herculens-0.2.3.tar.gz
- Upload date:
- Size: 164.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
625ef955fb52459e6d4c99028bccb4e263671733c6f47846e72a4ca78abb5c3c
|
|
| MD5 |
beff597a6b202385ba53fbe5a68d248c
|
|
| BLAKE2b-256 |
d0161c849fbba5a3f6c76cb1ab45ada7c92397934b94896a81cfd3ffe3c6af8a
|
Provenance
The following attestation bundles were made for herculens-0.2.3.tar.gz:
Publisher:
publish-to-pypi.yml on Herculens/herculens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
herculens-0.2.3.tar.gz -
Subject digest:
625ef955fb52459e6d4c99028bccb4e263671733c6f47846e72a4ca78abb5c3c - Sigstore transparency entry: 268679193
- Sigstore integration time:
-
Permalink:
Herculens/herculens@54167c9b302140fe9f213435717c74d760ca6716 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Herculens
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@54167c9b302140fe9f213435717c74d760ca6716 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file herculens-0.2.3-py3-none-any.whl.
File metadata
- Download URL: herculens-0.2.3-py3-none-any.whl
- Upload date:
- Size: 206.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
516fd51c8abf6d1034e72d95cff4f76cda71269716cac0f1a8362bff75390724
|
|
| MD5 |
5f61aac083b474e26d158cb3db061cd7
|
|
| BLAKE2b-256 |
dc1c31e404badb8af028415c79253cef4051325bdca45e69cc9c6699d1d423cd
|
Provenance
The following attestation bundles were made for herculens-0.2.3-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on Herculens/herculens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
herculens-0.2.3-py3-none-any.whl -
Subject digest:
516fd51c8abf6d1034e72d95cff4f76cda71269716cac0f1a8362bff75390724 - Sigstore transparency entry: 268679195
- Sigstore integration time:
-
Permalink:
Herculens/herculens@54167c9b302140fe9f213435717c74d760ca6716 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Herculens
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@54167c9b302140fe9f213435717c74d760ca6716 -
Trigger Event:
workflow_dispatch
-
Statement type: