Skip to content

Commit dc49594

Browse files
authored
Merge pull request #389 from Jammy2211/feature/psf_convolution_refactor
Feature/psf convolution refactor
2 parents 0b0c35e + b0dc0e3 commit dc49594

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

autolens/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from autoarray.inversion.inversion.factory import inversion_from as Inversion
2525
from autoarray.inversion.mappers.abstract import Mapper
2626
from autoarray.inversion.mesh.border_relocator import BorderRelocator
27+
from autoarray.operators.convolver import Convolver
2728
from autoarray.operators.transformer import TransformerDFT
2829
from autoarray.operators.transformer import TransformerNUFFT
2930
from autoarray.preloads import Preloads
@@ -45,7 +46,6 @@
4546
from autoarray.structures.triangles.shape import Polygon
4647
from autoarray.structures.vectors.uniform import VectorYX2D
4748
from autoarray.structures.vectors.irregular import VectorYX2DIrregular
48-
from autoarray.structures.arrays.kernel_2d import Kernel2D
4949
from autoarray.structures.visibilities import Visibilities
5050
from autoarray.structures.visibilities import VisibilitiesNoiseMap
5151
from autoarray.inversion.mesh.mesh_geometry.rectangular import (

autolens/imaging/simulator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def via_tracer_from(self, tracer : Tracer, grid : aa.type.Grid2DLike, xp=np) ->
4343
)
4444

4545
image = tracer.padded_image_2d_from(
46-
grid=grid, psf_shape_2d=self.psf.shape_native, xp=xp
46+
grid=grid, psf_shape_2d=self.psf.kernel.shape_native, xp=xp
4747
)
4848

4949
over_sample_size = grid.over_sample_size.resized_from(
@@ -53,7 +53,7 @@ def via_tracer_from(self, tracer : Tracer, grid : aa.type.Grid2DLike, xp=np) ->
5353
dataset = self.via_image_from(image=image, over_sample_size=over_sample_size, xp=xp)
5454

5555
return dataset.trimmed_after_convolution_from(
56-
kernel_shape=self.psf.shape_native
56+
kernel_shape=self.psf.kernel.shape_native
5757
)
5858

5959
def via_galaxies_from(self, galaxies : List[ag.Galaxy], grid : aa.type.Grid2DLike) -> aa.Imaging:
@@ -166,10 +166,10 @@ def via_source_image_from(self, tracer : Tracer, grid : aa.type.Grid2DLike, sour
166166
)
167167

168168
padded_image = image.padded_before_convolution_from(
169-
kernel_shape=self.psf.shape_native
169+
kernel_shape=self.psf.kernel.shape_native
170170
)
171171
dataset = self.via_image_from(image=padded_image)
172172

173173
return dataset.trimmed_after_convolution_from(
174-
kernel_shape=self.psf.shape_native
174+
kernel_shape=self.psf.kernel.shape_native
175175
)

autolens/lens/tracer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ def set_snr_of_snr_light_profiles(
11591159
grid: aa.type.Grid2DLike,
11601160
exposure_time: float,
11611161
background_sky_level: float = 0.0,
1162-
psf: Optional[aa.Kernel2D] = None,
1162+
psf: Optional[aa.Convolver] = None,
11631163
):
11641164
"""
11651165
Iterate over every `LightProfileSNR` in the tracer and set their `intensity` values to values which give

test_autolens/imaging/test_simulate_and_fit_imaging.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test__perfect_fit__chi_squared_0():
1111

1212
grid = al.Grid2D.uniform(shape_native=(11, 11), pixel_scales=0.2, over_sample_size=1)
1313

14-
psf = al.Kernel2D.from_gaussian(
14+
psf = al.Convolver.from_gaussian(
1515
shape_native=(3, 3), pixel_scales=0.2, sigma=0.75, normalize=True
1616
)
1717

@@ -85,7 +85,7 @@ def test__simulate_imaging_data_and_fit__known_likelihood():
8585

8686
grid = al.Grid2D.uniform(shape_native=(31, 31), pixel_scales=0.2)
8787

88-
psf = al.Kernel2D.from_gaussian(
88+
psf = al.Convolver.from_gaussian(
8989
shape_native=(3, 3), pixel_scales=0.2, sigma=0.75, normalize=True
9090
)
9191

@@ -127,7 +127,7 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_agree_with_standa
127127

128128
grid = al.Grid2D.uniform(shape_native=(11, 11), pixel_scales=0.2, over_sample_size=1)
129129

130-
psf = al.Kernel2D.from_gaussian(
130+
psf = al.Convolver.from_gaussian(
131131
shape_native=(3, 3), pixel_scales=0.2, sigma=0.75, normalize=True
132132
)
133133

@@ -235,7 +235,7 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_and_pixelization(
235235

236236
grid = al.Grid2D.uniform(shape_native=(11, 11), pixel_scales=0.2, over_sample_size=1)
237237

238-
psf = al.Kernel2D.from_gaussian(
238+
psf = al.Convolver.from_gaussian(
239239
shape_native=(3, 3), pixel_scales=0.2, sigma=0.75, normalize=True
240240
)
241241

@@ -357,7 +357,7 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_and_pixelization_
357357

358358
grid = al.Grid2D.uniform(shape_native=(11, 11), pixel_scales=0.2, over_sample_size=2)
359359

360-
psf = al.Kernel2D.from_gaussian(
360+
psf = al.Convolver.from_gaussian(
361361
shape_native=(3, 3), pixel_scales=0.2, sigma=0.75, normalize=True
362362
)
363363

@@ -489,7 +489,7 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_and_pixelization_
489489

490490
grid = al.Grid2D.uniform(shape_native=(11, 11), pixel_scales=0.2, over_sample_size=2)
491491

492-
psf = al.Kernel2D.from_gaussian(
492+
psf = al.Convolver.from_gaussian(
493493
shape_native=(3, 3), pixel_scales=0.2, sigma=0.75, normalize=True
494494
)
495495

@@ -645,7 +645,7 @@ def test__simulate_imaging_data_and_fit__complex_fit_compare_mapping_matrix_spar
645645

646646
grid = al.Grid2D.uniform(shape_native=(21, 21), pixel_scales=0.1)
647647

648-
psf = al.Kernel2D.from_gaussian(
648+
psf = al.Convolver.from_gaussian(
649649
shape_native=(3, 3), pixel_scales=0.2, sigma=0.75, normalize=True
650650
)
651651

@@ -748,7 +748,7 @@ def test__fit_figure_of_merit__mge_mass_model(masked_imaging_7x7, masked_imaging
748748
grid = al.Grid2D.uniform(shape_native=(11, 11), pixel_scales=0.2,
749749
over_sample_size=8)
750750

751-
psf = al.Kernel2D.from_gaussian(
751+
psf = al.Convolver.from_gaussian(
752752
shape_native=(3, 3), pixel_scales=0.2, sigma=0.75, normalize=True
753753
)
754754

test_autolens/lens/test_tracer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ def test__light_profile_snr__signal_to_noise_via_simulator_correct():
457457
]
458458
)
459459

460-
psf = al.Kernel2D.no_mask(values=[[1.0]], pixel_scales=1.0)
460+
kernel = al.Array2D.no_mask(values=[[1.0]], pixel_scales=1.0)
461+
psf = al.Convolver(kernel=kernel)
461462

462463
simulator = al.SimulatorImaging(
463464
psf=psf,

0 commit comments

Comments
 (0)