From b1182d85173778a7d6d5a62c067ff4576b597b44 Mon Sep 17 00:00:00 2001 From: samlange04 Date: Sun, 18 Oct 2026 13:21:50 +0800 Subject: [PATCH 1/6] Corner plot config switches and the superscript rule in the plot scripts `plots_search.yaml` gains PyAutoFit's two new nest switches: one corner plot per top-level model component (on) and the derived-parameter corner plots (off). The plotter scripts and the configs cookbook describe the superscript as the path of names a component was given in the model, with the notation config's class abbreviation only for a bare unnamed `Model`; `nautilus_plotter.py` names the `parameter_indices` and `derived` inputs of `corner_anesthetic`. Pairs with PyAutoFit's `fix/corner-anesthetic-duplicate-labels` branch. Co-Authored-By: Claude Fable 5.1 --- config/visualize/plots_search.yaml | 10 ++++++---- scripts/cookbooks/configs.py | 5 +++-- scripts/plot/dynesty_plotter.py | 4 ++-- scripts/plot/emcee_plotter.py | 4 ++-- scripts/plot/nautilus_plotter.py | 7 +++++-- scripts/plot/zeus_plotter.py | 4 ++-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/config/visualize/plots_search.yaml b/config/visualize/plots_search.yaml index 4a8fa365..c2564b73 100644 --- a/config/visualize/plots_search.yaml +++ b/config/visualize/plots_search.yaml @@ -1,4 +1,6 @@ -nest: - corner_anesthetic: true # Output corner figure (using anestetic) during a non-linear search fit? -mcmc: - corner_cornerpy: true # Output corner figure (using corner.py) during a non-linear search fit? +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_? + corner_anesthetic_derived: false # Output corner figure(s) of the derived parameters (e.g. a shear's magnitude and angle rather than gamma_1 / gamma_2), named corner_anesthetic_derived[_]? Independent of the two above. +mcmc: + corner_cornerpy: true # Output corner figure (using corner.py) during a non-linear search fit? diff --git a/scripts/cookbooks/configs.py b/scripts/cookbooks/configs.py index 189a187a..84d596a6 100644 --- a/scripts/cookbooks/configs.py +++ b/scripts/cookbooks/configs.py @@ -275,8 +275,9 @@ def model_data_from(self, xvalues: np.ndarray, xp=np) -> np.ndarray: parameter2: c rate: \lambda -It also contains a `superscript` section which pairs every model-component label with a superscript, so that -models with the same parameter names (e.g. `centre` can be distinguished). +It also contains a `superscript` section which gives a model class a superscript for the case where a model is a +bare `af.Model` of that class and so has no name of its own. A component given a name in a `Collection` (e.g. +`gaussian`) is labelled with that name, so models with the same parameter names (e.g. `centre`) are distinguished. label: superscript: diff --git a/scripts/plot/dynesty_plotter.py b/scripts/plot/dynesty_plotter.py index 384dd2a4..b18dabcc 100644 --- a/scripts/plot/dynesty_plotter.py +++ b/scripts/plot/dynesty_plotter.py @@ -67,8 +67,8 @@ The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file and can be customized. -Each label also has a superscript corresponding to the model component the parameter originates from. For example, -Gaussians are given the superscript `g`. This can also be customized in the `config/notation.yaml` file. +Each label also has a superscript naming the model component the parameter originates from: the path of names the +component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy). __Plotting__ diff --git a/scripts/plot/emcee_plotter.py b/scripts/plot/emcee_plotter.py index 0dc0cdf3..b4acc051 100644 --- a/scripts/plot/emcee_plotter.py +++ b/scripts/plot/emcee_plotter.py @@ -70,8 +70,8 @@ The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file and can be customized. -Each label also has a superscript corresponding to the model component the parameter originates from. For example, -Gaussians are given the superscript `g`. This can also be customized in the `config/notation.yaml` file. +Each label also has a superscript naming the model component the parameter originates from: the path of names the +component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy). __Plotting__ diff --git a/scripts/plot/nautilus_plotter.py b/scripts/plot/nautilus_plotter.py index 8db7dba6..c80943d2 100644 --- a/scripts/plot/nautilus_plotter.py +++ b/scripts/plot/nautilus_plotter.py @@ -72,8 +72,8 @@ The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file and can be customized. -Each label also has a superscript corresponding to the model component the parameter originates from. For example, -Gaussians are given the superscript `g`. This can also be customized in the `config/notation.yaml` file. +Each label also has a superscript naming the model component the parameter originates from: the path of names the +component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy). __Plotting__ @@ -98,6 +98,9 @@ libraries (`panelsize`, `xticksize`, `yticksize`, …) do not apply here. The `corner_anesthetic` function produces a triangle of 1D and 2D PDF's of every parameter using the library `anesthetic`. +Its `parameter_indices` input plots a subset of the parameters (a search writes one such plot per top-level model +component, `corner_anesthetic_.png`) and `derived=True` plots a component's derived parameters where its +class declares them (none do in this example), both switched in `config/visualize/plots_search.yaml`. """ aplt.corner_anesthetic(samples=samples) diff --git a/scripts/plot/zeus_plotter.py b/scripts/plot/zeus_plotter.py index b66a25c0..1cfd0efd 100644 --- a/scripts/plot/zeus_plotter.py +++ b/scripts/plot/zeus_plotter.py @@ -72,8 +72,8 @@ The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file and can be customized. -Each label also has a superscript corresponding to the model component the parameter originates from. For example, -Gaussians are given the superscript `g`. This can also be customized in the `config/notation.yaml` file. +Each label also has a superscript naming the model component the parameter originates from: the path of names the +component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy). __Plotting__ From 3932cc2ae74507bb24808d2777ba44da643f6e8f Mon Sep 17 00:00:00 2001 From: samlange04 Date: Sun, 18 Oct 2026 15:51:53 +0800 Subject: [PATCH 2/6] 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 --- config/visualize/plots_search.yaml | 2 +- scripts/plot/nautilus_plotter.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/visualize/plots_search.yaml b/config/visualize/plots_search.yaml index c2564b73..d8542b73 100644 --- a/config/visualize/plots_search.yaml +++ b/config/visualize/plots_search.yaml @@ -1,6 +1,6 @@ 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_? - corner_anesthetic_derived: false # Output corner figure(s) of the derived parameters (e.g. a shear's magnitude and angle rather than gamma_1 / gamma_2), named corner_anesthetic_derived[_]? Independent of the two above. + corner_anesthetic_latent: false # Output corner figure(s) of the latent parameters (e.g. a shear's magnitude and angle rather than gamma_1 / gamma_2), named corner_anesthetic_latent[_], per component only where one has a latent parameter? Independent of the two above. Made after the fit like latent.csv (during it only if output.yaml's latent_during_fit is on). mcmc: corner_cornerpy: true # Output corner figure (using corner.py) during a non-linear search fit? diff --git a/scripts/plot/nautilus_plotter.py b/scripts/plot/nautilus_plotter.py index c80943d2..5ef0d995 100644 --- a/scripts/plot/nautilus_plotter.py +++ b/scripts/plot/nautilus_plotter.py @@ -99,7 +99,7 @@ The `corner_anesthetic` function produces a triangle of 1D and 2D PDF's of every parameter using the library `anesthetic`. Its `parameter_indices` input plots a subset of the parameters (a search writes one such plot per top-level model -component, `corner_anesthetic_.png`) and `derived=True` plots a component's derived parameters where its +component, `corner_anesthetic_.png`) and `latent=True` plots a component's latent parameters where its class declares them (none do in this example), both switched in `config/visualize/plots_search.yaml`. """ aplt.corner_anesthetic(samples=samples) From 51742268c3fc64ffe91cb575e1742a4205e443f9 Mon Sep 17 00:00:00 2001 From: samlange04 Date: Sun, 18 Oct 2026 16:33:36 +0800 Subject: [PATCH 3/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 +- scripts/cookbooks/latent_variables.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config/output.yaml b/config/output.yaml index 84987ae4..55b52d01 100644 --- 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/cookbooks/latent_variables.py b/scripts/cookbooks/latent_variables.py index d566d7dd..22cfe671 100644 --- a/scripts/cookbooks/latent_variables.py +++ b/scripts/cookbooks/latent_variables.py @@ -135,6 +135,18 @@ latent computations cannot influence which models the search prefers — they only attach extra information to samples that have already been drawn. +A model component can also declare latent variables of its own, with no `Analysis` code at all. Many components are +sampled in one parameterisation but read in another (PyAutoGalaxy's shear is fit as `gamma_1` / `gamma_2` but read +as a magnitude and an angle). The class declares the conversion as a `latent_parameters` class attribute, keyed by +the names of the sampled parameters it replaces and valued by a function of every parameter of the component (the +sampled ones as arrays over the samples, the fixed ones as floats) returning the latent values by name; an angle is +returned as `af.Periodic(angle, period)` so its samples are recentred on their circular mean rather than split at +the branch cut. These latent parameters are added to `latent.csv`, `latent.results` and `latent_summary.json` +alongside the `Latent` class's variables (they are cheap, needing no model instance, so they are vectorised over the +samples), and the search writes a corner plot of them, `corner_anesthetic_latent.png`, when `corner_anesthetic_latent` +is on in `config/visualize/plots_search.yaml`. That plot follows the latent rule below rather than the fit's update +cadence: it is made once the fit completes, and during the fit only if `latent_during_fit` is on. + __Two Output Modes__ PyAutoFit supports two strategies for computing latent values after a fit, controlled by `output.yaml`. Both From f0ca772514392db77546af814fef6bae7d4ae211 Mon Sep 17 00:00:00 2001 From: samlange04 Date: Thu, 22 Oct 2026 19:21:13 +0800 Subject: [PATCH 4/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 + config/visualize/plots_search.yaml | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/output.yaml b/config/output.yaml index 55b52d01..ff526b86 100644 --- 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: diff --git a/config/visualize/plots_search.yaml b/config/visualize/plots_search.yaml index d8542b73..6712ef91 100644 --- a/config/visualize/plots_search.yaml +++ b/config/visualize/plots_search.yaml @@ -1,6 +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_? - corner_anesthetic_latent: false # Output corner figure(s) of the latent parameters (e.g. a shear's magnitude and angle rather than gamma_1 / gamma_2), named corner_anesthetic_latent[_], per component only where one has a latent parameter? 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_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? From aa0cd81e966f38c554066f6639f9329ebc082a24 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 26 Oct 2026 10:02:12 +0000 Subject: [PATCH 5/6] Complete corner configuration and regenerate notebooks --- config/notation.yaml | 5 +++-- notebooks/cookbooks/configs.ipynb | 5 +++-- notebooks/cookbooks/latent_variables.ipynb | 12 ++++++++++++ notebooks/plot/dynesty_plotter.ipynb | 4 ++-- notebooks/plot/emcee_plotter.ipynb | 4 ++-- notebooks/plot/nautilus_plotter.ipynb | 9 ++++++--- notebooks/plot/zeus_plotter.ipynb | 4 ++-- 7 files changed, 30 insertions(+), 13 deletions(-) diff --git a/config/notation.yaml b/config/notation.yaml index c600b4fd..b88d6216 100644 --- 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/notebooks/cookbooks/configs.ipynb b/notebooks/cookbooks/configs.ipynb index 23e8204c..a153d147 100644 --- a/notebooks/cookbooks/configs.ipynb +++ b/notebooks/cookbooks/configs.ipynb @@ -372,8 +372,9 @@ " parameter2: c\n", " rate: \\lambda\n", "\n", - "It also contains a `superscript` section which pairs every model-component label with a superscript, so that\n", - "models with the same parameter names (e.g. `centre` can be distinguished).\n", + "It also contains a `superscript` section which gives a model class a superscript for the case where a model is a\n", + "bare `af.Model` of that class and so has no name of its own. A component given a name in a `Collection` (e.g.\n", + "`gaussian`) is labelled with that name, so models with the same parameter names (e.g. `centre`) are distinguished.\n", "\n", "label:\n", " superscript:\n", diff --git a/notebooks/cookbooks/latent_variables.ipynb b/notebooks/cookbooks/latent_variables.ipynb index a8e64459..646aefe0 100644 --- a/notebooks/cookbooks/latent_variables.ipynb +++ b/notebooks/cookbooks/latent_variables.ipynb @@ -200,6 +200,18 @@ "latent computations cannot influence which models the search prefers \u2014 they only attach extra information to\n", "samples that have already been drawn.\n", "\n", + "A model component can also declare latent variables of its own, with no `Analysis` code at all. Many components are\n", + "sampled in one parameterisation but read in another (PyAutoGalaxy's shear is fit as `gamma_1` / `gamma_2` but read\n", + "as a magnitude and an angle). The class declares the conversion as a `latent_parameters` class attribute, keyed by\n", + "the names of the sampled parameters it replaces and valued by a function of every parameter of the component (the\n", + "sampled ones as arrays over the samples, the fixed ones as floats) returning the latent values by name; an angle is\n", + "returned as `af.Periodic(angle, period)` so its samples are recentred on their circular mean rather than split at\n", + "the branch cut. These latent parameters are added to `latent.csv`, `latent.results` and `latent_summary.json`\n", + "alongside the `Latent` class's variables (they are cheap, needing no model instance, so they are vectorised over the\n", + "samples), and the search writes a corner plot of them, `corner_anesthetic_latent.png`, when `corner_anesthetic_latent`\n", + "is on in `config/visualize/plots_search.yaml`. That plot follows the latent rule below rather than the fit's update\n", + "cadence: it is made once the fit completes, and during the fit only if `latent_during_fit` is on.\n", + "\n", "__Two Output Modes__\n", "\n", "PyAutoFit supports two strategies for computing latent values after a fit, controlled by `output.yaml`. Both\n", diff --git a/notebooks/plot/dynesty_plotter.ipynb b/notebooks/plot/dynesty_plotter.ipynb index 9b770d24..3694fa12 100644 --- a/notebooks/plot/dynesty_plotter.ipynb +++ b/notebooks/plot/dynesty_plotter.ipynb @@ -143,8 +143,8 @@ "The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file \n", "and can be customized.\n", "\n", - "Each label also has a superscript corresponding to the model component the parameter originates from. For example,\n", - "Gaussians are given the superscript `g`. This can also be customized in the `config/notation.yaml` file.\n", + "Each label also has a superscript naming the model component the parameter originates from: the path of names the\n", + "component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy).\n", "\n", "__Plotting__\n", "\n", diff --git a/notebooks/plot/emcee_plotter.ipynb b/notebooks/plot/emcee_plotter.ipynb index 04ecdab0..4bc8ff78 100644 --- a/notebooks/plot/emcee_plotter.ipynb +++ b/notebooks/plot/emcee_plotter.ipynb @@ -146,8 +146,8 @@ "The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file \n", "and can be customized.\n", "\n", - "Each label also has a superscript corresponding to the model component the parameter originates from. For example,\n", - "Gaussians are given the superscript `g`. This can also be customized in the `config/notation.yaml` file.\n", + "Each label also has a superscript naming the model component the parameter originates from: the path of names the\n", + "component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy).\n", "\n", "__Plotting__\n", "\n", diff --git a/notebooks/plot/nautilus_plotter.ipynb b/notebooks/plot/nautilus_plotter.ipynb index fb1fb30f..88ba863e 100644 --- a/notebooks/plot/nautilus_plotter.ipynb +++ b/notebooks/plot/nautilus_plotter.ipynb @@ -148,8 +148,8 @@ "The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file \n", "and can be customized.\n", "\n", - "Each label also has a superscript corresponding to the model component the parameter originates from. For example,\n", - "Gaussians are given the superscript `g`. This can also be customized in the `config/notation.yaml` file.\n", + "Each label also has a superscript naming the model component the parameter originates from: the path of names the\n", + "component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy).\n", "\n", "__Plotting__\n", "\n", @@ -173,7 +173,10 @@ "options, not nautilus's \u2014 `corner_cornerpy` wraps `corner.py`, so figure-geometry arguments from other plotting\n", "libraries (`panelsize`, `xticksize`, `yticksize`, \u2026) do not apply here.\n", "\n", - "The `corner_anesthetic` function produces a triangle of 1D and 2D PDF's of every parameter using the library `anesthetic`." + "The `corner_anesthetic` function produces a triangle of 1D and 2D PDF's of every parameter using the library `anesthetic`.\n", + "Its `parameter_indices` input plots a subset of the parameters (a search writes one such plot per top-level model\n", + "component, `corner_anesthetic_.png`) and `latent=True` plots a component's latent parameters where its\n", + "class declares them (none do in this example), both switched in `config/visualize/plots_search.yaml`." ] }, { diff --git a/notebooks/plot/zeus_plotter.ipynb b/notebooks/plot/zeus_plotter.ipynb index 992cde12..0bd27831 100644 --- a/notebooks/plot/zeus_plotter.ipynb +++ b/notebooks/plot/zeus_plotter.ipynb @@ -148,8 +148,8 @@ "The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file \n", "and can be customized.\n", "\n", - "Each label also has a superscript corresponding to the model component the parameter originates from. For example,\n", - "Gaussians are given the superscript `g`. This can also be customized in the `config/notation.yaml` file.\n", + "Each label also has a superscript naming the model component the parameter originates from: the path of names the\n", + "component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy).\n", "\n", "__Plotting__\n", "\n", From aaed07d7377e7374be0433775c3b3adb16598339 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 26 Oct 2026 14:20:37 +0000 Subject: [PATCH 6/6] Clarify latent outputs and bare-model corner labels --- config/output.yaml | 7 +++---- config/visualize/plots_search.yaml | 14 +++++++------- notebooks/cookbooks/latent_variables.ipynb | 10 ++++++---- notebooks/plot/dynesty_plotter.ipynb | 5 +++-- notebooks/plot/emcee_plotter.ipynb | 5 +++-- notebooks/plot/nautilus_plotter.ipynb | 5 +++-- notebooks/plot/zeus_plotter.ipynb | 5 +++-- scripts/cookbooks/latent_variables.py | 10 ++++++---- scripts/plot/dynesty_plotter.py | 5 +++-- scripts/plot/emcee_plotter.py | 5 +++-- scripts/plot/nautilus_plotter.py | 5 +++-- scripts/plot/zeus_plotter.py | 5 +++-- 12 files changed, 46 insertions(+), 35 deletions(-) diff --git a/config/output.yaml b/config/output.yaml index ff15ee8f..7ad91863 100644 --- 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: @@ -107,4 +107,3 @@ model_graph: false # `model.graph`: graphical-model factor graph summary. Only m # `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 -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. diff --git a/config/visualize/plots_search.yaml b/config/visualize/plots_search.yaml index 6712ef91..e868ef10 100644 --- 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_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? +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 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/cookbooks/latent_variables.ipynb b/notebooks/cookbooks/latent_variables.ipynb index 646aefe0..2d116c78 100644 --- a/notebooks/cookbooks/latent_variables.ipynb +++ b/notebooks/cookbooks/latent_variables.ipynb @@ -205,10 +205,12 @@ "as a magnitude and an angle). The class declares the conversion as a `latent_parameters` class attribute, keyed by\n", "the names of the sampled parameters it replaces and valued by a function of every parameter of the component (the\n", "sampled ones as arrays over the samples, the fixed ones as floats) returning the latent values by name; an angle is\n", - "returned as `af.Periodic(angle, period)` so its samples are recentred on their circular mean rather than split at\n", - "the branch cut. These latent parameters are added to `latent.csv`, `latent.results` and `latent_summary.json`\n", - "alongside the `Latent` class's variables (they are cheap, needing no model instance, so they are vectorised over the\n", - "samples), and the search writes a corner plot of them, `corner_anesthetic_latent.png`, when `corner_anesthetic_latent`\n", + "returned as `af.Periodic(angle, period)` so a corner plot can recentre it on its circular mean rather than split\n", + "it at the branch cut. Saved latent values retain the conversion's original range. When `latent_model_parameters`\n", + "is enabled, these columns join the `Latent` class's variables under the output policy below: full-sample output\n", + "uses `files/latent/samples.csv`, with summaries in `latent.results` and `files/latent/latent_summary.json`.\n", + "The conversions are vectorised over samples without constructing model instances. The search also writes\n", + "`corner_anesthetic_latent.png` when `corner_anesthetic_latent`\n", "is on in `config/visualize/plots_search.yaml`. That plot follows the latent rule below rather than the fit's update\n", "cadence: it is made once the fit completes, and during the fit only if `latent_during_fit` is on.\n", "\n", diff --git a/notebooks/plot/dynesty_plotter.ipynb b/notebooks/plot/dynesty_plotter.ipynb index 3694fa12..06cd85e8 100644 --- a/notebooks/plot/dynesty_plotter.ipynb +++ b/notebooks/plot/dynesty_plotter.ipynb @@ -143,8 +143,9 @@ "The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file \n", "and can be customized.\n", "\n", - "Each label also has a superscript naming the model component the parameter originates from: the path of names the\n", - "component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy).\n", + "This example uses a bare, unnamed `af.Model(af.ex.Gaussian)`, so its labels use the configured class superscript\n", + "`g` from `config/notation.yaml`. A component named in a `Collection` instead uses its path of names, such as\n", + "`gaussian` for `af.Collection(gaussian=...)`.\n", "\n", "__Plotting__\n", "\n", diff --git a/notebooks/plot/emcee_plotter.ipynb b/notebooks/plot/emcee_plotter.ipynb index 4bc8ff78..c66d3458 100644 --- a/notebooks/plot/emcee_plotter.ipynb +++ b/notebooks/plot/emcee_plotter.ipynb @@ -146,8 +146,9 @@ "The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file \n", "and can be customized.\n", "\n", - "Each label also has a superscript naming the model component the parameter originates from: the path of names the\n", - "component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy).\n", + "This example uses a bare, unnamed `af.Model(af.ex.Gaussian)`, so its labels use the configured class superscript\n", + "`g` from `config/notation.yaml`. A component named in a `Collection` instead uses its path of names, such as\n", + "`gaussian` for `af.Collection(gaussian=...)`.\n", "\n", "__Plotting__\n", "\n", diff --git a/notebooks/plot/nautilus_plotter.ipynb b/notebooks/plot/nautilus_plotter.ipynb index 88ba863e..82ca7c0d 100644 --- a/notebooks/plot/nautilus_plotter.ipynb +++ b/notebooks/plot/nautilus_plotter.ipynb @@ -148,8 +148,9 @@ "The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file \n", "and can be customized.\n", "\n", - "Each label also has a superscript naming the model component the parameter originates from: the path of names the\n", - "component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy).\n", + "This example uses a bare, unnamed `af.Model(af.ex.Gaussian)`, so its labels use the configured class superscript\n", + "`g` from `config/notation.yaml`. A component named in a `Collection` instead uses its path of names, such as\n", + "`gaussian` for `af.Collection(gaussian=...)`.\n", "\n", "__Plotting__\n", "\n", diff --git a/notebooks/plot/zeus_plotter.ipynb b/notebooks/plot/zeus_plotter.ipynb index 0bd27831..447a82ce 100644 --- a/notebooks/plot/zeus_plotter.ipynb +++ b/notebooks/plot/zeus_plotter.ipynb @@ -148,8 +148,9 @@ "The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file \n", "and can be customized.\n", "\n", - "Each label also has a superscript naming the model component the parameter originates from: the path of names the\n", - "component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy).\n", + "This example uses a bare, unnamed `af.Model(af.ex.Gaussian)`, so its labels use the configured class superscript\n", + "`g` from `config/notation.yaml`. A component named in a `Collection` instead uses its path of names, such as\n", + "`gaussian` for `af.Collection(gaussian=...)`.\n", "\n", "__Plotting__\n", "\n", diff --git a/scripts/cookbooks/latent_variables.py b/scripts/cookbooks/latent_variables.py index 22cfe671..ce5d94af 100644 --- a/scripts/cookbooks/latent_variables.py +++ b/scripts/cookbooks/latent_variables.py @@ -140,10 +140,12 @@ as a magnitude and an angle). The class declares the conversion as a `latent_parameters` class attribute, keyed by the names of the sampled parameters it replaces and valued by a function of every parameter of the component (the sampled ones as arrays over the samples, the fixed ones as floats) returning the latent values by name; an angle is -returned as `af.Periodic(angle, period)` so its samples are recentred on their circular mean rather than split at -the branch cut. These latent parameters are added to `latent.csv`, `latent.results` and `latent_summary.json` -alongside the `Latent` class's variables (they are cheap, needing no model instance, so they are vectorised over the -samples), and the search writes a corner plot of them, `corner_anesthetic_latent.png`, when `corner_anesthetic_latent` +returned as `af.Periodic(angle, period)` so a corner plot can recentre it on its circular mean rather than split +it at the branch cut. Saved latent values retain the conversion's original range. When `latent_model_parameters` +is enabled, these columns join the `Latent` class's variables under the output policy below: full-sample output +uses `files/latent/samples.csv`, with summaries in `latent.results` and `files/latent/latent_summary.json`. +The conversions are vectorised over samples without constructing model instances. The search also writes +`corner_anesthetic_latent.png` when `corner_anesthetic_latent` is on in `config/visualize/plots_search.yaml`. That plot follows the latent rule below rather than the fit's update cadence: it is made once the fit completes, and during the fit only if `latent_during_fit` is on. diff --git a/scripts/plot/dynesty_plotter.py b/scripts/plot/dynesty_plotter.py index b18dabcc..dc0f6e8f 100644 --- a/scripts/plot/dynesty_plotter.py +++ b/scripts/plot/dynesty_plotter.py @@ -67,8 +67,9 @@ The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file and can be customized. -Each label also has a superscript naming the model component the parameter originates from: the path of names the -component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy). +This example uses a bare, unnamed `af.Model(af.ex.Gaussian)`, so its labels use the configured class superscript +`g` from `config/notation.yaml`. A component named in a `Collection` instead uses its path of names, such as +`gaussian` for `af.Collection(gaussian=...)`. __Plotting__ diff --git a/scripts/plot/emcee_plotter.py b/scripts/plot/emcee_plotter.py index b4acc051..4966762d 100644 --- a/scripts/plot/emcee_plotter.py +++ b/scripts/plot/emcee_plotter.py @@ -70,8 +70,9 @@ The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file and can be customized. -Each label also has a superscript naming the model component the parameter originates from: the path of names the -component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy). +This example uses a bare, unnamed `af.Model(af.ex.Gaussian)`, so its labels use the configured class superscript +`g` from `config/notation.yaml`. A component named in a `Collection` instead uses its path of names, such as +`gaussian` for `af.Collection(gaussian=...)`. __Plotting__ diff --git a/scripts/plot/nautilus_plotter.py b/scripts/plot/nautilus_plotter.py index 5ef0d995..ef7d8a5b 100644 --- a/scripts/plot/nautilus_plotter.py +++ b/scripts/plot/nautilus_plotter.py @@ -72,8 +72,9 @@ The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file and can be customized. -Each label also has a superscript naming the model component the parameter originates from: the path of names the -component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy). +This example uses a bare, unnamed `af.Model(af.ex.Gaussian)`, so its labels use the configured class superscript +`g` from `config/notation.yaml`. A component named in a `Collection` instead uses its path of names, such as +`gaussian` for `af.Collection(gaussian=...)`. __Plotting__ diff --git a/scripts/plot/zeus_plotter.py b/scripts/plot/zeus_plotter.py index 1cfd0efd..6711419d 100644 --- a/scripts/plot/zeus_plotter.py +++ b/scripts/plot/zeus_plotter.py @@ -72,8 +72,9 @@ The mappings of every parameter to its shorthand symbol for plots is specified in the `config/notation.yaml` file and can be customized. -Each label also has a superscript naming the model component the parameter originates from: the path of names the -component was given in the model (e.g. `gaussian`, or `lens.mass` for a profile inside a galaxy). +This example uses a bare, unnamed `af.Model(af.ex.Gaussian)`, so its labels use the configured class superscript +`g` from `config/notation.yaml`. A component named in a `Collection` instead uses its path of names, such as +`gaussian` for `af.Collection(gaussian=...)`. __Plotting__