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
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,14 @@ for the chapter 1 tutorials listed with a `markdown` link below; every other tut
- Tutorial 5: Data — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_1_introduction/tutorial_5_data.ipynb) / [markdown](markdown/chapter_1_introduction/tutorial_5_data.md))
- 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/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.11.1.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.11.1.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.11.1.1/notebooks/chapter_2_lens_modeling/tutorial_8_need_for_speed.ipynb))
- Tutorial 9: Search Chaining — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.11.1.1/notebooks/chapter_2_lens_modeling/tutorial_9_search_chaining.ipynb))
- Tutorial 10: Prior Passing — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.11.1.1/notebooks/chapter_2_lens_modeling/tutorial_10_prior_passing.ipynb))
- Tutorial 11: SLaM — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.11.1.1/notebooks/chapter_2_lens_modeling/tutorial_11_slam.ipynb))
- **[Chapter 2: Lens Modeling](scripts/chapter_2_lens_modeling/README.md)** — Non-linear searches, linear profiles, datasets and likelihoods, and search chaining.
- [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) — Parameter space, priors and fitting a lens model.
- [Tutorial 2: Practicalities](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb) — Running fits and inspecting their results.
- [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) — Local maxima, degeneracies and investigating difficult fits.
- [Tutorial 4: Linear Profiles](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_4_linear_profiles.ipynb) — Solving light-profile intensities and using multi-Gaussian expansions.
- [Tutorial 5: Data and Likelihoods](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_5_data_and_likelihoods.ipynb) — Separating datasets, models and likelihoods, including positions penalties.
- [Tutorial 6: Search Chaining](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_6_search_chaining.ipynb) — Combining searches and introducing the SLaM pipelines.
- [Tutorial 7: Summary](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_2_lens_modeling/tutorial_7_summary.ipynb) — Bringing the chapter together and continuing to pixelized sources.
- **[Chapter 3: Pixelizations](scripts/chapter_3_pixelizations/README.md)** — From MGE to pixelized sources: mappings, inversions, Bayesian regularization, borders and chained lens fits.
- Tutorial 1 Pixelizations — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_3_pixelizations/tutorial_1_pixelizations.ipynb))
- Tutorial 2 Bayesian Regularization — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_3_pixelizations/tutorial_2_bayesian_regularization.ipynb))
Expand All @@ -116,8 +113,10 @@ for the chapter 1 tutorials listed with a `markdown` link below; every other tut
- Tutorial 4: Group Scale — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.11.1.1/notebooks/chapter_4_scaling_up_lensing/tutorial_4_group_scale.ipynb))
- Tutorial 5: Cluster Scale — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.11.1.1/notebooks/chapter_4_scaling_up_lensing/tutorial_5_cluster_scale.ipynb))
- Tutorial 6: Weak Lensing — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.11.1.1/notebooks/chapter_4_scaling_up_lensing/tutorial_6_weak_lensing.ipynb))
- **[Optional Tutorials](scripts/chapter_optional/)** — Alternative non-linear searches and advanced topics.
- Tutorial Optional: Searches — ([Colab](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/2026.11.1.1/notebooks/chapter_optional/tutorial_searches.ipynb))
- **[Optional Tutorials](scripts/chapter_optional/README.md)** — Search methods, runtime and historical workflows.
- [Need for Speed](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_optional/tutorial_need_for_speed.ipynb) — Computation, batching and estimating runtime.
- [Historical Prior Passing](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_optional/tutorial_prior_passing.ipynb) — An optional runnable example of prior passing using model_centred, a technique central to older workflows.
- [Searches](https://colab.research.google.com/github/PyAutoLabs/HowToLens/blob/main/notebooks/chapter_optional/tutorial_searches.ipynb) — Alternative non-linear search methods.

Model-fits can run faster on a GPU. In Colab, enable one via *Runtime* → *Change runtime type*
→ *Hardware accelerator* before running a notebook.
Expand Down
Binary file added images/chapter_2/circular_vs_annular.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 10 additions & 13 deletions llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,19 @@ AUTO-GENERATED by PyAutoHands — do not edit by hand; regenerate with generate.

## chapter_2_lens_modeling

- [Tutorial 10: Prior Passing](scripts/chapter_2_lens_modeling/tutorial_10_prior_passing.py): In the previous tutorial, we used non-linear search chaining to break the model-fitting procedure down into two non-linear searches. This used an initial search to fit a simple lens model, whose results were used to tune and initialize the priors of a more complex lens model that was fitted by the second search.
- 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): 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
- Contents: Overview, Parameter Space, More Dimensions, 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, Result, 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.
- Contents: Initial Setup, Dataset Auto-Simulation, Tracer & Fit, Samples, Workspace, Database, Wrap Up
- [Tutorial 8: Need For Speed](scripts/chapter_2_lens_modeling/tutorial_8_need_for_speed.py): In this chapter, we have learnt how to model strong lenses and how to balance complexity and realism to ensure that we infer a good lens model.
- Contents: Searching Non-linear Parameter Space, Cost Per Evaluation, JAX, Run Time Estimation, Data Quantity, Wrap Up
- [Tutorial 9: Search Chaining](scripts/chapter_2_lens_modeling/tutorial_9_search_chaining.py): Throughout this chapter, we have fitted the data using just one non-linear search. The previous tutorial discussed the run-time cost of doing this: with a single search, the dimensionality of the model, the priors on its parameters and the search settings must all be juggled at once, leaving us little flexibility to trade them off against one another.
- Contents: Initial Setup, Dataset Auto-Simulation, Model, Search + Analysis, Result, Prior Passing, Run Time, Model Fit, Wrap Up
- [Tutorial 5: Data and Likelihoods](scripts/chapter_2_lens_modeling/tutorial_5_data_and_likelihoods.py): Throughout this chapter, we have fitted imaging data using light and mass profiles. However, the modeling tools we have learnt are not tied to this particular type of observation. We can use the same approach to fit interferometer measurements, the positions of multiply imaged point sources, or the shapes of weakly lensed galaxies.
- Contents: Dataset, Circular Masks, Beyond the Bright Arcs, Mask, Positions Constraints, Choosing Positions, The Positions Penalty, Model and Analysis, Search and Result, Contaminating Light, Extra Galaxy Dataset, Extra Galaxy Region, Noise Scaling, Interpreting the Scaled Dataset, Interferometer Data, Point-Source Data, Weak-Lensing Data, Multiple Datasets, Wrap Up
- [Tutorial 6: Search Chaining](scripts/chapter_2_lens_modeling/tutorial_6_search_chaining.py): Look again at our lens image. The foreground galaxy's light, its gravitational deflection and the background source all contribute to what we observe. Fitting them together requires the search to explore several connected parts of the model.
- Contents: The Search Chain, Dataset and Mask, Multi-Gaussian Expansions, Model 1, Search 1, Inspecting Search 1, Fixing the Lens-Light Geometry, The Power-Law Mass Model, Model 2, Automatically Estimated Positions, Search 2, Result 2, Conditional Uncertainties, Search Chaining and SLaM, Wrap Up
- [Tutorial 7: Summary](scripts/chapter_2_lens_modeling/tutorial_7_summary.py): (no summary in script docstring)

## chapter_3_pixelizations

Expand Down Expand Up @@ -83,6 +76,10 @@ AUTO-GENERATED by PyAutoHands — do not edit by hand; regenerate with generate.

## chapter_optional

- [Optional Tutorial: Need for Speed](scripts/chapter_optional/tutorial_need_for_speed.py): Two fits to the same image can take very different amounts of time. Finding a good fit with a simple model may be quick, whereas exploring the uncertainties of a more flexible model can take much longer. Both the calculation performed for each model and the search through parameter space contribute to this difference.
- Contents: Searching Parameter Space, Cost Per Evaluation, JAX, Batches and GPU Memory, Run Time Estimation, Data Quantity, Wrap Up
- [Optional Tutorial: Historical Prior Passing](scripts/chapter_optional/tutorial_prior_passing.py): This optional tutorial preserves a technique used in earlier **PyAutoLens** modelling workflows, up to around 2025: passing parameter constraints from one search into the priors of a later search.
- Contents: Initial Setup, Dataset Auto-Simulation, Model, Search, Result (Search 1), Prior Passing, Result, Wrap Up, Detailed Explanation Of Prior Passing, EXAMPLE
- [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

Expand Down
2 changes: 1 addition & 1 deletion llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ analysis?" below).
- **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_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 chain searches / what is SLaM?** → [scripts/chapter_2_lens_modeling/tutorial_6_search_chaining.py](scripts/chapter_2_lens_modeling/tutorial_6_search_chaining.py), including its SLaM introduction.
- **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
Loading
Loading