astropy:docs

overlap_slices

astropy.nddata.utils.overlap_slices(large_array_shape, small_array_shape, position)[source] [edit on github]

Get slices for the overlapping part of a small and a large array.

Given a certain position of the center of the small array, with respect to the large array, tuples of slices are returned which can be used to extract, add or subtract the small array at the given position. This function takes care of the correct behavior at the boundaries, where the small array is cut of appropriately.

Parameters:

large_array_shape : tuple

Shape of the large array.

small_array_shape : tuple

Shape of the small array.

position : tuple

Position of the small array’s center, with respect to the large array. Coordinates should be in the same order as the array shape.

Returns:

slices_large : tuple of slices

Slices in all directions for the large array, such that large_array[slices_large] extracts the region of the large array that overlaps with the small array.

slices_small : slice

Slices in all directions for the small array, such that small_array[slices_small] extracts the region that is inside the large array.

Page Contents