Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhsparks committed Jul 4, 2021
2 parents b4d4329 + eff3931 commit 8584d81
Show file tree
Hide file tree
Showing 12 changed files with 234 additions and 225 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: GSODR
Type: Package
Title: Global Surface Summary of the Day ('GSOD') Weather Data Client
Version: 3.1.1.9000
Version: 3.1.2
Authors@R: c(person("Adam H.", "Sparks", role = c("aut", "cre"),
email = "adamhsparks@gmail.com",
comment = c(ORCID = "0000-0002-0061-8359")),
Expand Down Expand Up @@ -31,7 +31,7 @@ Authors@R: c(person("Adam H.", "Sparks", role = c("aut", "cre"),
person("Tyler", "Widdison", role = "ctb",
email = "Tyler.Widdison@usav.org", comment = "Reported bug where
`nearest_stations()` did not return stations in order of nearest to
farthest."))
farthest"))
URL: https://docs.ropensci.org/GSODR/
BugReports: https://github.com/ropensci/GSODR/issues
Description: Provides automated downloading, parsing, cleaning, unit conversion
Expand Down
13 changes: 10 additions & 3 deletions NEWS.md
@@ -1,10 +1,10 @@
# GSODR (development version)
# GSODR 3.1.2

## Bug fixes

* Fix (more) bugs related to `NA` value replacements.

## Minor changes
## Minor changes and improvements

* Simplify `NA` value replacement in "PRCP" column.

Expand All @@ -14,6 +14,13 @@

* Better tests for the generated weather data `data.table` output checking values and formats.

* Tests are updated for updated data availability in the GSOD data due to continuous improvements to the data set.

* Standardise handling of author/contributor comments.
None have a full stop now in the comment.

* Use `on.exit()` to reset the working directory to the original user-space value after changing the working directory to untar files located in `tempdir()`.

# GSODR 3.1.1

## Bug fixes
Expand All @@ -22,7 +29,7 @@

* Fixes bug where NA values reported as 99.99, 999.9 or 9999.9 were not replaced with `NA`.

* Fix bug where FRSHTT (Fog, Rain/Drizzle, Snow/Ice, Hail, Tornado, Thunder) column values split into the respective columns only returned NA, not the proper values as expected.
* Fix bug where FRSHTT (Fog, Rain/Drizzle, Snow/Ice, Hail, Tornado, Thunder) column values split into the respective columns only returned `NA`, not the proper values as expected.
Reported in [#84](https://github.com/ropensci/GSODR/issues/84).

## Minor changes
Expand Down
2 changes: 1 addition & 1 deletion R/internal_functions.R
Expand Up @@ -179,10 +179,10 @@
list.files(tempdir(), pattern = "*\\.tar.gz$", full.names = TRUE)
for (i in tar_files) {
wd <- getwd()
on.exit(setwd(wd))
setwd(tempdir())
year_dir <- substr(i, nchar(i) - 10, nchar(i) - 7)
utils::untar(i, exdir = year_dir)
setwd(wd)
}

GSOD_list <-
Expand Down
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -75,8 +75,6 @@ The [_**gsod**_](https://github.com/databrew/gsod) package from [DataBrew](https
[_**stationaRy**_](https://cran.r-project.org/package=stationaRy), from Richard Iannone offers hourly meteorological data from stations located all over the world.
There is a wealth of data available, with historic weather data accessible from nearly 30,000 stations.

[_**bomrang**_](https://CRAN.R-project.org/package=bomrang), from [rOpenSci](https://docs.ropensci.org/bomrang/) provides functions to interface with Australia Government Bureau of Meteorology (BoM) data, fetching current and historical data including précis and marine forecasts, current weather data from stations, agriculture bulletin data, BoM 0900 or 1500 weather bulletins and satellite and radar imagery.

[_**riem**_](https://CRAN.R-project.org/package=riem) from [rOpenSci](https://docs.ropensci.org/riem/) allows to get weather data from Automated Surface Observing System (ASOS) stations (airports) in the whole world thanks to the Iowa Environment Mesonet website.

[_**weathercan**_](https://CRAN.R-project.org/package=weathercan) from [rOpenSci](https://github.com/ropensci/weathercan) makes it easier to search for and download multiple months/years of historical weather data from Environment and Climate Change Canada (ECCC) website.
Expand Down
4 changes: 2 additions & 2 deletions codemeta.json
Expand Up @@ -35,7 +35,7 @@
"keywords": ["US-NCEI", "meteorological-data", "global-weather", "weather", "weather-data", "meteorology", "station-data", "surface-weather", "data-access", "US-NCDC", "r", "gsod", "ncdc", "weather-stations", "global-data", "ncei", "weather-information", "historical-weather", "historical-data", "daily-data", "daily-weather", "rstats", "r-package"],
"license": "https://spdx.org/licenses/MIT",
"title": "GSODR",
"version": "3.1.1",
"version": "3.1.2",
"name": "GSODR: Global Surface Summary of the Day ('GSOD') Weather Data Client",
"issueTracker": "https://github.com/ropensci/GSODR/issues",
"programmingLanguage": {
Expand Down Expand Up @@ -375,7 +375,7 @@
"relatedLink": ["https://docs.ropensci.org/GSODR/", "https://CRAN.R-project.org/package=GSODR"],
"developmentStatus": "https://www.repostatus.org/#active",
"funder": {},
"fileSize": "3777.459KB",
"fileSize": "3781.662KB",
"releaseNotes": "https://github.com/ropensci/GSODR/blob/master/NEWS.md",
"readme": "https://github.com/ropensci/GSODR/blob/main/README.md",
"review": {
Expand Down
13 changes: 10 additions & 3 deletions cran-comments.md
@@ -1,4 +1,8 @@
## GSODR 3.1.1
# GSODR 3.1.2

## Comments for the CRAN team

I realise that the last release was last week, however, I found a few more bugs in the code that could cause some surprises with `NA` values for end users, so I've elected to release a new patch release.

## Test environments
* GitHub Actions (ubuntu-latest): release, devel
Expand All @@ -10,5 +14,8 @@
## R CMD check results
0 ERRORs | 0 WARNINGs | 0 NOTES.

# Reverse dependencies
No ERRORs or WARNINGs found
## Reverse dependencies
We checked 1 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 0 packages
4 changes: 1 addition & 3 deletions inst/WORDLIST
Expand Up @@ -2,7 +2,6 @@ ASOS
Agroclimatology
Alduchov
Bigouette
BoM
CCI
CDO
CGIAR
Expand Down Expand Up @@ -58,6 +57,7 @@ SNDP
SRTM
STNID
STP
Standardise
Toowoomba
USCS
VISIB
Expand All @@ -75,7 +75,6 @@ YYYYMMDD
acc
agroclimatology
al
bomrang
capitalisation
cliflo
clifro
Expand Down Expand Up @@ -107,7 +106,6 @@ onLoad
optimised
plyr
pre
précis
purrr
rOpenSci
rda
Expand Down
2 changes: 1 addition & 1 deletion man/GSODR-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions tests/testthat/test-download_files.R
@@ -0,0 +1,37 @@
test_that(
".download_files properly works, subsetting for country and
agroclimatology works",
{
skip_on_cran()
do.call(file.remove, list(list.files(
tempdir(),
pattern = ".csv$",
full.names = TRUE
)))
years <- 1982
agroclimatology <- TRUE
country <- "RP"
station <- NULL

load(system.file("extdata", "isd_history.rda", package = "GSODR"))
setkey(isd_history, "STNID")
stations <- isd_history

load(system.file("extdata", "isd_history.rda",
package = "GSODR"))

GSOD_list <- .download_files(station,
years)

agro_list <- .agroclimatology_list(GSOD_list,
stations,
years)
expect_length(agro_list, 7480)

RP_list <- .subset_country_list(country,
GSOD_list,
stations,
years)
expect_length(RP_list, 54)
}
)
22 changes: 7 additions & 15 deletions tests/testthat/test-get_GSOD.R
Expand Up @@ -62,7 +62,7 @@ test_that("missing days check allows stations with permissible days missing,
data.frame(c(rep(12, 300)), c(rep("X", 300)))
df_list <- list(just_right_2015, too_short_2015)
dir.create(path = file.path(td, "2015"))

filenames <- c("just_right0", "too_short00")
sapply(seq_len(length(df_list)),
function(x)
Expand All @@ -75,7 +75,7 @@ test_that("missing days check allows stations with permissible days missing,
pattern = ".csv$",
full.names = TRUE
)

if (!is.null(max_missing)) {
GSOD_list_filtered <- .validate_missing_days(max_missing,
GSOD_list)
Expand All @@ -102,7 +102,7 @@ test_that("missing days check allows stations with permissible days missing,
data.frame(c(rep(12, 300)), c(rep("X", 300)))
df_list <- list(just_right_2016, too_short_2016)
dir.create(path = file.path(td, "2016"))

filenames <- c("just_right0", "too_short00")
sapply(seq_len(length(df_list)),
function(x)
Expand All @@ -119,7 +119,7 @@ test_that("missing days check allows stations with permissible days missing,
GSOD_list_filtered <- .validate_missing_days(max_missing,
GSOD_list)
}

expect_length(GSOD_list, 2)
expect_match(basename(GSOD_list_filtered), "just_right0.csv")
rm_files <-
Expand All @@ -128,14 +128,6 @@ test_that("missing days check allows stations with permissible days missing,
file.remove(file.path(td, "2016"))
})

# Check that stations are filtered for missing days ----------------------------
# 1929 has no stations with a full 365 days, so none should be returned
test_that("The 'max_missing' parameter filters out improper stations", {
skip_on_cran()
expect_error(get_GSOD(years = 1929, max_missing = 1),
regexp = "There were no stations that had a max of.")
})

# Check that max_missing only accepts positive values --------------------------
test_that("The 'max_missing' parameter will not accept NA values", {
skip_on_cran()
Expand All @@ -154,15 +146,15 @@ test_that("Check validate country returns a two letter code", {
# CRAN NOTE avoidance
isd_history <- NULL
load(system.file("extdata", "isd_history.rda", package = "GSODR"))

country <- "Philippines"
Philippines <- .validate_country(country, isd_history)
expect_match(Philippines, "RP")

country <- "PHL"
PHL <- .validate_country(country, isd_history)
expect_match(PHL, "RP")

country <- "PH"
PH <- .validate_country(country, isd_history)
expect_match(PH, "RP")
Expand Down

0 comments on commit 8584d81

Please sign in to comment.