Skip to content

Commit dedbd78

Browse files
Jammy2211Jammy2211
authored andcommitted
remove reconstructed image API
1 parent 73aa606 commit dedbd78

File tree

13 files changed

+78
-116
lines changed

13 files changed

+78
-116
lines changed

autoarray/config/visualize/plots.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ inversion: # Settings for plots of inversions (e
2727
sub_pixels_per_image_pixels: false # Plot the number of sub pixels per masked data pixels?
2828
mesh_pixels_per_image_pixels: false # Plot the number of image-plane mesh pixels per masked data pixels?
2929
image_pixels_per_mesh_pixels: false # Plot the number of image pixels in each pixel of the mesh?
30-
reconstructed_image: false # Plot image of the reconstructed data (e.g. in the image-plane)?
30+
reconstructed_operated_data: false # Plot image of the reconstructed data (e.g. in the image-plane)?
3131
reconstruction: false # Plot the reconstructed inversion (e.g. the pixelization's mesh in the source-plane)?
3232
regularization_weights: false # Plot the effective regularization weight of every inversion mesh pixel?
3333
fit_interferometer: # Settings for plots of fits to interferometer datasets (e.g. FitInterferometerPlotter).

autoarray/inversion/inversion/abstract.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -517,22 +517,6 @@ def source_quantity_dict_from(
517517
def mapped_reconstructed_operated_data_dict(self) -> Dict[LinearObj, Array2D]:
518518
raise NotImplementedError
519519

520-
@property
521-
def mapped_reconstructed_image_dict(self) -> Dict[LinearObj, Array2D]:
522-
"""
523-
Using the reconstructed source pixel fluxes we map each source pixel flux back to the image plane and
524-
reconstruct the image data.
525-
526-
This uses the unique mappings of every source pixel to image pixels, which is a quantity that is already
527-
computed when using the w-tilde formalism.
528-
529-
Returns
530-
-------
531-
Array2D
532-
The reconstructed image data which the inversion fits.
533-
"""
534-
return self.mapped_reconstructed_operated_data_dict
535-
536520
@property
537521
def mapped_reconstructed_data(self) -> Union[Array2D, Visibilities]:
538522
"""
@@ -565,22 +549,6 @@ def mapped_reconstructed_operated_data(self) -> Union[Array2D, Visibilities]:
565549
"""
566550
return sum(self.mapped_reconstructed_operated_data_dict.values())
567551

568-
@property
569-
def mapped_reconstructed_image(self) -> Array2D:
570-
"""
571-
Using the reconstructed source pixel fluxes we map each source pixel flux back to the image plane and
572-
reconstruct the image data.
573-
574-
This uses the unique mappings of every source pixel to image pixels, which is a quantity that is already
575-
computed when using the w-tilde formalism.
576-
577-
Returns
578-
-------
579-
Array2D
580-
The reconstructed image data which the inversion fits.
581-
"""
582-
return sum(self.mapped_reconstructed_image_dict.values())
583-
584552
@property
585553
def data_subtracted_dict(self) -> Dict[LinearObj, Array2D]:
586554
"""
@@ -605,7 +573,7 @@ def data_subtracted_dict(self) -> Dict[LinearObj, Array2D]:
605573
if linear_obj != linear_obj_other:
606574
data_subtracted_dict[
607575
linear_obj
608-
] -= self.mapped_reconstructed_image_dict[linear_obj_other]
576+
] -= self.mapped_reconstructed_operated_data_dict[linear_obj_other]
609577

610578
return data_subtracted_dict
611579

autoarray/inversion/inversion/imaging/abstract.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,22 @@ def __init__(
7575
def psf(self):
7676
return self.dataset.psf
7777

78+
@property
79+
def mapping_matrix_list(self) -> List[np.ndarray]:
80+
"""
81+
The `mapping_matrix` of a linear object describes the mappings between the observed data's values and
82+
the linear objects model, before a operation like a convolution is applied.
83+
84+
This is used to construct the simultaneous linear equations which reconstruct the data.
85+
86+
This property returns the a list of each linear object's blurred mapping matrix, which is computed by
87+
blurring each linear object's `mapping_matrix` property with the `psf` operator.
88+
89+
A linear object may have a `operated_mapping_matrix_override` property, which bypasses the `mapping_matrix`
90+
computation and convolution operator and is directly placed in the `operated_mapping_matrix_list`.
91+
"""
92+
return [linear_obj.mapping_matrix for linear_obj in self.linear_obj_list]
93+
7894
@property
7995
def operated_mapping_matrix_list(self) -> List[np.ndarray]:
8096
"""

autoarray/inversion/inversion/imaging/inversion_imaging_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def curvature_matrix_with_added_to_diag_from(
277277
return curvature_matrix.at[inds, inds].add(value)
278278

279279

280-
def mapped_reconstructed_image_via_sparse_operator_from(
280+
def mapped_reconstructed_operated_data_via_sparse_operator_from(
281281
reconstruction, # (S,)
282282
rows,
283283
cols,

autoarray/inversion/inversion/imaging/mapping.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,20 @@ def _mapped_reconstructed_data_dict_from(
118118
for index, linear_obj in enumerate(self.linear_obj_list):
119119
reconstruction = reconstruction_dict[linear_obj]
120120

121-
mapped_reconstructed_image = (
121+
mapped_reconstructed_operated_data = (
122122
inversion_util.mapped_reconstructed_data_via_mapping_matrix_from(
123123
mapping_matrix=mapping_matrix_list[index],
124124
reconstruction=reconstruction,
125125
xp=self._xp,
126126
)
127127
)
128128

129-
mapped_reconstructed_image = Array2D(
130-
values=mapped_reconstructed_image,
129+
mapped_reconstructed_operated_data = Array2D(
130+
values=mapped_reconstructed_operated_data,
131131
mask=self.mask,
132132
)
133133

134-
mapped_reconstructed_data_dict[linear_obj] = mapped_reconstructed_image
134+
mapped_reconstructed_data_dict[linear_obj] = mapped_reconstructed_operated_data
135135

136136
return mapped_reconstructed_data_dict
137137

autoarray/inversion/inversion/imaging/sparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def _mapped_reconstructed_data_dict_from(
508508

509509
rows, cols, vals = linear_obj.sparse_triplets_curvature
510510

511-
mapped = inversion_imaging_util.mapped_reconstructed_image_via_sparse_operator_from(
511+
mapped = inversion_imaging_util.mapped_reconstructed_operated_data_via_sparse_operator_from(
512512
reconstruction=reconstruction,
513513
rows=rows,
514514
cols=cols,

autoarray/inversion/inversion/interferometer/abstract.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def operated_mapping_matrix_list(self) -> List[np.ndarray]:
7171
]
7272

7373
@property
74-
def mapped_reconstructed_image_dict(
74+
def mapped_reconstructed_data_dict(
7575
self,
7676
) -> Dict[LinearObj, Array2D]:
7777
"""
@@ -97,7 +97,7 @@ def mapped_reconstructed_image_dict(
9797
The reconstruction (in the source frame) whose values are mapped to a dictionary of values for each
9898
individual mapper (in the image-plane).
9999
"""
100-
mapped_reconstructed_image_dict = {}
100+
mapped_reconstructed_data_dict = {}
101101

102102
reconstruction_dict = self.source_quantity_dict_from(
103103
source_quantity=self.reconstruction
@@ -106,21 +106,21 @@ def mapped_reconstructed_image_dict(
106106
for linear_obj in self.linear_obj_list:
107107
reconstruction = reconstruction_dict[linear_obj]
108108

109-
mapped_reconstructed_image = (
109+
mapped_reconstructed_data = (
110110
inversion_util.mapped_reconstructed_data_via_mapping_matrix_from(
111111
mapping_matrix=linear_obj.mapping_matrix,
112112
reconstruction=reconstruction,
113113
xp=self._xp,
114114
)
115115
)
116116

117-
mapped_reconstructed_image = Array2D(
118-
values=mapped_reconstructed_image, mask=self.mask
117+
mapped_reconstructed_data = Array2D(
118+
values=mapped_reconstructed_data, mask=self.mask
119119
)
120120

121-
mapped_reconstructed_image_dict[linear_obj] = mapped_reconstructed_image
121+
mapped_reconstructed_data_dict[linear_obj] = mapped_reconstructed_data
122122

123-
return mapped_reconstructed_image_dict
123+
return mapped_reconstructed_data_dict
124124

125125
@property
126126
def fast_chi_squared(self):

autoarray/inversion/inversion/interferometer/sparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def mapped_reconstructed_operated_data_dict(
137137
"""
138138
mapped_reconstructed_operated_data_dict = {}
139139

140-
image_dict = self.mapped_reconstructed_image_dict
140+
image_dict = self.mapped_reconstructed_data_dict
141141

142142
for linear_obj in self.linear_obj_list:
143143
visibilities = self.transformer.visibilities_from(

autoarray/inversion/mock/mock_inversion.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ def __init__(
2222
curvature_reg_matrix=None,
2323
reconstruction: np.ndarray = None,
2424
reconstruction_dict: List[np.ndarray] = None,
25-
mapped_reconstructed_operated_data_dict=None,
2625
mapped_reconstructed_data_dict=None,
27-
mapped_reconstructed_image_dict=None,
26+
mapped_reconstructed_operated_data_dict=None,
2827
reconstruction_noise_map: np.ndarray = None,
2928
reconstruction_noise_map_dict: List[np.ndarray] = None,
3029
regularization_term=None,
@@ -57,11 +56,10 @@ def __init__(
5756
self._reconstruction = reconstruction
5857
self._reconstruction_dict = reconstruction_dict
5958

59+
self._mapped_reconstructed_data_dict = mapped_reconstructed_data_dict
6060
self._mapped_reconstructed_operated_data_dict = (
6161
mapped_reconstructed_operated_data_dict
6262
)
63-
self._mapped_reconstructed_data_dict = mapped_reconstructed_data_dict
64-
self._mapped_reconstructed_image_dict = mapped_reconstructed_image_dict
6563

6664
self._reconstruction_noise_map = reconstruction_noise_map
6765
self._reconstruction_noise_map_dict = reconstruction_noise_map_dict
@@ -175,26 +173,6 @@ def mapped_reconstructed_operated_data_dict(self):
175173

176174
return self._mapped_reconstructed_operated_data_dict
177175

178-
@property
179-
def mapped_reconstructed_image_dict(self):
180-
"""
181-
Using the reconstructed source pixel fluxes we map each source pixel flux back to the image plane and
182-
reconstruct the image image.
183-
184-
This uses the unique mappings of every source pixel to image pixels, which is a quantity that is already
185-
computed when using the w-tilde formalism.
186-
187-
Returns
188-
-------
189-
Array2D
190-
The reconstructed image image which the inversion fits.
191-
"""
192-
193-
if self._mapped_reconstructed_image_dict is None:
194-
return super().mapped_reconstructed_image_dict
195-
196-
return self._mapped_reconstructed_image_dict
197-
198176
@property
199177
def reconstruction_noise_map(self):
200178
if self._reconstruction_noise_map is None:

autoarray/inversion/plot/inversion_plotters.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def mapper_plotter_from(self, mapper_index: int) -> MapperPlotter:
6666
visuals_2d=self.visuals_2d,
6767
)
6868

69-
def figures_2d(self, reconstructed_image: bool = False):
69+
def figures_2d(self, reconstructed_operated_data: bool = False):
7070
"""
7171
Plots the individual attributes of the plotter's `Inversion` object in 2D.
7272
@@ -75,23 +75,23 @@ def figures_2d(self, reconstructed_image: bool = False):
7575
7676
Parameters
7777
----------
78-
reconstructed_image
78+
reconstructed_operated_data
7979
Whether to make a 2D plot (via `imshow`) of the reconstructed image data.
8080
"""
81-
if reconstructed_image:
81+
if reconstructed_operated_data:
8282
self.mat_plot_2d.plot_array(
83-
array=self.inversion.mapped_reconstructed_image,
83+
array=self.inversion.mapped_reconstructed_operated_data,
8484
visuals_2d=self.visuals_2d,
8585
auto_labels=AutoLabels(
86-
title="Reconstructed Image", filename="reconstructed_image"
86+
title="Reconstructed Image", filename="reconstructed_operated_data"
8787
),
8888
)
8989

9090
def figures_2d_of_pixelization(
9191
self,
9292
pixelization_index: int = 0,
9393
data_subtracted: bool = False,
94-
reconstructed_image: bool = False,
94+
reconstructed_operated_data: bool = False,
9595
reconstruction: bool = False,
9696
reconstruction_noise_map: bool = False,
9797
signal_to_noise_map: bool = False,
@@ -112,7 +112,7 @@ def figures_2d_of_pixelization(
112112
----------
113113
pixelization_index
114114
The index of the `Mapper` in the `Inversion`'s `linear_obj_list` that is plotted.
115-
reconstructed_image
115+
reconstructed_operated_data
116116
Whether to make a 2D plot (via `imshow`) of the mapper's reconstructed image data.
117117
reconstruction
118118
Whether to make a 2D plot (via `imshow` or `fill`) of the mapper's source-plane reconstruction.
@@ -160,8 +160,8 @@ def figures_2d_of_pixelization(
160160
except AttributeError:
161161
pass
162162

163-
if reconstructed_image:
164-
array = self.inversion.mapped_reconstructed_image_dict[
163+
if reconstructed_operated_data:
164+
array = self.inversion.mapped_reconstructed_operated_data_dict[
165165
mapper_plotter.mapper
166166
]
167167

@@ -170,7 +170,7 @@ def figures_2d_of_pixelization(
170170
visuals_2d=self.visuals_2d,
171171
grid_indexes=mapper_plotter.mapper.over_sampler.uniform_over_sampled,
172172
auto_labels=AutoLabels(
173-
title="Reconstructed Image", filename="reconstructed_image"
173+
title="Reconstructed Image", filename="reconstructed_operated_data"
174174
),
175175
)
176176

@@ -320,14 +320,14 @@ def subplot_of_mapper(
320320
)
321321

322322
self.figures_2d_of_pixelization(
323-
pixelization_index=mapper_index, reconstructed_image=True
323+
pixelization_index=mapper_index, reconstructed_operated_data=True
324324
)
325325

326326
self.mat_plot_2d.use_log10 = True
327327
self.mat_plot_2d.contour = False
328328

329329
self.figures_2d_of_pixelization(
330-
pixelization_index=mapper_index, reconstructed_image=True
330+
pixelization_index=mapper_index, reconstructed_operated_data=True
331331
)
332332

333333
self.mat_plot_2d.use_log10 = False
@@ -340,7 +340,7 @@ def subplot_of_mapper(
340340

341341
self.set_title(label="Mesh Pixel Grid Overlaid")
342342
self.figures_2d_of_pixelization(
343-
pixelization_index=mapper_index, reconstructed_image=True
343+
pixelization_index=mapper_index, reconstructed_operated_data=True
344344
)
345345
self.set_title(label=None)
346346

@@ -424,7 +424,7 @@ def subplot_mappings(
424424
self.visuals_2d.indexes = indexes
425425

426426
self.figures_2d_of_pixelization(
427-
pixelization_index=pixelization_index, reconstructed_image=True
427+
pixelization_index=pixelization_index, reconstructed_operated_data=True
428428
)
429429

430430
self.figures_2d_of_pixelization(

0 commit comments

Comments
 (0)