From c294151ca54a9db065cbd4499df063b57c1dd754 Mon Sep 17 00:00:00 2001 From: samlange04 Date: Sun, 18 Oct 2026 13:21:50 +0800 Subject: [PATCH 1/7] Describe corner plot superscripts as the component's path of names PyAutoFit now labels every parameter with the path of names its component was given in the model (`lens.mass`, `galaxy.bulge`), so components of one class are told apart; the tutorial's sentence and example follow, and it shows the derived-parameter corner plot (`derived=True`). Co-Authored-By: Claude Fable 5.1 --- .../tutorial_2_practicalities.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py b/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py index 91f511b..b2c1192 100755 --- a/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py +++ b/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py @@ -386,11 +386,24 @@ The plot is labeled with short hand parameter names (e.g. `sersic_index` is mapped to the short hand parameter `n`). These mappings ate specified in the `config/notation.yaml` file and can be customized by users. -The superscripts of labels correspond to the name each component was given in the model (e.g. for the `Isothermal` -mass its name `mass` defined when making the `Model` above is used). +The superscripts of labels are the path of names each component was given in the model (e.g. for the `Isothermal` +mass, `lens.mass`: the galaxy's name `lens` and its name `mass` defined when making the `Model` above). """ aplt.corner_anesthetic(samples=result.samples) + +""" +Components of the same class are therefore told apart (every Gaussian of a basis is labelled by the galaxy and +light profile it belongs to) and, when the model has more than one top-level component, each also gets its own +corner plot in the output folder (`corner_anesthetic_.png`, switched in `config/visualize/plots_search.yaml`). + +The parameters a model is sampled in are not always the ones it is read in: a profile's elliptical components are an +axis ratio and a position angle, a shear's two components a magnitude and an angle. Passing `derived=True` plots +these derived parameters instead. The same figure is written to the output folder as `corner_anesthetic_derived.png` +when `corner_anesthetic_derived` is switched on in `config/visualize/plots_search.yaml` (off by default). +""" +aplt.corner_anesthetic(samples=result.samples, derived=True) + """ __Other Practicalities__ From d6a02cdb097e6cd3e75ec01d6c7bb794b5b96685 Mon Sep 17 00:00:00 2001 From: samlange04 Date: Sun, 18 Oct 2026 15:51:54 +0800 Subject: [PATCH 2/7] Corner plots: derived parameters are latent parameters The config switch is `corner_anesthetic_latent` and the files `corner_anesthetic_latent[_].png`; the plots are made once the fit completes, per component only where one has a latent parameter, and the latent parameters also reach `latent.csv`. Co-Authored-By: Claude Fable 5.1 --- .../chapter_2_lens_modeling/tutorial_2_practicalities.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py b/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py index b2c1192..ec13b54 100755 --- a/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py +++ b/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py @@ -398,11 +398,12 @@ corner plot in the output folder (`corner_anesthetic_.png`, switched in `config/visualize/plots_search.yaml`). The parameters a model is sampled in are not always the ones it is read in: a profile's elliptical components are an -axis ratio and a position angle, a shear's two components a magnitude and an angle. Passing `derived=True` plots -these derived parameters instead. The same figure is written to the output folder as `corner_anesthetic_derived.png` -when `corner_anesthetic_derived` is switched on in `config/visualize/plots_search.yaml` (off by default). +axis ratio and a position angle, a shear's two components a magnitude and an angle. Passing `latent=True` plots +these latent parameters instead. The same figure is written to the output folder as `corner_anesthetic_latent.png` +when `corner_anesthetic_latent` is switched on in `config/visualize/plots_search.yaml` (off by default), once the fit +is complete, and the latent parameters are also written to `latent.csv` with the other latent variables. """ -aplt.corner_anesthetic(samples=result.samples, derived=True) +aplt.corner_anesthetic(samples=result.samples, latent=True) """ __Other Practicalities__ From ed5a1dbd9e14b1cf578184b6577d1f0c3084a274 Mon Sep 17 00:00:00 2001 From: samlange04 Date: Sun, 18 Oct 2026 16:33:36 +0800 Subject: [PATCH 3/7] Latent descriptions: model latent parameters in latent.csv, latent corner plot after the fit Co-Authored-By: Claude Fable 5.1 --- config/output.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/output.yaml b/config/output.yaml index 58e9223..6352053 100755 --- a/config/output.yaml +++ b/config/output.yaml @@ -86,7 +86,7 @@ start_point: true # manually after completing a successful model-fit. This will save computational run time by not computing latent # variables during a any model-fit which is unsuccessful. -latent_during_fit: false # Whether to output the `latent.csv`, `latent.results` and `latent_summary.json` files during the fit when it performs on-the-fly output. +latent_during_fit: false # Whether to output the `latent.csv`, `latent.results` and `latent_summary.json` files during the fit when it performs on-the-fly output. Also whether the latent corner plot (`visualize/plots_search.yaml` -> `corner_anesthetic_latent`) is made during the fit; it is always made once the fit completes. latent_after_fit: true # If `latent_during_fit` is False, whether to output the `latent.csv`, `latent.results` and `latent_summary.json` files after the fit is complete. latent_draw_via_pdf : true # Whether to draw latent variable values via the PDF of every sample, which uses fewer samples to estimate latent variable errors. If False, latent variable values are drawn from every sample. latent_draw_via_pdf_size : 100 # The number of samples drawn to estimate latent variable errors if `latent_draw_via_pdf` is True. From 63fa600a48cb2836dbd1c47f40684f861cbf6a0d Mon Sep 17 00:00:00 2001 From: samlange04 Date: Thu, 22 Oct 2026 19:21:13 +0800 Subject: [PATCH 4/7] Config: corner_anesthetic_latent_components and latent_model_parameters switches Mirror the two keys PyAutoFit added when merging #1709: the per-component latent corner plots get their own plots_search.yaml switch, and output.yaml can keep a model's declared latent parameters out of latent.csv / latent.results. Co-Authored-By: Claude Fable 5.1 --- config/output.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/output.yaml b/config/output.yaml index 6352053..6cbdb25 100755 --- a/config/output.yaml +++ b/config/output.yaml @@ -92,6 +92,7 @@ latent_draw_via_pdf : true # Whether to draw latent variable values via the PDF latent_draw_via_pdf_size : 100 # The number of samples drawn to estimate latent variable errors if `latent_draw_via_pdf` is True. latent_csv: true # Whether to ouptut the `latent.csv` file. latent_results: true # Whether to output the `latent.results` file. +latent_model_parameters: true # Whether the latent parameters a model component declares (e.g. a shear's magnitude and angle for its gamma_1 / gamma_2) join the latent output (`latent.csv`, `latent.results`, `latent_summary.json`). An angle keeps the range its conversion gives it (the same in every fit); only the corner plots recentre it on the posterior. # Other Files: From 5590de15688cb2a103aa397eb8818815f3c7c3a8 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 26 Oct 2026 10:02:23 +0000 Subject: [PATCH 5/7] Complete corner configuration and regenerate notebooks --- config/notation.yaml | 5 ++-- config/visualize/plots_search.yaml | 3 ++ .../tutorial_2_practicalities.ipynb | 30 +++++++++++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/config/notation.yaml b/config/notation.yaml index 6a34774..b4e672f 100755 --- a/config/notation.yaml +++ b/config/notation.yaml @@ -7,9 +7,10 @@ # For example, if `centre=x`, the plot axis will be labeled 'x'. -# superscript: the superscript used on certain plots that show the results of different model-components. +# superscript: the class abbreviation used for priors directly on an unnamed Model. +# Named components use their model path instead (for example lens.bulge or source.pix.reg). -# For example, if `Gaussian=g`, plots where the parameters of the Gaussian model-component have superscript `g`. +# For example, `Gaussian=g` labels an unnamed Gaussian Model with superscript `g`. label: label: diff --git a/config/visualize/plots_search.yaml b/config/visualize/plots_search.yaml index 24f805e..8a1d3e4 100644 --- a/config/visualize/plots_search.yaml +++ b/config/visualize/plots_search.yaml @@ -1,5 +1,8 @@ nest: corner_anesthetic: true # Output corner figure (using anestetic) during a non-linear search fit? + corner_anesthetic_components: true # Also output one corner figure per top-level model component (e.g. per galaxy), each named corner_anesthetic_? Follows corner_anesthetic when absent. + corner_anesthetic_latent: false # Output a corner figure of the latent parameters (e.g. a shear's magnitude and angle rather than gamma_1 / gamma_2), named corner_anesthetic_latent? Independent of the two above. Made after the fit like latent.csv (during it only if output.yaml's latent_during_fit is on). + corner_anesthetic_latent_components: true # With corner_anesthetic_latent, also output one latent corner figure per top-level component that has a latent parameter, each named corner_anesthetic_latent_? Follows corner_anesthetic_latent when absent. mcmc: corner_cornerpy: true # Output corner figure (using corner.py) during a non-linear search fit? mle: diff --git a/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb b/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb index da5c1cb..1af1d76 100644 --- a/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb +++ b/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb @@ -572,15 +572,39 @@ "The plot is labeled with short hand parameter names (e.g. `sersic_index` is mapped to the short hand \n", "parameter `n`). These mappings ate specified in the `config/notation.yaml` file and can be customized by users.\n", "\n", - "The superscripts of labels correspond to the name each component was given in the model (e.g. for the `Isothermal`\n", - "mass its name `mass` defined when making the `Model` above is used)." + "The superscripts of labels are the path of names each component was given in the model (e.g. for the `Isothermal`\n", + "mass, `lens.mass`: the galaxy's name `lens` and its name `mass` defined when making the `Model` above)." ] }, { "cell_type": "code", "metadata": {}, "source": [ - "aplt.corner_anesthetic(samples=result.samples)" + "aplt.corner_anesthetic(samples=result.samples)\n" + ], + "outputs": [], + "execution_count": null + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Components of the same class are therefore told apart (every Gaussian of a basis is labelled by the galaxy and\n", + "light profile it belongs to) and, when the model has more than one top-level component, each also gets its own\n", + "corner plot in the output folder (`corner_anesthetic_.png`, switched in `config/visualize/plots_search.yaml`).\n", + "\n", + "The parameters a model is sampled in are not always the ones it is read in: a profile's elliptical components are an\n", + "axis ratio and a position angle, a shear's two components a magnitude and an angle. Passing `latent=True` plots\n", + "these latent parameters instead. The same figure is written to the output folder as `corner_anesthetic_latent.png`\n", + "when `corner_anesthetic_latent` is switched on in `config/visualize/plots_search.yaml` (off by default), once the fit\n", + "is complete, and the latent parameters are also written to `latent.csv` with the other latent variables." + ] + }, + { + "cell_type": "code", + "metadata": {}, + "source": [ + "aplt.corner_anesthetic(samples=result.samples, latent=True)" ], "outputs": [], "execution_count": null From 1f0b479f683f8e226456d647c40339591f95c182 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 26 Oct 2026 14:28:47 +0000 Subject: [PATCH 6/7] Clarify latent output policy in practicalities tutorial --- config/output.yaml | 8 ++++---- config/visualize/plots_search.yaml | 4 ++-- .../tutorial_2_practicalities.ipynb | 4 +++- .../chapter_2_lens_modeling/tutorial_2_practicalities.py | 4 +++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/config/output.yaml b/config/output.yaml index 6cbdb25..1d49fce 100755 --- a/config/output.yaml +++ b/config/output.yaml @@ -86,13 +86,13 @@ start_point: true # manually after completing a successful model-fit. This will save computational run time by not computing latent # variables during a any model-fit which is unsuccessful. -latent_during_fit: false # Whether to output the `latent.csv`, `latent.results` and `latent_summary.json` files during the fit when it performs on-the-fly output. Also whether the latent corner plot (`visualize/plots_search.yaml` -> `corner_anesthetic_latent`) is made during the fit; it is always made once the fit completes. -latent_after_fit: true # If `latent_during_fit` is False, whether to output the `latent.csv`, `latent.results` and `latent_summary.json` files after the fit is complete. +latent_during_fit: false # Write configured latent output during fit updates; also make the latent corner plot during updates if corner_anesthetic_latent is enabled. +latent_after_fit: true # Write configured latent output after completion. Full-sample mode writes files/latent/samples.csv; summaries use latent.results and files/latent/latent_summary.json. latent_draw_via_pdf : true # Whether to draw latent variable values via the PDF of every sample, which uses fewer samples to estimate latent variable errors. If False, latent variable values are drawn from every sample. latent_draw_via_pdf_size : 100 # The number of samples drawn to estimate latent variable errors if `latent_draw_via_pdf` is True. latent_csv: true # Whether to ouptut the `latent.csv` file. latent_results: true # Whether to output the `latent.results` file. -latent_model_parameters: true # Whether the latent parameters a model component declares (e.g. a shear's magnitude and angle for its gamma_1 / gamma_2) join the latent output (`latent.csv`, `latent.results`, `latent_summary.json`). An angle keeps the range its conversion gives it (the same in every fit); only the corner plots recentre it on the posterior. +latent_model_parameters: true # Include model-declared columns in configured latent output. Full-sample CSV: files/latent/samples.csv. Saved angles retain their conversion range; only plots recentre them. # Other Files: @@ -100,4 +100,4 @@ search_log: true # `search.log`: logging produced whilst running the fit method # `model.png`: the model figure drawn beside `model.info` (af.ModelPlotter). Opt-in until the # model-figures epic's phase-3 acceptance renders pass. Unlike other keys an absent key means off. -model_figure: false \ No newline at end of file +model_figure: false diff --git a/config/visualize/plots_search.yaml b/config/visualize/plots_search.yaml index 8a1d3e4..5c8d72d 100644 --- a/config/visualize/plots_search.yaml +++ b/config/visualize/plots_search.yaml @@ -1,11 +1,11 @@ nest: corner_anesthetic: true # Output corner figure (using anestetic) during a non-linear search fit? corner_anesthetic_components: true # Also output one corner figure per top-level model component (e.g. per galaxy), each named corner_anesthetic_? Follows corner_anesthetic when absent. - corner_anesthetic_latent: false # Output a corner figure of the latent parameters (e.g. a shear's magnitude and angle rather than gamma_1 / gamma_2), named corner_anesthetic_latent? Independent of the two above. Made after the fit like latent.csv (during it only if output.yaml's latent_during_fit is on). + corner_anesthetic_latent: false # Output corner_anesthetic_latent after completion for declared latent parameters; during the fit only if output.yaml's latent_during_fit is enabled. Independent of the ordinary corner switches. corner_anesthetic_latent_components: true # With corner_anesthetic_latent, also output one latent corner figure per top-level component that has a latent parameter, each named corner_anesthetic_latent_? Follows corner_anesthetic_latent when absent. mcmc: corner_cornerpy: true # Output corner figure (using corner.py) during a non-linear search fit? mle: subplot_parameters: true # Output a subplot of the best-fit parameters of the model? log_likelihood_vs_iteration: true # Output a plot of the log likelihood versus iteration number? - figure_of_merit_vs_iteration: true # Output the global-best figure-of-merit trace (auto-convergence gradient searches)? \ No newline at end of file + figure_of_merit_vs_iteration: true # Output the global-best figure-of-merit trace (auto-convergence gradient searches)? diff --git a/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb b/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb index 1af1d76..f8b60d3 100644 --- a/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb +++ b/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb @@ -597,7 +597,9 @@ "axis ratio and a position angle, a shear's two components a magnitude and an angle. Passing `latent=True` plots\n", "these latent parameters instead. The same figure is written to the output folder as `corner_anesthetic_latent.png`\n", "when `corner_anesthetic_latent` is switched on in `config/visualize/plots_search.yaml` (off by default), once the fit\n", - "is complete, and the latent parameters are also written to `latent.csv` with the other latent variables." + "is complete. With `latent_model_parameters` enabled, full-sample latent output (`latent_draw_via_pdf: false`)\n", + "writes these columns to `files/latent/samples.csv` with the other latent variables. Periodic angles are recentred\n", + "for the plot; saved values retain the conversion's original range." ] }, { diff --git a/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py b/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py index ec13b54..30accd9 100755 --- a/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py +++ b/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py @@ -401,7 +401,9 @@ axis ratio and a position angle, a shear's two components a magnitude and an angle. Passing `latent=True` plots these latent parameters instead. The same figure is written to the output folder as `corner_anesthetic_latent.png` when `corner_anesthetic_latent` is switched on in `config/visualize/plots_search.yaml` (off by default), once the fit -is complete, and the latent parameters are also written to `latent.csv` with the other latent variables. +is complete. With `latent_model_parameters` enabled, full-sample latent output (`latent_draw_via_pdf: false`) +writes these columns to `files/latent/samples.csv` with the other latent variables. Periodic angles are recentred +for the plot; saved values retain the conversion's original range. """ aplt.corner_anesthetic(samples=result.samples, latent=True) From 09b3b6b342a1d13f192f7a4d57253a60c6cc9fc7 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 26 Oct 2026 14:50:54 +0000 Subject: [PATCH 7/7] Qualify component superscripts for shared profile paths --- .../chapter_2_lens_modeling/tutorial_2_practicalities.ipynb | 5 +++-- scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb b/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb index f8b60d3..1bbd933 100644 --- a/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb +++ b/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb @@ -589,8 +589,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Components of the same class are therefore told apart (every Gaussian of a basis is labelled by the galaxy and\n", - "light profile it belongs to) and, when the model has more than one top-level component, each also gets its own\n", + "Components in different named galaxy or profile paths can be distinguished by their superscripts. Profiles within\n", + "the same path, such as Gaussians in a basis, can share a superscript. When the model has more than one top-level\n", + "component, each also gets its own\n", "corner plot in the output folder (`corner_anesthetic_.png`, switched in `config/visualize/plots_search.yaml`).\n", "\n", "The parameters a model is sampled in are not always the ones it is read in: a profile's elliptical components are an\n", diff --git a/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py b/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py index 30accd9..450f3cf 100755 --- a/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py +++ b/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py @@ -393,8 +393,9 @@ """ -Components of the same class are therefore told apart (every Gaussian of a basis is labelled by the galaxy and -light profile it belongs to) and, when the model has more than one top-level component, each also gets its own +Components in different named galaxy or profile paths can be distinguished by their superscripts. Profiles within +the same path, such as Gaussians in a basis, can share a superscript. When the model has more than one top-level +component, each also gets its own corner plot in the output folder (`corner_anesthetic_.png`, switched in `config/visualize/plots_search.yaml`). The parameters a model is sampled in are not always the ones it is read in: a profile's elliptical components are an