Skip to content

Commit a756db1

Browse files
authored
Revert "Feature/jax point source"
1 parent 661c4b9 commit a756db1

46 files changed

Lines changed: 515 additions & 357 deletions

Some content is hidden

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

autolens/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from autoarray.mask.mask_1d import Mask1D
1111
from autoarray.mask.mask_2d import Mask2D
1212
from autoarray.mask.derive.zoom_2d import Zoom2D
13+
from autoarray.operators.convolver import Convolver
1314
from autoarray.operators.over_sampling.over_sampler import OverSampler # noqa
1415
from autoarray.inversion.inversion.dataset_interface import DatasetInterface
1516
from autoarray.inversion.inversion.mapper_valued import MapperValued
@@ -26,7 +27,6 @@
2627
from autoarray.inversion.pixelization.mappers.mapper_grids import MapperGrids
2728
from autoarray.inversion.pixelization.mappers.factory import mapper_from as Mapper
2829
from autoarray.inversion.pixelization.border_relocator import BorderRelocator
29-
from autoarray.inversion.convolver import Convolver
3030
from autoarray.operators.transformer import TransformerDFT
3131
from autoarray.operators.transformer import TransformerNUFFT
3232
from autoarray.structures.arrays.uniform_1d import Array1D

autolens/analysis/positions.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def __init__(
7171
The plane redshift of the lensed source multiple images, which is only required if position threshold
7272
for a double source plane lens system is being used where the specific plane is required.
7373
"""
74-
7574
self.positions = positions
7675
self.threshold = threshold
7776
self.plane_redshift = plane_redshift
@@ -166,12 +165,10 @@ def log_likelihood_penalty_base_from(
166165
residual_map=residual_map, noise_map=dataset.noise_map
167166
)
168167

169-
chi_squared = aa.util.fit.chi_squared_from(
170-
chi_squared_map=chi_squared_map.array
171-
)
168+
chi_squared = aa.util.fit.chi_squared_from(chi_squared_map=chi_squared_map)
172169

173170
noise_normalization = aa.util.fit.noise_normalization_from(
174-
noise_map=dataset.noise_map.array
171+
noise_map=dataset.noise_map
175172
)
176173

177174
else:

autolens/analysis/result.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def positions_threshold_from(
233233
data=positions, noise_map=None, tracer=tracer, plane_redshift=plane_redshift
234234
)
235235

236-
threshold = factor * np.nanmax(positions_fits.max_separation_of_plane_positions)
236+
threshold = factor * np.max(positions_fits.max_separation_of_plane_positions)
237237

238238
if minimum_threshold is not None:
239239
if threshold < minimum_threshold:
@@ -285,7 +285,7 @@ def positions_likelihood_from(
285285
286286
Returns
287287
-------
288-
The `PositionsLH` object used to apply a likelihood penalty or resample the positions.
288+
The `PositionsLH` object used to apply a likelihood penalty using the positions.
289289
"""
290290

291291
if os.environ.get("PYAUTOFIT_TEST_MODE") == "1":
@@ -308,12 +308,6 @@ def positions_likelihood_from(
308308

309309
positions = positions[distances > mass_centre_radial_distance_min]
310310

311-
mask = np.isfinite(positions.array).all(axis=1)
312-
313-
positions = aa.Grid2DIrregular(
314-
positions[mask]
315-
)
316-
317311
threshold = self.positions_threshold_from(
318312
factor=factor,
319313
minimum_threshold=minimum_threshold,

autolens/imaging/fit_imaging.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,9 @@ def blurred_image(self) -> aa.Array2D:
8282
"""
8383
Returns the image of all light profiles in the fit's tracer convolved with the imaging dataset's PSF.
8484
"""
85-
86-
if len(self.tracer.cls_list_from(cls=ag.LightProfile)) == len(
87-
self.tracer.cls_list_from(cls=ag.lp_operated.LightProfileOperated)
88-
):
89-
return self.tracer.image_2d_from(
90-
grid=self.grids.lp,
91-
)
92-
9385
return self.tracer.blurred_image_2d_from(
9486
grid=self.grids.lp,
95-
psf=self.dataset.psf,
87+
convolver=self.dataset.convolver,
9688
blurring_grid=self.grids.blurring,
9789
)
9890

@@ -101,6 +93,7 @@ def profile_subtracted_image(self) -> aa.Array2D:
10193
"""
10294
Returns the dataset's image with all blurred light profile images in the fit's tracer subtracted.
10395
"""
96+
10497
return self.data - self.blurred_image
10598

10699
@property
@@ -110,7 +103,6 @@ def tracer_to_inversion(self) -> TracerToInversion:
110103
data=self.profile_subtracted_image,
111104
noise_map=self.noise_map,
112105
grids=self.grids,
113-
psf=self.dataset.psf,
114106
convolver=self.dataset.convolver,
115107
w_tilde=self.w_tilde,
116108
)
@@ -171,7 +163,7 @@ def galaxy_model_image_dict(self) -> Dict[ag.Galaxy, np.ndarray]:
171163

172164
galaxy_blurred_image_2d_dict = self.tracer.galaxy_blurred_image_2d_dict_from(
173165
grid=self.grids.lp,
174-
psf=self.dataset.psf,
166+
convolver=self.dataset.convolver,
175167
blurring_grid=self.grids.blurring,
176168
)
177169

autolens/imaging/model/analysis.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ def log_likelihood_function(self, instance: af.ModelInstance) -> float:
117117
np.linalg.LinAlgError,
118118
OverflowError,
119119
) as e:
120-
print(e)
121-
fggdfg
122120
raise exc.FitException from e
123121

124122
def fit_from(

autolens/imaging/plot/fit_imaging_plotters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def figures_2d_of_planes(
216216
for plane_index in plane_indexes:
217217

218218
if use_source_vmax:
219-
self.mat_plot_2d.cmap.kwargs["vmax"] = np.max(self.fit.model_images_of_planes_list[plane_index].array)
219+
self.mat_plot_2d.cmap.kwargs["vmax"] = np.max(self.fit.model_images_of_planes_list[plane_index])
220220

221221
if subtracted_image:
222222

@@ -765,7 +765,7 @@ def figures_2d(
765765
if data:
766766

767767
if use_source_vmax:
768-
self.mat_plot_2d.cmap.kwargs["vmax"] = np.max([model_image.array for model_image in self.fit.model_images_of_planes_list[1:]])
768+
self.mat_plot_2d.cmap.kwargs["vmax"] = np.max(self.fit.model_images_of_planes_list[1:])
769769

770770
self.mat_plot_2d.plot_array(
771771
array=self.fit.data,
@@ -799,7 +799,7 @@ def figures_2d(
799799
if model_image:
800800

801801
if use_source_vmax:
802-
self.mat_plot_2d.cmap.kwargs["vmax"] = np.max([model_image.array for model_image in self.fit.model_images_of_planes_list[1:]])
802+
self.mat_plot_2d.cmap.kwargs["vmax"] = np.max(self.fit.model_images_of_planes_list[1:])
803803

804804
self.mat_plot_2d.plot_array(
805805
array=self.fit.model_data,

autolens/lens/to_inversion.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ def lp_linear_func_list_galaxy_dict(
180180
data=self.dataset.data,
181181
noise_map=self.dataset.noise_map,
182182
grids=grids,
183-
psf=self.psf,
184-
convolver=self.dataset.convolver,
183+
convolver=self.convolver,
185184
transformer=self.transformer,
186185
w_tilde=self.dataset.w_tilde,
187186
)

autolens/lens/tracer.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from abc import ABC
22
import numpy as np
3+
from functools import wraps
34
from scipy.interpolate import griddata
45
from typing import Dict, List, Optional, Type, Union
56

@@ -548,9 +549,9 @@ def image_2d_via_input_plane_image_from(
548549
)[plane_index]
549550

550551
image = griddata(
551-
points=plane_grid.array,
552-
values=plane_image.array,
553-
xi=traced_grid.over_sampled.array,
552+
points=plane_grid,
553+
values=plane_image,
554+
xi=traced_grid.over_sampled,
554555
fill_value=0.0,
555556
method="linear",
556557
)
@@ -1190,5 +1191,5 @@ def set_snr_of_snr_light_profiles(
11901191
)
11911192

11921193
@aa.profile_func
1193-
def convolve_via_psf(self, image, blurring_image, psf):
1194-
return psf.convolve_image(image=image, blurring_image=blurring_image)
1194+
def convolve_via_convolver(self, image, blurring_image, convolver):
1195+
return convolver.convolve_image(image=image, blurring_image=blurring_image)

autolens/point/fit/fluxes.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import jax.numpy as jnp
21
from typing import Optional
32

43
import autoarray as aa
@@ -102,10 +101,10 @@ def model_data(self):
102101
are used.
103102
"""
104103
return aa.ArrayIrregular(
105-
values=jnp.array([
104+
values=[
106105
magnification * self.profile.flux
107106
for magnification in self.magnifications_at_positions
108-
])
107+
]
109108
)
110109

111110
@property
@@ -129,5 +128,5 @@ def chi_squared(self) -> float:
129128
RMS noise-map values squared.
130129
"""
131130
return ag.util.fit.chi_squared_from(
132-
chi_squared_map=self.chi_squared_map.array,
131+
chi_squared_map=self.chi_squared_map,
133132
)

autolens/point/fit/positions/image/pair.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import jax.numpy as jnp
21
import numpy as np
3-
from ott.geometry import pointcloud
4-
from ott.solvers.linear import sinkhorn
52
from scipy.optimize import linear_sum_assignment
63

74
import autoarray as aa

0 commit comments

Comments
 (0)