99from autoarray .inversion .pixelization .border_relocator import BorderRelocator
1010from autoconf import cached_property
1111
12+ from autoarray import exc
13+
1214
1315class GridsDataset :
1416 def __init__ (
@@ -24,7 +26,7 @@ def __init__(
2426
2527 The following grids are contained:
2628
27- - `uniform `: A grids of (y,x) coordinates which aligns with the centre of every image pixel of the image data,
29+ - `lp `: A grids of (y,x) coordinates which aligns with the centre of every image pixel of the image data,
2830 which is used for most normal calculations (e.g. evaluating the amount of light that falls in an pixel
2931 from a light profile).
3032
@@ -60,72 +62,30 @@ def __init__(
6062 self .over_sample_size_pixelization = over_sample_size_pixelization
6163 self .psf = psf
6264
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 (
65+ self .lp = Grid2D .from_mask (
7766 mask = self .mask ,
7867 over_sample_size = self .over_sample_size_lp ,
7968 )
69+ self .lp .over_sampled
8070
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 (
71+ self .pixelization = Grid2D .from_mask (
9872 mask = self .mask ,
9973 over_sample_size = self .over_sample_size_pixelization ,
10074 )
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- """
75+ self .pixelization .over_sampled
11876
11977 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 (
78+ self .blurring = None
79+ else :
80+ try :
81+ self .blurring = self .lp .blurring_grid_via_kernel_shape_from (
82+ kernel_shape_native = self .psf .shape_native ,
83+ )
84+ self .blurring .over_sampled
85+ except exc .MaskException :
86+ self .blurring = None
87+
88+ self .border_relocator = BorderRelocator (
12989 mask = self .mask , sub_size = self .over_sample_size_pixelization
13090 )
13191
0 commit comments