How to calculate wind direction from U and V wind components in R

前端 未结 3 1405
一向
一向 2020-12-15 00:35

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

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-15 01:17

    While the accepted answer has the right idea it has a flaw. As mentioned in the comments one does not need to normalize the u and v component in order to use atan2 on them. The flaw comes when u == v == 0 and wind_abs becomes 0. In C# the two divisions will return infinity (in compliance to IEEE 754) and atan2 will return NaN. When not normalizing the components atan2(0,0) happily returns 0. So not only is normalizing not necessary, it also introduces an error.

    Please also be aware that the most common function signature of atan2 is atan2(y, x) -- Microsoft Excel being an exception.

提交回复
热议问题