Skip to content

Commit ab62777

Browse files
Jammy2211claude
authored andcommitted
docs(aggregator): add module-level docstrings to aggregator package
Add module-level docstrings to all ten aggregator modules explaining the purpose of each module, the two public objects it exposes (a free helper function and an Agg class), and how they relate to the broader PyAutoFit database / aggregator workflow. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d99d74b commit ab62777

10 files changed

Lines changed: 161 additions & 0 deletions

File tree

autogalaxy/aggregator/agg_util.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
"""
2+
Shared utility functions for the **PyAutoGalaxy** aggregator interface.
3+
4+
This module provides low-level helpers used by all dataset-specific aggregator classes
5+
(`ImagingAgg`, `FitImagingAgg`, `GalaxiesAgg`, etc.). They centralise the logic that
6+
is repeated across every aggregator module so that the higher-level classes stay concise.
7+
8+
Key functions
9+
-------------
10+
- `instance_list_from` — Converts a ``PyAutoFit`` ``Fit`` into the correct list of model
11+
instances, handling both single-analysis fits and multi-analysis ``FactorGraphModel``
12+
fits.
13+
- `mask_header_from` — Loads a ``Mask2D`` and its FITS header from a stored dataset file.
14+
Used whenever a dataset must be reconstructed from the database.
15+
- `adapt_images_from` — Reconstructs ``AdaptImages`` objects from files stored during the
16+
model-fit. Needed so that adaptive features (e.g. an ``Hilbert`` image-mesh) reproduce
17+
the same behaviour on a local machine as on the HPC cluster where the fit was run.
18+
- `mesh_grids_of_planes_list_from` — Loads the pre-computed image-plane mesh grids that
19+
were saved during the fit, removing any stochastic variation when inspecting results
20+
offline.
21+
"""
122
from __future__ import annotations
223
import numpy as np
324
from typing import List, Optional

autogalaxy/aggregator/dataset_model.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
"""
2+
Aggregator interface for loading ``DatasetModel`` objects from model-fit results.
3+
4+
A ``DatasetModel`` holds dataset-level nuisance parameters (e.g. an overall background
5+
offset or a noise scaling factor) that form part of the fitted model. This module
6+
provides the helper function ``_dataset_model_from`` which reconstructs these objects from
7+
a stored ``PyAutoFit`` ``Fit`` entry so that the full fit can be replicated during
8+
offline analysis.
9+
10+
When no ``dataset_model`` is present in the model (the common case), ``None`` is returned
11+
for that entry so that downstream ``Fit*`` constructors receive a well-typed argument.
12+
"""
113
from __future__ import annotations
214
import logging
315
from typing import List

autogalaxy/aggregator/ellipse/ellipses.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
"""
2+
Aggregator interface for loading ``Ellipse`` objects from ellipse model-fit results.
3+
4+
After an ellipse model-fit the best-fit ellipse parameters are stored in the output
5+
directory or SQLite database as part of the model JSON file. This module reconstructs
6+
the list of ``Ellipse`` instances so that downstream analysis (e.g. re-plotting
7+
isophotes) can be performed without re-running the fit.
8+
9+
Two public objects are provided:
10+
11+
- ``_ellipses_from`` — a free function that accepts a single ``PyAutoFit`` ``Fit`` entry
12+
and returns the list of ``Ellipse`` objects for the requested model instance.
13+
- ``EllipsesAgg`` — a ``PyAutoFit`` ``AggBase`` subclass wrapping an ``Aggregator`` that
14+
exposes a generator of ellipse lists, one per stored model-fit.
15+
"""
116
from __future__ import annotations
217
import logging
318
from typing import TYPE_CHECKING, Optional, List

autogalaxy/aggregator/ellipse/fit_ellipse.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
"""
2+
Aggregator interface for loading ``FitEllipse`` objects from ellipse model-fit results.
3+
4+
This module reconstructs ``FitEllipse`` instances from the imaging dataset, fitted
5+
ellipses, and (optionally) multipole perturbations stored in an output directory or
6+
SQLite database, allowing full offline inspection of isophote fits without re-running the
7+
non-linear search.
8+
9+
Two public objects are provided:
10+
11+
- ``_fit_ellipse_from`` — a free function that accepts a single ``PyAutoFit`` ``Fit``
12+
entry and returns a list of ``FitEllipse`` objects (one per ellipse in the fit).
13+
- ``FitEllipseAgg`` — a ``PyAutoFit`` ``AggBase`` subclass wrapping an ``Aggregator``
14+
that exposes a generator of ``FitEllipse`` object lists, one entry per stored
15+
model-fit.
16+
"""
117
from __future__ import annotations
218
from typing import TYPE_CHECKING, Optional, List
319

autogalaxy/aggregator/ellipse/multipoles.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
"""
2+
Aggregator interface for loading ``EllipseMultipole`` objects from ellipse model-fit results.
3+
4+
``EllipseMultipole`` objects represent higher-order harmonic perturbations (e.g. m=3, m=4
5+
boxy/disky distortions) on top of the base ellipse isophotes. This module reconstructs
6+
the nested list of multipole objects from a stored ``PyAutoFit`` ``Fit`` entry so that
7+
multipole-enhanced isophote fits can be inspected offline.
8+
9+
Two public objects are provided:
10+
11+
- ``_multipoles_from`` — a free function that accepts a single ``PyAutoFit`` ``Fit``
12+
entry and returns the nested list of ``EllipseMultipole`` objects for the requested
13+
model instance.
14+
- ``MultipolesAgg`` — a ``PyAutoFit`` ``AggBase`` subclass wrapping an ``Aggregator``
15+
that exposes a generator of multipole lists, one per stored model-fit.
16+
"""
117
from __future__ import annotations
218
import logging
319
from typing import TYPE_CHECKING, Optional, List

autogalaxy/aggregator/galaxies.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
"""
2+
Aggregator interface for loading **PyAutoGalaxy** ``Galaxy`` objects from model-fit results.
3+
4+
After a non-linear search completes, its outputs (best-fit parameters, adapt images, etc.)
5+
are written to an output directory or stored in an SQLite database. The helpers in this
6+
module reconstruct ``Galaxy`` instances from those stored files so that the full galaxy
7+
model can be re-created and inspected without re-running the fit.
8+
9+
Two public objects are provided:
10+
11+
- ``_galaxies_from`` — a free function that accepts a single ``PyAutoFit`` ``Fit`` entry
12+
and returns the list of ``Galaxy`` objects (or lists of lists when multiple ``Analysis``
13+
objects were summed).
14+
- ``GalaxiesAgg`` — a ``PyAutoFit`` ``AggBase`` subclass that wraps an ``Aggregator``
15+
and returns a generator of galaxy lists, one per stored model-fit.
16+
"""
117
from __future__ import annotations
218
import logging
319
from typing import TYPE_CHECKING, Optional, List

autogalaxy/aggregator/imaging/fit_imaging.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
"""
2+
Aggregator interface for loading ``FitImaging`` objects from model-fit results.
3+
4+
This module combines all the pieces that are needed to re-create a ``FitImaging``
5+
object offline — the imaging dataset, galaxy model, dataset model, and adapt images —
6+
and assembles them into a ``FitImaging`` instance identical to the one produced during
7+
the original non-linear search.
8+
9+
Two public objects are provided:
10+
11+
- ``_fit_imaging_from`` — a free function that accepts a single ``PyAutoFit`` ``Fit``
12+
entry and returns a list of ``FitImaging`` objects (one per summed ``Analysis``).
13+
- ``FitImagingAgg`` — a ``PyAutoFit`` ``AggBase`` subclass that wraps an ``Aggregator``
14+
and exposes a generator of ``FitImaging`` objects, enabling memory-efficient iteration
15+
over large result sets.
16+
"""
117
from __future__ import annotations
218
from typing import TYPE_CHECKING, Optional, List
319

autogalaxy/aggregator/imaging/imaging.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
"""
2+
Aggregator interface for loading ``Imaging`` datasets from model-fit results.
3+
4+
After a model-fit the imaging dataset (data array, noise-map, PSF, mask, and
5+
over-sampling settings) is written to a FITS file in the output directory or SQLite
6+
database. This module reconstructs a fully-masked ``aa.Imaging`` object from those
7+
stored files.
8+
9+
Two public objects are provided:
10+
11+
- ``_imaging_from`` — a free function that accepts a single ``PyAutoFit`` ``Fit`` entry
12+
and returns a list of ``aa.Imaging`` datasets (one per summed ``Analysis``).
13+
- ``ImagingAgg`` — a class wrapping an ``Aggregator`` that returns a lazy generator of
14+
``Imaging`` datasets, avoiding loading all results into memory at once.
15+
"""
116
from functools import partial
217
from typing import List
318

autogalaxy/aggregator/interferometer/fit_interferometer.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
"""
2+
Aggregator interface for loading ``FitInterferometer`` objects from model-fit results.
3+
4+
This module combines all the pieces that are needed to re-create a ``FitInterferometer``
5+
object offline — the interferometer dataset, galaxy model, dataset model, and adapt
6+
images — and assembles them into a ``FitInterferometer`` instance identical to the one
7+
produced during the original non-linear search.
8+
9+
Two public objects are provided:
10+
11+
- ``_fit_interferometer_from`` — a free function that accepts a single ``PyAutoFit``
12+
``Fit`` entry and returns a list of ``FitInterferometer`` objects (one per summed
13+
``Analysis``).
14+
- ``FitInterferometerAgg`` — a ``PyAutoFit`` ``AggBase`` subclass wrapping an
15+
``Aggregator`` that exposes a generator of ``FitInterferometer`` objects, enabling
16+
memory-efficient iteration over large result sets.
17+
"""
118
from __future__ import annotations
219
from typing import TYPE_CHECKING, Optional, List
320

autogalaxy/aggregator/interferometer/interferometer.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
"""
2+
Aggregator interface for loading ``Interferometer`` datasets from model-fit results.
3+
4+
After an interferometer model-fit the dataset (complex visibilities, noise-map,
5+
uv-wavelengths, real-space mask, and transformer class) is written to a FITS file in
6+
the output directory or SQLite database. This module reconstructs a fully-configured
7+
``aa.Interferometer`` object from those stored files.
8+
9+
Two public objects are provided:
10+
11+
- ``_interferometer_from`` — a free function that accepts a single ``PyAutoFit`` ``Fit``
12+
entry and returns a list of ``aa.Interferometer`` datasets (one per summed
13+
``Analysis``).
14+
- ``InterferometerAgg`` — a class wrapping an ``Aggregator`` that returns a lazy
15+
generator of ``Interferometer`` datasets, avoiding loading all results into memory at
16+
once.
17+
"""
118
from functools import partial
219
from typing import List
320

0 commit comments

Comments
 (0)