ropensci / rnoaa

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

Error from coops_search(product = "predictions") for any time zone argument other than "gmt" #342

Closed Maggie-Mason closed 4 years ago

Maggie-Mason commented 4 years ago

I have a nearly identical script using product = "water_level", time_zone = "lst_ldt" with no issue. Trying to request tide predictions with any time zone argument other than "gmt" produces the error at the bottom. Currently I can request it as GMT then convert the datetime to EST, but that means my data call is starting and ending a quarter day off from what I want for my EST station.

> may.tides <- (coops_search(station_name = 8551762, 
+                                           begin_date = 20200501, end_date = 20200531, 
+                                           datum = "mtl", product = "predictions", units = "metric", time_zone = "lst_ldt"))

Error in if (!repeated && grepl("%[[:xdigit:]]{2}", URL, useBytes = TRUE)) return(URL) : 
  missing value where TRUE/FALSE needed
sckott commented 4 years ago

Can you please share your sessionInfo() (or devtools::session_info()) as requested

Maggie-Mason commented 4 years ago
R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rnoaa_0.9.5

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3       pillar_1.4.3     compiler_3.6.2   geonames_0.999   tools_3.6.2      digest_0.6.25    jsonlite_1.6.1  
 [8] lubridate_1.7.4  lifecycle_0.1.0  tibble_2.1.3     gtable_0.3.0     pkgconfig_2.0.3  rlang_0.4.5      rstudioapi_0.11 
[15] crul_0.9.0       curl_4.3         gridExtra_2.3    dplyr_0.8.4      stringr_1.4.0    xml2_1.2.2       vctrs_0.2.3     
[22] rappdirs_0.3.1   triebeard_0.3.0  grid_3.6.2       tidyselect_1.0.0 glue_1.3.1       httpcode_0.2.0   R6_2.4.1        
[29] XML_3.99-0.3     ggplot2_3.2.1    purrr_0.3.3      tidyr_1.0.2      hoardr_0.5.2     magrittr_1.5     urltools_1.7.3  
[36] scales_1.1.0     assertthat_0.2.1 colorspace_1.4-1 stringi_1.4.6    lazyeval_0.2.2   munsell_0.5.0    rjson_0.2.20    
[43] crayon_1.3.4

I've double checked with the script to see if it was this specific product producing the error:

#"Predictions" product with time zone other than gmt arguments
> march.tides <- as.data.frame(coops_search(station_name = 8551762, 
+                                           begin_date = 20200301, end_date = 20200331, 
+                                           datum = "mtl", product = "predictions", units = "metric", time_zone = "lst"))
Error in if (!repeated && grepl("%[[:xdigit:]]{2}", URL, useBytes = TRUE)) return(URL) : 
  missing value where TRUE/FALSE needed

> march.tides <- as.data.frame(coops_search(station_name = 8551762, 
+                                           begin_date = 20200301, end_date = 20200331, 
+                                           datum = "mtl", product = "predictions", units = "metric", time_zone = "lst_ldt"))
Error in if (!repeated && grepl("%[[:xdigit:]]{2}", URL, useBytes = TRUE)) return(URL) : 
  missing value where TRUE/FALSE needed
> #Different product "water_level" with non-gmt time zone argument
> march.tides <- as.data.frame(coops_search(station_name = 8551762, 
+                                           begin_date = 20200301, end_date = 20200331, 
+                                           datum = "mtl", product = "water_level", units = "metric", time_zone = "lst_ldt"))
sckott commented 4 years ago

@Maggie-Mason try again after reinstalling - should work now.

predictions gives no information with which to adjust time zone - so we just skip that in this case