From a9ea74abd505262b33834bc4f24ff382d8592798 Mon Sep 17 00:00:00 2001 From: samlange04 Date: Sun, 18 Oct 2026 13:21:50 +0800 Subject: [PATCH 1/6] 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 --- scripts/chapter_2_modeling/tutorial_2_practicalities.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/chapter_2_modeling/tutorial_2_practicalities.py b/scripts/chapter_2_modeling/tutorial_2_practicalities.py index a481f12..8cee13b 100644 --- a/scripts/chapter_2_modeling/tutorial_2_practicalities.py +++ b/scripts/chapter_2_modeling/tutorial_2_practicalities.py @@ -360,8 +360,8 @@ The plot is labeled with short hand parameter names (e.g. `sersic_index` is mapped to the short hand parameter `n`). These mappings are 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 `Sersic` -bulge its name `bulge` 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 `Sersic` +bulge, `galaxy.bulge`: the galaxy's name `galaxy` and its name `bulge` defined when making the `Model` above). __Other Practicalities__ From 4e0347df2e8e05663e3053dfca30f8b6e00f709b Mon Sep 17 00:00:00 2001 From: samlange04 Date: Sun, 18 Oct 2026 16:33:36 +0800 Subject: [PATCH 2/6] 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 +- .../chapter_2_modeling/tutorial_2_practicalities.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config/output.yaml b/config/output.yaml index 88f7d01..3e7b45f 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. diff --git a/scripts/chapter_2_modeling/tutorial_2_practicalities.py b/scripts/chapter_2_modeling/tutorial_2_practicalities.py index 8cee13b..12e037b 100644 --- a/scripts/chapter_2_modeling/tutorial_2_practicalities.py +++ b/scripts/chapter_2_modeling/tutorial_2_practicalities.py @@ -363,6 +363,16 @@ The superscripts of labels are the path of names each component was given in the model (e.g. for the `Sersic` bulge, `galaxy.bulge`: the galaxy's name `galaxy` and its name `bulge` defined when making the `Model` above). +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. Passing `latent=True` to `corner_anesthetic` 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. + __Other Practicalities__ The following are examples of other practicalities which I will document fully in this example script in the future, From 05dceb03a8161f871ba9f3726231a0ad0d18572f Mon Sep 17 00:00:00 2001 From: samlange04 Date: Thu, 22 Oct 2026 19:21:13 +0800 Subject: [PATCH 3/6] 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 3e7b45f..ffb4982 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 b1253b0f0c2155c3a770357d95da0146131d96fa Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 26 Oct 2026 10:02:20 +0000 Subject: [PATCH 4/6] Complete corner configuration and regenerate notebooks --- config/notation.yaml | 5 +++-- config/visualize/plots_search.yaml | 3 +++ .../tutorial_2_practicalities.ipynb | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/config/notation.yaml b/config/notation.yaml index 808844e..6da97e5 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 228d4aa..53be364 100755 --- 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_modeling/tutorial_2_practicalities.ipynb b/notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb index 76240e7..bd04dca 100644 --- a/notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb +++ b/notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb @@ -534,8 +534,18 @@ "The plot is labeled with short hand parameter names (e.g. `sersic_index` is mapped to the short hand\n", "parameter `n`). These mappings are 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 `Sersic`\n", - "bulge its name `bulge` defined when making the `Model` above is used).\n", + "The superscripts of labels are the path of names each component was given in the model (e.g. for the `Sersic`\n", + "bulge, `galaxy.bulge`: the galaxy's name `galaxy` and its name `bulge` defined when making the `Model` above).\n", + "\n", + "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. Passing `latent=True` to `corner_anesthetic` plots these latent parameters instead.\n", + "The same figure is written to the output folder as `corner_anesthetic_latent.png` when `corner_anesthetic_latent`\n", + "is switched on in `config/visualize/plots_search.yaml` (off by default), once the fit is complete, and the latent\n", + "parameters are also written to `latent.csv` with the other latent variables.\n", "\n", "__Other Practicalities__\n", "\n", From c190915fb91731dcdac3eb5a34d0356d174eb459 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 26 Oct 2026 14:32:26 +0000 Subject: [PATCH 5/6] Clarify latent output policy in practicalities tutorial --- config/output.yaml | 8 ++++---- config/visualize/plots_search.yaml | 2 +- .../chapter_2_modeling/tutorial_2_practicalities.ipynb | 5 +++-- scripts/chapter_2_modeling/tutorial_2_practicalities.py | 5 +++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/config/output.yaml b/config/output.yaml index ffb4982..44841e5 100755 --- a/config/output.yaml +++ b/config/output.yaml @@ -86,14 +86,14 @@ 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: -search_log: true # `search.log`: logging produced whilst running the fit method \ No newline at end of file +search_log: true # `search.log`: logging produced whilst running the fit method diff --git a/config/visualize/plots_search.yaml b/config/visualize/plots_search.yaml index d1a7bb6..5c8d72d 100755 --- a/config/visualize/plots_search.yaml +++ b/config/visualize/plots_search.yaml @@ -1,7 +1,7 @@ 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? diff --git a/notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb b/notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb index bd04dca..fe57fc4 100644 --- a/notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb +++ b/notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb @@ -544,8 +544,9 @@ "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. Passing `latent=True` to `corner_anesthetic` plots these latent parameters instead.\n", "The same figure is written to the output folder as `corner_anesthetic_latent.png` when `corner_anesthetic_latent`\n", - "is switched on in `config/visualize/plots_search.yaml` (off by default), once the fit is complete, and the latent\n", - "parameters are also written to `latent.csv` with the other latent variables.\n", + "is switched on in `config/visualize/plots_search.yaml` (off by default), once the fit is complete. With\n", + "`latent_model_parameters` enabled, full-sample latent output (`latent_draw_via_pdf: false`) writes these columns\n", + "to `files/latent/samples.csv`. Only the plot recentres periodic angles; saved values keep the conversion's range.\n", "\n", "__Other Practicalities__\n", "\n", diff --git a/scripts/chapter_2_modeling/tutorial_2_practicalities.py b/scripts/chapter_2_modeling/tutorial_2_practicalities.py index 12e037b..884d2e5 100644 --- a/scripts/chapter_2_modeling/tutorial_2_practicalities.py +++ b/scripts/chapter_2_modeling/tutorial_2_practicalities.py @@ -370,8 +370,9 @@ 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. Passing `latent=True` to `corner_anesthetic` 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 switched on in `config/visualize/plots_search.yaml` (off by default), once the fit is complete. With +`latent_model_parameters` enabled, full-sample latent output (`latent_draw_via_pdf: false`) writes these columns +to `files/latent/samples.csv`. Only the plot recentres periodic angles; saved values keep the conversion's range. __Other Practicalities__ From 1236e75f5f1c456573feedb21b50b0ef8a716a95 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 26 Oct 2026 14:50:53 +0000 Subject: [PATCH 6/6] Qualify component superscripts for shared profile paths --- notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb | 5 +++-- scripts/chapter_2_modeling/tutorial_2_practicalities.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb b/notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb index fe57fc4..7d4b8ff 100644 --- a/notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb +++ b/notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb @@ -537,8 +537,9 @@ "The superscripts of labels are the path of names each component was given in the model (e.g. for the `Sersic`\n", "bulge, `galaxy.bulge`: the galaxy's name `galaxy` and its name `bulge` defined when making the `Model` above).\n", "\n", - "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_modeling/tutorial_2_practicalities.py b/scripts/chapter_2_modeling/tutorial_2_practicalities.py index 884d2e5..26869c6 100644 --- a/scripts/chapter_2_modeling/tutorial_2_practicalities.py +++ b/scripts/chapter_2_modeling/tutorial_2_practicalities.py @@ -363,8 +363,9 @@ The superscripts of labels are the path of names each component was given in the model (e.g. for the `Sersic` bulge, `galaxy.bulge`: the galaxy's name `galaxy` and its name `bulge` defined when making the `Model` above). -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