Skip to content

Commit 4216c2e

Browse files
committed
Reverted, switching back to toy
1 parent 5fb8793 commit 4216c2e

38 files changed

Lines changed: 1234 additions & 1166 deletions

autoarray/dataset/imaging.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
logger = logging.getLogger(__name__)
1414

1515

16-
class AbstractImagingSet(abstract_dataset.AbstractDataset):
16+
class AbstractImagingDataSet(abstract_dataset.AbstractDataset):
1717
@property
1818
def image(self):
1919
return self.data
@@ -331,7 +331,9 @@ def output_to_fits(
331331
overwrite=False,
332332
):
333333
self.image.output_to_fits(file_path=image_path, overwrite=overwrite)
334-
self.psf.output_to_fits(file_path=psf_path, overwrite=overwrite)
334+
335+
if self.psf is not None and psf_path is not None:
336+
self.psf.output_to_fits(file_path=psf_path, overwrite=overwrite)
335337

336338
if self.noise_map is not None and noise_map_path is not None:
337339
self.noise_map.output_to_fits(file_path=noise_map_path, overwrite=overwrite)
@@ -360,7 +362,7 @@ def output_to_fits(
360362
)
361363

362364

363-
class Imaging(AbstractImagingSet):
365+
class Imaging(AbstractImagingDataSet):
364366
def __init__(
365367
self,
366368
image,
@@ -464,9 +466,9 @@ def from_fits(
464466
lens_name=None,
465467
):
466468
"""Factory for loading the imaging data_type from .fits files, as well as computing properties like the noise-map,
467-
exposure-time map, etc. from the imaging-simulator.
469+
exposure-time map, etc. from the imaging-data.
468470
469-
This factory also includes a number of routines for converting the imaging-simulator from units not supported by PyAutoLens \
471+
This factory also includes a number of routines for converting the imaging-data from units not supported by PyAutoLens \
470472
(e.g. adus, electrons) to electrons per second.
471473
472474
Parameters
@@ -659,7 +661,7 @@ def simulate(
659661
exposure_time,
660662
psf=None,
661663
exposure_time_map=None,
662-
background_sky_level=0.0,
664+
background_level=0.0,
663665
background_sky_map=None,
664666
add_noise=True,
665667
noise_if_add_noise_false=0.1,
@@ -702,7 +704,7 @@ def simulate(
702704

703705
if background_sky_map is None:
704706
background_sky_map = arrays.Array.full(
705-
fill_value=background_sky_level, shape_2d=image.shape_2d
707+
fill_value=background_level, shape_2d=image.shape_2d
706708
)
707709

708710
image += background_sky_map
@@ -730,7 +732,7 @@ def simulate(
730732
)
731733
else:
732734
noise_map = arrays.Array.full(
733-
fill_value=noise_if_add_noise_false, shape_2d=image.shape_2d
735+
fill_value=noise_if_add_noise_false, shape_2d=image.shape_2d, pixel_scales=image.pixel_scales
734736
)
735737
noise_realization = None
736738

autoarray/dataset/interferometer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def simulate(
273273
transformer,
274274
primary_beam=None,
275275
exposure_time_map=None,
276-
background_sky_level=0.0,
276+
background_level=0.0,
277277
background_sky_map=None,
278278
noise_sigma=None,
279279
noise_if_add_noise_false=0.1,
@@ -316,7 +316,7 @@ def simulate(
316316
if background_sky_map is None:
317317

318318
background_sky_map = aa.array.full(
319-
fill_value=background_sky_level,
319+
fill_value=background_level,
320320
shape_2d=real_space_image.shape_2d,
321321
pixel_scales=real_space_pixel_scales,
322322
)

autoarray/exc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ class ArrayException(Exception):
22
pass
33

44

5-
class ScaledException(Exception):
6-
pass
7-
8-
95
class GridException(Exception):
106
pass
117

@@ -14,7 +10,7 @@ class KernelException(Exception):
1410
pass
1511

1612

17-
class ConvolutionException(Exception):
13+
class ConvolverException(Exception):
1814
pass
1915

2016

@@ -36,3 +32,7 @@ class PixelizationException(Exception):
3632

3733
class InversionException(Exception):
3834
pass
35+
36+
37+
class PlottingException(Exception):
38+
pass

autoarray/fit/fit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from autoarray.masked import masked_dataset as md
44
from autoarray.util import fit_util
55

6+
def fit_masked_dataset(masked_dataset, model_data, inversion=None):
7+
return fit(masked_dataset=masked_dataset, model_data=model_data, inversion=inversion)
68

79
def fit(masked_dataset, model_data, inversion=None):
810
if isinstance(masked_dataset, md.MaskedImaging):

autoarray/mask/geometry.py

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ def central_pixel_coordinates(self):
2727
def origin(self):
2828
return self.mask.origin
2929

30-
def pixel_coordinates_from_arcsec_coordinates(self, arcsec_coordinates):
30+
def pixel_coordinates_from_scaled_coordinates(self, scaled_coordinates):
3131
return (
3232
int(
3333
(
34-
(-arcsec_coordinates[0] + self.mask.origin[0])
34+
(-scaled_coordinates[0] + self.mask.origin[0])
3535
/ self.mask.pixel_scales[0]
3636
)
3737
+ self.central_pixel_coordinates[0]
3838
+ 0.5
3939
),
4040
int(
4141
(
42-
(arcsec_coordinates[1] - self.mask.origin[1])
42+
(scaled_coordinates[1] - self.mask.origin[1])
4343
/ self.mask.pixel_scales[1]
4444
)
4545
+ self.central_pixel_coordinates[1]
@@ -53,46 +53,46 @@ def mask_centre(self):
5353
return grid_util.grid_centre_from_grid_1d(grid_1d=self.masked_grid)
5454

5555
@property
56-
def shape_2d_arcsec(self):
56+
def shape_2d_scaled(self):
5757
return (
5858
float(self.mask.pixel_scales[0] * self.mask.shape[0]),
5959
float(self.mask.pixel_scales[1] * self.mask.shape[1]),
6060
)
6161

6262
@property
63-
def arc_second_maxima(self):
63+
def scaled_maxima(self):
6464
return (
65-
(self.shape_2d_arcsec[0] / 2.0) + self.mask.origin[0],
66-
(self.shape_2d_arcsec[1] / 2.0) + self.mask.origin[1],
65+
(self.shape_2d_scaled[0] / 2.0) + self.mask.origin[0],
66+
(self.shape_2d_scaled[1] / 2.0) + self.mask.origin[1],
6767
)
6868

6969
@property
70-
def arc_second_minima(self):
70+
def scaled_minima(self):
7171
return (
72-
(-(self.shape_2d_arcsec[0] / 2.0)) + self.mask.origin[0],
73-
(-(self.shape_2d_arcsec[1] / 2.0)) + self.mask.origin[1],
72+
(-(self.shape_2d_scaled[0] / 2.0)) + self.mask.origin[0],
73+
(-(self.shape_2d_scaled[1] / 2.0)) + self.mask.origin[1],
7474
)
7575

7676
@property
7777
def extent(self):
7878
return np.asarray(
7979
[
80-
self.arc_second_minima[1],
81-
self.arc_second_maxima[1],
82-
self.arc_second_minima[0],
83-
self.arc_second_maxima[0],
80+
self.scaled_minima[1],
81+
self.scaled_maxima[1],
82+
self.scaled_minima[0],
83+
self.scaled_maxima[0],
8484
]
8585
)
8686

8787
@property
8888
def yticks(self):
8989
"""Compute the yticks labels of this grid, used for plotting the y-axis ticks when visualizing an image-grid"""
90-
return np.linspace(self.arc_second_minima[0], self.arc_second_maxima[0], 4)
90+
return np.linspace(self.scaled_minima[0], self.scaled_maxima[0], 4)
9191

9292
@property
9393
def xticks(self):
9494
"""Compute the xticks labels of this grid, used for plotting the x-axis ticks when visualizing an image-grid"""
95-
return np.linspace(self.arc_second_minima[1], self.arc_second_maxima[1], 4)
95+
return np.linspace(self.scaled_minima[1], self.scaled_maxima[1], 4)
9696

9797
@property
9898
def unmasked_grid(self):
@@ -143,7 +143,7 @@ def border_grid(self):
143143
grid_1d=border_grid_1d
144144
)
145145

146-
def grid_pixels_from_grid_arcsec(self, grid_arcsec_1d):
146+
def grid_pixels_from_grid_scaled_1d(self, grid_scaled_1d):
147147
"""Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel values. Pixel coordinates are \
148148
returned as floats such that they include the decimal offset from each pixel's top-left corner.
149149
@@ -155,18 +155,18 @@ def grid_pixels_from_grid_arcsec(self, grid_arcsec_1d):
155155
156156
Parameters
157157
----------
158-
grid_arcsec_1d: ndarray
158+
grid_scaled_1d: ndarray
159159
A grid of (y,x) coordinates in arc seconds.
160160
"""
161-
grid_pixels_1d = grid_util.grid_pixels_1d_from_grid_arcsec_1d_shape_2d_and_pixel_scales(
162-
grid_arcsec_1d=grid_arcsec_1d,
161+
grid_pixels_1d = grid_util.grid_pixels_1d_from_grid_scaled_1d_shape_2d_and_pixel_scales(
162+
grid_scaled_1d=grid_scaled_1d,
163163
shape_2d=self.mask.shape,
164164
pixel_scales=self.mask.pixel_scales,
165165
origin=self.mask.origin,
166166
)
167167
return self.mask.mapping.grid_from_grid_1d(grid_1d=grid_pixels_1d)
168168

169-
def grid_pixel_centres_from_grid_arcsec_1d(self, grid_arcsec_1d):
169+
def grid_pixel_centres_from_grid_scaled_1d(self, grid_scaled_1d):
170170
"""Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel values. Pixel coordinates are \
171171
returned as integers such that they map directly to the pixel they are contained within.
172172
@@ -178,11 +178,11 @@ def grid_pixel_centres_from_grid_arcsec_1d(self, grid_arcsec_1d):
178178
179179
Parameters
180180
----------
181-
grid_arcsec_1d: ndarray
181+
grid_scaled_1d: ndarray
182182
The grid of (y,x) coordinates in arc seconds.
183183
"""
184-
grid_pixel_centres_1d = grid_util.grid_pixel_centres_1d_from_grid_arcsec_1d_shape_2d_and_pixel_scales(
185-
grid_arcsec_1d=grid_arcsec_1d,
184+
grid_pixel_centres_1d = grid_util.grid_pixel_centres_1d_from_grid_scaled_1d_shape_2d_and_pixel_scales(
185+
grid_scaled_1d=grid_scaled_1d,
186186
shape_2d=self.mask.shape,
187187
pixel_scales=self.mask.pixel_scales,
188188
origin=self.mask.origin,
@@ -191,7 +191,7 @@ def grid_pixel_centres_from_grid_arcsec_1d(self, grid_arcsec_1d):
191191
)
192192
return self.mask.mapping.grid_from_grid_1d(grid_1d=grid_pixel_centres_1d)
193193

194-
def grid_pixel_indexes_from_grid_arcsec_1d(self, grid_arcsec_1d):
194+
def grid_pixel_indexes_from_grid_scaled_1d(self, grid_scaled_1d):
195195
"""Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel 1D indexes. Pixel coordinates are \
196196
returned as integers such that they are the pixel from the top-left of the 2D grid going rights and then \
197197
downwards.
@@ -207,11 +207,11 @@ def grid_pixel_indexes_from_grid_arcsec_1d(self, grid_arcsec_1d):
207207
208208
Parameters
209209
----------
210-
grid_arcsec_1d: ndarray
210+
grid_scaled_1d: ndarray
211211
The grid of (y,x) coordinates in arc seconds.
212212
"""
213-
grid_pixel_indexes_1d = grid_util.grid_pixel_indexes_1d_from_grid_arcsec_1d_shape_2d_and_pixel_scales(
214-
grid_arcsec_1d=grid_arcsec_1d,
213+
grid_pixel_indexes_1d = grid_util.grid_pixel_indexes_1d_from_grid_scaled_1d_shape_2d_and_pixel_scales(
214+
grid_scaled_1d=grid_scaled_1d,
215215
shape_2d=self.mask.shape,
216216
pixel_scales=self.mask.pixel_scales,
217217
origin=self.mask.origin,
@@ -220,7 +220,7 @@ def grid_pixel_indexes_from_grid_arcsec_1d(self, grid_arcsec_1d):
220220
)
221221
return self.mask.mapping.grid_from_grid_1d(grid_1d=grid_pixel_indexes_1d)
222222

223-
def grid_arcsec_from_grid_pixels_1d(self, grid_pixels_1d):
223+
def grid_scaled_from_grid_pixels_1d(self, grid_pixels_1d):
224224
"""Convert a grid of (y,x) pixel coordinates to a grid of (y,x) arc second values.
225225
226226
The pixel coordinate origin is at the top left corner of the grid, such that the pixel [0,0] corresponds to \
@@ -234,23 +234,23 @@ def grid_arcsec_from_grid_pixels_1d(self, grid_pixels_1d):
234234
grid_pixels_1d : ndarray
235235
The grid of (y,x) coordinates in pixels.
236236
"""
237-
grid_arcsec_1d = grid_util.grid_arcsec_1d_from_grid_pixels_1d_shape_2d_and_pixel_scales(
237+
grid_scaled_1d = grid_util.grid_scaled_1d_from_grid_pixels_1d_shape_2d_and_pixel_scales(
238238
grid_pixels_1d=grid_pixels_1d,
239239
shape_2d=self.mask.shape,
240240
pixel_scales=self.mask.pixel_scales,
241241
origin=self.mask.origin,
242242
)
243-
return self.mask.mapping.grid_from_grid_1d(grid_1d=grid_arcsec_1d)
243+
return self.mask.mapping.grid_from_grid_1d(grid_1d=grid_scaled_1d)
244244

245245
@property
246246
def sub_size(self):
247247
return self.mask.sub_size
248248

249-
def grid_arcsec_from_grid_pixels_1d_for_marching_squares(
249+
def grid_scaled_from_grid_pixels_1d_for_marching_squares(
250250
self, grid_pixels_1d, shape_2d
251251
):
252252

253-
grid_arcsec_1d = grid_util.grid_arcsec_1d_from_grid_pixels_1d_shape_2d_and_pixel_scales(
253+
grid_scaled_1d = grid_util.grid_scaled_1d_from_grid_pixels_1d_shape_2d_and_pixel_scales(
254254
grid_pixels_1d=grid_pixels_1d,
255255
shape_2d=shape_2d,
256256
pixel_scales=(
@@ -260,10 +260,10 @@ def grid_arcsec_from_grid_pixels_1d_for_marching_squares(
260260
origin=self.mask.origin,
261261
)
262262

263-
grid_arcsec_1d[:, 0] -= self.mask.pixel_scales[0] / (2.0 * self.mask.sub_size)
264-
grid_arcsec_1d[:, 1] += self.mask.pixel_scales[1] / (2.0 * self.mask.sub_size)
263+
grid_scaled_1d[:, 0] -= self.mask.pixel_scales[0] / (2.0 * self.mask.sub_size)
264+
grid_scaled_1d[:, 1] += self.mask.pixel_scales[1] / (2.0 * self.mask.sub_size)
265265

266-
return self.mask.mapping.grid_from_grid_1d(grid_1d=grid_arcsec_1d)
266+
return self.mask.mapping.grid_from_grid_1d(grid_1d=grid_scaled_1d)
267267

268268
@property
269269
def masked_sub_grid(self):
@@ -286,8 +286,8 @@ def sub_border_grid_1d(self):
286286
@property
287287
def _zoom_centre(self):
288288

289-
extraction_grid_1d = self.mask.geometry.grid_pixels_from_grid_arcsec(
290-
grid_arcsec_1d=self.masked_grid.in_1d
289+
extraction_grid_1d = self.mask.geometry.grid_pixels_from_grid_scaled_1d(
290+
grid_scaled_1d=self.masked_grid.in_1d
291291
)
292292
y_pixels_max = np.max(extraction_grid_1d[:, 0])
293293
y_pixels_min = np.min(extraction_grid_1d[:, 0])
@@ -311,7 +311,7 @@ def _zoom_offset_pixels(self):
311311
)
312312

313313
@property
314-
def _zoom_offset_arcsec(self):
314+
def _zoom_offset_scaled(self):
315315

316316
return (
317317
-self.mask.pixel_scales[0] * self._zoom_offset_pixels[0],

0 commit comments

Comments
 (0)