Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ for the chapter 1 tutorials listed with a `markdown` link below; every other tut
- Tutorial 6: Fitting — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_1_introduction/tutorial_6_fitting.ipynb) / [markdown](markdown/chapter_1_introduction/tutorial_6_fitting.md))
- Tutorial 7: Summary — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_1_introduction/tutorial_7_summary.ipynb) / [markdown](markdown/chapter_1_introduction/tutorial_7_summary.md))
- **[Chapter 2: Lens Modeling](scripts/chapter_2_lens_modeling/README.md)** — Bayesian inference, non-linear searches, lens modeling, search chaining, prior passing, and SLaM pipelines.
- Tutorial 1: Non-linear Search — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_1_non_linear_search.ipynb))
- Tutorial 2: Practicalities — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb))
- Tutorial 3: Realism and Complexity — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_3_realism_and_complexity.ipynb))
- Tutorial 4: Dealing with Failure — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.ipynb))
- Tutorial 5: Linear Profiles — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_5_linear_profiles.ipynb))
- Tutorial 1: Non-linear Search — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_1_non_linear_search.ipynb))
- Tutorial 2: Practicalities — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb))
- Tutorial 3: Why Modeling Is Hard — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_3_why_modeling_is_hard.ipynb))
- Tutorial 4: Linear Profiles — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_4_linear_profiles.ipynb))
- Tutorial 6: Masking and Positions — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_6_masking_and_positions.ipynb))
- Tutorial 7: Results — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_7_results.ipynb))
- Tutorial 8: Need for Speed — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_8_need_for_speed.ipynb))
Expand Down
22 changes: 10 additions & 12 deletions llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ AUTO-GENERATED by PyAutoHands — do not edit by hand; regenerate with generate.
- Contents: Initial Setup, Dataset Auto-Simulation, Model, Search, Result (Search 1), Prior Passing, Result, Wrap Up, Detailed Explanation Of Prior Passing, EXAMPLE
- [Tutorial 11: SLaM](scripts/chapter_2_lens_modeling/tutorial_11_slam.py): In the previous two tutorials, we learnt how search chaining breaks a lens model-fit into a sequence of simpler non-linear searches, and how prior passing carries the results of each search into the next. Together, they give us the flexibility to juggle the dimensionality, priors and settings of each search — the three drivers of run-time we met in tutorial 8 — whilst still fitting a complex and realistic lens model at the end.
- Contents: Search Chaining In The Workspace, SLaM (Source, Light and Mass), Wrap Up
- [Tutorial 1: Non-linear Search](scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py): The starting point for most scientific analysis conducted by an Astronomer is that they have observations of a strong lens using a telescope like the Hubble Space Telescope, and seek to learn about the lens galaxy, source galaxy and the Universe from these observations. With **PyAutoLens**, we seek to learn about the lens's mass and ray-tracing, asking questions like how big is the lens galaxy and what does the unlensed source galaxy look like?
- Contents: Overview, Parameter Space, Non-Linear Search, Search Types, Deeper Background, PyAutoFit, Initial Setup, Dataset Auto-Simulation, Mask, Model, Priors, Analysis, Searches, Maximum Likelihood Estimation (MLE), Markov Chain Monte Carlo (MCMC), Nested Sampling, What is The Best Search To Use?, Wrap Up
- [Tutorial 2: Practicalities](scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py): In the last tutorial, we introduced foundational statistical concepts essential for model-fitting, such as parameter spaces, likelihoods, priors, and non-linear searches. Understanding these statistical concepts is crucial for performing model fits effectively.
- Contents: PyAutoFit, Initial Setup, Dataset Auto-Simulation, Mask, Model, Search, Search Settings, Iterations Per Update, Analysis, VRAM Use, Run Times, Model-Fit, Result Info, Output Folder, Unique Identifier, Output Folder Contents, Result, Other Practicalities, Wrap Up
- [Tutorial 3: Realism and Complexity](scripts/chapter_2_lens_modeling/tutorial_3_realism_and_complexity.py): In the previous two tutorials, we fitted a fairly crude and unrealistic model: the lens's mass was spherical, as was the source's light. Given most lens galaxies are literally called 'elliptical galaxies' we should probably model their mass as elliptical! Furthermore, we have completely omitted the lens galaxy's light, which in real observations outshines the source's light and therefore must be included in the lens model.
- Contents: Initial Setup, Dataset Auto-Simulation, Mask, Model, Search + Analysis, Run Time, Result, Global and Local Maxima, Wrap Up
- [Tutorial 4: Dealing With Failure](scripts/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.py): In the previous tutorial we intentionally made our non-linear search infer a local maxima solution and therefore return a physically incorrect lens model. In this tutorial, we will pretend that we have modeled our lens and inferred a local maxima. We introduce three approaches one can take that changes how we fit the model, all of which have the aim of ensuring we infer the global maxima:
- Contents: Initial Setup, Dataset Auto-Simulation, Mask, Prior Tuning, Run Time, Result, Discussion, Approach 2: Reducing Complexity, Approach 3: Look Harder, Wrap Up
- [Tutorial 5: Linear Profiles](scripts/chapter_2_lens_modeling/tutorial_5_linear_profiles.py): In the previous tutorial we learned how to balance model complexity with our non-linear search in order to infer accurate lens model solutions and avoid failure. We saw how in order to fit a model accurately one may have to parameterize and fit a simpler model with fewer non-linear parameters, at the expense of fitting the data less accurately.
- Contents: Initial Setup, Dataset Auto-Simulation, Mask, Linear Light Profiles, Run Time, Result, Intensities, Visualization, Basis, Model Fit, Source MGE, Multi Gaussian Expansion Benefits, Disadvantage of Basis Functions, Positive Only Solver, Other Basis Functions, Wrap Up
- [Tutorial 1: Non-linear Search](scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py): In Chapter 1, we predicted what a strong lens would look like for a given set of model parameters and compared that prediction with an observed image.
- Contents: Overview, Parameter Space, Automated Exploration, Deeper Background, PyAutoFit, Initial Setup, Dataset Auto-Simulation, Mask, Model, Priors, Analysis, Non-linear Search, Search Settings, Model Fit, Result, Inspecting the Fit, Other Searches, Wrap Up
- [Tutorial 2: Practicalities](scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py): In the previous tutorial, we fitted a simple lens model using Nautilus. We now move to a more realistic image, containing both the foreground lens galaxy’s light and the lensed source.
- Contents: Dataset, Mask, Model, Analysis, Search, Search Settings, Output Updates, VRAM Use, Run Times, Notebooks and Scripts, Model Fit, Result Info, Output Folder, Unique Identifier, Resuming and Loading, Output Folder Contents, Parameter Uncertainties, Plot Labels, Configuration, Further Results, Wrap Up
- [Tutorial 3: Why Modeling Is Hard](scripts/chapter_2_lens_modeling/tutorial_3_why_modeling_is_hard.py): We now have the tools to build a lens model, run a search and inspect its results. However, a search finishing does not necessarily mean that it has found a satisfactory fit.
- Contents: Overview, Dataset and Mask, Model and Analysis, A Less Thorough Search, Inspecting the Result, Comparing Searches, Why Modeling Is Hard, Three Ways Forward, Prior Tuning, Profile Centres, Lens-Light Shape, Mass Shape, Lens-Light Size, Light Concentration, Einstein Radius, Source and Shear Priors, Inspecting the Tuned Model, Prior-Tuned Fit, Assessing the Improvement, Prior Tuning: Benefits and Limitations, Reducing Complexity, Linking Parameters, Inspecting the Simpler Model, Fitting the Simpler Model, Reducing Complexity: Benefits and Limitations, Search More Thoroughly, Original Model, More Thorough Search, Comparing the Approaches, Benefits and Weaknesses, Run Times, Model Mismatch, Wrap Up
- [Tutorial 4: Linear Profiles](scripts/chapter_2_lens_modeling/tutorial_4_linear_profiles.py): In the previous tutorial, we made a lens model easier to fit by tuning priors, linking parameters or searching more thoroughly. Each approach involved a trade-off between flexibility, assumptions and computation.
- Contents: Overview, Dataset and Mask, Linear Light Profiles, Why This Helps, Model, Search and Run Time, Result, Intensities, Visualisation, Basis, A First Gaussian Basis, Evaluating the Basis, Inspecting the Basis Fit, Lens MGE, Source MGE, Combined Model, Inspecting the Model, Model Fit, Multi-Gaussian Expansion Benefits, Benefits Have Costs, Positive Intensities, Other Basis Functions, Wrap Up
- [Tutorial 6: Masking and Positions](scripts/chapter_2_lens_modeling/tutorial_6_masking_and_positions.py): We have learnt everything we need to know about non-linear searches to model a strong lens and infer a good lens model solution. Now, lets consider masking in more detail, something we have not given much consideration previously. We'll also learn a neat trick to improve the speed and accuracy of a non-linear search.
- Contents: Initial Setup, Dataset Auto-Simulation, Mask, Model + Analysis, Run Time, Search, Discussion, Positions Thresholding, Wrap Up
- [Tutorial 7: Results](scripts/chapter_2_lens_modeling/tutorial_7_results.py): In the previous tutorials, each search returned a `Result` object, which we used to plot the maximum log likelihood fit each model-fit. In this tutorial, we'll take a look at the result object in a little more detail.
Expand Down Expand Up @@ -85,8 +83,8 @@ AUTO-GENERATED by PyAutoHands — do not edit by hand; regenerate with generate.

## chapter_optional

- [Tutorial: Alternative Searches](scripts/chapter_optional/tutorial_searches.py): Up to now, we've always used the non-linear search Nautilus and not considered the input parameters that control its sampling. In this tutorial, we'll consider how we can change these setting to balance finding the global maxima solution with fast run time.
- Contents: Nested Sampling, Optimizers, MCMC
- [Tutorial: Alternative Searches](scripts/chapter_optional/tutorial_searches.py): Chapter 2 introduces lens modeling using Nautilus. This optional tutorial explores alternative search settings, optimisation and Markov chain Monte Carlo (MCMC) after you have completed HowToLens.
- Contents: Nested Sampling, Optimisation, MCMC

## simulator

Expand Down
4 changes: 2 additions & 2 deletions llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ analysis?" below).
- **How does a telescope image (and noise/PSF) get simulated?** → [scripts/chapter_1_introduction/tutorial_5_data.py](scripts/chapter_1_introduction/tutorial_5_data.py): Optics blurring, Poisson noise, background sky, the simulator API.
- **What does "fitting" a lens actually mean?** → [scripts/chapter_1_introduction/tutorial_6_fitting.py](scripts/chapter_1_introduction/tutorial_6_fitting.py): Masking, model images, residuals and the log likelihood.
- **How does a non-linear search find a model?** → [scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py](scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py): Parameter space, priors, nested sampling with Nautilus.
- **My fit found a wrong (local-maxima) solution — what do I do?** → [scripts/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.py](scripts/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.py): Prior tuning, simplifying the model, and other escapes from local maxima.
- **What are linear light profiles / MGE?** → [scripts/chapter_2_lens_modeling/tutorial_5_linear_profiles.py](scripts/chapter_2_lens_modeling/tutorial_5_linear_profiles.py): Solving intensities linearly; the Multi-Gaussian Expansion basis.
- **My fit found a wrong (local-maxima) solution — what do I do?** → [scripts/chapter_2_lens_modeling/tutorial_3_why_modeling_is_hard.py](scripts/chapter_2_lens_modeling/tutorial_3_why_modeling_is_hard.py): Prior tuning, simplifying the model, and other escapes from local maxima.
- **What are linear light profiles / MGE?** → [scripts/chapter_2_lens_modeling/tutorial_4_linear_profiles.py](scripts/chapter_2_lens_modeling/tutorial_4_linear_profiles.py): Solving intensities linearly; the Multi-Gaussian Expansion basis.
- **How do I chain searches / what is SLaM?** → [scripts/chapter_2_lens_modeling/tutorial_9_search_chaining.py](scripts/chapter_2_lens_modeling/tutorial_9_search_chaining.py) then [scripts/chapter_2_lens_modeling/tutorial_11_slam.py](scripts/chapter_2_lens_modeling/tutorial_11_slam.py).
- **How do I reconstruct a complex source on a pixel grid?** → [scripts/chapter_3_pixelizations/tutorial_1_pixelizations.py](scripts/chapter_3_pixelizations/tutorial_1_pixelizations.py) through [tutorial_2_bayesian_regularization.py](scripts/chapter_3_pixelizations/tutorial_2_bayesian_regularization.py).
- **How do I model lenses with many galaxies, groups, clusters or weak lensing?** → [scripts/chapter_4_scaling_up_lensing/tutorial_1_extra_galaxies.py](scripts/chapter_4_scaling_up_lensing/tutorial_1_extra_galaxies.py) through [tutorial_6_weak_lensing.py](scripts/chapter_4_scaling_up_lensing/tutorial_6_weak_lensing.py).
Expand Down
9 changes: 4 additions & 5 deletions notebooks/chapter_2_lens_modeling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ searches are chained together into automated lens modeling pipelines.

# Files

- [Tutorial 1: Non-linear Search](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_1_non_linear_search.ipynb) — How a non-linear search is used to fit a lens model and the concepts of a parameter space and priors.
- [Tutorial 1: Non-linear Search](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_1_non_linear_search.ipynb) — How a non-linear search is used to fit a lens model and the concepts of a parameter space and priors.

- [Tutorial 2: Practicalities](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb) — Practicalities of performing model-fitting, like how to inspect the results on your hard-disk.
- [Tutorial 2: Practicalities](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb) — Practicalities of performing model-fitting, like how to inspect the results on your hard-disk.

- [Tutorial 3: Realism and Complexity](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_3_realism_and_complexity.ipynb) — Finding a balance between realism and complexity when composing and fitting a lens model.

- [Tutorial 4: Dealing with Failure](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.ipynb) — What to do when PyAutoLens finds an inaccurate lens model.
- [Tutorial 3: Why Modeling Is Hard](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_3_why_modeling_is_hard.ipynb) — What to do when PyAutoLens finds an inaccurate lens model.

- [Tutorial 5: Linear Profiles](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_5_linear_profiles.ipynb) — Light profiles which capture complex morphologies in a reduced number of non-linear parameters.
- [Tutorial 4: Linear Profiles](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_4_linear_profiles.ipynb) — Light profiles which capture complex morphologies in a reduced number of non-linear parameters.

- [Tutorial 6: Masking and Positions](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.10.29.1/notebooks/chapter_2_lens_modeling/tutorial_6_masking_and_positions.ipynb) — How to mask and mark positions on your data to improve the lens model.

Expand Down
Loading
Loading