Reputation: 91
I have a data set which consist of wind direction vector, as follows:
wdir <- c(296.9, 215.2, 204.8, 110.8, 287.6, 203.4, 253.1, 46.0, 298.8, 62.8, 183.4, 62.3,
44.3, 97.6, 78.6, 125.6, 116.9, 121.0, 111.2, 335.8, 287.4, 51.7, 232.6, 265.5,
269.7, 20.5, 17.0, 310.8)
Scalar values are in degrees.
How can I calculate mean wind direction?
Upvotes: 6
Views: 5421
Reputation: 41
You can't simply average the wind direction, you need the speed for each direction and with the speed you can evaluate the average considering the vector form. Another way is to convert wind speed and direction into u and v components, than you can average u and v separately and then evaluating speed and direction. Wind spd = sqrt(u^2+v^2); wind dir = atan2(u,v)*(180/pi)+180
Upvotes: 4
Reputation: 944
This can be done using the circular
package.
To get the mean of 45
and 315
you can use:
library(circular)
mean(circular(c(pi/4,7*pi/4)))
#Circular Data:
#Type = angles
#Units = radians
#Template = none
#Modulo = asis
#Zero = 0
#Rotation = counter
#[1] -1.570092e-16
The reason it isn't exactly 0
is because of floating point precision in R
.
To get the mean of wdir
you can use:
mean(circular(wdir, units = "degrees"))
#Circular Data:
#Type = angles
#Units = degrees
#Template = none
#Modulo = asis
#Zero = 0
#Rotation = counter
#[1] 41.05411
Another example:
mean(circular(c(7*pi/2,pi/4, pi/2, 7*pi/2 )))
#Circular Data:
#Type = angles
#Units = radians
#Template = none
#Modulo = asis
#Zero = 0
#Rotation = counter
#[1] -0.3926991
Upvotes: 10