So I have a 2D matrix, in the code called wave[2]
(it's the place-2 element of the three-dimensional array wave
), which I want to map into a matrix of equal dimensions but with the condition that if the element I am mapping is between -0.001 and 0.001 I will map it into a 0, otherwise I will map into a np.nan value. This is what I wrote to do so:
zeros=np.array(n,n)
zeros[wave[2] < 0.01 and wave[2] > -0.01] = 0
zeros[wave[2] > 0.01 or wave[2] < -0.01] = np.nan
But I guess passing two conditions inside the brackets is not legal, because I get this error message: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
. I'm not able to fix it.