openair
openair copied to clipboard
Windrose() error, Length of logical index must be 1 or 12, not 0
I created dummy data to test out the windRose function but I am being greeted with an error
`library(openair) Winddirection <- seq( from = 10, to = 350, by = 10) Windspeed <- rep(10, 35) df <- data.frame(Winddirection, Windspeed) openair::windRose(mydata = df, ws = "Windspeed", wd = "Winddirection")
Error in e2[[j]] : subscript out of bounds In addition: Warning message: Length of logical index must be 1 or 12, not 0`
Thanks for the report. I can confirm a problem, which seems to be related to the bias correction used. I will look into this. With no bias correction it should work OK:
windRose(mydata = df, ws = "Windspeed", wd = "Winddirection", bias.corr = FALSE, angle = 10)
Should be fixed now in latest commit...
Thank you, that was quick. What is the ETA before this update makes it's way to the package in CRAN?
I'll probably submit a new version next week. I have however made a source and binary package available here
I have a similar problem that apparently relates to the bias correction. I'm trying to plot a lot of wind roses and for some subsets of my data, I get "Error in e2[[j]] : subscript out of bounds". Small examples that do and don't work are below:
w1 <- data.frame(WDIR=c(118,190,110), WSPD=c(7,8,4), date=as.Date(c("2019-02-17","2019-02-16","2019-02-15"))) windRose(w1,ws="WSPD",wd="WDIR") # works fine w2 <- data.frame(WDIR=c(160,190,110), WSPD=c(7,8,4), date=as.Date(c("2019-02-17","2019-02-16","2019-02-15"))) windRose(w2,ws="WSPD",wd="WDIR", bias.corr=T) # gives "subscript out of bounds" error windRose(w2,ws="WSPD",wd="WDIR", bias.corr=F) # works fine
I can use the bias.corr=F option, but wanted to report this because it seems there may still be an error lurking. Thanks.
Could you the GitHub version of openair? Seems to work OK for me...
Closing as this appears to have been fixed.
w1 <-
data.frame(
WDIR = c(118, 190, 110),
WSPD = c(7, 8, 4),
date = as.Date(c("2019-02-17", "2019-02-16", "2019-02-15"))
)
openair::windRose(w1, ws = "WSPD", wd = "WDIR")
w2 <-
data.frame(
WDIR = c(160, 190, 110),
WSPD = c(7, 8, 4),
date = as.Date(c("2019-02-17", "2019-02-16", "2019-02-15"))
)
openair::windRose(w2,
ws = "WSPD",
wd = "WDIR",
bias.corr = T)
Created on 2023-02-07 with reprex v2.0.2