openair icon indicating copy to clipboard operation
openair copied to clipboard

Windrose() error, Length of logical index must be 1 or 12, not 0

Open mccroweyclinton-EPA opened this issue 6 years ago • 6 comments

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`

mccroweyclinton-EPA avatar Apr 05 '18 15:04 mccroweyclinton-EPA

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)

davidcarslaw avatar Apr 05 '18 15:04 davidcarslaw

Should be fixed now in latest commit...

davidcarslaw avatar Apr 05 '18 16:04 davidcarslaw

Thank you, that was quick. What is the ETA before this update makes it's way to the package in CRAN?

mccroweyclinton-EPA avatar Apr 05 '18 16:04 mccroweyclinton-EPA

I'll probably submit a new version next week. I have however made a source and binary package available here

davidcarslaw avatar Apr 05 '18 16:04 davidcarslaw

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.

anon94041 avatar Mar 03 '19 15:03 anon94041

Could you the GitHub version of openair? Seems to work OK for me...

davidcarslaw avatar Mar 03 '19 16:03 davidcarslaw

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

jack-davison avatar Feb 07 '23 11:02 jack-davison