I have a 3-D numpy array a with dimensions (6,m,n). I also have a 6-D boolean numpy array b with dimensions (20,20,20,20,20,20) that effectively works as a mask.
I would like to use the 6 values at each location (m,n) in the first array to retrieve the corresponding value in the second array. Effectively, I will compress the 3D int array into a 2D boolean array. I thought the solution would be using np.where, but I don't think it can deal with using values as indices.
The naive implementation for this will be something like:
for i in range(m):
for j in range(n):
new_arr[i,j]=b[tuple(a[:,i,j])]
Is there any way to implement this without using a loop?