Skip to content

Commit 8bb449a

Browse files
Jammy2211Jammy2211
authored andcommitted
remove native_sub_index_for_slim_sub_index_2d_from
1 parent ab45cf5 commit 8bb449a

5 files changed

Lines changed: 1 addition & 397 deletions

File tree

autoarray/operators/over_sampling/over_sample_util.py

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -78,89 +78,6 @@ def total_sub_pixels_2d_from(sub_size: np.ndarray) -> int:
7878
return int(np.sum(sub_size**2))
7979

8080

81-
@numba_util.jit()
82-
def native_sub_index_for_slim_sub_index_2d_from(
83-
mask_2d: np.ndarray, sub_size: np.ndarray
84-
) -> np.ndarray:
85-
"""
86-
Returns an array of shape [total_unmasked_pixels*sub_size] that maps every unmasked sub-pixel to its
87-
corresponding native 2D pixel using its (y,x) pixel indexes.
88-
89-
For example, for the following ``Mask2D`` for ``sub_size=1``:
90-
91-
::
92-
[[True, True, True, True]
93-
[True, False, False, True],
94-
[True, False, True, True],
95-
[True, True, True, True]]
96-
97-
This has three unmasked (``False`` values) which have the ``slim`` indexes:
98-
99-
::
100-
[0, 1, 2]
101-
102-
The array ``native_index_for_slim_index_2d`` is therefore:
103-
104-
::
105-
[[1,1], [1,2], [2,1]]
106-
107-
For a ``Mask2D`` with ``sub_size=2`` each unmasked ``False`` entry is split into a sub-pixel of size 2x2 and
108-
there are therefore 12 ``slim`` indexes:
109-
110-
::
111-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
112-
113-
The array ``native_index_for_slim_index_2d`` is therefore:
114-
115-
::
116-
[[2,2], [2,3], [2,4], [2,5], [3,2], [3,3], [3,4], [3,5], [4,2], [4,3], [5,2], [5,3]]
117-
118-
Parameters
119-
----------
120-
mask_2d
121-
A 2D array of bools, where `False` values are unmasked.
122-
sub_size
123-
The size of the sub-grid in each mask pixel.
124-
125-
Returns
126-
-------
127-
ndarray
128-
An array that maps pixels from a slimmed array of shape [total_unmasked_pixels*sub_size] to its native array
129-
of shape [total_pixels*sub_size, total_pixels*sub_size].
130-
131-
Examples
132-
--------
133-
mask_2d = np.array([[True, True, True],
134-
[True, False, True]
135-
[True, True, True]])
136-
137-
sub_native_index_for_sub_slim_index_2d = sub_native_index_for_sub_slim_index_via_mask_2d_from(mask_2d=mask_2d, sub_size=1)
138-
"""
139-
140-
total_sub_pixels = total_sub_pixels_2d_from(sub_size=sub_size)
141-
sub_native_index_for_sub_slim_index_2d = np.zeros(shape=(total_sub_pixels, 2))
142-
143-
slim_index = 0
144-
sub_slim_index = 0
145-
146-
for y in range(mask_2d.shape[0]):
147-
for x in range(mask_2d.shape[1]):
148-
if not mask_2d[y, x]:
149-
sub = sub_size[slim_index]
150-
151-
for y1 in range(sub):
152-
for x1 in range(sub):
153-
sub_native_index_for_sub_slim_index_2d[sub_slim_index, :] = (
154-
(y * sub) + y1,
155-
(x * sub) + x1,
156-
)
157-
sub_slim_index += 1
158-
159-
slim_index += 1
160-
161-
return sub_native_index_for_sub_slim_index_2d
162-
163-
16481
@numba_util.jit()
16582
def slim_index_for_sub_slim_index_via_mask_2d_from(
16683
mask_2d: np.ndarray, sub_size: np.ndarray

autoarray/operators/over_sampling/over_sampler.py

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __init__(self, mask: Mask2D, sub_size: Union[int, Array2D]):
128128
based on the sub-grid sizes.
129129
130130
The over sampling class has functions dedicated to mapping between the sub-grid and pixel-grid, for example
131-
`sub_mask_native_for_sub_mask_slim` and `slim_for_sub_slim`.
131+
`slim_for_sub_slim`.
132132
133133
The class `OverSampling` is used for the high level API, whereby this is where users input their
134134
preferred over-sampling configuration. This class, `OverSampler`, contains the functionality
@@ -258,63 +258,6 @@ def binned_array_2d_from(self, array: Array2D) -> "Array2D":
258258
mask=self.mask,
259259
)
260260

261-
@cached_property
262-
def sub_mask_native_for_sub_mask_slim(self) -> np.ndarray:
263-
"""
264-
Derives a 1D ``ndarray`` which maps every subgridded 1D ``slim`` index of the ``Mask2D`` to its
265-
subgridded 2D ``native`` index.
266-
267-
For example, for the following ``Mask2D`` for ``sub_size=1``:
268-
269-
::
270-
[[True, True, True, True]
271-
[True, False, False, True],
272-
[True, False, True, True],
273-
[True, True, True, True]]
274-
275-
This has three unmasked (``False`` values) which have the ``slim`` indexes:
276-
277-
::
278-
[0, 1, 2]
279-
280-
The array ``sub_mask_native_for_sub_mask_slim`` is therefore:
281-
282-
::
283-
[[1,1], [1,2], [2,1]]
284-
285-
For a ``Mask2D`` with ``sub_size=2`` each unmasked ``False`` entry is split into a sub-pixel of size 2x2 and
286-
there are therefore 12 ``slim`` indexes:
287-
288-
::
289-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
290-
291-
The array ``native_for_slim`` is therefore:
292-
293-
::
294-
[[2,2], [2,3], [2,4], [2,5], [3,2], [3,3], [3,4], [3,5], [4,2], [4,3], [5,2], [5,3]]
295-
296-
Examples
297-
--------
298-
299-
.. code-block:: python
300-
301-
import autoarray as aa
302-
303-
mask_2d = aa.Mask2D(
304-
mask=[[True, True, True, True]
305-
[True, False, False, True],
306-
[True, False, True, True],
307-
[True, True, True, True]]
308-
pixel_scales=1.0,
309-
)
310-
311-
derive_indexes_2d = aa.DeriveIndexes2D(mask=mask_2d)
312-
313-
print(derive_indexes_2d.sub_mask_native_for_sub_mask_slim)
314-
"""
315-
return over_sample_util.native_sub_index_for_slim_sub_index_2d_from(
316-
mask_2d=self.mask.array, sub_size=self.sub_size.array
317-
).astype("int")
318261

319262
@cached_property
320263
def slim_for_sub_slim(self) -> np.ndarray:

autoarray/structures/arrays/array_2d_util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
if TYPE_CHECKING:
77
from autoarray.mask.mask_2d import Mask2D
88

9-
from autoarray import numba_util
109
from autoarray.mask import mask_2d_util
1110

1211
from autoarray import exc

autoarray/util/cholesky_funcs.py

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

0 commit comments

Comments
 (0)