0

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

rt.l
  • 306
  • 1
  • 7
  • I'm not sure I understood what you mean. I'm taking the mean value of the v and u components, not of the angle itself. – rt.l Nov 11 '19 at 15:41
  • No, sorry for not specifying. Wind is decomposed in y (v component) and x (u component). So v is northward wind component and u is eastward wind component. Here is a discussion on how to transform wind components to direction and speed (but with slightly different definitions on the direction of each component): https://stackoverflow.com/questions/21484558/how-to-calculate-wind-direction-from-u-and-v-wind-components-in-r – rt.l Nov 11 '19 at 16:12
  • Can you provide the formulas instead of the code ? –  Nov 12 '19 at 11:24

1 Answers1

3

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.

Iaroslav Domin
  • 2,698
  • 10
  • 19