I have a 4 dimensional array, i.e., data.shape = (20,30,33,288). I am finding the index of the closest array to n using
data.shape = (20,30,33,288)
index = abs(data - n).a
You should be able to access the maximum values indexed by index using numpy.indices():
index
numpy.indices()
x, z, t = numpy.indices(index.shape) data[x, index, z, t]
If I understood you correctly, this should work:
numpy.put(data, index, values)
I learned something new today, thanks.