I want to find the location of a subarray in an numpy array.
For example, if the large array is of shape (10000, 10, 10, 10)
, namely 10000 arrays of shape (10,10,10) and I want to find the location of the subarray of shape (3,3,3)
as follows:
subarray = array(
[[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 1., 0.],
[0., 0., 0.]]])
So I will know that at the location of n, i, j, k
I will get:
largearray[n, i:i+subarray.shape[0], j:j+subarray.shape[1], k:k+subarray.shape[2]] == subarray