0
votes

I want to plot a wind rose in R. I'm trying with the package "openair". My database is in degrees/10 (within 0 and 36), if I plot this values (but it doesn't make sense), it works. But if i real degrees (degrees*10) it says:

Error in e2[[j]] : out of limits (What is it?)

My code is:

windRose(meteo, ws = "Int Viento [Nudos]", wd = "Dir Viento", ws2 = NA, wd2 = NA, 
               ws.int = 3, angle = 3, type = "default", bias.corr = TRUE, cols= "default", 
              grid.line = NULL, width = 1, seg = NULL, auto.text= TRUE, 
              offset = 0, normalise = FALSE, max.freq =NULL, 
              paddle = FALSE, key.header = NULL, key.footer = "Nudos", 
               key.position = "bottom", key = TRUE, dig.lab = 5, statistic = "prop.count",
              pollutant = NULL, annotate = TRUE, border = NA)

I tried with the example database of Openair, and it works:

windRose(mydata, ws = "ws", wd = "wd", ws2 = NA, wd2 = NA, 
     ws.int = 2, angle = 30, type = "default", bias.corr = TRUE, cols
     = "default", grid.line = NULL, width = 1, seg = NULL, auto.text 
     = TRUE, breaks = 4, offset = 10, normalise = FALSE, max.freq = 
       NULL, paddle = TRUE, key.header = NULL, key.footer = "(m/s)", 
     key.position = "bottom", key = TRUE, dig.lab = 5, statistic = 
       "prop.count", pollutant = NULL, annotate = TRUE, angle.scale = 
       360, border = NA)

To compare both:

summary(mydata$wd)

 Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
  0     140     210     200     270     360     219 


summary(meteo$`Dir Viento`)
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
0.0    90.0   140.0   175.5   270.0   360.0      43 
1
Does it take 360, or does it only want values 0 --> 359? I'd check that.MLavrentyev
Openair typically views 360 as North. So, it is likely something else...sconfluentus
If your are not going to supply data, there's only the opportunity for us to encourage you to learn to debug for yourself. Use traceback() and options(error=recover)IRTFM

1 Answers

0
votes

I just had the exact same (rather obscure) error when trying to make a windRose() of my own data, i.e.:

Error in e2[[j]] : subscript out of bounds

This error seems to occur when my winddirections (wd) are expressed exactly as multiples of 10 degree units between 0 and 360 degrees. In the help of the windRose() function I noticed the following for the bias.corr argument:

bias.corr When angle does not divide exactly into 360 a bias is introduced in the frequencies when the wind direction is already supplied rounded to the nearest 10 degrees, as is often the case. For example, if angle = 22.5, N, E, S, W will include 3 wind sectors and all other angles will be two. A bias correction can made to correct for this problem. A simple method according to Applequist (2012) is used to adjust the frequencies

By setting the argument bias.corr=F I managed to make the windRose without any errors, i.e.

windRose(mydata, ws, wd, bias.corr=F)

PS I use R 3.3.2 and openair 2.1-5