I have got a three dimensional array with air pressure values in the form:
[[[1000 1010]
[1005 990]]
[[950 960]
[955 940]]
[[900 910]
[905 890]]]
The structure represents the pressure at different levels, so each element in the 2-d is ordered for each layer.
I would like to know at which level the pressure is 950 would be for each 2d element, getting a 2-d array with the index of the level for each element.
In a 1-D array like
a = [890, 940, 990]
I would use
a.searchsorted(950)
and the result would be 2, indicating that 950 would go at the 3rd position.
Is there a way to do it for all my array at once, without having to do it for each 2-d element?
(m,n)array of pressure values corresponding to one level, are you saying that you want the rank of valuevwithin the(m*n,)vector of sorted values for that level, e.g.np.sort(A[0,:,:].flat).searchsorted(v)? Then you just want to do the same thing for each level?(m,n)arrays, one for each layer. I want to know between which levels a value would be, for each element in(m,n). i.e. For the element [1][1], the value 950 would be between the layer 0 and the layer 1.A[:,i,j]the pressure values increase monotonically across levels (otherwise what you're asking for doesn't make sense)