Reputation: 75
I am working on wind power and speed
u
and v
are zonal and meridional wind. (I have the values of these 2 vectors)
The wind speed is calculated by V = np.sqrt(u2*v2)
Wind direction is given by α
between 0
and 360 degree
I know this relation holds - u / V = sin( abs(α))
and - v / V = cos( abs(α))
In python I am using np.arccos
and np.arcsin
to try to find α
between 0
and 360
with the 2 equation above. For the first one, it returns the radian so I convert with np.rad2deg(...)
but it gives me a value between 0
and 180 degree
for the second one, I also try to convert but it returns me a valus between 0
and 90
.
Anyone knows how to code it? I am lost :(
Upvotes: 0
Views: 1386
Reputation: 149075
The underlying problem is mathematics: cos(-x) == cos(x), so the function acos
has only values in the [0,pi] interval. And for equivalent reasons asin
has values in [-pi/2,pi/2] one.
But trigonometric library designers know about that, and provide a special function (atan2
) which uses both coordinates (and not a ratio) to give a value in the [-pi, pi] interval.
That being said, be careful when processing wind values. A 360 wind is a wind coming from the North, and 90 is a wind coming from the East. Which is not the way mathematicians count angles...
Upvotes: 1