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 autolens/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
from autogalaxy.quantity.dataset_quantity import DatasetQuantity
from autogalaxy import convert

from . import plot
from . import aggregator as agg
from .analysis import model_util
from .lens import subhalo
Expand Down Expand Up @@ -131,3 +130,12 @@
conf.instance.register(__file__)

__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}")
2 changes: 1 addition & 1 deletion autolens/analysis/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
fits_tracer,
fits_source_plane_images,
)
from autogalaxy.plot.plot_utils import plot_array
from autogalaxy.util.plot_utils import plot_array


class Plotter(AgPlotter):
Expand Down
1 change: 0 additions & 1 deletion autolens/imaging/model/plotter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import matplotlib.pyplot as plt
import numpy as np
from typing import List

Expand Down
23 changes: 11 additions & 12 deletions autolens/imaging/plot/fit_imaging_plots.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import logging
import matplotlib.pyplot as plt
import numpy as np
from typing import Optional, List

import autoarray as aa
import autogalaxy as ag

from autogalaxy.plot.plot_utils import plot_array
from autogalaxy.util.plot_utils import plot_array
from autoarray.plot.array import _zoom_array_2d
from autoarray.plot.utils import save_figure, hide_unused_axes, conf_subplot_figsize, tight_layout
from autoarray.plot.utils import subplots, save_figure, hide_unused_axes, conf_subplot_figsize, tight_layout
from autoarray.plot.utils import numpy_lines as _to_lines
from autoarray.inversion.mappers.abstract import Mapper
from autoarray.inversion.plot.mapper_plots import plot_mapper
from autogalaxy.plot.plot_utils import _critical_curves_from, _caustics_from
from autogalaxy.util.plot_utils import _critical_curves_from, _caustics_from

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -243,7 +242,7 @@ def subplot_fit(
_compute_critical_curves_from_fit(fit)
)

fig, axes = plt.subplots(3, 4, figsize=conf_subplot_figsize(3, 4))
fig, axes = subplots(3, 4, figsize=conf_subplot_figsize(3, 4))
axes_flat = list(axes.flatten())

plot_array(array=fit.data, ax=axes_flat[0], title="Data", colormap=colormap)
Expand Down Expand Up @@ -357,7 +356,7 @@ def subplot_fit_x1_plane(
colormap : str, optional
Matplotlib colormap name applied to all image panels.
"""
fig, axes = plt.subplots(2, 3, figsize=conf_subplot_figsize(2, 3))
fig, axes = subplots(2, 3, figsize=conf_subplot_figsize(2, 3))
axes_flat = list(axes.flatten())

try:
Expand Down Expand Up @@ -442,7 +441,7 @@ def subplot_fit_log10(
_compute_critical_curves_from_fit(fit)
)

fig, axes = plt.subplots(3, 4, figsize=conf_subplot_figsize(3, 4))
fig, axes = subplots(3, 4, figsize=conf_subplot_figsize(3, 4))
axes_flat = list(axes.flatten())

plot_array(array=fit.data, ax=axes_flat[0], title="Data", colormap=colormap,
Expand Down Expand Up @@ -540,7 +539,7 @@ def subplot_fit_log10_x1_plane(
colormap : str, optional
Matplotlib colormap name applied to all image panels.
"""
fig, axes = plt.subplots(2, 3, figsize=conf_subplot_figsize(2, 3))
fig, axes = subplots(2, 3, figsize=conf_subplot_figsize(2, 3))
axes_flat = list(axes.flatten())

try:
Expand Down Expand Up @@ -616,7 +615,7 @@ def subplot_of_planes(
plane_indexes = [plane_index]

for pidx in plane_indexes:
fig, axes = plt.subplots(1, 4, figsize=conf_subplot_figsize(1, 4))
fig, axes = subplots(1, 4, figsize=conf_subplot_figsize(1, 4))
axes_flat = list(axes.flatten())

plot_array(array=fit.data, ax=axes_flat[0], title="Data", colormap=colormap)
Expand Down Expand Up @@ -702,7 +701,7 @@ def subplot_tracer_from_fit(

magnification = LensCalc.from_mass_obj(tracer).magnification_2d_from(grid=grid)

fig, axes = plt.subplots(3, 3, figsize=conf_subplot_figsize(3, 3))
fig, axes = subplots(3, 3, figsize=conf_subplot_figsize(3, 3))
axes_flat = list(axes.flatten())

# Panel 0: Model Image
Expand Down Expand Up @@ -802,7 +801,7 @@ def subplot_fit_combined(
"""
n_fits = len(fit_list)
n_cols = 6
fig, axes = plt.subplots(n_fits, n_cols, figsize=conf_subplot_figsize(n_fits, n_cols))
fig, axes = subplots(n_fits, n_cols, figsize=conf_subplot_figsize(n_fits, n_cols))
if n_fits == 1:
all_axes = [list(axes)]
else:
Expand Down Expand Up @@ -876,7 +875,7 @@ def subplot_fit_combined_log10(
"""
n_fits = len(fit_list)
n_cols = 6
fig, axes = plt.subplots(n_fits, n_cols, figsize=conf_subplot_figsize(n_fits, n_cols))
fig, axes = subplots(n_fits, n_cols, figsize=conf_subplot_figsize(n_fits, n_cols))
if n_fits == 1:
all_axes = [list(axes)]
else:
Expand Down
15 changes: 7 additions & 8 deletions autolens/interferometer/plot/fit_interferometer_plots.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import logging
import matplotlib.pyplot as plt
import numpy as np
from typing import Optional

import autoarray as aa
import autogalaxy as ag

from autogalaxy.plot.plot_utils import plot_array
from autogalaxy.util.plot_utils import plot_array
from autoarray.plot.yx import plot_yx
from autoarray.plot.utils import save_figure, conf_subplot_figsize, tight_layout
from autoarray.plot.utils import subplots, save_figure, conf_subplot_figsize, tight_layout
from autoarray.plot.utils import numpy_lines as _to_lines
from autoarray.inversion.mappers.abstract import Mapper
from autoarray.inversion.plot.mapper_plots import plot_mapper
from autogalaxy.plot.plot_utils import _critical_curves_from, _caustics_from
from autogalaxy.util.plot_utils import _critical_curves_from, _caustics_from
from autolens.lens.plot.tracer_plots import plane_image_from

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -184,7 +183,7 @@ def subplot_fit(
_compute_critical_curve_lines(tracer, _cc_grid)
)

fig, axes = plt.subplots(3, 4, figsize=conf_subplot_figsize(3, 4))
fig, axes = subplots(3, 4, figsize=conf_subplot_figsize(3, 4))
axes_flat = list(axes.flatten())

# Panel 0: amplitudes vs UV-distances
Expand Down Expand Up @@ -304,7 +303,7 @@ def subplot_fit_dirty_images(
_compute_critical_curve_lines(tracer, _cc_grid)
)

fig, axes = plt.subplots(2, 3, figsize=conf_subplot_figsize(2, 3))
fig, axes = subplots(2, 3, figsize=conf_subplot_figsize(2, 3))
axes_flat = list(axes.flatten())

plot_array(array=fit.dirty_image, ax=axes_flat[0], title="Dirty Image",
Expand Down Expand Up @@ -361,7 +360,7 @@ def subplot_fit_real_space(
tracer = fit.tracer_linear_light_profiles_to_light_profiles
final_plane_index = len(fit.tracer.planes) - 1

fig, axes = plt.subplots(1, 2, figsize=conf_subplot_figsize(1, 2))
fig, axes = subplots(1, 2, figsize=conf_subplot_figsize(1, 2))
axes_flat = list(axes.flatten())

if fit.inversion is None:
Expand Down Expand Up @@ -446,7 +445,7 @@ def subplot_tracer_from_fit(

magnification = LensCalc.from_mass_obj(tracer).magnification_2d_from(grid=grid)

fig, axes = plt.subplots(3, 3, figsize=conf_subplot_figsize(3, 3))
fig, axes = subplots(3, 3, figsize=conf_subplot_figsize(3, 3))
axes_flat = list(axes.flatten())

# Panel 0: Dirty Model Image
Expand Down
13 changes: 6 additions & 7 deletions autolens/lens/plot/sensitivity_plots.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Standalone subplot functions for subhalo sensitivity mapping visualisation."""
import matplotlib.pyplot as plt
import numpy as np
from typing import Optional

import autoarray as aa

from autogalaxy.plot.plot_utils import plot_array
from autoarray.plot.utils import save_figure, tight_layout
from autogalaxy.util.plot_utils import plot_array
from autoarray.plot.utils import subplots, save_figure, tight_layout


def subplot_tracer_images(
Expand Down Expand Up @@ -59,7 +58,7 @@ def subplot_tracer_images(
use_log10 : bool, optional
If ``True`` the colour scale is applied on a log10 stretch.
"""
from autogalaxy.plot.plot_utils import _critical_curves_from, _caustics_from
from autogalaxy.util.plot_utils import _critical_curves_from, _caustics_from
from autoarray.plot.utils import numpy_lines as _to_lines

grid = aa.Grid2D.from_mask(mask=mask)
Expand Down Expand Up @@ -94,7 +93,7 @@ def subplot_tracer_images(

residual_map = lensed_source_image - lensed_source_image_no_perturb

fig, axes = plt.subplots(1, 6, figsize=(42, 7))
fig, axes = subplots(1, 6, figsize=(42, 7))

plot_array(array=image, ax=axes[0], title="Image",
colormap=colormap, use_log10=use_log10)
Expand Down Expand Up @@ -180,7 +179,7 @@ def subplot_sensitivity(
above_threshold = np.where(log_likelihoods > 5.0, 1.0, 0.0)
above_threshold = aa.Array2D(values=above_threshold, mask=log_likelihoods.mask)

fig, axes = plt.subplots(2, 4, figsize=(28, 14))
fig, axes = subplots(2, 4, figsize=(28, 14))
axes_flat = list(axes.flatten())

plot_array(array=data_subtracted, ax=axes_flat[0], title="Subtracted Image",
Expand Down Expand Up @@ -285,7 +284,7 @@ def subplot_figures_of_merit_grid(
remove_zeros=remove_zeros,
)

fig, ax = plt.subplots(1, 1, figsize=(7, 7))
fig, ax = subplots(1, 1, figsize=(7, 7))
plot_array(array=figures_of_merit, ax=ax, title="Increase in Log Evidence",
colormap=colormap)
tight_layout()
Expand Down
9 changes: 4 additions & 5 deletions autolens/lens/plot/subhalo_plots.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""Standalone subplot functions for subhalo detection visualisation."""
import matplotlib.pyplot as plt
from typing import Optional

from autogalaxy.plot.plot_utils import plot_array
from autoarray.plot.utils import save_figure, tight_layout
from autogalaxy.util.plot_utils import plot_array
from autoarray.plot.utils import subplots, save_figure, tight_layout
from autolens.imaging.plot.fit_imaging_plots import _plot_source_plane


Expand Down Expand Up @@ -57,7 +56,7 @@ def subplot_detection_imaging(
If ``True`` grid positions where the figure of merit is exactly
zero are masked out before plotting.
"""
fig, axes = plt.subplots(1, 4, figsize=(28, 7))
fig, axes = subplots(1, 4, figsize=(28, 7))

plot_array(
array=fit_imaging_with_subhalo.data,
Expand Down Expand Up @@ -141,7 +140,7 @@ def subplot_detection_fits(
colormap : str, optional
Matplotlib colormap name.
"""
fig, axes = plt.subplots(2, 3, figsize=(21, 14))
fig, axes = subplots(2, 3, figsize=(21, 14))

plot_array(
array=fit_imaging_no_subhalo.normalized_residual_map,
Expand Down
11 changes: 5 additions & 6 deletions autolens/lens/plot/tracer_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 Optional, List

import autoarray as aa
import autogalaxy as ag

from autogalaxy.plot.plot_utils import plot_array
from autoarray.plot.utils import save_figure, hide_unused_axes, conf_subplot_figsize, tight_layout
from autogalaxy.util.plot_utils import plot_array
from autoarray.plot.utils import subplots, save_figure, hide_unused_axes, conf_subplot_figsize, tight_layout
from autoarray.plot.utils import numpy_positions as _to_positions


Expand Down Expand Up @@ -161,7 +160,7 @@ def subplot_tracer(

magnification = LensCalc.from_mass_obj(tracer).magnification_2d_from(grid=grid)

fig, axes = plt.subplots(3, 3, figsize=conf_subplot_figsize(3, 3))
fig, axes = subplots(3, 3, figsize=conf_subplot_figsize(3, 3))
axes_flat = list(axes.flatten())

plot_array(array=image, ax=axes_flat[0], title="Model Image",
Expand Down Expand Up @@ -227,7 +226,7 @@ def subplot_lensed_images(
traced_grids = tracer.traced_grid_2d_list_from(grid=grid)
n = tracer.total_planes

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(np.array(axes).flatten())

for plane_index in range(n):
Expand Down Expand Up @@ -287,7 +286,7 @@ def subplot_galaxies_images(
traced_grids = tracer.traced_grid_2d_list_from(grid=grid)
n = 2 * tracer.total_planes - 1

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(np.array(axes).flatten())

idx = 0
Expand Down
2 changes: 1 addition & 1 deletion autolens/plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# ---------------------------------------------------------------------------
# Standalone plot helpers (autoarray)
# ---------------------------------------------------------------------------
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 autolens/plot/plot_utils.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from autogalaxy.plot.plot_utils import _critical_curves_from, _caustics_from
from autogalaxy.util.plot_utils import _critical_curves_from, _caustics_from
7 changes: 3 additions & 4 deletions autolens/point/plot/fit_point_plots.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import matplotlib.pyplot as plt
import numpy as np
from typing import Optional

from autoarray.plot.utils import save_figure, conf_subplot_figsize, tight_layout
from autoarray.plot.utils import subplots, save_figure, conf_subplot_figsize, tight_layout


def subplot_fit(
Expand Down Expand Up @@ -36,13 +35,13 @@ def subplot_fit(
output_format : str, optional
Image format passed to :func:`~autoarray.plot.utils.save_figure`.
"""
from autogalaxy.plot.plot_utils import plot_grid
from autogalaxy.util.plot_utils import plot_grid
from autoarray.plot.yx import plot_yx

has_fluxes = fit.dataset.fluxes is not None
n = 2 if has_fluxes else 1

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(np.array(axes).flatten())

# Positions panel
Expand Down
7 changes: 3 additions & 4 deletions autolens/point/plot/point_dataset_plots.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import matplotlib.pyplot as plt
import numpy as np
from typing import Optional

from autoarray.plot.utils import save_figure, conf_subplot_figsize, tight_layout
from autoarray.plot.utils import subplots, save_figure, conf_subplot_figsize, tight_layout


def subplot_dataset(
Expand Down Expand Up @@ -32,13 +31,13 @@ def subplot_dataset(
output_format : str, optional
Image format passed to :func:`~autoarray.plot.utils.save_figure`.
"""
from autogalaxy.plot.plot_utils import plot_grid
from autogalaxy.util.plot_utils import plot_grid
from autoarray.plot.yx import plot_yx

has_fluxes = dataset.fluxes is not None
n = 2 if has_fluxes else 1

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(np.array(axes).flatten())

grid = np.array(
Expand Down
Loading