ropensci / rnoaa

R interface to many NOAA data APIs
https://docs.ropensci.org/rnoaa
Other
330 stars 84 forks source link

rnoaa gefs not taking longitude coordinate correctly #316

Closed morrisseyj closed 5 years ago

morrisseyj commented 5 years ago

Perhaps I am misunderstanding the documentation but the gefs function seems to be behaving strangely, when returning a list of longitude coordinates.

I want the coordinates from lon of: 200 - 204. I therefore use:

library(rnoaa) a <- gefs("u-component_of_wind_height_above_ground_ens", ens_idx = 1, forecast_time = "0000", lon = c(200:204), lat = c(50:54)) b <- as.data.frame(a["data"]) head(b) data.u.component_of_wind_height_above_ground_ens data.lon data.lat data.height_above_ground1 data.ens data.time2 1 14.21 204 54 10 0 0 2 13.90 205 53 10 0 6 3 13.01 206 52 10 0 12 4 12.00 207 51 10 0 18 5 11.83 208 50 10 0 24 6 13.99 204 54 10 0 30

You can see that while lat works giving me values from 50-54, lon gets it wrong, giving me values from 204 - 208. This happens regardless of the order of the list (i.e. lon(204:200) gives the same thing. The function appears to be doing something like: max(lon):(max(lon) - min(lon) + max(lon))

Apologies if I am misreading the documentation, but the only way i was able to solve this was to set lon(196:200)

Session Info ```r ─ Session info ──────── setting value version R version 3.5.2 (2018-12-20) os Ubuntu 19.04 system x86_64, linux-gnu ui RStudio language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz America/Los_Angeles date 2019-09-14 ─ Packages ───────── package * version date lib source assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.2) backports 1.1.4 2019-04-10 [1] CRAN (R 3.5.2) callr 3.3.0 2019-07-04 [1] CRAN (R 3.5.2) cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.2) crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.2) desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.2) devtools 2.2.0 2019-09-07 [1] CRAN (R 3.5.2) digest 0.6.20 2019-07-04 [1] CRAN (R 3.5.2) DT 0.8 2019-08-07 [1] CRAN (R 3.5.2) ellipsis 0.2.0.1 2019-07-02 [1] CRAN (R 3.5.2) fs 1.3.1 2019-05-06 [1] CRAN (R 3.5.2) glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.2) htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.2) htmlwidgets 1.3 2018-09-30 [1] CRAN (R 3.5.2) magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.2) memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.2) packrat 0.5.0 2018-11-14 [1] CRAN (R 3.5.2) pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.5.2) pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.2) prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.2) processx 3.4.0 2019-07-03 [1] CRAN (R 3.5.2) ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.2) R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.2) Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.5.2) remotes 2.1.0 2019-06-24 [1] CRAN (R 3.5.2) rlang 0.4.0 2019-06-25 [1] CRAN (R 3.5.2) rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.2) rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.5.2) sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.2) testthat 2.2.1 2019-07-25 [1] CRAN (R 3.5.2) usethis 1.5.1 2019-07-04 [1] CRAN (R 3.5.2) withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.2) [1] /home/[USER]/R/x86_64-pc-linux-gnu-library/3.5 [2] /usr/local/lib/R/site-library [3] /usr/lib/R/site-library [4] /usr/lib/R/library ```
sckott commented 5 years ago

thanks for the report @morrisseyj ! having a look

sckott commented 5 years ago

@potterzot can you comment on this? It seems a bit complicated what's going on internally in the function.

potterzot commented 5 years ago

@morrisseyj thank you for submitting this! It seems to work correctly when longitude is specified on the (-180, 180) scale but when specified on the (0,360) scale it starts at the wrong value. Submitting a fix now and will update when submitted.

sckott commented 5 years ago

thanks @potterzot

morrisseyj commented 5 years ago

@potterzot and @sckott: Great, thanks for the rapid turnaround on this.