-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_windroses.R
26 lines (21 loc) · 1.06 KB
/
plot_windroses.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#install.packages("openair")
require("openair")
require("ggplot2")
# read the file with default export naming (of today's export)
csvfile=paste("/tmp/influxdataexport.",Sys.Date(),".csv.gz",sep="")
d<-read.csv(csvfile)
summary(d)
d$timestamp=as.POSIXct(d$time/1000/1000/1000, origin = "1970-01-01", tz = "UTC")
# windRose(d, ws="wind_speed", wd="wind_direction")
#ggplot(d,aes(wind_angle,wind_speed))+geom_point()
pdf("windrose_plots.pdf")
for (cmpgn in unique(d$campaign)){
for (dvcd in unique(d$deviceid)){
# credits for the title changing solution by
# https://stackoverflow.com/questions/18376679/removing-default-title-from-wind-rose-in-openair-package
my.statistic <- list("fun"=length,"unit" = "%","scale" = "all", "lab" = paste("campaign:",cmpgn, "deviceid:",dvcd) , "fun2" = function(x) signif(mean(x, na.rm = TRUE), 3), "lab2" = "mean","labcalm" = function(x) round(x, 1))
windRose(d[d$deviceid==dvcd&d$campaign==cmpgn,], ws="WGA", wd="WRA", angle=10,statistic=my.statistic)
# windRose(d, ws="WGA", wd="WRA")
}
}
dev.off()