I have an extensive dataset in an array format of
a=[X, Y, Z, value]
. At the same time i have another array b=[X,Y]
, with all the unique combinations of coordinates (X,Y) for the same dataset.
I would like to generate a new array, where for a given z=100, it contains the records of the original array a[X,Y,Z,value] where the Z is closest to the given z=100 for each possible X,Y combination.
The purpose of this is to extract a Z slice of the original dataset at a given depth
a description of the desired outcome would go like this
np.in1d(a[:,0], b[:,0]) and np.in1d(a[:,1], b[:,1]) # for each row
#where both these two arguments are True
a[:,2] == z+min(abs(a[:,2]-z))) # find the rows where Z is closest to z=100
#and append these rows to a new array c[X,Y,Z,value]
The idea is to first find the unique X,Y data and effectively slice the dataset in X,Y columns of the domain. Then search each of these columns to extract the row where Z is closest to the given z value
Any suggestion even for a much different approach would be highly appreciated