SamAct SamAct - 1 year ago 58
R Question

Sector wise mean wind speed and directions in R

I am trying to get mean wind speeds of a data-set based on its mean direction within a sector. It is fairly simple and the below program does the trick. I, however, am unable to automate it, meaning I have to manually input the values of

fsector
and
esector
every time. Also, the output is not where I would like. Please tell me a better way or help me on improving this one.

##Dummy Wind Speed and Directional Data.

ws<-c(seq(1,25,by=0.5))
wd<-C(seq(0,360,by=7.346939))

fsector<-22.5 ##Starting point
esector<-45 ##End point

wind <- as.data.frame(cbind(ws,wd))
wind$test<- ifelse(wind$wd > fsector & wind$wd < esector,'mean','greater')
mean<-rbind(aggregate(wind$wd,by=list(wind$test),mean))
meanws<-rbind(aggregate(wind$ws,by=list(wind$test),mean))
mean<-cbind(meanws[2,2],mean[2,2])
mean


It would be great if i can choose the number of sectors and automatically generate the list of mean wind speeds and mean direction. Thanks.


Answer Source

Actually I'm working with the same data. First I do a wind rose like this: enter image description here

And then, depending the direction, I put the data:

max(Windspeed[direc >=11.25 & direc <= 33.75])
min(Windspeed[direc >=11.25 & direc <= 33.75])
mean(Windspeed[direc >=11.25 & direc <= 33.75])

I put he direccion in degrees. If you don't search that, I will be here waiting for help you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download