Skip to content

Commit

Permalink
Update stations list link and add tests to ensure data is recent in f…
Browse files Browse the repository at this point in the history
…uture.
  • Loading branch information
steffilazerte committed Jan 27, 2025
1 parent 3a9ce63 commit 9d017e9
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: weathercan
Type: Package
Title: Download Weather Data from Environment and Climate Change Canada
Version: 0.7.2.9000
Version: 0.7.3
Authors@R: c(
person("Steffi", "LaZerte", email = "[email protected]", role = c("aut","cre"), comment = c(ORCID = "0000-0002-7690-8360")),
person("Sam", "Albers", email = "[email protected]", role = c("ctb"), comment = c(ORCID = "0000-0002-9270-7884")),
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# weathercan (development version)
# weathercan 0.7.3
- Switch stations inventory list to new location

# weathercan 0.7.2
- Fix normals to work with new ECCC data format
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
26 changes: 15 additions & 11 deletions R/weathercan-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,21 @@ NULL
get_html <<- memoise::memoise(get_html, ~memoise::timeout(24 * 60 * 60))
normals_html <<- memoise::memoise(normals_html, ~memoise::timeout(24 * 60 * 60))

options(weathercan.urls.weather =
"https://climate.weather.gc.ca/climate_data/bulk_data_e.html",
weathercan.urls.normals =
"https://climate.weather.gc.ca/climate_normals/bulk_data_e.html",
# Download from google drive: https://stackoverflow.com/a/50533232/3362144
weathercan.urls.stations =
paste0("https://drive.google.com/uc?export=download&id=",
"1HDRnj41YBWpMioLPwAFiLlK4SK8NV72C"),
weathercan.urls.stations.normals =
"https://climate.weather.gc.ca/climate_normals/station_inventory_e.html",
weathercan.time.message = FALSE)
options(
weathercan.urls.weather =
"https://climate.weather.gc.ca/climate_data/bulk_data_e.html",
weathercan.urls.normals =
"https://climate.weather.gc.ca/climate_normals/bulk_data_e.html",
# Download from google drive: https://stackoverflow.com/a/50533232/3362144
weathercan.urls.stations =
paste0("https://collaboration.cmc.ec.gc.ca/cmc/climate/",
"Get_More_Data_Plus_de_donnees/Station%20Inventory%20EN.csv"),
#weathercan.urls.stations =
# paste0("https://drive.google.com/uc?export=download&id=",
# "1HDRnj41YBWpMioLPwAFiLlK4SK8NV72C"),
weathercan.urls.stations.normals =
"https://climate.weather.gc.ca/climate_normals/station_inventory_e.html",
weathercan.time.message = FALSE)

# CRAN Note avoidance
if(getRversion() >= "2.15.1")
Expand Down
Binary file modified data/codes.rda
Binary file not shown.
Binary file modified data/flags.rda
Binary file not shown.
Binary file modified data/glossary.rda
Binary file not shown.
Binary file modified data/glossary_normals.rda
Binary file not shown.
Binary file modified data/kamloops.rda
Binary file not shown.
Binary file modified data/kamloops_day.rda
Binary file not shown.
Binary file modified data/pg.rda
Binary file not shown.
Binary file modified inst/extdata/stations.rds
Binary file not shown.
1 change: 1 addition & 0 deletions release_script.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ usethis::use_github_release()
## Prep for next
usethis::pr_init("dev")
usethis::use_dev_version()
usethis::pr_push()


# Good practices --------------------
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test_00_onLoad.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ test_that("URLS correctly set", {
expect_true(stringr::str_detect(w, "climate.weather.gc.ca"))

expect_type(w <- getOption("weathercan.urls.stations"), "character")
expect_true(stringr::str_detect(w, "drive.google.com"))
#expect_true(stringr::str_detect(w, "drive.google.com"))
expect_true(stringr::str_detect(w, "collaboration.cmc.ec.gc.ca"))

expect_type(w <- getOption("weathercan.urls.stations.normals"), "character")
expect_true(stringr::str_detect(w, "climate.weather.gc.ca"))
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test_03_station_dl.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ test_that("stations_dl() runs and updates data", {
expect_type(s$meta, "list") %>%
expect_length(2)

# Ensure that we're getting recent data
expect_equal(max(s$stn$end, na.rm = TRUE), lubridate::year(Sys.Date()))

# stations_read() ----

# Without local file, use package file
Expand Down
1 change: 1 addition & 0 deletions weathercan.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 03f10167-c7d2-438e-98c3-52cbb5d1948c

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down

0 comments on commit 9d017e9

Please sign in to comment.