# pyautolabs/pyautogalaxy architecture

> Architecture diagram of the GitHub repository pyautolabs/pyautogalaxy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pyautolabs/pyautogalaxy
- Repository: https://github.com/pyautolabs/pyautogalaxy

## Overview

PyAutoGalaxy models galaxy morphology and structure, then fits those models to imaging or interferometer observations. The main workflow combines light and mass profiles into galaxies, evaluates their predicted signal, and compares it with data; linear components may be reconstructed through an inversion. Analysis modules wrap fits for scientific modeling and results. The graph also preserves ellipse fitting, lensing calculations, cosmology, plotting, and COOLEST interoperability. Some subsystem links reflect README capabilities rather than inspected runtime calls because their implementation was not sampled.

Main entry points: [`autogalaxy/galaxy/galaxies.py`](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/galaxy/galaxies.py) (Galaxy collections), [`autogalaxy/imaging/fit_imaging.py`](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/imaging/fit_imaging.py) (Imaging fit), [`autogalaxy/galaxy/galaxy.py`](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/galaxy/galaxy.py) (Galaxy model), [`autogalaxy/interferometer/fit_interferometer.py`](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/interferometer/fit_interferometer.py) (Interferometer fit)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Galaxy modeling"]
  node_light_profiles["Light profiles<br/>[abstract.py]"]
  node_mass_profiles["Mass profiles<br/>[abstract.py]"]
  node_basis["Profile bases<br/>[basis.py]"]
  node_galaxy["Galaxy model<br/>[galaxy.py]"]
  node_galaxies["Galaxy collections<br/>[galaxies.py]"]
end

subgraph group_fit["Data fitting"]
  node_imaging_fit["Imaging fit<br/>[fit_imaging.py]"]
  node_interferometer_fit["Interferometer fit"]
  node_inversion["Linear inversion<br/>[to_inversion.py]"]
  node_adapt_images["Adaptive images<br/>[adapt_images.py]"]
  node_image_operations["Image operations<br/>[image.py]"]
end

subgraph group_analysis["Scientific analysis"]
  node_analysis_dataset["Dataset analysis<br/>[dataset.py]"]
  node_imaging_analysis["Imaging analysis<br/>[analysis.py]"]
  node_interferometer_analysis["Interferometer analysis<br/>[analysis.py]"]
  node_results["Analysis results<br/>[result.py]"]
end

subgraph group_science["Lensing science"]
  node_ellipse_fit["Ellipse fitting<br/>[fit_ellipse.py]"]
  node_cosmology["Lensing cosmology<br/>[model.py]"]
  node_lens_calculations["Lensing quantities<br/>[lens_calc.py]"]
  node_conversion["Coordinate conversion<br/>[convert.py]"]
end

subgraph group_tools["Outputs and interoperability"]
  node_plotting["Scientific plotting<br/>[plot_utils.py]"]
  node_coolest["COOLEST exchange<br/>[mass.py]"]
  node_jax_tree["JAX pytrees<br/>[jax_pytrees.py]"]
end

node_astronomer(("Researcher"))
node_observations["Observations"]

node_astronomer -->|"specifies model"| node_galaxies
node_observations -->|"supplies imaging"| node_imaging_fit
node_observations -->|"supplies visibilities"| node_interferometer_fit
node_light_profiles -->|"composes"| node_galaxy
node_mass_profiles -->|"composes"| node_galaxy
node_basis -->|"groups profiles"| node_galaxy
node_galaxy -->|"aggregates"| node_galaxies
node_galaxies -->|"provides model"| node_imaging_fit
node_galaxies -->|"provides model"| node_interferometer_fit
node_imaging_fit -->|"builds inversion"| node_inversion
node_interferometer_fit -->|"builds inversion"| node_inversion
node_adapt_images -->|"guides reconstruction"| node_inversion
node_imaging_fit -->|"operates images"| node_image_operations
node_imaging_fit -->|"evaluated by"| node_analysis_dataset
node_interferometer_fit -->|"evaluated by"| node_analysis_dataset
node_analysis_dataset -->|"uses distances"| node_cosmology
node_imaging_analysis -->|"constructs fit"| node_imaging_fit
node_interferometer_analysis -->|"constructs fit"| node_interferometer_fit
node_imaging_analysis -->|"produces results"| node_results
node_interferometer_analysis -->|"produces results"| node_results
node_astronomer -->|"fits morphology"| node_ellipse_fit
node_galaxy -.->|"supplies deflections"| node_lens_calculations
node_mass_profiles -.->|"uses lens distances"| node_cosmology
node_galaxies -->|"plots model"| node_plotting
node_mass_profiles -->|"converts mass"| node_coolest
node_galaxies -->|"registered as pytree"| node_jax_tree
node_light_profiles -->|"converts ellipticity"| node_conversion

click node_light_profiles "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/profiles/light/abstract.py"
click node_mass_profiles "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/profiles/mass/abstract/abstract.py"
click node_basis "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/profiles/basis.py"
click node_galaxy "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/galaxy/galaxy.py"
click node_galaxies "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/galaxy/galaxies.py"
click node_imaging_fit "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/imaging/fit_imaging.py"
click node_interferometer_fit "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/interferometer/fit_interferometer.py"
click node_inversion "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/galaxy/to_inversion.py"
click node_adapt_images "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/analysis/adapt_images/adapt_images.py"
click node_analysis_dataset "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/analysis/analysis/dataset.py"
click node_imaging_analysis "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/imaging/model/analysis.py"
click node_interferometer_analysis "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/interferometer/model/analysis.py"
click node_results "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/analysis/result.py"
click node_ellipse_fit "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/ellipse/fit_ellipse.py"
click node_cosmology "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/cosmology/model.py"
click node_lens_calculations "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/operate/lens_calc.py"
click node_conversion "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/convert.py"
click node_plotting "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/util/plot_utils.py"
click node_coolest "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/interop/coolest/mass.py"
click node_jax_tree "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/analysis/jax_pytrees.py"
click node_image_operations "https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/operate/image.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_light_profiles,node_mass_profiles,node_basis,node_galaxy,node_galaxies toneBlue
class node_imaging_fit,node_interferometer_fit,node_inversion,node_adapt_images,node_image_operations toneAmber
class node_analysis_dataset,node_imaging_analysis,node_interferometer_analysis,node_results toneMint
class node_ellipse_fit,node_cosmology,node_lens_calculations,node_conversion toneRose
class node_plotting,node_coolest,node_jax_tree,node_astronomer,node_observations toneIndigo
```

## Components

### Galaxy modeling

- [Light profiles](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/profiles/light/abstract.py): `autogalaxy/profiles/light/abstract.py`
- [Mass profiles](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/profiles/mass/abstract/abstract.py): `autogalaxy/profiles/mass/abstract/abstract.py`
- [Profile bases](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/profiles/basis.py): `autogalaxy/profiles/basis.py`
- [Galaxy model](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/galaxy/galaxy.py): `autogalaxy/galaxy/galaxy.py`
- [Galaxy collections](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/galaxy/galaxies.py): `autogalaxy/galaxy/galaxies.py`

### Data fitting

- [Imaging fit](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/imaging/fit_imaging.py): `autogalaxy/imaging/fit_imaging.py`
- [Interferometer fit](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/interferometer/fit_interferometer.py): `autogalaxy/interferometer/fit_interferometer.py`
- [Linear inversion](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/galaxy/to_inversion.py): `autogalaxy/galaxy/to_inversion.py`
- [Adaptive images](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/analysis/adapt_images/adapt_images.py): `autogalaxy/analysis/adapt_images/adapt_images.py`
- [Image operations](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/operate/image.py): `autogalaxy/operate/image.py`

### Scientific analysis

- [Dataset analysis](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/analysis/analysis/dataset.py): `autogalaxy/analysis/analysis/dataset.py`
- [Imaging analysis](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/imaging/model/analysis.py): `autogalaxy/imaging/model/analysis.py`
- [Interferometer analysis](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/interferometer/model/analysis.py): `autogalaxy/interferometer/model/analysis.py`
- [Analysis results](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/analysis/result.py): `autogalaxy/analysis/result.py`

### Lensing science

- [Ellipse fitting](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/ellipse/fit_ellipse.py): `autogalaxy/ellipse/fit_ellipse.py`
- [Lensing cosmology](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/cosmology/model.py): `autogalaxy/cosmology/model.py`
- [Lensing quantities](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/operate/lens_calc.py): `autogalaxy/operate/lens_calc.py`
- [Coordinate conversion](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/convert.py): `autogalaxy/convert.py`

### Outputs and interoperability

- [Scientific plotting](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/util/plot_utils.py): `autogalaxy/util/plot_utils.py`
- [COOLEST exchange](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/interop/coolest/mass.py): `autogalaxy/interop/coolest/mass.py`
- [JAX pytrees](https://github.com/pyautolabs/pyautogalaxy/blob/main/autogalaxy/analysis/jax_pytrees.py): `autogalaxy/analysis/jax_pytrees.py`

### Other components

- **Researcher**
- **Observations**

## Connections

- Researcher → Galaxy collections: specifies model
- Observations → Imaging fit: supplies imaging (evidence: `autogalaxy/imaging/fit_imaging.py`)
- Observations → Interferometer fit: supplies visibilities (evidence: `autogalaxy/interferometer/fit_interferometer.py`)
- Light profiles → Galaxy model: composes (evidence: `autogalaxy/galaxy/galaxy.py`)
- Mass profiles → Galaxy model: composes (evidence: `autogalaxy/galaxy/galaxy.py`)
- Profile bases → Galaxy model: groups profiles (evidence: `autogalaxy/galaxy/galaxy.py`)
- Galaxy model → Galaxy collections: aggregates (evidence: `autogalaxy/galaxy/galaxies.py`)
- Galaxy collections → Imaging fit: provides model (evidence: `autogalaxy/imaging/fit_imaging.py`)
- Galaxy collections → Interferometer fit: provides model (evidence: `autogalaxy/interferometer/fit_interferometer.py`)
- Imaging fit → Linear inversion: builds inversion (evidence: `autogalaxy/imaging/fit_imaging.py`)
- Interferometer fit → Linear inversion: builds inversion (evidence: `autogalaxy/interferometer/fit_interferometer.py`)
- Adaptive images → Linear inversion: guides reconstruction (evidence: `autogalaxy/galaxy/to_inversion.py`)
- Imaging fit → Image operations: operates images
- Imaging fit → Dataset analysis: evaluated by (evidence: `autogalaxy/imaging/model/analysis.py`)
- Interferometer fit → Dataset analysis: evaluated by (evidence: `autogalaxy/interferometer/model/analysis.py`)
- Dataset analysis → Lensing cosmology: uses distances (evidence: `autogalaxy/analysis/analysis/dataset.py`)
- Imaging analysis → Imaging fit: constructs fit (evidence: `autogalaxy/imaging/model/analysis.py`)
- Interferometer analysis → Interferometer fit: constructs fit (evidence: `autogalaxy/interferometer/model/analysis.py`)
- Imaging analysis → Analysis results: produces results (evidence: `autogalaxy/imaging/model/analysis.py`)
- Interferometer analysis → Analysis results: produces results (evidence: `autogalaxy/interferometer/model/analysis.py`)
- Researcher → Ellipse fitting: fits morphology
- Galaxy model → Lensing quantities: supplies deflections
- Mass profiles → Lensing cosmology: uses lens distances
- Galaxy collections → Scientific plotting: plots model (evidence: `autogalaxy/galaxy/plot/galaxies_plots.py`)
- Mass profiles → COOLEST exchange: converts mass (evidence: `autogalaxy/interop/coolest/mass.py`)
- Galaxy collections → JAX pytrees: registered as pytree (evidence: `autogalaxy/analysis/jax_pytrees.py`)
- Light profiles → Coordinate conversion: converts ellipticity (evidence: `autogalaxy/profiles/light/abstract.py`)
