davidcarslaw / openair

Tools for air quality data analysis
https://davidcarslaw.github.io/openair/
GNU General Public License v2.0
304 stars 113 forks source link

Vector.ws in timeAverage() #34

Closed Mbex closed 8 years ago

Mbex commented 8 years ago

Hi David

I am using vector and scalar time averaging of wind data on two identical data sets. I expect when I subtract the wind directions time averaged by one method from the other to plot a time series of where the two averaging methods give different results. However I produce a flat line at 0 indicating the two wind direction data series' are the same.

example: dat1 = timeAverage(mydata, avg.time = "day", vector.ws=TRUE) dat2 = timeAverage(mydata, avg.time = "day", vector.ws=FALSE) dat3 = subset(dat1, select=c("date","wd")) dat3$wd.b = dat2$wd dat3$c = dat3$wd - dat3$wd.b timePlot(dat3,"c")

I'm using: R version 3.1.2 (2014-10-31) openair 1.1-3

davidcarslaw commented 8 years ago

Currently timeAverage always returns the vector average wind direction (using ws * the u/v components). The vector.ws is to provide the vector-averaged wind speed, rather than the scalar (the default). For this reason, setting vector.ws = TRUE will not affect the wind direction calculation. I did however notice a bug in this calculation that is now fixed. The other way of averaging wind direction would be to assume unit vector length for each time period (rather than multiplying with wind speed). openair does not do this. Is that what you would want?

Mbex commented 8 years ago

Ah brilliant I understand now. I don't think assuming unit vector length is something I require. Thanks for your explanation.