Skip to content

Commit 1b1a59c

Browse files
Jammy2211Jammy2211
authored andcommitted
resolve a conflict
2 parents c226c2d + 06ba8e3 commit 1b1a59c

238 files changed

Lines changed: 7248 additions & 9845 deletions

File tree

Some content is hidden

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

autoarray/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
from autoconf.dictable import register_parser
2+
from autoconf import conf
3+
4+
conf.instance.register(__file__)
5+
16
from . import exc
27
from . import type
38
from . import util
49
from . import fixtures
510
from . import mock as m
6-
from .numba_util import profile_func
7-
from .preloads import Preloads
811
from .dataset import preprocess
912
from .dataset.abstract.dataset import AbstractDataset
1013
from .dataset.abstract.w_tilde import AbstractWTilde
@@ -39,13 +42,13 @@
3942
from .inversion.pixelization.mappers.rectangular import MapperRectangular
4043
from .inversion.pixelization.mappers.delaunay import MapperDelaunay
4144
from .inversion.pixelization.mappers.voronoi import MapperVoronoi
45+
from .inversion.pixelization.mappers.rectangular_uniform import MapperRectangularUniform
4246
from .inversion.pixelization.image_mesh.abstract import AbstractImageMesh
4347
from .inversion.pixelization.mesh.abstract import AbstractMesh
4448
from .inversion.inversion.imaging.mapping import InversionImagingMapping
4549
from .inversion.inversion.imaging.w_tilde import InversionImagingWTilde
4650
from .inversion.inversion.interferometer.w_tilde import InversionInterferometerWTilde
4751
from .inversion.inversion.interferometer.mapping import InversionInterferometerMapping
48-
from .inversion.inversion.interferometer.lop import InversionInterferometerMappingPyLops
4952
from .inversion.linear_obj.linear_obj import LinearObj
5053
from .inversion.linear_obj.func_list import AbstractLinearObjFuncList
5154
from .mask.derive.indexes_2d import DeriveIndexes2D
@@ -64,6 +67,7 @@
6467
from .operators.contour import Grid2DContour
6568
from .layout.layout import Layout1D
6669
from .layout.layout import Layout2D
70+
from .preloads import Preloads
6771
from .structures.arrays.uniform_1d import Array1D
6872
from .structures.arrays.uniform_2d import Array2D
6973
from .structures.arrays.rgb import Array2DRGB
@@ -73,6 +77,7 @@
7377
from .operators.over_sampling.over_sampler import OverSampler
7478
from .structures.grids.irregular_2d import Grid2DIrregular
7579
from .structures.mesh.rectangular_2d import Mesh2DRectangular
80+
from .structures.mesh.rectangular_2d_uniform import Mesh2DRectangularUniform
7681
from .structures.mesh.voronoi_2d import Mesh2DVoronoi
7782
from .structures.mesh.delaunay_2d import Mesh2DDelaunay
7883
from .structures.arrays.kernel_2d import Kernel2D

autoarray/abstract_ndarray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def output_to_fits(self, file_path: str, overwrite: bool = False):
282282
If a file already exists at the path, if overwrite=True it is overwritten else an error is raised.
283283
"""
284284
output_to_fits(
285-
values=self.native.array,
285+
values=self.native.array.astype("float"),
286286
file_path=file_path,
287287
overwrite=overwrite,
288288
header_dict=self.mask.header_dict,

autoarray/config/general.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
jax:
2+
use_jax: true # If True, uses JAX internally, whereas False uses normal Numpy.
13
fits:
24
flip_for_ds9: false # If True, the image is flipped before output to a .fits file, which is useful for viewing in DS9.
35
inversion:

autoarray/config/visualize/include.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

autoarray/dataset/grids.py

Lines changed: 18 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
from autoarray.mask.mask_2d import Mask2D
44
from autoarray.structures.arrays.uniform_2d import Array2D
55
from autoarray.structures.arrays.kernel_2d import Kernel2D
6-
from autoarray.structures.grids.uniform_1d import Grid1D
76
from autoarray.structures.grids.uniform_2d import Grid2D
87

98
from autoarray.inversion.pixelization.border_relocator import BorderRelocator
10-
from autoconf import cached_property
9+
10+
from autoarray import exc
1111

1212

1313
class GridsDataset:
@@ -24,7 +24,7 @@ def __init__(
2424
2525
The following grids are contained:
2626
27-
- `uniform`: A grids of (y,x) coordinates which aligns with the centre of every image pixel of the image data,
27+
- `lp`: A grids of (y,x) coordinates which aligns with the centre of every image pixel of the image data,
2828
which is used for most normal calculations (e.g. evaluating the amount of light that falls in an pixel
2929
from a light profile).
3030
@@ -60,72 +60,30 @@ def __init__(
6060
self.over_sample_size_pixelization = over_sample_size_pixelization
6161
self.psf = psf
6262

63-
@cached_property
64-
def lp(self) -> Union[Grid1D, Grid2D]:
65-
"""
66-
Returns the grid of (y,x) Cartesian coordinates at the centre of every pixel in the masked data, which is used
67-
to perform most normal calculations (e.g. evaluating the amount of light that falls in an pixel from a light
68-
profile).
69-
70-
This grid is computed based on the mask, in particular its pixel-scale and sub-grid size.
71-
72-
Returns
73-
-------
74-
The (y,x) coordinates of every pixel in the data.
75-
"""
76-
return Grid2D.from_mask(
63+
self.lp = Grid2D.from_mask(
7764
mask=self.mask,
7865
over_sample_size=self.over_sample_size_lp,
7966
)
67+
self.lp.over_sampled
8068

81-
@cached_property
82-
def pixelization(self) -> Grid2D:
83-
"""
84-
Returns the grid of (y,x) Cartesian coordinates of every pixel in the masked data which is used
85-
specifically for calculations associated with a pixelization.
86-
87-
The `pixelization` grid is identical to the `uniform` grid but often uses a different over sampling scheme
88-
when performing calculations. For example, the pixelization may benefit from using a a higher `sub_size` than
89-
the `uniform` grid, in order to better prevent aliasing effects.
90-
91-
This grid is computed based on the mask, in particular its pixel-scale and sub-grid size.
92-
93-
Returns
94-
-------
95-
The (y,x) coordinates of every pixel in the data, used for pixelization / inversion calculations.
96-
"""
97-
return Grid2D.from_mask(
69+
self.pixelization = Grid2D.from_mask(
9870
mask=self.mask,
9971
over_sample_size=self.over_sample_size_pixelization,
10072
)
101-
102-
@cached_property
103-
def blurring(self) -> Optional[Grid2D]:
104-
"""
105-
Returns a blurring-grid from a mask and the 2D shape of the PSF kernel.
106-
107-
A blurring grid consists of all pixels that are masked (and therefore have their values set to (0.0, 0.0)),
108-
but are close enough to the unmasked pixels that their values will be convolved into the unmasked those pixels.
109-
This when computing images from light profile objects.
110-
111-
This uses lazy allocation such that the calculation is only performed when the blurring grid is used, ensuring
112-
efficient set up of the `Imaging` class.
113-
114-
Returns
115-
-------
116-
The blurring grid given the mask of the imaging data.
117-
"""
73+
self.pixelization.over_sampled
11874

11975
if self.psf is None:
120-
return None
121-
122-
return self.lp.blurring_grid_via_kernel_shape_from(
123-
kernel_shape_native=self.psf.shape_native,
124-
)
125-
126-
@cached_property
127-
def border_relocator(self) -> BorderRelocator:
128-
return BorderRelocator(
76+
self.blurring = None
77+
else:
78+
try:
79+
self.blurring = self.lp.blurring_grid_via_kernel_shape_from(
80+
kernel_shape_native=self.psf.shape_native,
81+
)
82+
self.blurring.over_sampled
83+
except exc.MaskException:
84+
self.blurring = None
85+
86+
self.border_relocator = BorderRelocator(
12987
mask=self.mask, sub_size=self.over_sample_size_pixelization
13088
)
13189

autoarray/dataset/imaging/dataset.py

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from autoarray import exc
1818
from autoarray.operators.over_sampling import over_sample_util
19-
from autoarray.inversion.inversion.imaging import inversion_imaging_util
19+
from autoarray.inversion.inversion.imaging import inversion_imaging_numba_util
2020

2121
logger = logging.getLogger(__name__)
2222

@@ -160,16 +160,35 @@ def __init__(
160160
"""
161161
)
162162

163-
if psf is not None and use_normalized_psf:
163+
if psf is not None:
164+
165+
if not data.mask.is_all_false:
166+
167+
image_mask = data.mask
168+
blurring_mask = data.mask.derive_mask.blurring_from(
169+
kernel_shape_native=psf.shape_native
170+
)
171+
172+
else:
173+
174+
image_mask = None
175+
blurring_mask = None
176+
164177
psf = Kernel2D.no_mask(
165-
values=psf.native, pixel_scales=psf.pixel_scales, normalize=True
178+
values=psf.native._array,
179+
pixel_scales=psf.pixel_scales,
180+
normalize=use_normalized_psf,
181+
image_mask=image_mask,
182+
blurring_mask=blurring_mask,
166183
)
167184

168185
self.psf = psf
169186

170-
@cached_property
171-
def grids(self):
172-
return GridsDataset(
187+
if psf is not None:
188+
if psf.mask.shape[0] % 2 == 0 or psf.mask.shape[1] % 2 == 0:
189+
raise exc.KernelException("Kernel2D Kernel2D must be odd")
190+
191+
self.grids = GridsDataset(
173192
mask=self.data.mask,
174193
over_sample_size_lp=self.over_sample_size_lp,
175194
over_sample_size_pixelization=self.over_sample_size_pixelization,
@@ -219,17 +238,22 @@ def w_tilde(self):
219238
curvature_preload,
220239
indexes,
221240
lengths,
222-
) = inversion_imaging_util.w_tilde_curvature_preload_imaging_from(
223-
noise_map_native=np.array(self.noise_map.native),
224-
kernel_native=np.array(self.psf.native),
225-
native_index_for_slim_index=self.mask.derive_indexes.native_for_slim,
241+
) = inversion_imaging_numba_util.w_tilde_curvature_preload_imaging_from(
242+
noise_map_native=np.array(self.noise_map.native.array).astype("float64"),
243+
kernel_native=np.array(self.psf.native.array).astype("float64"),
244+
native_index_for_slim_index=np.array(
245+
self.mask.derive_indexes.native_for_slim
246+
).astype("int"),
226247
)
227248

228249
return WTildeImaging(
229250
curvature_preload=curvature_preload,
230251
indexes=indexes.astype("int"),
231252
lengths=lengths.astype("int"),
232253
noise_map_value=self.noise_map[0],
254+
noise_map=self.noise_map,
255+
psf=self.psf,
256+
mask=self.mask,
233257
)
234258

235259
@classmethod
@@ -426,7 +450,7 @@ def apply_noise_scaling(
426450

427451
if signal_to_noise_value is None:
428452
noise_map = self.noise_map.native
429-
noise_map[mask == False] = noise_value
453+
noise_map[mask.array == False] = noise_value
430454
else:
431455
noise_map = np.where(
432456
mask == False,
@@ -504,7 +528,7 @@ def apply_over_sampling(
504528
passed into the calculations performed in the `inversion` module.
505529
"""
506530

507-
return Imaging(
531+
dataset = Imaging(
508532
data=self.data,
509533
noise_map=self.noise_map,
510534
psf=self.psf,
@@ -515,6 +539,8 @@ def apply_over_sampling(
515539
check_noise_map=False,
516540
)
517541

542+
return dataset
543+
518544
def output_to_fits(
519545
self,
520546
data_path: Union[Path, str],

autoarray/dataset/imaging/simulator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def via_image_from(
151151
pixel_scales=image.pixel_scales,
152152
)
153153

154-
if np.isnan(noise_map).any():
154+
if np.isnan(noise_map.array).any():
155155
raise exc.DatasetException(
156156
"The noise-map has NaN values in it. This suggests your exposure time and / or"
157157
"background sky levels are too low, creating signal counts at or close to 0.0."
@@ -161,7 +161,9 @@ def via_image_from(
161161
image = image - background_sky_map
162162

163163
mask = Mask2D.all_false(
164-
shape_native=image.shape_native, pixel_scales=image.pixel_scales
164+
shape_native=image.shape_native,
165+
pixel_scales=image.pixel_scales,
166+
origin=image.origin,
165167
)
166168

167169
image = Array2D(values=image, mask=mask)

0 commit comments

Comments
 (0)