Skip to content

Commit 9d1e5c8

Browse files
committed
Got test in phase passing, now going to make decorator for pixel scale conversion
1 parent 925fb32 commit 9d1e5c8

4 files changed

Lines changed: 59 additions & 30 deletions

File tree

autoarray/data/imaging.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def pixel_scale(self):
3131
def shape(self):
3232
return self.image.shape_2d
3333

34+
@property
35+
def shape_2d(self):
36+
return self.image.shape_2d
37+
3438
def binned_from_bin_up_factor(self, bin_up_factor):
3539

3640
image = self.image.binned_from_bin_up_factor(

autoarray/mask/mask.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ def circular(cls, shape_2d, radius_arcsec, pixel_scales, sub_size=1, origin=(0.0
9191
centre: (float, float)
9292
The centre of the circle used to mask pixels.
9393
"""
94+
95+
if type(pixel_scales) is not tuple:
96+
if type(pixel_scales) is float or int:
97+
pixel_scales = (float(pixel_scales), float(pixel_scales))
98+
9499
mask_2d = mask_util.mask_2d_circular_from_shape_2d_pixel_scales_and_radius(
95100
shape_2d=shape_2d,
96101
pixel_scales=pixel_scales,
@@ -121,6 +126,10 @@ def circular_annular(cls, shape_2d, inner_radius_arcsec, outer_radius_arcsec, pi
121126
centre: (float, float)
122127
The centre of the annulus used to mask pixels.
123128
"""
129+
130+
if type(pixel_scales) is float:
131+
pixel_scales = (pixel_scales, pixel_scales)
132+
124133
mask_2d = mask_util.mask_2d_circular_annular_from_shape_2d_pixel_scales_and_radii(
125134
shape_2d=shape_2d,
126135
pixel_scales=pixel_scales,
@@ -160,6 +169,10 @@ def circular_anti_annular(cls, shape_2d, inner_radius_arcsec, outer_radius_arcse
160169
centre: (float, float)
161170
The centre of the anti-annulus used to mask pixels.
162171
"""
172+
173+
if type(pixel_scales) is float:
174+
pixel_scales = (pixel_scales, pixel_scales)
175+
163176
mask_2d = mask_util.mask_2d_circular_anti_annular_from_shape_2d_pixel_scales_and_radii(
164177
shape_2d=shape_2d,
165178
pixel_scales=pixel_scales,
@@ -196,6 +209,10 @@ def elliptical(cls, shape_2d,
196209
centre: (float, float)
197210
The centre of the ellipse used to mask pixels.
198211
"""
212+
213+
if type(pixel_scales) is float:
214+
pixel_scales = (pixel_scales, pixel_scales)
215+
199216
mask_2d = mask_util.mask_2d_elliptical_from_shape_2d_pixel_scales_and_radius(
200217
shape_2d=shape_2d,
201218
pixel_scales=pixel_scales,
@@ -243,6 +260,10 @@ def elliptical_annular(cls, shape_2d,
243260
centre: (float, float)
244261
The centre of the elliptical annuli used to mask pixels.
245262
"""
263+
264+
if type(pixel_scales) is float:
265+
pixel_scales = (pixel_scales, pixel_scales)
266+
246267
mask_2d = mask_util.mask_2d_elliptical_annular_from_shape_2d_pixel_scales_and_radius(
247268
shape_2d=shape_2d,
248269
pixel_scales=pixel_scales,
@@ -273,6 +294,10 @@ def from_fits(cls, file_path, hdu, pixel_scales, sub_size, origin=(0.0, 0.0)):
273294
pixel_scales : (float, float)
274295
The arc-second to pixel conversion factor of each pixel.
275296
"""
297+
298+
if type(pixel_scales) is float:
299+
pixel_scales = (pixel_scales, pixel_scales)
300+
276301
return cls(
277302
array_util.numpy_array_2d_from_fits(file_path=file_path, hdu=hdu),
278303
pixel_scales=pixel_scales,

test_autoarray/mock/mock_data.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,44 @@
66

77

88
class MockImage(object):
9-
def __new__(cls, shape, value, pixel_scales=1.0):
10-
return aa.array.manual_2d(
11-
array=value * np.ones(shape=shape), pixel_scales=pixel_scales
9+
def __new__(cls, shape_2d, value, pixel_scales=1.0):
10+
return aa.array.full(
11+
fill_value=value, shape_2d=shape_2d, pixel_scales=pixel_scales
1212
)
1313

1414

1515
class MockNoiseMap(object):
16-
def __new__(cls, shape, value, pixel_scales=1.0):
17-
return aa.array.manual_2d(
18-
array=value * np.ones(shape=shape), pixel_scales=pixel_scales
16+
def __new__(cls, shape_2d, value, pixel_scales=1.0):
17+
return aa.array.full(
18+
fill_value=value, shape_2d=shape_2d, pixel_scales=pixel_scales
1919
)
2020

2121

2222
class MockBackgroundNoiseMap(object):
23-
def __new__(cls, shape, value, pixel_scales=1.0):
24-
return aa.array.manual_2d(
25-
array=value * np.ones(shape=shape), pixel_scales=pixel_scales
23+
def __new__(cls, shape_2d, value, pixel_scales=1.0):
24+
return aa.array.full(
25+
fill_value=value, shape_2d=shape_2d, pixel_scales=pixel_scales
2626
)
2727

2828

2929
class MockPoissonNoiseMap(object):
30-
def __new__(cls, shape, value, pixel_scales=1.0):
31-
return aa.array.manual_2d(
32-
array=value * np.ones(shape=shape), pixel_scales=pixel_scales
30+
def __new__(cls, shape_2d, value, pixel_scales=1.0):
31+
return aa.array.full(
32+
fill_value=value, shape_2d=shape_2d, pixel_scales=pixel_scales
3333
)
3434

3535

3636
class MockExposureTimeMap(object):
37-
def __new__(cls, shape, value, pixel_scales=1.0):
38-
return aa.array.manual_2d(
39-
array=value * np.ones(shape=shape), pixel_scales=pixel_scales
37+
def __new__(cls, shape_2d, value, pixel_scales=1.0):
38+
return aa.array.full(
39+
fill_value=value, shape_2d=shape_2d, pixel_scales=pixel_scales
4040
)
4141

4242

4343
class MockBackgrondSkyMap(object):
44-
def __new__(cls, shape, value, pixel_scales=1.0):
45-
return aa.array.manual_2d(
46-
array=value * np.ones(shape=shape), pixel_scales=pixel_scales
44+
def __new__(cls, shape_2d, value, pixel_scales=1.0):
45+
return aa.array.full(
46+
fill_value=value, shape_2d=shape_2d, pixel_scales=pixel_scales
4747
)
4848

4949

test_autoarray/unit/conftest.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def make_convolver_7x7(mask_7x7, blurring_mask_7x7, psf_3x3):
145145

146146
@pytest.fixture(name="image_7x7")
147147
def make_image_7x7():
148-
return mock_data.MockImage(shape=(7, 7), value=1.0)
148+
return mock_data.MockImage(shape_2d=(7, 7), value=1.0)
149149

150150

151151
@pytest.fixture(name="psf_3x3")
@@ -155,27 +155,27 @@ def make_psf_3x3():
155155

156156
@pytest.fixture(name="noise_map_7x7")
157157
def make_noise_map_7x7():
158-
return mock_data.MockNoiseMap(shape=(7, 7), value=2.0)
158+
return mock_data.MockNoiseMap(shape_2d=(7, 7), value=2.0)
159159

160160

161161
@pytest.fixture(name="background_noise_map_7x7")
162162
def make_background_noise_map_7x7():
163-
return mock_data.MockBackgroundNoiseMap(shape=(7, 7), value=3.0)
163+
return mock_data.MockBackgroundNoiseMap(shape_2d=(7, 7), value=3.0)
164164

165165

166166
@pytest.fixture(name="poisson_noise_map_7x7")
167167
def make_poisson_noise_map_7x7():
168-
return mock_data.MockPoissonNoiseMap(shape=(7, 7), value=4.0)
168+
return mock_data.MockPoissonNoiseMap(shape_2d=(7, 7), value=4.0)
169169

170170

171171
@pytest.fixture(name="exposure_time_map_7x7")
172172
def make_exposure_time_map_7x7():
173-
return mock_data.MockExposureTimeMap(shape=(7, 7), value=5.0)
173+
return mock_data.MockExposureTimeMap(shape_2d=(7, 7), value=5.0)
174174

175175

176176
@pytest.fixture(name="background_sky_map_7x7")
177177
def make_background_sky_map_7x7():
178-
return mock_data.MockBackgrondSkyMap(shape=(7, 7), value=6.0)
178+
return mock_data.MockBackgrondSkyMap(shape_2d=(7, 7), value=6.0)
179179

180180

181181
@pytest.fixture(name="positions_7x7")
@@ -209,13 +209,13 @@ def make_imaging_7x7(
209209

210210
@pytest.fixture(name="imaging_6x6")
211211
def make_imaging_6x6():
212-
image = mock_data.MockImage(shape=(6, 6), value=1.0)
212+
image = mock_data.MockImage(shape_2d=(6, 6), value=1.0)
213213
psf = mock_data.MockPSF(shape_2d=(3, 3), value=1.0)
214-
noise_map = mock_data.MockNoiseMap(shape=(6, 6), value=2.0)
215-
background_noise_map = mock_data.MockBackgroundNoiseMap(shape=(6, 6), value=3.0)
216-
poisson_noise_map = mock_data.MockPoissonNoiseMap(shape=(6, 6), value=4.0)
217-
exposure_time_map = mock_data.MockExposureTimeMap(shape=(6, 6), value=5.0)
218-
background_sky_map = mock_data.MockBackgrondSkyMap(shape=(6, 6), value=6.0)
214+
noise_map = mock_data.MockNoiseMap(shape_2d=(6, 6), value=2.0)
215+
background_noise_map = mock_data.MockBackgroundNoiseMap(shape_2d=(6, 6), value=3.0)
216+
poisson_noise_map = mock_data.MockPoissonNoiseMap(shape_2d=(6, 6), value=4.0)
217+
exposure_time_map = mock_data.MockExposureTimeMap(shape_2d=(6, 6), value=5.0)
218+
background_sky_map = mock_data.MockBackgrondSkyMap(shape_2d=(6, 6), value=6.0)
219219

220220
return mock_data.MockImaging(
221221
image=image,

0 commit comments

Comments
 (0)