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
5 changes: 3 additions & 2 deletions config/notation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions config/output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +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.
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 # 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:

Expand All @@ -106,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.
3 changes: 3 additions & 0 deletions config/visualize/plots_search.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +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_<component>? 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_<component>? Follows corner_anesthetic_latent when absent.
mcmc:
corner_cornerpy: true # Output corner figure (using corner.py) during a non-linear search fit?
5 changes: 3 additions & 2 deletions notebooks/cookbooks/configs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions notebooks/cookbooks/latent_variables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,20 @@
"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 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",
"__Two Output Modes__\n",
"\n",
"PyAutoFit supports two strategies for computing latent values after a fit, controlled by `output.yaml`. Both\n",
Expand Down
5 changes: 3 additions & 2 deletions notebooks/plot/dynesty_plotter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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 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",
"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",
Expand Down
5 changes: 3 additions & 2 deletions notebooks/plot/emcee_plotter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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 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",
"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",
Expand Down
10 changes: 7 additions & 3 deletions notebooks/plot/nautilus_plotter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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 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",
"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",
Expand All @@ -173,7 +174,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_<component>.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`."
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions notebooks/plot/zeus_plotter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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 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",
"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",
Expand Down
5 changes: 3 additions & 2 deletions scripts/cookbooks/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions scripts/cookbooks/latent_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@
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 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.

__Two Output Modes__

PyAutoFit supports two strategies for computing latent values after a fit, controlled by `output.yaml`. Both
Expand Down
5 changes: 3 additions & 2 deletions scripts/plot/dynesty_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.
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__

Expand Down
5 changes: 3 additions & 2 deletions scripts/plot/emcee_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.
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__

Expand Down
8 changes: 6 additions & 2 deletions scripts/plot/nautilus_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.
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__

Expand All @@ -98,6 +99,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_<component>.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)

Expand Down
5 changes: 3 additions & 2 deletions scripts/plot/zeus_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.
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__

Expand Down
Loading