I want to get the indices of an xarray data array where some condition is satisfied. An answer provided in a related thread (here) for how to find the location for the maximum did not work for me either. In my case, I want to find out the locations for other types of conditions too, not just maximum. Here is what I tried:
h=xr.DataArray(np.random.randn(3,4))
h.where(h==h.max(),drop=True).squeeze()
# This is the output I got:
<xarray.DataArray ()>
array(1.66065694)
This does not return the position as shown in the example I linked to, even though I am executing the same command. Am not sure why.