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
12 changes: 6 additions & 6 deletions scripts/chapter_1_introduction/tutorial_0_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

__Contents__

**Directories:** Set the working directory so PyAutoGalaxy can find configs, data and output folders.
**Dataset:** Load an example imaging dataset of a galaxy.
**Plot Customization:** Customize matplotlib options like title, figure size and colormap.
**Subplots:** Plot all components of a dataset simultaneously using subplots.
**Visuals:** Add visual overlays like masks and grids to figures.
**Wrap Up:** Summary of visualization in PyAutoGalaxy.
- **Directories:** Set the working directory so PyAutoGalaxy can find configs, data and output folders.
- **Dataset:** Load an example imaging dataset of a galaxy.
- **Plot Customization:** Customize matplotlib options like title, figure size and colormap.
- **Subplots:** Plot all components of a dataset simultaneously using subplots.
- **Visuals:** Add visual overlays like masks and grids to figures.
- **Wrap Up:** Summary of visualization in PyAutoGalaxy.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
14 changes: 7 additions & 7 deletions scripts/chapter_1_introduction/tutorial_1_grids_and_galaxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@

__Contents__

**Grids:** Create a uniform grid of (y,x) coordinates and show how it can be used to measure the light of a galaxy.
**Geometry:** How to shift and rotate a grid, and convert it to elliptical coordinates.
**Light Profiles:** Using light profiles, analytic functions that describe how a galaxy's light is distributed.
**Galaxies:** Creating galaxies containing light profiles and computing the image of a galaxy.
**One Dimension Projection:** Create projected 2D radial grids for 1D profile calculations.
**Unit Conversion:** Converting angular distances to physical distances using cosmology.
**Wrap Up:** Summary of the key concepts covered in this tutorial.
- **Grids:** Create a uniform grid of (y,x) coordinates and show how it can be used to measure the light of a galaxy.
- **Geometry:** How to shift and rotate a grid, and convert it to elliptical coordinates.
- **Light Profiles:** Using light profiles, analytic functions that describe how a galaxy's light is distributed.
- **Galaxies:** Creating galaxies containing light profiles and computing the image of a galaxy.
- **One Dimension Projection:** Create projected 2D radial grids for 1D profile calculations.
- **Unit Conversion:** Converting angular distances to physical distances using cosmology.
- **Wrap Up:** Summary of the key concepts covered in this tutorial.

The imports below are required to run the howtogalaxy tutorials in a Jupiter notebook. They also import the
`autogalaxy` package and the `autogalaxy.plot` module which are used throughout the tutorials.
Expand Down
14 changes: 7 additions & 7 deletions scripts/chapter_1_introduction/tutorial_2_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

__Contents__

**Initial Setup:** Create a 2D grid and define galaxy light profiles for simulation.
**Optics Blurring:** Simulate how the telescope optics blur the galaxy's light using PSF convolution.
**Poisson Noise:** Add Poisson noise to the image, simulating CCD photon-to-electron randomness.
**Background Sky:** Add background sky light that introduces noise across the entire image.
**Simulator:** Use the SimulatorImaging object to simulate imaging data with all effects combined.
**Output:** Save the simulated data to .fits files for use in future tutorials.
**Wrap Up:** Summary of how CCD imaging data is simulated.
- **Initial Setup:** Create a 2D grid and define galaxy light profiles for simulation.
- **Optics Blurring:** Simulate how the telescope optics blur the galaxy's light using PSF convolution.
- **Poisson Noise:** Add Poisson noise to the image, simulating CCD photon-to-electron randomness.
- **Background Sky:** Add background sky light that introduces noise across the entire image.
- **Simulator:** Use the SimulatorImaging object to simulate imaging data with all effects combined.
- **Output:** Save the simulated data to .fits files for use in future tutorials.
- **Wrap Up:** Summary of how CCD imaging data is simulated.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
14 changes: 7 additions & 7 deletions scripts/chapter_1_introduction/tutorial_3_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

__Contents__

**Dataset:** Load the imaging dataset previously simulated, consisting of the image, noise map, and PSF.
**Mask:** Apply a mask to the data, excluding regions with low signal-to-noise ratios from the analysis.
**Masked Grid:** Create a masked grid containing only coordinates of unmasked pixels.
**Fitting:** Fit the data with a galaxy model, computing the model image, residuals, chi-squared, and log likelihood.
**Incorrect Fit:** Demonstrate how small deviations from true parameters impact fit quality.
**Model Fitting:** Perform a basic model fit, adjusting parameters to improve the fit.
**Wrap Up:** Summary of the fitting process and key statistical concepts.
- **Dataset:** Load the imaging dataset previously simulated, consisting of the image, noise map, and PSF.
- **Mask:** Apply a mask to the data, excluding regions with low signal-to-noise ratios from the analysis.
- **Masked Grid:** Create a masked grid containing only coordinates of unmasked pixels.
- **Fitting:** Fit the data with a galaxy model, computing the model image, residuals, chi-squared, and log likelihood.
- **Incorrect Fit:** Demonstrate how small deviations from true parameters impact fit quality.
- **Model Fitting:** Perform a basic model fit, adjusting parameters to improve the fit.
- **Wrap Up:** Summary of the fitting process and key statistical concepts.
"""

import numpy as np
Expand Down
12 changes: 6 additions & 6 deletions scripts/chapter_1_introduction/tutorial_5_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

__Contents__

**Initial Setup:** Create profiles, galaxies and a Galaxies object for illustration.
**Object Composition:** How Galaxies, Galaxy and Profile objects compose together.
**Visualization:** Customize and visualize any aspect of galaxies using the plotting API.
**Code Design:** Discussion of PyAutoGalaxy's object-oriented design philosophy.
**Source Code:** Links to the source code repositories for PyAutoFit, PyAutoArray and PyAutoGalaxy.
**Wrap Up:** Summary of chapter 1 and preview of the modeling chapter.
- **Initial Setup:** Create profiles, galaxies and a Galaxies object for illustration.
- **Object Composition:** How Galaxies, Galaxy and Profile objects compose together.
- **Visualization:** Customize and visualize any aspect of galaxies using the plotting API.
- **Code Design:** Discussion of PyAutoGalaxy's object-oriented design philosophy.
- **Source Code:** Links to the source code repositories for PyAutoFit, PyAutoArray and PyAutoGalaxy.
- **Wrap Up:** Summary of chapter 1 and preview of the modeling chapter.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
10 changes: 5 additions & 5 deletions scripts/chapter_2_modeling/tutorial_3_realism_and_complexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

__Contents__

**Initial Setup:** Load the dataset and apply a mask.
**Model + Search + Analysis:** Compose a bulge+disk model and fit it using Nautilus.
**Result:** Inspect the result and compare to the true model.
**Global and Local Maxima:** Demonstrate how the search can infer incorrect local maxima solutions.
**Wrap Up:** Summary of the challenges of fitting more complex and realistic models.
- **Initial Setup:** Load the dataset and apply a mask.
- **Model + Search + Analysis:** Compose a bulge+disk model and fit it using Nautilus.
- **Result:** Inspect the result and compare to the true model.
- **Global and Local Maxima:** Demonstrate how the search can infer incorrect local maxima solutions.
- **Wrap Up:** Summary of the challenges of fitting more complex and realistic models.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
8 changes: 4 additions & 4 deletions scripts/chapter_2_modeling/tutorial_4_dealing_with_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

__Contents__

**Initial Setup:** Load the dataset and apply a mask.
**Approach 1: Prior Tuning:** Narrow the priors to guide the search to the correct region of parameter space.
**Approach 2: Reducing Complexity:** Simplify the model to reduce the dimensionality of parameter space.
**Approach 3: Look Harder:** Increase the thoroughness of the non-linear search sampling.
- **Initial Setup:** Load the dataset and apply a mask.
- **Approach 1: Prior Tuning:** Narrow the priors to guide the search to the correct region of parameter space.
- **Approach 2: Reducing Complexity:** Simplify the model to reduce the dimensionality of parameter space.
- **Approach 3: Look Harder:** Increase the thoroughness of the non-linear search sampling.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
26 changes: 13 additions & 13 deletions scripts/chapter_2_modeling/tutorial_5_linear_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@

__Contents__

**Initial Setup:** Load the dataset and apply a mask.
**Linear Light Profiles:** Fit a model using linear light profiles that solve for intensity via linear algebra.
**Run Time:** Estimate the run time of the model-fit before starting.
**Result:** Inspect the result and the solved intensity values.
**Intensities:** Access the intensity values of linear light profiles after the fit.
**Visualization:** Visualize the fit using linear light profiles.
**Basis:** Combine many linear light profiles into a basis for fitting complex structures.
**Model Fit:** Fit the basis model to the data.
**Disk MGE:** Use a Multi-Gaussian Expansion for the disk component.
**Multi Gaussian Expansion Benefits:** Discussion of the advantages of MGE models.
**Positive Only Solver:** Ensure linear algebra solutions have positive intensity values.
**Other Basis Functions:** Overview of other basis functions like shapelets.
**Wrap Up:** Summary of linear light profiles and basis functions.
- **Initial Setup:** Load the dataset and apply a mask.
- **Linear Light Profiles:** Fit a model using linear light profiles that solve for intensity via linear algebra.
- **Run Time:** Estimate the run time of the model-fit before starting.
- **Result:** Inspect the result and the solved intensity values.
- **Intensities:** Access the intensity values of linear light profiles after the fit.
- **Visualization:** Visualize the fit using linear light profiles.
- **Basis:** Combine many linear light profiles into a basis for fitting complex structures.
- **Model Fit:** Fit the basis model to the data.
- **Disk MGE:** Use a Multi-Gaussian Expansion for the disk component.
- **Multi Gaussian Expansion Benefits:** Discussion of the advantages of MGE models.
- **Positive Only Solver:** Ensure linear algebra solutions have positive intensity values.
- **Other Basis Functions:** Overview of other basis functions like shapelets.
- **Wrap Up:** Summary of linear light profiles and basis functions.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
10 changes: 5 additions & 5 deletions scripts/chapter_2_modeling/tutorial_6_masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

__Contents__

**Initial Setup:** Load the dataset and apply a mask.
**Mask:** Apply a custom mask to focus the fit on specific regions.
**Model + Search + Analysis:** Fit the model using the custom mask.
**Discussion:** How the mask affects the fit quality and run time.
**Wrap Up:** Summary of masking strategies for galaxy modeling.
- **Initial Setup:** Load the dataset and apply a mask.
- **Mask:** Apply a custom mask to focus the fit on specific regions.
- **Model + Search + Analysis:** Fit the model using the custom mask.
- **Discussion:** How the mask affects the fit quality and run time.
- **Wrap Up:** Summary of masking strategies for galaxy modeling.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
12 changes: 6 additions & 6 deletions scripts/chapter_2_modeling/tutorial_7_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

__Contents__

**Initial Setup:** Perform a model-fit to obtain a Result object.
**Galaxies & Fit:** Access the maximum likelihood galaxies and fit from the result.
**Samples:** Inspect the non-linear search samples, including parameter estimates and errors.
**Workspace:** Pointers to more detailed results examples in the workspace.
**Database:** Overview of the database functionality for managing large numbers of results.
**Wrap Up:** Summary of the Result object and its key attributes.
- **Initial Setup:** Perform a model-fit to obtain a Result object.
- **Galaxies & Fit:** Access the maximum likelihood galaxies and fit from the result.
- **Samples:** Inspect the non-linear search samples, including parameter estimates and errors.
- **Workspace:** Pointers to more detailed results examples in the workspace.
- **Database:** Overview of the database functionality for managing large numbers of results.
- **Wrap Up:** Summary of the Result object and its key attributes.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
8 changes: 4 additions & 4 deletions scripts/chapter_2_modeling/tutorial_8_need_for_speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

__Contents__

**Searching Non-linear Parameter Space:** How dimensionality, priors and settings drive search run-times.
**Algorithmic Optimization:** How PyAutoGalaxy uses numba and JAX for fast computation.
**Data Quantity:** How the number of image pixels affects run-time.
**Wrap Up:** Summary of strategies for keeping model-fit run-times manageable.
- **Searching Non-linear Parameter Space:** How dimensionality, priors and settings drive search run-times.
- **Algorithmic Optimization:** How PyAutoGalaxy uses numba and JAX for fast computation.
- **Data Quantity:** How the number of image pixels affects run-time.
- **Wrap Up:** Summary of strategies for keeping model-fit run-times manageable.

For fitting more complex models, the final challenge that we face is keeping the run-time low. One can easily end
up in a situation where a model-fit takes days, or longer, to fit just one image. For fitting complex models and high
Expand Down
14 changes: 7 additions & 7 deletions scripts/chapter_3_search_chaining/tutorial_1_search_chaining.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@

__Contents__

**Initial Setup:** Load the dataset and apply a mask.
**Model:** Compose a simplified model for the first search with aligned bulge-disk assumptions.
**Search + Analysis:** Run the first search with the simplified model.
**Result:** Inspect the result of the first search.
**Prior Passing:** Manually pass results from search 1 as priors for search 2.
**Result:** Inspect the final result of the chained search.
**Wrap Up:** Summary of how search chaining improves model-fitting reliability.
- **Initial Setup:** Load the dataset and apply a mask.
- **Model:** Compose a simplified model for the first search with aligned bulge-disk assumptions.
- **Search + Analysis:** Run the first search with the simplified model.
- **Result:** Inspect the result of the first search.
- **Prior Passing:** Manually pass results from search 1 as priors for search 2.
- **Result:** Inspect the final result of the chained search.
- **Wrap Up:** Summary of how search chaining improves model-fitting reliability.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
18 changes: 9 additions & 9 deletions scripts/chapter_3_search_chaining/tutorial_2_prior_passing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

__Contents__

**Initial Setup:** Load the dataset and apply a mask.
**Model:** Compose the model for the first search.
**Search:** Run the first search.
**Result (Search 1):** Inspect the result of the first search.
**Prior Passing:** Use the prior passing API to pass results to the second search.
**Result:** Inspect the final result of the chained search.
**Wrap Up:** Summary of the prior passing API.
**Detailed Explanation Of Prior Passing:** In-depth explanation of how priors are passed between searches.
**EXAMPLE:** A worked example of prior passing for a Sersic sersic_index parameter.
- **Initial Setup:** Load the dataset and apply a mask.
- **Model:** Compose the model for the first search.
- **Search:** Run the first search.
- **Result (Search 1):** Inspect the result of the first search.
- **Prior Passing:** Use the prior passing API to pass results to the second search.
- **Result:** Inspect the final result of the chained search.
- **Wrap Up:** Summary of the prior passing API.
- **Detailed Explanation Of Prior Passing:** In-depth explanation of how priors are passed between searches.
- **EXAMPLE:** A worked example of prior passing for a Sersic sersic_index parameter.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
22 changes: 11 additions & 11 deletions scripts/chapter_3_search_chaining/tutorial_3_x2_galaxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@

__Contents__

**Initial Setup:** Load the double-galaxy dataset and apply a mask.
**Paths:** Set the output path for chained search results.
**Search Chaining Approach:** Strategy for fitting two galaxies using a sequence of searches.
**Model + Search + Analysis + Model-Fit (Search 1):** Fit the first galaxy alone.
**Result (Search 1):** Inspect the result of fitting the first galaxy.
**Model (Search 2):** Compose a model for the second galaxy, fixing the first.
**Search + Analysis + Model-Fit (Search 2):** Fit the second galaxy.
**Result (Search 2):** Inspect the result of fitting the second galaxy.
**Model + Search + Analysis + Model-Fit (Search 4):** Fit both galaxies simultaneously.
**Result (Search 3):** Inspect the final simultaneous fit result.
**Wrap Up:** Summary of search chaining for multi-galaxy systems.
- **Initial Setup:** Load the double-galaxy dataset and apply a mask.
- **Paths:** Set the output path for chained search results.
- **Search Chaining Approach:** Strategy for fitting two galaxies using a sequence of searches.
- **Model + Search + Analysis + Model-Fit (Search 1):** Fit the first galaxy alone.
- **Result (Search 1):** Inspect the result of fitting the first galaxy.
- **Model (Search 2):** Compose a model for the second galaxy, fixing the first.
- **Search + Analysis + Model-Fit (Search 2):** Fit the second galaxy.
- **Result (Search 2):** Inspect the result of fitting the second galaxy.
- **Model + Search + Analysis + Model-Fit (Search 4):** Fit both galaxies simultaneously.
- **Result (Search 3):** Inspect the final simultaneous fit result.
- **Wrap Up:** Summary of search chaining for multi-galaxy systems.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
6 changes: 3 additions & 3 deletions scripts/chapter_4_pixelizations/tutorial_1_pixelizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

__Contents__

**Initial Setup:** Create a grid for illustration.
**Mesh:** Set up a rectangular mesh for the pixelization.
**Wrap Up:** Summary of pixelization concepts.
- **Initial Setup:** Create a grid for illustration.
- **Mesh:** Set up a rectangular mesh for the pixelization.
- **Wrap Up:** Summary of pixelization concepts.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
8 changes: 4 additions & 4 deletions scripts/chapter_4_pixelizations/tutorial_2_mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

__Contents__

**Initial Setup:** Load the dataset for illustration.
**Mappers:** Understand how mappers map image-plane pixels to pixelization pixels.
**Mask:** Apply a mask and see how it affects the mapper.
**Wrap Up:** Summary of mapper concepts.
- **Initial Setup:** Load the dataset for illustration.
- **Mappers:** Understand how mappers map image-plane pixels to pixelization pixels.
- **Mask:** Apply a mask and see how it affects the mapper.
- **Wrap Up:** Summary of mapper concepts.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
10 changes: 5 additions & 5 deletions scripts/chapter_4_pixelizations/tutorial_3_inversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

__Contents__

**Initial Setup:** Load the dataset for illustration.
**Pixelization:** Create a pixelization and perform an inversion to reconstruct the galaxy.
**Positive Only Solver:** Ensure the reconstruction has only positive intensity values.
**Wrap Up:** Summary of inversion concepts.
**Detailed Explanation:** In-depth explanation of the linear algebra behind inversions.
- **Initial Setup:** Load the dataset for illustration.
- **Pixelization:** Create a pixelization and perform an inversion to reconstruct the galaxy.
- **Positive Only Solver:** Ensure the reconstruction has only positive intensity values.
- **Wrap Up:** Summary of inversion concepts.
- **Detailed Explanation:** In-depth explanation of the linear algebra behind inversions.
"""

# from autoconf import setup_notebook; setup_notebook()
Expand Down
Loading
Loading