'Python numpy np.argmax() using user specific range/axis
I have an array named fft
with the length of length (800)
and want to get the np.argmax(fft)
and get as expected the maximum at position result (420)
.
The data of the fft is from -pi/2 to pi/2 (-90° to 90°). So the position of the maximum is actually at 0.078° radian. There is also an array x_axis = np.linespace(-np.pi/2, np.pi/2, length)
.
I thought maybe there is a way to use the np.argmax()
and the x_axis
in one function or two to get the angle directly.
Would make the code clearer then using result = np.argmax(fff) / length * np.pi - np.pi/2
.
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|