Skip to content

Commit 5d94e9a

Browse files
authored
Merge pull request #184 from Jammy2211/feature/jax_simplify_visualization
Feature/jax simplify visualization
2 parents 741ff6a + 0cb75eb commit 5d94e9a

41 files changed

Lines changed: 503 additions & 1668 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

autoarray/config/visualize/include.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

autoarray/dataset/grids.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
from autoarray.mask.mask_2d import Mask2D
44
from autoarray.structures.arrays.uniform_2d import Array2D
55
from autoarray.structures.arrays.kernel_2d import Kernel2D
6-
from autoarray.structures.grids.uniform_1d import Grid1D
76
from autoarray.structures.grids.uniform_2d import Grid2D
87

98
from autoarray.inversion.pixelization.border_relocator import BorderRelocator
10-
from autoconf import cached_property
119

1210
from autoarray import exc
1311

autoarray/dataset/plot/imaging_plotters.py

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@
22
from typing import Callable, Optional
33

44
from autoarray.plot.visuals.two_d import Visuals2D
5-
from autoarray.plot.include.two_d import Include2D
65
from autoarray.plot.mat_plot.two_d import MatPlot2D
76
from autoarray.plot.auto_labels import AutoLabels
8-
from autoarray.plot.abstract_plotters import Plotter
7+
from autoarray.plot.abstract_plotters import AbstractPlotter
98
from autoarray.dataset.imaging.dataset import Imaging
109

1110

12-
class ImagingPlotterMeta(Plotter):
11+
class ImagingPlotterMeta(AbstractPlotter):
1312
def __init__(
1413
self,
1514
dataset: Imaging,
16-
get_visuals_2d: Callable,
1715
mat_plot_2d: MatPlot2D = None,
1816
visuals_2d: Visuals2D = None,
19-
include_2d: Include2D = None,
2017
):
2118
"""
2219
Plots the attributes of `Imaging` objects using the matplotlib method `imshow()` and many other matplotlib
@@ -27,29 +24,21 @@ def __init__(
2724
but a user can manually input values into `MatPlot2d` to customize the figure's appearance.
2825
2926
Overlaid on the figure are visuals, contained in the `Visuals2D` object. Attributes may be extracted from
30-
the `Imaging` and plotted via the visuals object, if the corresponding entry is `True` in the `Include2D`
31-
object or the `config/visualize/include.ini` file.
27+
the `Imaging` and plotted via the visuals object.
3228
3329
Parameters
3430
----------
3531
dataset
3632
The imaging dataset the plotter plots.
37-
get_visuals_2d
38-
A function which extracts from the `Imaging` the 2D visuals which are plotted on figures.
3933
mat_plot_2d
4034
Contains objects which wrap the matplotlib function calls that make 2D plots.
4135
visuals_2d
4236
Contains 2D visuals that can be overlaid on 2D plots.
43-
include_2d
44-
Specifies which attributes of the `Imaging` are extracted and plotted as visuals for 2D plots.
4537
"""
4638

47-
super().__init__(
48-
mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d
49-
)
39+
super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d)
5040

5141
self.dataset = dataset
52-
self.get_visuals_2d = get_visuals_2d
5342

5443
@property
5544
def imaging(self):
@@ -91,21 +80,21 @@ def figures_2d(
9180
if data:
9281
self.mat_plot_2d.plot_array(
9382
array=self.dataset.data,
94-
visuals_2d=self.get_visuals_2d(),
83+
visuals_2d=self.visuals_2d,
9584
auto_labels=AutoLabels(title=title_str or f" Data", filename="data"),
9685
)
9786

9887
if noise_map:
9988
self.mat_plot_2d.plot_array(
10089
array=self.dataset.noise_map,
101-
visuals_2d=self.get_visuals_2d(),
90+
visuals_2d=self.visuals_2d,
10291
auto_labels=AutoLabels(title_str or f"Noise-Map", filename="noise_map"),
10392
)
10493

10594
if psf:
10695
self.mat_plot_2d.plot_array(
10796
array=self.dataset.psf,
108-
visuals_2d=self.get_visuals_2d(),
97+
visuals_2d=self.visuals_2d,
10998
auto_labels=AutoLabels(
11099
title=title_str or f"Point Spread Function",
111100
filename="psf",
@@ -116,7 +105,7 @@ def figures_2d(
116105
if signal_to_noise_map:
117106
self.mat_plot_2d.plot_array(
118107
array=self.dataset.signal_to_noise_map,
119-
visuals_2d=self.get_visuals_2d(),
108+
visuals_2d=self.visuals_2d,
120109
auto_labels=AutoLabels(
121110
title=title_str or f"Signal-To-Noise Map",
122111
filename="signal_to_noise_map",
@@ -127,7 +116,7 @@ def figures_2d(
127116
if over_sample_size_lp:
128117
self.mat_plot_2d.plot_array(
129118
array=self.dataset.grids.over_sample_size_lp,
130-
visuals_2d=self.get_visuals_2d(),
119+
visuals_2d=self.visuals_2d,
131120
auto_labels=AutoLabels(
132121
title=title_str or f"Over Sample Size (Light Profiles)",
133122
filename="over_sample_size_lp",
@@ -138,7 +127,7 @@ def figures_2d(
138127
if over_sample_size_pixelization:
139128
self.mat_plot_2d.plot_array(
140129
array=self.dataset.grids.over_sample_size_pixelization,
141-
visuals_2d=self.get_visuals_2d(),
130+
visuals_2d=self.visuals_2d,
142131
auto_labels=AutoLabels(
143132
title=title_str or f"Over Sample Size (Pixelization)",
144133
filename="over_sample_size_pixelization",
@@ -227,13 +216,12 @@ def subplot_dataset(self):
227216
self.mat_plot_2d.use_log10 = use_log10_original
228217

229218

230-
class ImagingPlotter(Plotter):
219+
class ImagingPlotter(AbstractPlotter):
231220
def __init__(
232221
self,
233222
dataset: Imaging,
234223
mat_plot_2d: MatPlot2D = None,
235224
visuals_2d: Visuals2D = None,
236-
include_2d: Include2D = None,
237225
):
238226
"""
239227
Plots the attributes of `Imaging` objects using the matplotlib method `imshow()` and many other matplotlib
@@ -244,8 +232,7 @@ def __init__(
244232
but a user can manually input values into `MatPlot2d` to customize the figure's appearance.
245233
246234
Overlaid on the figure are visuals, contained in the `Visuals2D` object. Attributes may be extracted from
247-
the `Imaging` and plotted via the visuals object, if the corresponding entry is `True` in the `Include2D`
248-
object or the `config/visualize/include.ini` file.
235+
the `Imaging` and plotted via the visuals object.
249236
250237
Parameters
251238
----------
@@ -255,27 +242,18 @@ def __init__(
255242
Contains objects which wrap the matplotlib function calls that make 2D plots.
256243
visuals_2d
257244
Contains 2D visuals that can be overlaid on 2D plots.
258-
include_2d
259-
Specifies which attributes of the `Imaging` are extracted and plotted as visuals for 2D plots.
260245
"""
261246

262-
super().__init__(
263-
mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d
264-
)
247+
super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d)
265248

266249
self.dataset = dataset
267250

268251
self._imaging_meta_plotter = ImagingPlotterMeta(
269252
dataset=self.dataset,
270-
get_visuals_2d=self.get_visuals_2d,
271253
mat_plot_2d=self.mat_plot_2d,
272-
include_2d=self.include_2d,
273254
visuals_2d=self.visuals_2d,
274255
)
275256

276257
self.figures_2d = self._imaging_meta_plotter.figures_2d
277258
self.subplot = self._imaging_meta_plotter.subplot
278259
self.subplot_dataset = self._imaging_meta_plotter.subplot_dataset
279-
280-
def get_visuals_2d(self):
281-
return self.get_2d.via_mask_from(mask=self.dataset.mask)

0 commit comments

Comments
 (0)