Example scripts and notebooks for modeling strong gravitational lenses with PyAutoLens. Start with an introductory example, then explore the tools for your own data.
- Try it in your browser — run the introductory notebook on Google Colab without installing anything.
- Run it locally — follow the installation guide, then open
start_here.ipynb. - Browse examples with images — read worked examples and view their results directly on GitHub.
See Find Your Examples below to choose where to start.
The PyAutoLens AI Assistant helps you learn lensing, run examples and analyse your own data through conversation. Visit its README for setup instructions and a starting prompt.
Examples are available as Python scripts in scripts/ and Jupyter notebooks in notebooks/.
For a single lens galaxy, choose your data type below. For larger systems, start with multi_galaxy/, group/ or cluster/.
Choose the example for your observations. Each folder has a start_here example to get you going.
Imaging![]() Fit images from Hubble, JWST and other telescopes with imaging/. |
Interferometry![]() Fit radio and submillimetre observations with interferometer/. |
Multi-band Imaging![]() Fit several wavebands together with multi_dataset/. |
Data Cubes![]() Fit spectral channels together with interferometer/features/datacube/. |
Point Sources![]() Model lensed quasars and supernovae with point_source/. |
Weak Lensing![]() Model the subtle shape distortions of many background galaxies, alone or combined with strong lensing, with weak/. |
AI-generated illustrations (weak lensing rendered procedurally), not observations. Lens panels use different angular scales. See the new user guide for details.
| I want to… | Start here |
|---|---|
| Learn the API, customise models or inspect results | Guides |
| Model a lens in imaging data | Imaging |
| Model interferometer observations | Interferometry |
| Fit observations in multiple wavebands | Multiple datasets |
| Model lensed point sources | Point sources |
| Model a lens with several main galaxies | Multiple galaxies |
| Model a galaxy group | Groups |
| Model a galaxy cluster | Clusters |
| Explore weak lensing | Weak lensing |
Each folder has a README explaining its examples. You’ll find sample data in dataset/; analysis results are written to output/.
HowToLens teaches gravitational lensing and Bayesian inference through worked notebooks. Start here if you’re new to the subject or would like more explanation alongside the workspace examples.
Ask questions, suggest improvements and share your work in PyAutoLabs Discussions, or chat with us on Slack.
To contribute examples or explore community projects, visit the PyAutoLens community page.
If you use PyAutoLens in your research, see the citation guide.
See the PyAutoLens license.







