33from autoarray .mask .mask_2d import Mask2D
44from autoarray .structures .arrays .uniform_2d import Array2D
55from autoarray .structures .arrays .kernel_2d import Kernel2D
6- from autoarray .structures .grids .uniform_1d import Grid1D
76from autoarray .structures .grids .uniform_2d import Grid2D
87
98from autoarray .inversion .pixelization .border_relocator import BorderRelocator
10- from autoconf import cached_property
9+
10+ from autoarray import exc
1111
1212
1313class 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
0 commit comments