I have hourly u and v wind components, and I’m having trouble to aggregate it to the daily level.
In principle, I thought that I could just take the mean of U and V wind components and find the direction of these means, but the result I get using this algorithm is different from when I use specialized package CircStat. In the code that follows, variable dir_rwind is the direction calculated from the mean U and V components, while dir_CircStat is the mean direction calculated with CircStat.
set.seed(123)
uc <- rnorm(300,0,2)
vc <- rnorm(300,0,2)
df <- data.frame(uc=uc, vc=vc,id=1:10)
df <- cbind(df,as.data.frame(rWind::uv2ds(df$uc,df$vc)))
agg <- df %>%
group_by(id)%>%
summarise(mean_u10 = mean(uc),
mean_v10 = mean(vc),
dir_rwind = rWind::uv2ds(mean_u10, mean_v10)[1],
dir_CircStat = (180/pi)*CircStats::circ.mean(dir*pi/180))
agg
Why do I get different mean wind directions? Should I ever use the first algorithm I tried (taking the mean of each component: like variable dir_rwind)? If yes, when should I use each calculation algorithm?
Thanks a lot
It's more of a math question rather than an r
question. The thing is that you can't say that mean direction of n vectors equals to the direction of the mean-vector. Consider e.g. two vectors: (1, 0)
and (0, 10000)
. The angle of the first is 0 degrees, the angle of the second is 90 degrees. So, the average direction is 45 degrees. But the mean-vector is (.5, 5000)
and it's angle is in fact almost indistinguishable from 90 degrees.