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
10 changes: 9 additions & 1 deletion autogalaxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
from .analysis.adapt_images.adapt_images import galaxy_name_image_dict_via_result_from
from . import aggregator as agg
from . import exc
from . import plot
from . import util
from .ellipse.dataset_interp import DatasetInterp
from .ellipse.ellipse.ellipse import Ellipse
Expand Down Expand Up @@ -120,3 +119,12 @@
from autoconf.fitsable import hdu_list_for_output_from

__version__ = "2026.4.5.3"


def __getattr__(name):
if name == "plot":
from . import plot

globals()["plot"] = plot
return plot
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
8 changes: 5 additions & 3 deletions autogalaxy/analysis/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

if TYPE_CHECKING:
from pathlib import Path
from autoarray.plot.output import Output

from autoconf import conf

import autoarray as aa
import autoarray.plot as aplt

from autogalaxy.analysis.adapt_images.adapt_images import AdaptImages
from autogalaxy.galaxy.galaxy import Galaxy
Expand Down Expand Up @@ -68,9 +68,11 @@ def fmt(self) -> List[str]:
except KeyError:
return conf.instance["visualize"]["plots"]["format"]

def output_from(self) -> aplt.Output:
def output_from(self) -> "Output":
"""Return an ``autoarray`` ``Output`` object pointed at ``image_path``."""
return aplt.Output(path=self.image_path, format=self.fmt)
from autoarray.plot.output import Output

return Output(path=self.image_path, format=self.fmt)

def galaxies(
self,
Expand Down
3 changes: 2 additions & 1 deletion autogalaxy/ellipse/plot/fit_ellipse_plot_util.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import itertools
import matplotlib.pyplot as plt
import numpy as np


def plot_ellipse_residuals(array, fit_list, colors, output, for_subplot: bool = False):
import matplotlib.pyplot as plt

"""Plot the 1-D ellipse residuals as a function of position angle.

For each :class:`~autogalaxy.ellipse.fit_ellipse.FitEllipse` in
Expand Down
14 changes: 7 additions & 7 deletions autogalaxy/ellipse/plot/fit_ellipse_plots.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import numpy as np
import math
import matplotlib.pyplot as plt
from typing import List, Optional

import autoarray as aa
from autoarray import plot as aplt
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
from autoarray.plot.utils import subplots, conf_subplot_figsize, tight_layout

from autogalaxy.ellipse.plot import fit_ellipse_plot_util
from autogalaxy.ellipse.fit_ellipse import FitEllipse
from autogalaxy.plot.plot_utils import plot_array, _save_subplot
from autogalaxy.util.plot_utils import plot_array, _save_subplot
from autogalaxy.util import error_util


Expand Down Expand Up @@ -108,7 +106,9 @@ def _plot_ellipse_residuals(
ax : matplotlib.axes.Axes or None
Reserved for future direct-axes support (currently unused).
"""
output = aplt.Output(path=output_path, format=output_format) if output_path else aplt.Output()
from autoarray.plot.output import Output

output = Output(path=output_path, format=output_format) if output_path else Output()

fit_ellipse_plot_util.plot_ellipse_residuals(
array=fit_list[0].dataset.data.native,
Expand Down Expand Up @@ -148,7 +148,7 @@ def subplot_fit_ellipse(
disable_data_contours : bool
If ``True``, suppress ellipse contour overlays on the image panel.
"""
fig, axes = plt.subplots(1, 2, figsize=conf_subplot_figsize(1, 2))
fig, axes = subplots(1, 2, figsize=conf_subplot_figsize(1, 2))

_plot_data(
fit_list=fit_list,
Expand Down Expand Up @@ -213,7 +213,7 @@ def subplot_ellipse_errors(
fit_ellipse_list[i].append(aa.Grid2DIrregular.from_yx_1d(y=y, x=x))

n = len(fit_ellipse_list)
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = [axes] if n == 1 else list(axes.flatten())

for i in range(n):
Expand Down
7 changes: 3 additions & 4 deletions autogalaxy/galaxy/plot/adapt_plots.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import matplotlib.pyplot as plt
import numpy as np
from typing import Dict

import autoarray as aa
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
from autoarray.plot.utils import subplots, conf_subplot_figsize, tight_layout

from autogalaxy.galaxy.galaxy import Galaxy
from autogalaxy.plot.plot_utils import plot_array, _save_subplot
from autogalaxy.util.plot_utils import plot_array, _save_subplot


def subplot_adapt_images(
Expand Down Expand Up @@ -46,7 +45,7 @@ def subplot_adapt_images(
n = len(adapt_galaxy_name_image_dict)
cols = min(n, 3)
rows = (n + cols - 1) // cols
fig, axes = plt.subplots(rows, cols, figsize=conf_subplot_figsize(rows, cols))
fig, axes = subplots(rows, cols, figsize=conf_subplot_figsize(rows, cols))
axes_list = [axes] if n == 1 else list(np.array(axes).flatten())

for i, (_, galaxy_image) in enumerate(adapt_galaxy_name_image_dict.items()):
Expand Down
9 changes: 4 additions & 5 deletions autogalaxy/galaxy/plot/galaxies_plots.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import matplotlib.pyplot as plt
import numpy as np

import autoarray as aa

from autogalaxy.galaxy.galaxies import Galaxies
from autogalaxy.plot.plot_utils import _to_lines, _to_positions, plot_array, plot_grid, _save_subplot, _critical_curves_from
from autoarray.plot.utils import hide_unused_axes, conf_subplot_figsize, tight_layout
from autogalaxy.util.plot_utils import _to_lines, _to_positions, plot_array, plot_grid, _save_subplot, _critical_curves_from
from autoarray.plot.utils import subplots, hide_unused_axes, conf_subplot_figsize, tight_layout
from autogalaxy import exc


Expand Down Expand Up @@ -141,7 +140,7 @@ def _defl_x():
n = len(panels)
cols = min(n, 3)
rows = (n + cols - 1) // cols
fig, axes = plt.subplots(rows, cols, figsize=conf_subplot_figsize(rows, cols))
fig, axes = subplots(rows, cols, figsize=conf_subplot_figsize(rows, cols))
axes_flat = [axes] if n == 1 else list(np.array(axes).flatten())

for i, (_, array, title, p, l) in enumerate(panels):
Expand Down Expand Up @@ -201,7 +200,7 @@ def subplot_galaxy_images(
gs = Galaxies(galaxies=galaxies)

n = len(gs)
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = [axes] if n == 1 else list(axes.flatten())

for i in range(n):
Expand Down
9 changes: 4 additions & 5 deletions autogalaxy/galaxy/plot/galaxy_plots.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from __future__ import annotations
import matplotlib.pyplot as plt
from typing import TYPE_CHECKING

import autoarray as aa
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
from autoarray.plot.utils import subplots, conf_subplot_figsize, tight_layout

from autogalaxy.galaxy.galaxy import Galaxy
from autogalaxy.profiles.light.abstract import LightProfile
from autogalaxy.profiles.mass.abstract.abstract import MassProfile
from autogalaxy.plot.plot_utils import plot_array, _save_subplot
from autogalaxy.util.plot_utils import plot_array, _save_subplot


def subplot_of_light_profiles(
Expand Down Expand Up @@ -48,7 +47,7 @@ def subplot_of_light_profiles(
return

n = len(light_profiles)
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = [axes] if n == 1 else list(axes.flatten())

for i, lp in enumerate(light_profiles):
Expand Down Expand Up @@ -130,7 +129,7 @@ def _deflections_x(mp):
if not flag:
continue

fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = [axes] if n == 1 else list(axes.flatten())

for i, mp in enumerate(mass_profiles):
Expand Down
6 changes: 3 additions & 3 deletions autogalaxy/gui/clicker.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import numpy as np
from matplotlib import pyplot as plt

import autoarray as aa
import autoarray.plot as aplt
from autoarray.plot.utils import _conf_imshow_origin

from autogalaxy import exc

Expand All @@ -23,6 +20,9 @@ def __init__(self, image, pixel_scales, search_box_size, in_pixels: bool = False
self.in_pixels = in_pixels

def start(self, data, pixel_scales):
from matplotlib import pyplot as plt
import autoarray.plot as aplt
from autoarray.plot.utils import _conf_imshow_origin

n_y, n_x = data.shape_native
hw = int(n_x / 2) * pixel_scales
Expand Down
8 changes: 4 additions & 4 deletions autogalaxy/gui/scribbler.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from collections import OrderedDict
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from typing import Tuple

from autoarray.plot.utils import _conf_imshow_origin


class Scribbler:
def __init__(
Expand Down Expand Up @@ -60,6 +56,10 @@ def __init__(

extent = (x0_pix, x1_pix, y0_pix, y1_pix)

import matplotlib
import matplotlib.pyplot as plt
from autoarray.plot.utils import _conf_imshow_origin

matplotlib.use(backend)
self.im = image

Expand Down
11 changes: 5 additions & 6 deletions autogalaxy/imaging/plot/fit_imaging_plots.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import matplotlib.pyplot as plt
from pathlib import Path

import autoarray as aa
from autoconf.fitsable import hdu_list_for_output_from
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
from autoarray.plot.utils import subplots, conf_subplot_figsize, tight_layout

from autogalaxy.imaging.fit_imaging import FitImaging
from autogalaxy.plot.plot_utils import plot_array, _save_subplot
from autogalaxy.util.plot_utils import plot_array, _save_subplot


def subplot_fit(
Expand Down Expand Up @@ -50,7 +49,7 @@ def subplot_fit(
(fit.chi_squared_map, "Chi-Squared Map", r"$\chi^2$"),
]
n = len(panels)
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = list(axes.flatten())

for i, (array, title, cb_unit) in enumerate(panels):
Expand Down Expand Up @@ -116,7 +115,7 @@ def subplot_of_galaxy(
),
]
n = len(panels)
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = list(axes.flatten())

for i, (array, title) in enumerate(panels):
Expand Down Expand Up @@ -156,7 +155,7 @@ def subplot_fit_imaging_list(
File format string or list, e.g. ``"png"`` or ``["png"]``.
"""
n = len(fit_list)
fig, axes = plt.subplots(n, 5, figsize=conf_subplot_figsize(n, 5))
fig, axes = subplots(n, 5, figsize=conf_subplot_figsize(n, 5))
if n == 1:
axes = [axes]
for i, fit in enumerate(fit_list):
Expand Down
11 changes: 5 additions & 6 deletions autogalaxy/interferometer/plot/fit_interferometer_plots.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import matplotlib.pyplot as plt
import numpy as np
from pathlib import Path

import autoarray as aa
from autoconf.fitsable import hdu_list_for_output_from
from autoarray.plot import plot_visibilities_1d
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
from autoarray.plot.utils import subplots, conf_subplot_figsize, tight_layout

from autogalaxy.interferometer.fit_interferometer import FitInterferometer
from autogalaxy.galaxy.plot import galaxies_plots
from autogalaxy.plot.plot_utils import plot_array, _save_subplot
from autogalaxy.util.plot_utils import plot_array, _save_subplot


def subplot_fit(
Expand Down Expand Up @@ -48,7 +47,7 @@ def subplot_fit(
(fit.chi_squared_map, "Chi-Squared Map"),
]
n = len(panels)
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = list(axes.flatten())

for i, (vis, title) in enumerate(panels):
Expand Down Expand Up @@ -97,7 +96,7 @@ def subplot_fit_dirty_images(
(fit.dirty_chi_squared_map, "Dirty Chi-Squared Map", r"$\chi^2$"),
]
n = len(panels)
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = list(axes.flatten())

for i, (array, title, cb_unit) in enumerate(panels):
Expand Down Expand Up @@ -165,7 +164,7 @@ def subplot_fit_real_space(
(fit.dirty_residual_map, "Dirty Residual Map"),
]
n = len(panels)
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = list(axes.flatten())
for i, (array, title) in enumerate(panels):
plot_array(
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
output_figure,
)

from autogalaxy.plot.plot_utils import plot_array, plot_grid, fits_array
from autogalaxy.util.plot_utils import plot_array, plot_grid, fits_array

from autoarray.dataset.plot.imaging_plots import (
subplot_imaging_dataset,
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/plot/plot_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import os
import numpy as np
import matplotlib.pyplot as plt

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -74,6 +73,7 @@ def _save_subplot(fig, output_path, output_filename, output_format=None,

For FITS output use the dedicated ``fits_*`` functions instead.
"""
import matplotlib.pyplot as plt
from autoarray.plot.utils import _output_mode_save, _conf_output_format, _FAST_PLOTS

if _output_mode_save(fig, output_filename):
Expand Down
7 changes: 3 additions & 4 deletions autogalaxy/profiles/plot/basis_plots.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import matplotlib.pyplot as plt
import numpy as np

import autoarray as aa
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
from autoarray.plot.utils import subplots, conf_subplot_figsize, tight_layout

from autogalaxy.profiles.basis import Basis
from autogalaxy.plot.plot_utils import _to_positions, plot_array, _save_subplot
from autogalaxy.util.plot_utils import _to_positions, plot_array, _save_subplot
from autogalaxy import exc


Expand Down Expand Up @@ -60,7 +59,7 @@ def subplot_image(
n = len(basis.light_profile_list)
cols = min(n, 4)
rows = (n + cols - 1) // cols
fig, axes = plt.subplots(rows, cols, figsize=conf_subplot_figsize(rows, cols))
fig, axes = subplots(rows, cols, figsize=conf_subplot_figsize(rows, cols))
axes_flat = [axes] if n == 1 else list(np.array(axes).flatten())

_positions = _to_positions(positions)
Expand Down
7 changes: 3 additions & 4 deletions autogalaxy/quantity/plot/fit_quantity_plots.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import matplotlib.pyplot as plt

import autoarray as aa
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
from autoarray.plot.utils import subplots, conf_subplot_figsize, tight_layout

from autogalaxy.quantity.fit_quantity import FitQuantity
from autogalaxy.plot.plot_utils import plot_array, _save_subplot
from autogalaxy.util.plot_utils import plot_array, _save_subplot


def _subplot_fit_array(fit, output_path, output_format, colormap, use_log10, positions, filename="fit"):
Expand Down Expand Up @@ -43,7 +42,7 @@ def _subplot_fit_array(fit, output_path, output_format, colormap, use_log10, pos
(fit.chi_squared_map, "Chi-Squared Map"),
]
n = len(panels)
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = list(axes.flatten())

for i, (array, title) in enumerate(panels):
Expand Down
Loading
Loading