Learn gravitational lensing and Bayesian inference through worked examples with PyAutoLens. HowToLens starts from first principles and guides you from tracing light through a galaxy to fitting lens models and reconstructing distant sources.
You don’t need prior experience with lensing or Bayesian statistics. If you already know the fundamentals, head to the PyAutoLens workspace for concise examples.
- Start in your browser — open the series introduction in Google Colab without installing anything locally.
- Run it locally — install PyAutoLens, download this repository and open the Jupyter notebooks in
notebooks/. - Read Chapter 1 with images — browse the available lectures and their results directly on GitHub.
Begin with Tutorial 0: Visualization to check your setup and learn how to display figures.
The PyAutoLens AI Assistant can explain concepts, equations and code, help with notebook errors, and discuss your results. Paste this prompt into your AI coding agent:
I want to work through HowToLens
(https://github.com/PyAutoLabs/HowToLens) with the
PyAutoLens Assistant (https://github.com/PyAutoLabs/autolens_assistant).
First clone the assistant repository, cd into it and follow its AGENTS.md.
Enter teacher mode. Help me find the lectures and get started,
then answer questions as I work through them at my own pace.
See AI Options for tools and setup guidance.
| Chapter | What you’ll learn |
|---|---|
| 1. Introduction | Grids, galaxies, ray tracing, simulated observations and fitting |
| 2. Lens Modeling | Bayesian inference, fitting lens models and combining searches |
| 3. Pixelizations | Reconstructing irregular sources with pixels and regularization |
| 4. Scaling Up Lensing | Multiple lens galaxies, groups, clusters and weak lensing |
| Optional tutorials | Search methods, runtime and additional modeling techniques |
Start with Chapters 1 and 2, then try the workspace examples before returning for Chapters 3 and 4.
Ask questions, suggest improvements and share your work in PyAutoLabs Discussions, or chat with us on Slack.
To contribute, see the contribution guide.
If you use HowToLens or PyAutoLens in your research, see the citation guide.
See the license.
