I have a numpy array (mat) of shape (n,4). The array has four columns and large number (n) of rows. The first three columns represent x, y, z columns in my calculation. I wish to select those rows of the numpy array where the x column has values below a given number (min_x) or values above a given number (max_x), and where the y column has values below a given number (min_y) or values above a given number (max_y) and where the z column has values below a given number (min_z) or values above a given number (max_z).
This is how I am trying to implement this desired functionality presently:
import numpy as np
mark = np.where( ( (mat[:,0]<=min_x) | \
(mat[:,0]>max_x) ) & \
( (mat[:,1]<=min_y) | \
(mat[:,1]>max_y) ) & \
( (mat[:,2]<=min_z) | \
(mat[:,2]>max_z) ) )
mat_new = mat[:,mark[0]]
Is the technique that I am using correct, and the best way to achieve the desired functionality? I will greatly appreciate any help. Thanks.