Skip to content

Commit de2f767

Browse files
committed
Begun to implement interferometer at phase level.
1 parent 426116e commit de2f767

15 files changed

Lines changed: 78 additions & 78 deletions

File tree

autoarray/data/imaging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,12 +710,12 @@ def simulate(
710710
image = psf.convolved_array_from_array(array=image)
711711

712712
if image_needs_trimming:
713-
image = image.trimmed_from_kernel_shape(kernel_shape=psf.shape_2d)
713+
image = image.trimmed_from_kernel_shape(kernel_shape_2d=psf.shape_2d)
714714
exposure_time_map = exposure_time_map.trimmed_from_kernel_shape(
715-
kernel_shape=psf.shape_2d
715+
kernel_shape_2d=psf.shape_2d
716716
)
717717
background_sky_map = background_sky_map.trimmed_from_kernel_shape(
718-
kernel_shape=psf.shape_2d
718+
kernel_shape_2d=psf.shape_2d
719719
)
720720

721721
if add_noise is True:

autoarray/mask/regions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ def _sub_border_1d_indexes(self):
6262
).astype("int")
6363

6464
@array_util.Memoizer()
65-
def blurring_mask_from_kernel_shape(self, kernel_shape):
65+
def blurring_mask_from_kernel_shape(self, kernel_shape_2d):
6666
"""Compute a blurring mask, which represents all masked pixels whose light will be blurred into unmasked \
6767
pixels via PSF convolution (see grid.Grid.blurring_grid_from_mask_and_psf_shape).
6868
6969
Parameters
7070
----------
71-
kernel_shape : (int, int)
71+
kernel_shape_2d : (int, int)
7272
The shape of the psf which defines the blurring region (e.g. the shape of the PSF)
7373
"""
7474

75-
if kernel_shape[0] % 2 == 0 or kernel_shape[1] % 2 == 0:
75+
if kernel_shape_2d[0] % 2 == 0 or kernel_shape_2d[1] % 2 == 0:
7676
raise exc.MaskException("psf_size of exterior region must be odd")
7777

7878
blurring_mask = mask_util.blurring_mask_2d_from_mask_2d_and_kernel_shape_2d(
79-
mask_2d=self.mask, kernel_shape_2d=kernel_shape
79+
mask_2d=self.mask, kernel_shape_2d=kernel_shape_2d
8080
)
8181

8282
return msk.Mask(

autoarray/masked/masked_data.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(
4343
self,
4444
imaging,
4545
mask,
46-
trimmed_psf_shape_2d=None,
46+
psf_shape_2d=None,
4747
pixel_scale_interpolation_grid=None,
4848
inversion_pixel_limit=None,
4949
inversion_uses_border=True,
@@ -64,7 +64,7 @@ def __init__(
6464
sub_size : int
6565
The size of the sub-grid used for each lens SubGrid. E.g. a value of 2 grid each image-pixel on a 2x2 \
6666
sub-grid.
67-
trimmed_psf_shape_2d : (int, int)
67+
psf_shape_2d : (int, int)
6868
The shape of the PSF used for convolving model image generated using analytic light profiles. A smaller \
6969
shape will trim the PSF relative to the input image PSF, giving a faster analysis run-time.
7070
positions : [[]]
@@ -98,14 +98,14 @@ def __init__(
9898

9999
if imaging.psf is not None:
100100

101-
if trimmed_psf_shape_2d is None:
102-
self.trimmed_psf_shape_2d = imaging.psf.shape_2d
101+
if psf_shape_2d is None:
102+
self.psf_shape_2d = imaging.psf.shape_2d
103103
else:
104-
self.trimmed_psf_shape_2d = trimmed_psf_shape_2d
104+
self.psf_shape_2d = psf_shape_2d
105105

106106
self.psf = kernel.Kernel.manual_2d(
107107
array=imaging.psf.resized_from_new_shape(
108-
new_shape=self.trimmed_psf_shape_2d
108+
new_shape=self.psf_shape_2d
109109
).in_2d
110110
)
111111

@@ -114,7 +114,7 @@ def __init__(
114114
if mask.pixel_scales is not None:
115115

116116
self.blurring_grid = self.grid.blurring_grid_from_kernel_shape(
117-
kernel_shape=self.trimmed_psf_shape_2d
117+
kernel_shape_2d=self.psf_shape_2d
118118
)
119119

120120
if pixel_scale_interpolation_grid is not None:
@@ -132,15 +132,15 @@ def manual(
132132
cls,
133133
imaging,
134134
mask,
135-
trimmed_psf_shape_2d=None,
135+
psf_shape_2d=None,
136136
pixel_scale_interpolation_grid=None,
137137
inversion_pixel_limit=None,
138138
inversion_uses_border=True,
139139
):
140140
return cls(
141141
imaging=imaging,
142142
mask=mask,
143-
trimmed_psf_shape_2d=trimmed_psf_shape_2d,
143+
psf_shape_2d=psf_shape_2d,
144144
pixel_scale_interpolation_grid=pixel_scale_interpolation_grid,
145145
inversion_pixel_limit=inversion_pixel_limit,
146146
inversion_uses_border=inversion_uses_border,
@@ -161,7 +161,7 @@ def binned_from_bin_up_factor(self, bin_up_factor):
161161
return self.__class__(
162162
imaging=binned_imaging,
163163
mask=binned_mask,
164-
trimmed_psf_shape_2d=self.trimmed_psf_shape_2d,
164+
psf_shape_2d=self.psf_shape_2d,
165165
pixel_scale_interpolation_grid=self.pixel_scale_interpolation_grid,
166166
inversion_pixel_limit=self.inversion_pixel_limit,
167167
inversion_uses_border=self.inversion_uses_border,
@@ -176,7 +176,7 @@ def signal_to_noise_limited_from_signal_to_noise_limit(self, signal_to_noise_lim
176176
return self.__class__(
177177
imaging=imaging_with_signal_to_noise_limit,
178178
mask=self.mask,
179-
trimmed_psf_shape_2d=self.trimmed_psf_shape_2d,
179+
psf_shape_2d=self.psf_shape_2d,
180180
pixel_scale_interpolation_grid=self.pixel_scale_interpolation_grid,
181181
inversion_pixel_limit=self.inversion_pixel_limit,
182182
inversion_uses_border=self.inversion_uses_border,
@@ -188,7 +188,7 @@ def __init__(
188188
self,
189189
interferometer,
190190
real_space_mask,
191-
trimmed_primary_beam_shape_2d=None,
191+
primary_beam_shape_2d=None,
192192
pixel_scale_interpolation_grid=None,
193193
inversion_pixel_limit=None,
194194
inversion_uses_border=True,
@@ -209,7 +209,7 @@ def __init__(
209209
sub_size : int
210210
The size of the sub-grid used for each lens SubGrid. E.g. a value of 2 grid each image-pixel on a 2x2 \
211211
sub-grid.
212-
trimmed_primary_beam_shape_2d : (int, int)
212+
primary_beam_shape_2d : (int, int)
213213
The shape of the primary_beam used for convolving model image generated using analytic light profiles. A smaller \
214214
shape will trim the primary_beam relative to the input image primary_beam, giving a faster analysis run-time.
215215
positions : [[]]
@@ -233,21 +233,21 @@ def __init__(
233233
)
234234

235235
if self.interferometer.primary_beam is None:
236-
self.trimmed_primary_beam_shape_2d = None
236+
self.primary_beam_shape_2d = None
237237
elif (
238-
trimmed_primary_beam_shape_2d is None
239-
and self.interferometer.primary_beam is not None
238+
primary_beam_shape_2d is None
239+
and self.interferometer.primary_beam is not None
240240
):
241-
self.trimmed_primary_beam_shape_2d = (
241+
self.primary_beam_shape_2d = (
242242
self.interferometer.primary_beam.shape_2d
243243
)
244244
else:
245-
self.trimmed_primary_beam_shape_2d = trimmed_primary_beam_shape_2d
245+
self.primary_beam_shape_2d = primary_beam_shape_2d
246246

247-
if self.trimmed_primary_beam_shape_2d is not None:
247+
if self.primary_beam_shape_2d is not None:
248248
self.primary_beam = kernel.Kernel.manual_2d(
249249
array=interferometer.primary_beam.resized_from_new_shape(
250-
new_shape=self.trimmed_primary_beam_shape_2d
250+
new_shape=self.primary_beam_shape_2d
251251
).in_2d
252252
)
253253

@@ -271,15 +271,15 @@ def manual(
271271
cls,
272272
interferometer,
273273
real_space_mask,
274-
trimmed_primary_beam_shape_2d=None,
274+
primary_beam_shape_2d=None,
275275
pixel_scale_interpolation_grid=None,
276276
inversion_pixel_limit=None,
277277
inversion_uses_border=True,
278278
):
279279
return cls(
280280
interferometer,
281281
real_space_mask=real_space_mask,
282-
trimmed_primary_beam_shape_2d=trimmed_primary_beam_shape_2d,
282+
primary_beam_shape_2d=primary_beam_shape_2d,
283283
pixel_scale_interpolation_grid=pixel_scale_interpolation_grid,
284284
inversion_pixel_limit=inversion_pixel_limit,
285285
inversion_uses_border=inversion_uses_border,

autoarray/operators/convolution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def frame_at_coordinates_jit(coordinates, mask, mask_index_array, kernel_2d):
267267
----------
268268
coordinates: (int, int)
269269
The coordinates of mask_index_array on which the frame should be centred
270-
kernel_shape: (int, int)
270+
kernel_shape_2d: (int, int)
271271
The shape of the kernel for which this frame will be used
272272
"""
273273

autoarray/simulator/simulator.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def lsst(
5555
shape=(101, 101),
5656
pixel_scales=0.2,
5757
sub_size=8,
58-
psf_shape=(31, 31),
58+
psf_shape_2d=(31, 31),
5959
psf_sigma=0.5,
6060
exposure_time=100.0,
6161
background_sky_level=1.0,
@@ -67,7 +67,7 @@ def lsst(
6767
6868
This can be customized by over-riding the default input values."""
6969
psf = aa.kernel.from_gaussian(
70-
shape_2d=psf_shape, sigma=psf_sigma, pixel_scales=pixel_scales
70+
shape_2d=psf_shape_2d, sigma=psf_sigma, pixel_scales=pixel_scales
7171
)
7272
return ImagingSimulator(
7373
shape_2d=shape,
@@ -87,7 +87,7 @@ def euclid(
8787
shape=(151, 151),
8888
pixel_scales=0.1,
8989
sub_size=8,
90-
psf_shape=(31, 31),
90+
psf_shape_2d=(31, 31),
9191
psf_sigma=0.1,
9292
exposure_time=565.0,
9393
background_sky_level=1.0,
@@ -99,7 +99,7 @@ def euclid(
9999
100100
This can be customized by over-riding the default input values."""
101101
psf = aa.kernel.from_gaussian(
102-
shape_2d=psf_shape, sigma=psf_sigma, pixel_scales=pixel_scales
102+
shape_2d=psf_shape_2d, sigma=psf_sigma, pixel_scales=pixel_scales
103103
)
104104
return ImagingSimulator(
105105
shape_2d=shape,
@@ -119,7 +119,7 @@ def hst(
119119
shape=(251, 251),
120120
pixel_scales=0.05,
121121
sub_size=8,
122-
psf_shape=(31, 31),
122+
psf_shape_2d=(31, 31),
123123
psf_sigma=0.05,
124124
exposure_time=2000.0,
125125
background_sky_level=1.0,
@@ -131,7 +131,7 @@ def hst(
131131
132132
This can be customized by over-riding the default input values."""
133133
psf = aa.kernel.from_gaussian(
134-
shape_2d=psf_shape, sigma=psf_sigma, pixel_scales=pixel_scales
134+
shape_2d=psf_shape_2d, sigma=psf_sigma, pixel_scales=pixel_scales
135135
)
136136
return ImagingSimulator(
137137
shape_2d=shape,
@@ -151,7 +151,7 @@ def hst_up_sampled(
151151
shape=(401, 401),
152152
pixel_scales=0.03,
153153
sub_size=8,
154-
psf_shape=(31, 31),
154+
psf_shape_2d=(31, 31),
155155
psf_sigma=0.05,
156156
exposure_time=2000.0,
157157
background_sky_level=1.0,
@@ -164,7 +164,7 @@ def hst_up_sampled(
164164
165165
This can be customized by over-riding the default input values."""
166166
psf = aa.kernel.from_gaussian(
167-
shape_2d=psf_shape, sigma=psf_sigma, pixel_scales=pixel_scales
167+
shape_2d=psf_shape_2d, sigma=psf_sigma, pixel_scales=pixel_scales
168168
)
169169
return ImagingSimulator(
170170
shape_2d=shape,
@@ -184,7 +184,7 @@ def keck_adaptive_optics(
184184
shape=(751, 751),
185185
pixel_scales=0.01,
186186
sub_size=8,
187-
psf_shape=(31, 31),
187+
psf_shape_2d=(31, 31),
188188
psf_sigma=0.025,
189189
exposure_time=1000.0,
190190
background_sky_level=1.0,
@@ -196,7 +196,7 @@ def keck_adaptive_optics(
196196
197197
This can be customized by over-riding the default input values."""
198198
psf = aa.kernel.from_gaussian(
199-
shape_2d=psf_shape, sigma=psf_sigma, pixel_scales=pixel_scales
199+
shape_2d=psf_shape_2d, sigma=psf_sigma, pixel_scales=pixel_scales
200200
)
201201
return ImagingSimulator(
202202
shape_2d=shape,

autoarray/structures/arrays.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ def resized_from_new_shape(self, new_shape):
148148

149149
return resized_mask_2d.mapping.array_from_array_2d(array_2d=resized_array_2d)
150150

151-
def trimmed_from_kernel_shape(self, kernel_shape):
152-
psf_cut_y = np.int(np.ceil(kernel_shape[0] / 2)) - 1
153-
psf_cut_x = np.int(np.ceil(kernel_shape[1] / 2)) - 1
151+
def trimmed_from_kernel_shape(self, kernel_shape_2d):
152+
psf_cut_y = np.int(np.ceil(kernel_shape_2d[0] / 2)) - 1
153+
psf_cut_x = np.int(np.ceil(kernel_shape_2d[1] / 2)) - 1
154154
array_y = np.int(self.mask.shape[0])
155155
array_x = np.int(self.mask.shape[1])
156156
trimmed_array_2d = self.in_2d[

autoarray/structures/grids.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ def in_1d_binned(self):
178178
def in_2d_binned(self):
179179
return self.mask.mapping.grid_2d_binned_from_sub_grid_1d(sub_grid_1d=self)
180180

181-
def blurring_grid_from_kernel_shape(self, kernel_shape):
181+
def blurring_grid_from_kernel_shape(self, kernel_shape_2d):
182182

183183
blurring_mask = self.mask.regions.blurring_mask_from_kernel_shape(
184-
kernel_shape=kernel_shape
184+
kernel_shape_2d=kernel_shape_2d
185185
)
186186

187187
blurring_grid_1d = grid_util.grid_1d_via_mask_2d(
@@ -314,11 +314,11 @@ def relocated_grid_from_grid_jit(grid, border_grid):
314314

315315
return grid
316316

317-
def padded_grid_from_kernel_shape(self, kernel_shape):
317+
def padded_grid_from_kernel_shape(self, kernel_shape_2d):
318318

319319
shape = self.mask.shape
320320

321-
padded_shape = (shape[0] + kernel_shape[0] - 1, shape[1] + kernel_shape[1] - 1)
321+
padded_shape = (shape[0] + kernel_shape_2d[0] - 1, shape[1] + kernel_shape_2d[1] - 1)
322322

323323
padded_mask = msk.Mask.unmasked(
324324
shape_2d=padded_shape,
@@ -524,7 +524,7 @@ def from_sub_grid_2d_and_mask(cls, sub_grid_2d, mask):
524524
return mask.mapping.grid_from_sub_grid_2d(sub_grid_2d=sub_grid_2d)
525525

526526
@classmethod
527-
def blurring_grid_from_mask_and_kernel_shape(cls, mask, kernel_shape):
527+
def blurring_grid_from_mask_and_kernel_shape(cls, mask, kernel_shape_2d):
528528
"""Setup a blurring-grid from a mask, where a blurring grid consists of all pixels that are masked, but they \
529529
are close enough to the unmasked pixels that a fraction of their light will be blurred into those pixels \
530530
via PSF convolution. For example, if our mask is as follows:
@@ -584,7 +584,7 @@ def blurring_grid_from_mask_and_kernel_shape(cls, mask, kernel_shape):
584584
"""
585585

586586
blurring_mask = mask.regions.blurring_mask_from_kernel_shape(
587-
kernel_shape=kernel_shape
587+
kernel_shape_2d=kernel_shape_2d
588588
)
589589

590590
blurring_grid_1d = grid_util.grid_1d_via_mask_2d(

autoarray/util/mask_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def blurring_mask_2d_from_mask_2d_and_kernel_shape_2d(mask_2d, kernel_shape_2d):
447447
[True, False, True]
448448
[True, True, True]])
449449
450-
blurring_mask = blurring_mask_from_mask_and_psf_shape(mask=mask, psf_shape=(3,3))
450+
blurring_mask = blurring_mask_from_mask_and_psf_shape(mask=mask, psf_shape_2d=(3,3))
451451
452452
"""
453453

@@ -895,7 +895,7 @@ def sub_mask_2d_index_for_sub_mask_1d_index_via_mask_2d(mask_2d, sub_size):
895895
[True, False, True]
896896
[True, True, True]])
897897
898-
blurring_mask = blurring_mask_from_mask_and_psf_shape(mask=mask, psf_shape=(3,3))
898+
blurring_mask = blurring_mask_from_mask_and_psf_shape(mask=mask, psf_shape_2d=(3,3))
899899
900900
"""
901901

test_autoarray/mock/mock_mask.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ def __init__(
3939
):
4040
pass
4141

42-
def blurring_mask_from_kernel_shape(self, kernel_shape):
42+
def blurring_mask_from_kernel_shape(self, kernel_shape_2d):
4343
"""Compute a blurring mask, which represents all masked pixels whose light will be blurred into unmasked \
4444
pixels via PSF convolution (see grid.Grid.blurring_grid_from_mask_and_psf_shape).
4545
4646
Parameters
4747
----------
48-
kernel_shape : (int, int)
48+
kernel_shape_2d : (int, int)
4949
The shape of the psf which defines the blurring region (e.aa. the shape of the PSF)
5050
"""
5151

52-
if kernel_shape[0] % 2 == 0 or kernel_shape[1] % 2 == 0:
52+
if kernel_shape_2d[0] % 2 == 0 or kernel_shape_2d[1] % 2 == 0:
5353
raise exc.MaskException("psf_size of exterior region must be odd")
5454

5555
blurring_mask = mask_util.blurring_mask_2d_from_mask_2d_and_kernel_shape_2d(
56-
self, kernel_shape
56+
self, kernel_shape_2d
5757
)
5858

5959
return MockMask(mask_2d=blurring_mask, pixel_scales=self.pixel_scales)

test_autoarray/unit/mask/test_regions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test__blurring_mask_for_psf_shape__compare_to_array_util(self):
6161
)
6262

6363
blurring_mask = mask.regions.blurring_mask_from_kernel_shape(
64-
kernel_shape=(3, 3)
64+
kernel_shape_2d=(3, 3)
6565
)
6666

6767
assert (blurring_mask == blurring_mask_via_util).all()

0 commit comments

Comments
 (0)