From 934b583fc11205e0415d78bf9b48c1a2bfc6ce46 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 26 Mar 2026 10:49:15 +0000 Subject: [PATCH] Plot improvements: rename fits functions, fit_of_plane filenames, remove subplot_ from PNG filenames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rename save_tracer_fits→fits_tracer, save_source_plane_images_fits→fits_source_plane_images - Import fits_fit, fits_galaxy_images, fits_model_galaxy_images from autogalaxy plot module; replace fits_to_fits call in both imaging and interferometer model plotters - Rename fit_imaging subplot output filenames: strip subplot_ prefix (fit.png, tracer.png, etc.) - Rename of_plane_{n} → fit_of_plane_{n} output filenames - Update all tests to match new filenames and function names Co-Authored-By: Claude Sonnet 4.6 --- autolens/analysis/plotter.py | 8 +++---- autolens/imaging/model/plotter.py | 15 ++++++++++-- autolens/imaging/plot/fit_imaging_plots.py | 2 +- autolens/interferometer/model/plotter.py | 15 +++++++----- autolens/lens/plot/tracer_plots.py | 4 ++-- test_autolens/analysis/test_plotter.py | 2 +- .../imaging/model/test_plotter_imaging.py | 8 +++---- .../imaging/plot/test_fit_imaging_plots.py | 24 +++++++++---------- .../model/test_plotter_interferometer.py | 6 ++--- .../plot/test_fit_interferometer_plots.py | 4 ++-- test_autolens/lens/plot/test_tracer_plots.py | 18 +++++++------- .../point/model/test_plotter_point.py | 2 +- .../point/plot/test_fit_point_plots.py | 2 +- .../point/plot/test_point_dataset_plots.py | 2 +- 14 files changed, 63 insertions(+), 49 deletions(-) diff --git a/autolens/analysis/plotter.py b/autolens/analysis/plotter.py index 3dee1fc72..b7ef98b15 100644 --- a/autolens/analysis/plotter.py +++ b/autolens/analysis/plotter.py @@ -12,8 +12,8 @@ from autolens.lens.plot.tracer_plots import ( subplot_tracer, subplot_galaxies_images, - save_tracer_fits, - save_source_plane_images_fits, + fits_tracer, + fits_source_plane_images, ) from autoarray.plot.array import plot_array @@ -72,10 +72,10 @@ def should_plot(name): ) if should_plot("fits_tracer"): - save_tracer_fits(tracer=tracer, grid=grid, output_path=self.image_path) + fits_tracer(tracer=tracer, grid=grid, output_path=self.image_path) if should_plot("fits_source_plane_images"): - save_source_plane_images_fits(tracer=tracer, grid=grid, output_path=self.image_path) + fits_source_plane_images(tracer=tracer, grid=grid, output_path=self.image_path) def image_with_positions(self, image: aa.Array2D, positions: aa.Grid2DIrregular): """ diff --git a/autolens/imaging/model/plotter.py b/autolens/imaging/model/plotter.py index 23780883e..7f075ec23 100644 --- a/autolens/imaging/model/plotter.py +++ b/autolens/imaging/model/plotter.py @@ -3,7 +3,11 @@ from typing import List from autogalaxy.imaging.model.plotter import PlotterImaging as AgPlotterImaging -from autogalaxy.imaging.model.plotter import fits_to_fits +from autogalaxy.imaging.plot.fit_imaging_plots import ( + fits_fit, + fits_galaxy_images, + fits_model_galaxy_images, +) from autolens.analysis.plotter import Plotter from autolens.imaging.fit_imaging import FitImaging @@ -75,7 +79,14 @@ def should_plot(name): if should_plot("subplot_of_planes"): subplot_of_planes(fit, output_path=output_path, output_format=fmt) - fits_to_fits(should_plot=should_plot, image_path=self.image_path, fit=fit) + if should_plot("fits_fit"): + fits_fit(fit=fit, output_path=self.image_path) + + if should_plot("fits_galaxy_images"): + fits_galaxy_images(fit=fit, output_path=self.image_path) + + if should_plot("fits_model_galaxy_images"): + fits_model_galaxy_images(fit=fit, output_path=self.image_path) def fit_imaging_combined( self, diff --git a/autolens/imaging/plot/fit_imaging_plots.py b/autolens/imaging/plot/fit_imaging_plots.py index 3cd9d6368..df6418c0e 100644 --- a/autolens/imaging/plot/fit_imaging_plots.py +++ b/autolens/imaging/plot/fit_imaging_plots.py @@ -518,7 +518,7 @@ def subplot_of_planes( _plot_source_plane(fit, axes_flat[3], pidx, colormap=colormap) plt.tight_layout() - save_figure(fig, path=output_path, filename=f"of_plane_{pidx}", format=output_format) + save_figure(fig, path=output_path, filename=f"fit_of_plane_{pidx}", format=output_format) def subplot_tracer_from_fit( diff --git a/autolens/interferometer/model/plotter.py b/autolens/interferometer/model/plotter.py index b69604eda..b537e6fbe 100644 --- a/autolens/interferometer/model/plotter.py +++ b/autolens/interferometer/model/plotter.py @@ -2,8 +2,11 @@ PlotterInterferometer as AgPlotterInterferometer, ) -from autogalaxy.interferometer.model.plotter import fits_to_fits from autogalaxy.interferometer.plot import fit_interferometer_plots as ag_fit_interferometer_plots +from autogalaxy.interferometer.plot.fit_interferometer_plots import ( + fits_galaxy_images, + fits_dirty_images, +) from autolens.interferometer.fit_interferometer import FitInterferometer from autolens.interferometer.plot.fit_interferometer_plots import ( @@ -54,8 +57,8 @@ def should_plot(name): if should_plot("subplot_fit_real_space"): subplot_fit_real_space(fit, output_path=output_path, output_format=fmt) - fits_to_fits( - should_plot=should_plot, - image_path=self.image_path, - fit=fit, - ) + if should_plot("fits_galaxy_images"): + fits_galaxy_images(fit=fit, output_path=self.image_path) + + if should_plot("fits_dirty_images"): + fits_dirty_images(fit=fit, output_path=self.image_path) diff --git a/autolens/lens/plot/tracer_plots.py b/autolens/lens/plot/tracer_plots.py index d2bd6563c..2005b2f71 100644 --- a/autolens/lens/plot/tracer_plots.py +++ b/autolens/lens/plot/tracer_plots.py @@ -231,7 +231,7 @@ def subplot_galaxies_images( save_figure(fig, path=output_path, filename="galaxies_images", format=output_format) -def save_tracer_fits( +def fits_tracer( tracer, grid: aa.type.Grid2DLike, output_path, @@ -274,7 +274,7 @@ def save_tracer_fits( hdu_list.writeto(output_path / "tracer.fits", overwrite=True) -def save_source_plane_images_fits( +def fits_source_plane_images( tracer, grid: aa.type.Grid2DLike, output_path, diff --git a/test_autolens/analysis/test_plotter.py b/test_autolens/analysis/test_plotter.py index b4df8b0cf..fb6864097 100644 --- a/test_autolens/analysis/test_plotter.py +++ b/test_autolens/analysis/test_plotter.py @@ -25,7 +25,7 @@ def test__tracer(masked_imaging_7x7, tracer_x2_plane_7x7, plot_path, plot_patch) grid=masked_imaging_7x7.grids.lp, ) - assert path.join(plot_path, "subplot_galaxies_images.png") in plot_patch.paths + assert path.join(plot_path, "galaxies_images.png") in plot_patch.paths image = al.ndarray_via_fits_from( file_path=path.join(plot_path, "tracer.fits"), hdu=0 diff --git a/test_autolens/imaging/model/test_plotter_imaging.py b/test_autolens/imaging/model/test_plotter_imaging.py index 8c70e79ba..02e8b24ef 100644 --- a/test_autolens/imaging/model/test_plotter_imaging.py +++ b/test_autolens/imaging/model/test_plotter_imaging.py @@ -26,9 +26,9 @@ def test__fit_imaging( fit=fit_imaging_x2_plane_inversion_7x7, ) - assert path.join(plot_path, "subplot_tracer.png") in plot_patch.paths - assert path.join(plot_path, "subplot_fit.png") in plot_patch.paths - assert path.join(plot_path, "subplot_fit_log10.png") in plot_patch.paths + assert path.join(plot_path, "tracer.png") in plot_patch.paths + assert path.join(plot_path, "fit.png") in plot_patch.paths + assert path.join(plot_path, "fit_log10.png") in plot_patch.paths image = al.ndarray_via_fits_from( file_path=path.join(plot_path, "fit.fits"), hdu=0 @@ -52,4 +52,4 @@ def test__fit_imaging_combined( visualizer.fit_imaging_combined(fit_list=2 * [fit_imaging_x2_plane_inversion_7x7]) - assert path.join(plot_path, "subplot_fit_combined.png") in plot_patch.paths + assert path.join(plot_path, "fit_combined.png") in plot_patch.paths diff --git a/test_autolens/imaging/plot/test_fit_imaging_plots.py b/test_autolens/imaging/plot/test_fit_imaging_plots.py index 71db64582..435cd2127 100644 --- a/test_autolens/imaging/plot/test_fit_imaging_plots.py +++ b/test_autolens/imaging/plot/test_fit_imaging_plots.py @@ -31,7 +31,7 @@ def test__subplot_fit__two_plane_tracer__output_file_created( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_fit.png") in plot_patch.paths + assert path.join(plot_path, "fit.png") in plot_patch.paths def test__subplot_fit__single_plane_tracer__delegates_to_x1_plane_and_creates_file( @@ -42,7 +42,7 @@ def test__subplot_fit__single_plane_tracer__delegates_to_x1_plane_and_creates_fi output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_fit_x1_plane.png") in plot_patch.paths + assert path.join(plot_path, "fit_x1_plane.png") in plot_patch.paths def test__subplot_fit_x1_plane__single_plane_tracer__output_file_created( @@ -53,7 +53,7 @@ def test__subplot_fit_x1_plane__single_plane_tracer__output_file_created( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_fit_x1_plane.png") in plot_patch.paths + assert path.join(plot_path, "fit_x1_plane.png") in plot_patch.paths def test__subplot_fit_log10__two_plane_tracer__output_file_created( @@ -64,7 +64,7 @@ def test__subplot_fit_log10__two_plane_tracer__output_file_created( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_fit_log10.png") in plot_patch.paths + assert path.join(plot_path, "fit_log10.png") in plot_patch.paths def test__subplot_fit_log10__single_plane_tracer__delegates_to_x1_plane_and_creates_file( @@ -75,7 +75,7 @@ def test__subplot_fit_log10__single_plane_tracer__delegates_to_x1_plane_and_crea output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_fit_log10.png") in plot_patch.paths + assert path.join(plot_path, "fit_log10.png") in plot_patch.paths def test__subplot_fit_log10_x1_plane__single_plane_tracer__output_file_created( @@ -86,7 +86,7 @@ def test__subplot_fit_log10_x1_plane__single_plane_tracer__output_file_created( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_fit_log10.png") in plot_patch.paths + assert path.join(plot_path, "fit_log10.png") in plot_patch.paths def test__subplot_of_planes__no_plane_index_specified__all_plane_files_created( @@ -98,8 +98,8 @@ def test__subplot_of_planes__no_plane_index_specified__all_plane_files_created( output_format="png", ) - assert path.join(plot_path, "subplot_of_plane_0.png") in plot_patch.paths - assert path.join(plot_path, "subplot_of_plane_1.png") in plot_patch.paths + assert path.join(plot_path, "fit_of_plane_0.png") in plot_patch.paths + assert path.join(plot_path, "fit_of_plane_1.png") in plot_patch.paths def test__subplot_of_planes__plane_index_0_specified__only_plane_0_file_created( @@ -112,8 +112,8 @@ def test__subplot_of_planes__plane_index_0_specified__only_plane_0_file_created( plane_index=0, ) - assert path.join(plot_path, "subplot_of_plane_0.png") in plot_patch.paths - assert path.join(plot_path, "subplot_of_plane_1.png") not in plot_patch.paths + assert path.join(plot_path, "fit_of_plane_0.png") in plot_patch.paths + assert path.join(plot_path, "fit_of_plane_1.png") not in plot_patch.paths def test__subplot_tracer_from_fit__two_plane_tracer__output_file_created( @@ -124,7 +124,7 @@ def test__subplot_tracer_from_fit__two_plane_tracer__output_file_created( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_tracer.png") in plot_patch.paths + assert path.join(plot_path, "tracer.png") in plot_patch.paths def test__subplot_fit_combined__list_of_two_fits__output_file_created( @@ -135,7 +135,7 @@ def test__subplot_fit_combined__list_of_two_fits__output_file_created( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_fit_combined.png") in plot_patch.paths + assert path.join(plot_path, "fit_combined.png") in plot_patch.paths def test__subplot_fit_combined_log10__list_of_two_fits__output_file_created( diff --git a/test_autolens/interferometer/model/test_plotter_interferometer.py b/test_autolens/interferometer/model/test_plotter_interferometer.py index dc0741366..958255486 100644 --- a/test_autolens/interferometer/model/test_plotter_interferometer.py +++ b/test_autolens/interferometer/model/test_plotter_interferometer.py @@ -27,9 +27,9 @@ def test__fit_interferometer( fit=fit_interferometer_x2_plane_7x7, ) - assert path.join(plot_path, "subplot_fit.png") in plot_patch.paths - assert path.join(plot_path, "subplot_fit_real_space.png") in plot_patch.paths - assert path.join(plot_path, "subplot_fit_dirty_images.png") in plot_patch.paths + assert path.join(plot_path, "fit.png") in plot_patch.paths + assert path.join(plot_path, "fit_real_space.png") in plot_patch.paths + assert path.join(plot_path, "fit_dirty_images.png") in plot_patch.paths image = al.ndarray_via_fits_from( file_path=path.join(plot_path, "galaxy_images.fits"), hdu=0 diff --git a/test_autolens/interferometer/plot/test_fit_interferometer_plots.py b/test_autolens/interferometer/plot/test_fit_interferometer_plots.py index 1029f8ffe..22f9a72f8 100644 --- a/test_autolens/interferometer/plot/test_fit_interferometer_plots.py +++ b/test_autolens/interferometer/plot/test_fit_interferometer_plots.py @@ -22,7 +22,7 @@ def test__subplot_fit( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_fit.png") in plot_patch.paths + assert path.join(plot_path, "fit.png") in plot_patch.paths def test__subplot_fit_real_space( @@ -36,4 +36,4 @@ def test__subplot_fit_real_space( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_fit_real_space.png") in plot_patch.paths + assert path.join(plot_path, "fit_real_space.png") in plot_patch.paths diff --git a/test_autolens/lens/plot/test_tracer_plots.py b/test_autolens/lens/plot/test_tracer_plots.py index cfa4cf9da..d4a05410c 100644 --- a/test_autolens/lens/plot/test_tracer_plots.py +++ b/test_autolens/lens/plot/test_tracer_plots.py @@ -7,8 +7,8 @@ subplot_tracer, subplot_lensed_images, subplot_galaxies_images, - save_tracer_fits, - save_source_plane_images_fits, + fits_tracer, + fits_source_plane_images, ) directory = path.dirname(path.realpath(__file__)) @@ -33,7 +33,7 @@ def test__subplot_tracer__two_plane_tracer__output_file_created( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_tracer.png") in plot_patch.paths + assert path.join(plot_path, "tracer.png") in plot_patch.paths def test__subplot_galaxies_images__two_plane_tracer__output_file_created( @@ -45,7 +45,7 @@ def test__subplot_galaxies_images__two_plane_tracer__output_file_created( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_galaxies_images.png") in plot_patch.paths + assert path.join(plot_path, "galaxies_images.png") in plot_patch.paths def test__subplot_lensed_images__two_plane_tracer__output_file_created( @@ -57,13 +57,13 @@ def test__subplot_lensed_images__two_plane_tracer__output_file_created( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_lensed_images.png") in plot_patch.paths + assert path.join(plot_path, "lensed_images.png") in plot_patch.paths -def test__save_tracer_fits__two_plane_tracer__tracer_fits_file_written( +def test__fits_tracer__two_plane_tracer__tracer_fits_file_written( tracer_x2_plane_7x7, grid_2d_7x7, tmp_path ): - save_tracer_fits( + fits_tracer( tracer=tracer_x2_plane_7x7, grid=grid_2d_7x7, output_path=tmp_path, @@ -71,10 +71,10 @@ def test__save_tracer_fits__two_plane_tracer__tracer_fits_file_written( assert (tmp_path / "tracer.fits").exists() -def test__save_source_plane_images_fits__two_plane_tracer__source_plane_fits_file_written( +def test__fits_source_plane_images__two_plane_tracer__source_plane_fits_file_written( tracer_x2_plane_7x7, grid_2d_7x7, tmp_path ): - save_source_plane_images_fits( + fits_source_plane_images( tracer=tracer_x2_plane_7x7, grid=grid_2d_7x7, output_path=tmp_path, diff --git a/test_autolens/point/model/test_plotter_point.py b/test_autolens/point/model/test_plotter_point.py index 5467c50e8..62e93b751 100644 --- a/test_autolens/point/model/test_plotter_point.py +++ b/test_autolens/point/model/test_plotter_point.py @@ -21,4 +21,4 @@ def test__fit_point(fit_point_dataset_x2_plane, plot_path, plot_patch): plotter.fit_point(fit=fit_point_dataset_x2_plane) - assert path.join(plot_path, "subplot_fit.png") in plot_patch.paths + assert path.join(plot_path, "fit.png") in plot_patch.paths diff --git a/test_autolens/point/plot/test_fit_point_plots.py b/test_autolens/point/plot/test_fit_point_plots.py index 17ad135ea..e3012fc87 100644 --- a/test_autolens/point/plot/test_fit_point_plots.py +++ b/test_autolens/point/plot/test_fit_point_plots.py @@ -23,4 +23,4 @@ def test__subplot_fit(fit_point_dataset_x2_plane, plot_path, plot_patch): output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_fit.png") in plot_patch.paths + assert path.join(plot_path, "fit.png") in plot_patch.paths diff --git a/test_autolens/point/plot/test_point_dataset_plots.py b/test_autolens/point/plot/test_point_dataset_plots.py index 29862211f..79e5077d5 100644 --- a/test_autolens/point/plot/test_point_dataset_plots.py +++ b/test_autolens/point/plot/test_point_dataset_plots.py @@ -23,4 +23,4 @@ def test__subplot_dataset(point_dataset, plot_path, plot_patch): output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_dataset_point.png") in plot_patch.paths + assert path.join(plot_path, "dataset_point.png") in plot_patch.paths