Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ghcnd_stations() not finding file it expects (ghcnd-stations.txt) #349

Closed
mpettis opened this issue May 14, 2020 · 4 comments · Fixed by #350
Closed

ghcnd_stations() not finding file it expects (ghcnd-stations.txt) #349

mpettis opened this issue May 14, 2020 · 4 comments · Fixed by #350
Milestone

Comments

@mpettis
Copy link

mpettis commented May 14, 2020

I just downloaded this package, and am trying to use it to find weather stations near me. Using the example from here, I cannot proceed past the first step. Please advise. Below is the reprex and session info.

Session:

library(rnoaa)
#> Warning: package 'rnoaa' was built under R version 3.6.3
station_data <- ghcnd_stations()
#> Error in curl::curl_fetch_disk(x$url$url, x$disk, handle = x$url$handle): Failed to open file C:\Users\IRINZN\AppData\Local\Cache\R\noaa_ghcnd\ghcnd-stations.txt.
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.6.1 (2019-07-05)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/Chicago             
#>  date     2020-05-13                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version   date       lib source        
#>  assertthat    0.2.1     2019-03-21 [1] CRAN (R 3.6.1)
#>  cli           2.0.2     2020-02-28 [1] CRAN (R 3.6.3)
#>  colorspace    1.4-1     2019-03-18 [1] CRAN (R 3.6.1)
#>  crayon        1.3.4     2017-09-16 [1] CRAN (R 3.6.1)
#>  crul          0.9.0     2019-11-06 [1] CRAN (R 3.6.1)
#>  curl          4.2       2019-09-24 [1] CRAN (R 3.6.1)
#>  digest        0.6.23    2019-11-23 [1] CRAN (R 3.6.1)
#>  dplyr         0.8.5     2020-03-07 [1] CRAN (R 3.6.3)
#>  ellipsis      0.3.0     2019-09-20 [1] CRAN (R 3.6.1)
#>  evaluate      0.14      2019-05-28 [1] CRAN (R 3.6.1)
#>  fansi         0.4.0     2018-10-05 [1] CRAN (R 3.6.1)
#>  ggplot2       3.2.1     2019-08-10 [1] CRAN (R 3.6.1)
#>  glue          1.3.1     2019-03-12 [1] CRAN (R 3.6.1)
#>  gridExtra     2.3       2017-09-09 [1] CRAN (R 3.6.1)
#>  gtable        0.3.0     2019-03-25 [1] CRAN (R 3.6.1)
#>  highr         0.8       2019-03-20 [1] CRAN (R 3.6.1)
#>  hoardr        0.5.2     2018-12-02 [1] CRAN (R 3.6.1)
#>  htmltools     0.4.0     2019-10-04 [1] CRAN (R 3.6.1)
#>  httpcode      0.2.0     2016-11-14 [1] CRAN (R 3.6.0)
#>  jsonlite      1.6       2018-12-07 [1] CRAN (R 3.6.1)
#>  knitr         1.26      2019-11-12 [1] CRAN (R 3.6.1)
#>  lazyeval      0.2.2     2019-03-15 [1] CRAN (R 3.6.1)
#>  lifecycle     0.2.0     2020-03-06 [1] CRAN (R 3.6.3)
#>  lubridate     1.7.4     2018-04-11 [1] CRAN (R 3.6.1)
#>  magrittr      1.5       2014-11-22 [1] CRAN (R 3.6.1)
#>  munsell       0.5.0     2018-06-12 [1] CRAN (R 3.6.1)
#>  pillar        1.4.3     2019-12-20 [1] CRAN (R 3.6.3)
#>  pkgconfig     2.0.3     2019-09-22 [1] CRAN (R 3.6.1)
#>  purrr         0.3.3     2019-10-18 [1] CRAN (R 3.6.1)
#>  R6            2.4.1     2019-11-12 [1] CRAN (R 3.6.1)
#>  rappdirs      0.3.1     2016-03-28 [1] CRAN (R 3.6.1)
#>  Rcpp          1.0.3     2019-11-08 [1] CRAN (R 3.6.1)
#>  rlang         0.4.5     2020-03-01 [1] CRAN (R 3.6.3)
#>  rmarkdown     1.18      2019-11-27 [1] CRAN (R 3.6.1)
#>  rnoaa       * 0.9.6     2020-04-07 [1] CRAN (R 3.6.3)
#>  scales        1.1.0     2019-11-18 [1] CRAN (R 3.6.1)
#>  sessioninfo   1.1.1     2018-11-05 [1] CRAN (R 3.6.1)
#>  stringi       1.4.3     2019-03-12 [1] CRAN (R 3.6.0)
#>  stringr       1.4.0     2019-02-10 [1] CRAN (R 3.6.1)
#>  tibble        3.0.1     2020-04-20 [1] CRAN (R 3.6.3)
#>  tidyr         1.0.0     2019-09-11 [1] CRAN (R 3.6.1)
#>  tidyselect    0.2.5     2018-10-11 [1] CRAN (R 3.6.1)
#>  triebeard     0.3.0     2016-08-04 [1] CRAN (R 3.6.1)
#>  urltools      1.7.3     2019-04-14 [1] CRAN (R 3.6.1)
#>  vctrs         0.2.4     2020-03-10 [1] CRAN (R 3.6.3)
#>  withr         2.1.2     2018-03-15 [1] CRAN (R 3.6.1)
#>  xfun          0.11      2019-11-12 [1] CRAN (R 3.6.1)
#>  XML           3.98-1.20 2019-06-06 [1] CRAN (R 3.6.0)
#>  xml2          1.2.2     2019-08-09 [1] CRAN (R 3.6.1)
#>  yaml          2.2.0     2018-07-25 [1] CRAN (R 3.6.0)
#> 
#> [1] C:/Users/IRINZN/Documents/R/R-3.6.1/library

Created on 2020-05-13 by the reprex package (v0.3.0)

@sckott
Copy link
Contributor

sckott commented May 14, 2020

thanks for the report @mpettis ! and for including your session info. i'll have a look

@mpettis
Copy link
Author

mpettis commented May 14, 2020

Perhaps some helpful things I found on my machine:

  • I ran a debug on ghcnd_stations(), stepped into get_stations().
  • I see it is referencing ghcnd_cache$cache_path_get(), where it intends to cache ghcnd-stations.txt. That cache path, as of the execution of the line ff <- file.path(ghcnd_cache$cache_path_get(), "ghcnd-stations.txt") does not yet exist.
  • The error actually occurs when the following line from get_stations() is executed:
    res <- GET_retry("ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/ghcnd-stations.txt", 
            disk = ff, ...)

My suspicion is that when ghcnd_cache is defined in R/onload.R, assigning it here , that directory path is expected to be created upon instantiation. But it is not.

@mpettis
Copy link
Author

mpettis commented May 14, 2020

I suspect a call to ghcnd_cache$mkdir() is required prior to the GET_retry() call. I'm not sure if it should go in just prior, or somewhere further up the call stack. I could do a fork and pull request if that helps you out by placing that call just prior to GET_retry()...

@sckott
Copy link
Contributor

sckott commented May 15, 2020

thanks very much - i suspect you're right, having a look at the PR

@sckott sckott added the bug label May 15, 2020
@sckott sckott added this to the v0.9.7 milestone May 15, 2020
@sckott sckott added the ghcnd label May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants