I have U and V wind component data and I would like to calculate wind direction from these values in R.
I would like to end up with wind direction data on a scale o
In Python:
Dir=np.mod(180+np.rad2deg(np.arctan2(U, V)),360)
This leads to a Southerly wind (180 degrees) for a [0,1] vector, a Northerly wind (0 degrees) for a [0,-1] vector, a South Westerly wind (225 degrees) for a [1,1] vector:
U
Out[86]:
array([[ 0. ],
[ 0. ],
[ 1. ],
[-3.47]])
V
Out[87]:
array([[ 1. ],
[-1. ],
[ 1. ],
[-1.47]])
np.mod(180+np.rad2deg(np.arctan2(U, V)),360)
Out[89]:
array([[180. ],
[ 0. ],
[225. ],
[ 67.04097233]])