Numpy where function multiple conditions

I have an array of distances called dists. I want to select dists which are within a range.

 dists[(np.where(dists >= r)) and (np.where(dists <= r + dr))]

However, this selects only for the condition

 (np.where(dists <= r + dr))

If I do the commands sequentially by using a temporary variable it works fine. Why does the above code not work, and how do I get it to work?

9 Answers
9

Leave a Comment