I have a netCDF4 dataset representing multiple matrices of the same dimension (551, 146), one matrix (M1
) contains longitude values, another matrix (M2
) contains latitude values. Each matrix is a numpy masked array.
Given a lon/lat tuple, (A, B)
, I want to get the matrix indices (lon, lat
) where value A
matches in M1
and value B
matches in M2
.
I thought I could represent the indices with:
lon_idx, lat_idx = np.mgrid[:lon.shape[0], :lon.shape[1]]
and two matrices of same shape where one have all values set to A
and the other have all values set to B
.
Then I am hoping to somehow combine these matrices and end up with an array of lon
, lat
indices where the values matched.
What is the idiomatic way to do this in numpy?