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

Update v0.7.3 #157

Merged
merged 8 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.gitignore
.Rproj.user
.Rhistory
.RData
Expand Down
9 changes: 7 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
Package: weathercan
Type: Package
Title: Download Weather Data from Environment and Climate Change Canada
Version: 0.7.2
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")),
person("Nick", "Brown", email = "[email protected]", role = c("ctb"), comment = c(ORCID = "0000-0002-2719-0671")),
person("Kevin", "Cazelles", email = "[email protected]", role = c("ctb"), comment = c(ORCID = "0000-0001-6619-9874")))
person("Kevin", "Cazelles", email = "[email protected]", role = c("ctb"), comment = c(ORCID = "0000-0001-6619-9874")),
person("Shandiya", "Balasubramaniam", role = "ctb", comment = c(ORCID = "0000-0001-9928-9964")),
person("Mark", "Ciechanowski", role = "ctb"),
person("Jeremy", "Selva", role = "ctb"),
person("Kelli", "Johnson", email = "[email protected]", role = "ctb")
)
Description: Provides means for downloading historical weather data from
the Environment and Climate Change Canada website
(<https://climate.weather.gc.ca/historical_data/search_historic_data_e.html>).
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# weathercan (development version)
# weathercan 0.7.3
- Switch stations inventory list to new location
- Don't try to download future weather
- Better test coverage (#149; 🙏 thanks @shandiya, @mciechanumich!)
- Replaced superseded dplyr functions (#150; 🙏 thanks @JauntyJJS, @RichardLitt!)
- Fixed test coverage GitHub Action (🙏 thanks @kellijohnson-NOAA!)

# 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.
9 changes: 8 additions & 1 deletion R/weather.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,16 @@
msg.start <- "earliest date"
} else {
s.start <- as.Date(start)
if(s.start > Sys.Date()) s.start <- Sys.Date()
msg.start <- start
}

if(is.null(end)) s.end <- Sys.Date() else s.end <- as.Date(end)
if(is.null(end)) {

Check warning on line 194 in R/weather.R

View check run for this annotation

Codecov / codecov/patch

R/weather.R#L194

Added line #L194 was not covered by tests
s.end <- Sys.Date()
} else {
s.end <- as.Date(end)
if(s.end > Sys.Date()) s.end <- Sys.Date()
}

Check warning on line 199 in R/weather.R

View check run for this annotation

Codecov / codecov/patch

R/weather.R#L199

Added line #L199 was not covered by tests
msg.end <- as.character(s.end)

dates <- lubridate::interval(s.start, s.end)
Expand Down Expand Up @@ -381,6 +387,7 @@
}

weather_single <- function(date_range, s, interval, encoding) {

w <- dplyr::tibble(date_range = date_range)
w <- dplyr::mutate(w, html = purrr::map(.data$date_range,
~ weather_html(station_id = s,
Expand Down
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 @@
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",

Check warning on line 75 in R/weathercan-package.R

View check run for this annotation

Codecov / codecov/patch

R/weathercan-package.R#L71-L75

Added lines #L71 - L75 were not covered by tests
# 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"),

Check warning on line 79 in R/weathercan-package.R

View check run for this annotation

Codecov / codecov/patch

R/weathercan-package.R#L77-L79

Added lines #L77 - L79 were not covered by tests
#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)

Check warning on line 85 in R/weathercan-package.R

View check run for this annotation

Codecov / codecov/patch

R/weathercan-package.R#L83-L85

Added lines #L83 - L85 were not covered by tests

# 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
3 changes: 3 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.html
*.R
normals_cache
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
Loading