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
44 changes: 18 additions & 26 deletions markdown/chapter_1_introduction/tutorial_3_more_ray_tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,7 @@ import autolens as al
import autolens.plot as aplt
```

.../PyAutoNerves/autonerves/workspace.py:206: UserWarning: Cannot verify the workspace at HowToLens/scripts/chapter_1_introduction is compatible with the installed library version (2026.7.23.1): no `version.minimum_library_version` or `version.workspace_version` key in config/general.yaml and no version.txt at the workspace root.

If you cloned the workspace from `main` rather than a release tag, set `version.workspace_version_check: False` in config/general.yaml to silence this warning. The `main` branch updates more frequently than library releases, so version mismatches are expected and not actionable for `main`-branch users.

You can also set the environment variable PYAUTO_SKIP_WORKSPACE_VERSION_CHECK=1 to disable temporarily.
warnings.warn(_missing_version_warning(root, library_version))
.../PyAutoNerves/autonerves/workspace.py:206: UserWarning: Cannot verify the workspace at HowToLens/scripts/chapter_1_introduction is compatible with the installed library version (2026.7.23.1): no `version.minimum_library_version` or `version.workspace_version` key in config/general.yaml and no version.txt at the workspace root.

If you cloned the workspace from `main` rather than a release tag, set `version.workspace_version_check: False` in config/general.yaml to silence this warning. The `main` branch updates more frequently than library releases, so version mismatches are expected and not actionable for `main`-branch users.

You can also set the environment variable PYAUTO_SKIP_WORKSPACE_VERSION_CHECK=1 to disable temporarily.
warnings.warn(_missing_version_warning(root, library_version))
Working Directory has been set to `HowToLens`
.../PyAutoNerves/autonerves/workspace.py:206: UserWarning: Cannot verify the workspace at HowToLens/scripts/chapter_1_introduction is compatible with the installed library version (2026.7.23.1): no `version.minimum_library_version` or `version.workspace_version` key in config/general.yaml and no version.txt at the workspace root.

If you cloned the workspace from `main` rather than a release tag, set `version.workspace_version_check: False` in config/general.yaml to silence this warning. The `main` branch updates more frequently than library releases, so version mismatches are expected and not actionable for `main`-branch users.

You can also set the environment variable PYAUTO_SKIP_WORKSPACE_VERSION_CHECK=1 to disable temporarily.
warnings.warn(_missing_version_warning(root, library_version))


__Initial Setup__
Expand Down Expand Up @@ -156,6 +138,12 @@ radial_critical_curves_list = al.LensCalc.from_mass_obj(

```

.../PyAutoGalaxy/autogalaxy/operate/lens_calc.py:565: UserWarning: LensCalc Hessian: 1 of 9801 points did not converge after 20 halvings (largest relative error estimate 4.26e-01); values kept.
warnings.warn(
.../PyAutoGalaxy/autogalaxy/operate/lens_calc.py:565: UserWarning: LensCalc Hessian: 1 of 9801 points did not converge after 20 halvings (largest relative error estimate 4.26e-01); values kept.
warnings.warn(


__Caustics__

In the previous section, we plotted the critical curves of the mass profile on the image-plane. We will now plot the
Expand Down Expand Up @@ -218,6 +206,10 @@ radial_caustics_list = al.LensCalc.from_tracer(tracer=tracer).radial_caustic_lis



.../PyAutoGalaxy/autogalaxy/operate/lens_calc.py:565: UserWarning: LensCalc Hessian: 1 of 9801 points did not converge after 20 halvings (largest relative error estimate 4.26e-01); values kept.
warnings.warn(


We can also plot the caustic on the source-plane image.


Expand Down Expand Up @@ -272,15 +264,19 @@ aplt.subplot_tracer(tracer=tracer, grid=grid)
aplt.subplot_galaxies_images(tracer=tracer, grid=grid)
```

.../PyAutoGalaxy/autogalaxy/operate/lens_calc.py:565: UserWarning: LensCalc Hessian: 1 of 9801 points did not converge after 20 halvings (largest relative error estimate 4.26e-01); values kept.
warnings.warn(




![png](tutorial_3_more_ray_tracing_files/tutorial_3_more_ray_tracing_17_0.png)
![png](tutorial_3_more_ray_tracing_files/tutorial_3_more_ray_tracing_17_1.png)





![png](tutorial_3_more_ray_tracing_files/tutorial_3_more_ray_tracing_17_1.png)
![png](tutorial_3_more_ray_tracing_files/tutorial_3_more_ray_tracing_17_2.png)



Expand Down Expand Up @@ -361,8 +357,8 @@ lens = al.Galaxy(
mass=al.mp.Isothermal(
centre=(0.0, 0.0), ell_comps=(0.0, -0.111111), einstein_radius=1.6
),
shear=al.mp.ExternalShear(gamma_1=0.05, gamma_2=0.0),
)
field = al.MassField(redshift=0.5, shear=al.mp.ExternalShear(gamma_1=0.05, gamma_2=0.0))

print(lens)
```
Expand All @@ -382,11 +378,6 @@ print(lens)
einstein_radius: 1.6
slope: 2.0
core_radius: 0.0
ExternalShear
centre: (0.0, 0.0)
ell_comps: (0.0, 0.0)
gamma_1: 0.05
gamma_2: 0.0


Lets also create a small satellite galaxy nearby the lens galaxy and at the same redshift.
Expand Down Expand Up @@ -513,6 +504,7 @@ ray-tracing is performed.
tracer = al.Tracer(
galaxies=[lens, lens_satellite, source_0, source_1],
cosmology=al.cosmo.Planck15(),
fields=[field],
)
```

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@
" mass=al.mp.Isothermal(\n",
" centre=(0.0, 0.0), ell_comps=(0.0, -0.111111), einstein_radius=1.6\n",
" ),\n",
" shear=al.mp.ExternalShear(gamma_1=0.05, gamma_2=0.0),\n",
")\n",
"field = al.MassField(redshift=0.5, shear=al.mp.ExternalShear(gamma_1=0.05, gamma_2=0.0))\n",
"\n",
"print(lens)"
],
Expand Down Expand Up @@ -531,6 +531,7 @@
"tracer = al.Tracer(\n",
" galaxies=[lens, lens_satellite, source_0, source_1],\n",
" cosmology=al.cosmo.Planck15(),\n",
" fields=[field],\n",
")"
],
"outputs": [],
Expand Down
17 changes: 10 additions & 7 deletions notebooks/chapter_2_lens_modeling/tutorial_10_prior_passing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"we'll use the same strong lensing data as the previous tutorial, where:\n",
"\n",
" - The lens galaxy's light is an `Sersic`.\n",
" - The lens galaxy's total mass distribution is an `Isothermal` and `ExternalShear`.\n",
" - The lens system uses an `Isothermal` galaxy mass profile and a separate `ExternalShear` field.\n",
" - The source galaxy's light is an `Exponential`.\n",
" \n",
"All the usual steps for setting up a model fit (masking, analysis, etc.) are included below."
Expand Down Expand Up @@ -182,12 +182,13 @@
"bulge.sersic_index = 4.0\n",
"\n",
"lens = af.Model(\n",
" al.Galaxy, redshift=0.5, bulge=bulge, mass=mass, shear=al.mp.ExternalShear\n",
" al.Galaxy, redshift=0.5, bulge=bulge, mass=mass\n",
")\n",
"field = af.Model(al.MassField, redshift=0.5, shear=al.mp.ExternalShear)\n",
"\n",
"source = af.Model(al.Galaxy, redshift=1.0, bulge=al.lp_linear.ExponentialCore)\n",
"\n",
"model_1 = af.Collection(galaxies=af.Collection(lens=lens, source=source))"
"model_1 = af.Collection(galaxies=af.Collection(lens=lens, source=source), fields=field)"
],
"outputs": [],
"execution_count": null
Expand Down Expand Up @@ -323,7 +324,9 @@
"metadata": {},
"source": [
"For the mass, we again must account for how its centre was fixed to (0.0\", 0.0\") and therefore not pass the centre.\n",
"Passing the other parameters is the same as how we passed the bulge parameters, as is the shear."
"The external shear belongs to its own field, so we pass that field model separately. Taking it from\n",
"`result_1.model.fields` keeps its parameters free with the priors learned in the first search; taking\n",
"`result_1.instance.fields` would fix them to the fitted values instead."
]
},
{
Expand All @@ -333,7 +336,7 @@
"mass = af.Model(al.mp.Isothermal)\n",
"mass.einstein_radius = result_1.model.galaxies.lens.mass.einstein_radius\n",
"mass.ell_comps = result_1.model.galaxies.lens.mass.ell_comps\n",
"shear = result_1.model.galaxies.lens.shear"
"field = result_1.model.fields"
],
"outputs": [],
"execution_count": null
Expand Down Expand Up @@ -376,11 +379,11 @@
"cell_type": "code",
"metadata": {},
"source": [
"lens = af.Model(al.Galaxy, redshift=0.5, bulge=bulge, mass=mass, shear=shear)\n",
"lens = af.Model(al.Galaxy, redshift=0.5, bulge=bulge, mass=mass)\n",
"\n",
"source = af.Model(al.Galaxy, redshift=1.0, bulge=source_bulge)\n",
"\n",
"model_2 = af.Collection(galaxies=af.Collection(lens=lens, source=source))"
"model_2 = af.Collection(galaxies=af.Collection(lens=lens, source=source), fields=field)"
],
"outputs": [],
"execution_count": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"we'll use new strong lensing data, where:\n",
"\n",
" - The lens galaxy's light is an `Sersic`.\n",
" - The lens galaxy's total mass distribution is an `Isothermal` and `ExternalShear`.\n",
" - The lens system uses an `Isothermal` galaxy mass profile and a separate `ExternalShear` field.\n",
" - The source galaxy's light is an `Exponential`."
]
},
Expand Down Expand Up @@ -212,17 +212,18 @@
"cell_type": "code",
"metadata": {},
"source": [
"field = af.Model(al.MassField, redshift=0.5, shear=al.mp.ExternalShear)\n",
"model = af.Collection(\n",
" galaxies=af.Collection(\n",
" lens=af.Model(\n",
" al.Galaxy,\n",
" redshift=0.5,\n",
" bulge=al.lp.Sersic,\n",
" mass=al.mp.Isothermal,\n",
" shear=al.mp.ExternalShear,\n",
" ),\n",
" source=af.Model(al.Galaxy, redshift=1.0, bulge=al.lp.ExponentialCore),\n",
" ),\n",
" fields=field,\n",
")"
],
"outputs": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"we'll use the same strong lensing data as the previous tutorial, where:\n",
"\n",
" - The lens galaxy's light is an `Sersic`.\n",
" - The lens galaxy's total mass distribution is an `Isothermal` and `ExternalShear`.\n",
" - The lens system uses an `Isothermal` galaxy mass profile and a separate `ExternalShear` field.\n",
" - The source galaxy's light is an `Exponential`."
]
},
Expand Down Expand Up @@ -401,12 +401,13 @@
"metadata": {},
"source": [
"lens = af.Model(\n",
" al.Galaxy, redshift=0.5, bulge=bulge, mass=mass, shear=al.mp.ExternalShear\n",
" al.Galaxy, redshift=0.5, bulge=bulge, mass=mass\n",
")\n",
"field = af.Model(al.MassField, redshift=0.5, shear=al.mp.ExternalShear)\n",
"\n",
"source = af.Model(al.Galaxy, redshift=1.0, bulge=al.lp.ExponentialCore)\n",
"\n",
"model = af.Collection(galaxies=af.Collection(lens=lens, source=source))"
"model = af.Collection(galaxies=af.Collection(lens=lens, source=source), fields=field)"
],
"outputs": [],
"execution_count": null
Expand Down Expand Up @@ -611,12 +612,13 @@
"metadata": {},
"source": [
"lens = af.Model(\n",
" al.Galaxy, redshift=0.5, bulge=bulge, mass=mass, shear=al.mp.ExternalShear\n",
" al.Galaxy, redshift=0.5, bulge=bulge, mass=mass\n",
")\n",
"field = af.Model(al.MassField, redshift=0.5, shear=al.mp.ExternalShear)\n",
"\n",
"source = af.Model(al.Galaxy, redshift=1.0, bulge=al.lp.ExponentialCore)\n",
"\n",
"model = af.Collection(galaxies=af.Collection(lens=lens, source=source))"
"model = af.Collection(galaxies=af.Collection(lens=lens, source=source), fields=field)"
],
"outputs": [],
"execution_count": null
Expand Down Expand Up @@ -769,12 +771,12 @@
" redshift=0.5,\n",
" bulge=al.lp.Sersic,\n",
" mass=al.mp.Isothermal,\n",
" shear=al.mp.ExternalShear,\n",
")\n",
"field = af.Model(al.MassField, redshift=0.5, shear=al.mp.ExternalShear)\n",
"\n",
"source = af.Model(al.Galaxy, redshift=1.0, bulge=al.lp.ExponentialCore)\n",
"\n",
"model = af.Collection(galaxies=af.Collection(lens=lens, source=source))\n",
"model = af.Collection(galaxies=af.Collection(lens=lens, source=source), fields=field)\n",
"\n",
"search = af.Nautilus(\n",
" path_prefix=Path(\"howtolens\") / \"chapter_2\",\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"we'll use the same strong lensing data as the previous tutorial, where:\n",
"\n",
" - The lens galaxy's light is an `Sersic`.\n",
" - The lens galaxy's total mass distribution is an `Isothermal` and `ExternalShear`.\n",
" - The lens system uses an `Isothermal` galaxy mass profile and a separate `ExternalShear` field.\n",
" - The source galaxy's light is an `Exponential`."
]
},
Expand Down Expand Up @@ -237,12 +237,13 @@
"mass = af.Model(al.mp.Isothermal)\n",
"\n",
"lens = af.Model(\n",
" al.Galaxy, redshift=0.5, bulge=bulge, mass=mass, shear=al.mp.ExternalShear\n",
" al.Galaxy, redshift=0.5, bulge=bulge, mass=mass\n",
")\n",
"field = af.Model(al.MassField, redshift=0.5, shear=al.mp.ExternalShear)\n",
"\n",
"source = af.Model(al.Galaxy, redshift=1.0, bulge=al.lp_linear.ExponentialCore)\n",
"\n",
"model = af.Collection(galaxies=af.Collection(lens=lens, source=source))"
"model = af.Collection(galaxies=af.Collection(lens=lens, source=source), fields=field)"
],
"outputs": [],
"execution_count": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"we'll use the same strong lensing data as tutorials 3, 4 and 5 of this chapter, where:\n",
"\n",
" - The lens galaxy's light is an `Sersic`.\n",
" - The lens galaxy's total mass distribution is an `Isothermal` and `ExternalShear`.\n",
" - The lens system uses an `Isothermal` galaxy mass profile and a separate `ExternalShear` field.\n",
" - The source galaxy's light is an `Exponential`."
]
},
Expand Down Expand Up @@ -279,12 +279,13 @@
"metadata": {},
"source": [
"lens = af.Model(\n",
" al.Galaxy, redshift=0.5, bulge=bulge, mass=mass, shear=al.mp.ExternalShear\n",
" al.Galaxy, redshift=0.5, bulge=bulge, mass=mass\n",
")\n",
"field = af.Model(al.MassField, redshift=0.5, shear=al.mp.ExternalShear)\n",
"\n",
"source = af.Model(al.Galaxy, redshift=1.0, bulge=al.lp_linear.ExponentialCore)\n",
"\n",
"model_1 = af.Collection(galaxies=af.Collection(lens=lens, source=source))"
"model_1 = af.Collection(galaxies=af.Collection(lens=lens, source=source), fields=field)"
],
"outputs": [],
"execution_count": null
Expand Down Expand Up @@ -434,7 +435,7 @@
"source": [
"bulge = af.Model(al.lp_linear.Sersic)\n",
"mass = af.Model(al.mp.Isothermal)\n",
"shear = af.Model(al.mp.ExternalShear)\n",
"field = af.Model(al.MassField, redshift=0.5, shear=al.mp.ExternalShear)\n",
"source_bulge = af.Model(al.lp_linear.Sersic)"
],
"outputs": [],
Expand Down Expand Up @@ -507,8 +508,8 @@
"mass.einstein_radius = af.TruncatedGaussianPrior(\n",
" mean=1.6, sigma=0.1, lower_limit=0.0, upper_limit=np.inf\n",
")\n",
"shear.gamma_1 = af.GaussianPrior(mean=0.05, sigma=0.05)\n",
"shear.gamma_2 = af.GaussianPrior(mean=0.05, sigma=0.05)"
"field.shear.gamma_1 = af.GaussianPrior(mean=0.05, sigma=0.05)\n",
"field.shear.gamma_2 = af.GaussianPrior(mean=0.05, sigma=0.05)"
],
"outputs": [],
"execution_count": null
Expand Down Expand Up @@ -559,11 +560,11 @@
"cell_type": "code",
"metadata": {},
"source": [
"lens = af.Model(al.Galaxy, redshift=0.5, bulge=bulge, mass=mass, shear=shear)\n",
"lens = af.Model(al.Galaxy, redshift=0.5, bulge=bulge, mass=mass)\n",
"\n",
"source = af.Model(al.Galaxy, redshift=1.0, bulge=source_bulge)\n",
"\n",
"model_2 = af.Collection(galaxies=af.Collection(lens=lens, source=source))"
"model_2 = af.Collection(galaxies=af.Collection(lens=lens, source=source), fields=field)"
],
"outputs": [],
"execution_count": null
Expand Down
Loading
Loading