如何在R中绘制风玫瑰?

时间:2017-06-26 23:16:46

标签: r openair

我想在R中绘制一朵风玫瑰。我正在尝试使用包裹"露天"。 我的数据库是度/ 10(在0和36之间),如果我绘制这个值(但它没有意义),它的工作原理。但如果我真实度(度* 10),它说:

e2 [[j]]出错:超出界限(这是什么?)

我的代码是:

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)

我尝试使用Openair的示例数据库,它可以工作:

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)

比较两者:

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 个答案:

答案 0 :(得分:0)

在尝试使用我自己的数据的windRose()时,我只有完全相同(相当模糊)的错误,即:

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

当我的winddirections(wd)完全表示为0到360度之间的10度单位的倍数时,似乎会发生此错误。在windRose()函数的帮助下,我注意到bias.corr参数的以下内容:

  

bias.corr   当角度没有精确地划分为360°时,在已经提供的风向被舍入到最接近的10度时,在频率中引入偏差,这通常是这种情况。例如,如果angle = 22.5,则N,E,S,W将包括3个扇区,所有其他角度将为2。可以进行偏差校正以纠正此问题。根据Applequist(2012)的简单方法用于调整频率

通过设置参数bias.corr=F,我设法使windRose没有任何错误,即

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

PS我使用R 3.3.2和openair 2.1-5