From 5a64ea5971b2be7a2274b2d1f13643ef87adb2f6 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Mon, 29 Mar 2021 09:35:57 +0800 Subject: [PATCH] Lint package --- R/get_ag_bulletin.R | 16 --- R/get_coastal_forecast.R | 34 ------ R/get_current_weather.R | 2 +- R/get_historical_weather.R | 7 +- R/get_precis_forecast.R | 4 - R/get_radar_imagery.R | 24 ++--- R/get_satellite_imagery.R | 7 +- R/get_weather_bulletins.R | 152 +++++++++++++-------------- R/update_forecast_towns.R | 4 +- R/update_station_locations.R | 10 +- R/zzz.R | 4 +- man/get_satellite_imagery.Rd | 7 +- man/update_forecast_towns.Rd | 4 +- man/update_station_locations.Rd | 10 +- tests/testthat/test-file_caching.R | 1 - tests/testthat/test-get_historical.R | 10 +- 16 files changed, 116 insertions(+), 180 deletions(-) diff --git a/R/get_ag_bulletin.R b/R/get_ag_bulletin.R index 264ef9d1..beb73e55 100644 --- a/R/get_ag_bulletin.R +++ b/R/get_ag_bulletin.R @@ -90,7 +90,6 @@ get_ag_bulletin <- function(state = "AUS") { xml_url <- .create_bom_file(AUS_XML, .the_state = cleaned_state, .file_loc = file_loc) - bulletin_out <- .parse_bulletin(xml_url) if (is.null(bulletin_out)) { return(invisible(NULL)) @@ -110,7 +109,6 @@ get_ag_bulletin <- function(state = "AUS") { # CRAN NOTE avoidance stations_site_list <- site <- obs_time_local <- obs_time_utc <- r <- .SD <- NULL # nocov - # load the XML from ftp if (substr(xml_url, 1, 3) == "ftp") { xml_object <- .get_url(remote_file = xml_url) @@ -120,17 +118,14 @@ get_ag_bulletin <- function(state = "AUS") { } else {# load the XML from local xml_object <- xml2::read_xml(xml_url) } - # get definitions (and all possible value fields to check against) definition_attrs <- xml2::xml_find_all(xml_object, "//data-def") definition_attrs <- xml2::xml_attrs(definition_attrs) definition_attrs <- lapply(definition_attrs, function(x) x[[1]][[1]]) - # get the actual observations and create a data table observations <- xml2::xml_find_all(xml_object, ".//d") - out <- data.table::data.table( obs_time_local = xml2::xml_find_first(observations, ".//ancestor::obs") %>% xml2::xml_attr("obs-time-local"), @@ -148,24 +143,20 @@ get_ag_bulletin <- function(state = "AUS") { 1, nchar(basename(xml_url)) - 4) ) - out <- data.table::dcast( out, product_id + obs_time_local + obs_time_utc + time_zone + site + station ~ observation, value.var = "values" ) - # check that all fields are present, if not add missing col with NAs missing <- setdiff(unlist(definition_attrs), names(out[, -c(1:5)])) if (length(missing) != 0) { out[, eval(missing) := NA] } - # remove leading 0 to merge with stations_site_list out[, site := gsub("^0{1,2}", "", out$site)] - # merge with AAC codes # load AAC code/town name list to join with final output load(system.file("extdata", "stations_site_list.rda", # nocov @@ -174,7 +165,6 @@ get_ag_bulletin <- function(state = "AUS") { data.table::setkey(stations_site_list, "site") data.table::setkey(out, "site") out <- stations_site_list[out, on = "site"] - # tidy up the cols refcols <- c( "product_id", @@ -208,13 +198,11 @@ get_ag_bulletin <- function(state = "AUS") { "t1m", "wr" ) - # set col classes # factor out[, c(1:3, 11:12) := lapply(.SD, function(x) as.factor(x)), .SDcols = c(1:3, 11:12)] - # dates out[, obs_time_local := gsub("T", " ", obs_time_local)] out[, obs_time_utc := gsub("T", " ", obs_time_utc)] @@ -223,16 +211,12 @@ get_ag_bulletin <- function(state = "AUS") { origin = "1970-1-1", format = "%Y%m%d %H%M")), .SDcols = c(13:14)] - # set "Tce" to 0.01 out[, r := gsub("Tce", "0.01", r)] - # set numeric cols out[, c(4:7, 9:10, 17:30) := lapply(.SD, as.numeric), .SDcols = c(4:7, 9:10, 17:30)] - data.table::setcolorder(out, refcols) - # return from main function return(out) } diff --git a/R/get_coastal_forecast.R b/R/get_coastal_forecast.R index 10b3ceaf..b147bffe 100644 --- a/R/get_coastal_forecast.R +++ b/R/get_coastal_forecast.R @@ -55,7 +55,6 @@ get_coastal_forecast <- function(state = "AUS") { # this is just a placeholder for functionality with parse_coastal_forecast() filepath <- NULL - # see internal_functions.R for these functions the_state <- .check_states(state) location <- .validate_filepath(filepath) @@ -87,7 +86,6 @@ get_coastal_forecast <- function(state = "AUS") { xml_url <- .create_bom_file(AUS_XML, .the_state = cleaned_state, .file_loc = file_loc) - coastal_out <- .parse_coastal_forecast(xml_url) if (is.null(coastal_out)) { return(invisible(NULL)) @@ -112,7 +110,6 @@ get_coastal_forecast <- function(state = "AUS") { state_code <- tropical_system_location <- forecast_waves <- .SD <- AAC_codes <- NULL # nocov end - # load the XML from ftp if (substr(xml_url, 1, 3) == "ftp") { xml_object <- .get_url(xml_url) @@ -123,50 +120,37 @@ get_coastal_forecast <- function(state = "AUS") { # load the XML from local xml_object <- xml2::read_xml(xml_url) } - out <- .parse_coastal_xml(xml_object) - # clean up and split out time cols into offset and remove extra chars .split_time_cols(x = out) - # merge with aac codes for location information load(system.file("extdata", "marine_AAC_codes.rda", package = "bomrang")) # nocov data.table::setkey(out, "aac") out <- marine_AAC_codes[out, on = c("aac", "dist_name")] - # add state field out[, state_code := gsub("_.*", "", out$aac)] - - # return final forecast object - # add product ID field out[, product_id := substr(basename(xml_url), 1, nchar(basename(xml_url)) - 4)] - # some fields only come out on special occasions, if absent, add as NA if (!"forecast_swell2" %in% colnames(out)) { out[, forecast_swell2 := NA] } - if (!"forecast_caution" %in% colnames(out)) { out[, forecast_caution := NA] } - if (!"marine_forecast" %in% colnames(out)) { out[, marine_forecast := NA] } - if (!"tropical_system_location" %in% colnames(out)) { out[, tropical_system_location := NA] } - if (!"forecast_waves" %in% colnames(out)) { out[, forecast_waves := NA] } - # reorder columns refcols <- c( "index", @@ -192,21 +176,17 @@ get_coastal_forecast <- function(state = "AUS") { "tropical_system_location", "forecast_waves" ) - data.table::setcolorder(out, refcols) - # set col classes # factors out[, c(1, 11) := lapply(.SD, function(x) as.factor(x)), .SDcols = c(1, 11)] - out[, c(9:10) := lapply(.SD, function(x) as.POSIXct(x, origin = "1970-1-1", format = "%Y-%m-%d %H:%M:%OS")), .SDcols = c(9:10)] - out[, c(12:13) := lapply(.SD, function(x) as.POSIXct( x, @@ -215,12 +195,10 @@ get_coastal_forecast <- function(state = "AUS") { tz = "GMT" )), .SDcols = c(12:13)] - # character out[, c(6:8, 14:20) := lapply(.SD, function(x) as.character(x)), .SDcols = c(6:8, 14:20)] - return(out) } @@ -238,11 +216,9 @@ get_coastal_forecast <- function(state = "AUS") { forecast_waves <- synoptic_situation <- # nocov start preamble <- warning_summary_footer <- product_footer <- postamble <- NULL # nocov end - # get the actual forecast objects meta <- xml2::xml_find_all(xml_object, ".//text") fp <- xml2::xml_find_all(xml_object, ".//forecast-period") - locations_index <- data.table::data.table( # find all the aacs aac = xml2::xml_parent(meta) %>% @@ -269,7 +245,6 @@ get_coastal_forecast <- function(state = "AUS") { xml2::xml_find_first(".//parent::forecast-period") %>% xml2::xml_attr("start-time-local") ) - vals <- lapply(fp, function(node) { # find names of all children nodes childnodes <- node %>% @@ -281,40 +256,31 @@ get_coastal_forecast <- function(state = "AUS") { xml2::xml_attr("type") # create columns names based on either node name or attr value names <- ifelse(is.na(names), childnodes, names) - # find all values values <- node %>% xml2::xml_children() %>% xml2::xml_text() - # create data frame and properly label the columns df <- data.frame(t(values), stringsAsFactors = FALSE) names(df) <- names df }) - vals <- data.table::rbindlist(vals, fill = TRUE) sub_out <- cbind(locations_index, vals) - if ("synoptic_situation" %in% names(sub_out)) { sub_out[, synoptic_situation := NULL] } - if ("preamble" %in% names(sub_out)) { sub_out[, preamble := NULL] } - if ("warning_summary_footer" %in% names(sub_out)) { sub_out[, warning_summary_footer := NULL] } - if ("product_footer" %in% names(sub_out)) { sub_out[, product_footer := NULL] } - if ("postamble" %in% names(sub_out)) { sub_out[, postamble := NULL] } - return(sub_out) } diff --git a/R/get_current_weather.R b/R/get_current_weather.R index ef7ed898..bd78d729 100644 --- a/R/get_current_weather.R +++ b/R/get_current_weather.R @@ -74,7 +74,7 @@ get_current_weather <- strict = FALSE, latlon = NULL, emit_latlon_msg = TRUE) { - JSONurl_site_list <- name <- .SD <- na_if <- NULL + JSONurl_site_list <- name <- .SD <- NULL # Load JSON URL list load(system.file("extdata", "JSONurl_site_list.rda", # nocov start diff --git a/R/get_historical_weather.R b/R/get_historical_weather.R index db884419..0fd96e45 100644 --- a/R/get_historical_weather.R +++ b/R/get_historical_weather.R @@ -176,7 +176,8 @@ get_historical_weather <- get_historical <- "quality"), solar = c("solar_exposure") )) - dat[["station_number"]] <- sprintf("%06d", as.integer(dat[["station_number"]])) + dat[["station_number"]] <- sprintf("%06d", + as.integer(dat[["station_number"]])) return( structure( @@ -259,8 +260,8 @@ get_historical <- get_historical_weather # read the station list in as a vector first so that we can # detect and remove the header and footer... ncc <- readLines(weather[i]) - header_start <- grep('^\\-+$', ncc) + 1L - footer_start <- grep('^[0-9]+ stations', ncc) - 1L + header_start <- grep("^\\-+$", ncc) + 1L + footer_start <- grep("^[0-9]+ stations", ncc) - 1L if (length(header_start > 0) && length(footer_start > 0)) { # ... then process it as a data frame diff --git a/R/get_precis_forecast.R b/R/get_precis_forecast.R index 5003bf9c..1ad5bfa4 100644 --- a/R/get_precis_forecast.R +++ b/R/get_precis_forecast.R @@ -75,9 +75,6 @@ get_precis_forecast <- function(state = "AUS") { #' #' @noRd .return_precis <- function(file_loc, cleaned_state) { - - product_id <- probability_of_precipitation <- lower_precipitation_limit <- NULL - # create vector of XML files AUS_XML <- c( "IDN11060.xml", @@ -98,7 +95,6 @@ get_precis_forecast <- function(state = "AUS") { xml_url <- .create_bom_file(AUS_XML, .the_state = cleaned_state, .file_loc = file_loc) - precis_out <- .parse_precis_forecast(xml_url) if (is.null(precis_out)) { return(invisible(NULL)) diff --git a/R/get_radar_imagery.R b/R/get_radar_imagery.R index e50603c1..e735ebf2 100644 --- a/R/get_radar_imagery.R +++ b/R/get_radar_imagery.R @@ -36,11 +36,12 @@ get_available_radar <- function(radar_id = "all") { radar_locations <- NULL #nocov load(system.file("extdata", "radar_locations.rda", package = "bomrang")) list_files <- curl::new_handle() - curl::handle_setopt(handle = list_files, - FTP_RESPONSE_TIMEOUT = 200000, - CONNECTTIMEOUT = 90, - ftp_use_epsv = TRUE, - dirlistonly = TRUE + curl::handle_setopt( + handle = list_files, + FTP_RESPONSE_TIMEOUT = 200000, + CONNECTTIMEOUT = 90, + ftp_use_epsv = TRUE, + dirlistonly = TRUE ) con <- curl::curl(url = ftp_base, "r", handle = list_files) files <- readLines(con) @@ -65,7 +66,7 @@ get_available_radar <- function(radar_id = "all") { if (radar_id[1] == "all") { dat <- dat } else if (is.numeric(radar_id) && radar_id %in% dat$Radar_id) { - dat <- dat[dat$Radar_id %in% radar_id, ] + dat <- dat[dat$Radar_id %in% radar_id,] } else{ stop("radar_id not found") } @@ -129,10 +130,10 @@ get_radar_imagery <- get_radar <- call. = FALSE ) } - + ftp_base <- "ftp://ftp.bom.gov.au/anon/gen/radar" fp <- file.path(ftp_base, paste0(product_id, ".gif")) - + if (is.null(path)) { path <- tempfile(fileext = ".gif", tmpdir = tempdir()) } @@ -167,10 +168,9 @@ get_radar_imagery <- get_radar <- }, error = function() { return(magick::image_read( - path = - system.file("error_images", - "image_error_message.png", - package = "bomrang") + path = system.file("error_images", + "image_error_message.png", + package = "bomrang") )) }) } diff --git a/R/get_satellite_imagery.R b/R/get_satellite_imagery.R index 6f90bc1e..e1c1c92a 100644 --- a/R/get_satellite_imagery.R +++ b/R/get_satellite_imagery.R @@ -66,9 +66,10 @@ get_available_imagery <- function(product_id = "all") { #' #' Fetch \acronym{BOM} satellite GeoTIFF imagery from #' \url{ftp://ftp.bom.gov.au/anon/gen/gms/} and return a raster -#' \code{\link[terra]{SpatRaster}} object of 'GeoTIFF' files. Files are available at -#' ten minute update frequency with a 24 hour delete time. Suggested to check -#' file availability first by using \code{\link{get_available_imagery}}. +#' \code{\link[terra]{SpatRaster}} object of 'GeoTIFF' files. Files are +#' available at ten minutes update frequency with a 24 hour delete time. +#' It is suggested to check file availability first by using +#' \code{\link{get_available_imagery}}. #' #' @param product_id Character. \acronym{BOM} product ID to download in #' 'GeoTIFF' format and import as a \code{\link[terra]{SpatRaster}} object. A diff --git a/R/get_weather_bulletins.R b/R/get_weather_bulletins.R index 7c265183..b1602586 100644 --- a/R/get_weather_bulletins.R +++ b/R/get_weather_bulletins.R @@ -48,7 +48,6 @@ #' @export get_weather_bulletin get_weather_bulletin <- function(state = "qld", morning = TRUE) { - na_if <- NULL the_state <- .convert_state(state) # see internal_functions.R @@ -56,17 +55,19 @@ get_weather_bulletin <- function(state = "qld", morning = TRUE) { stop(call. = FALSE, "Weather bulletins can only be extracted for individual states.") } - + if (morning) { url_suffix <- "9am_bulletin.shtml" } else { url_suffix <- "3pm_bulletin.shtml" } - + # http server - USERAGENT <- paste0("{bomrang} R package (", - utils::packageVersion("bomrang"), - ") https://github.com/ropensci/bomrang") + USERAGENT <- paste0( + "{bomrang} R package (", + utils::packageVersion("bomrang"), + ") https://github.com/ropensci/bomrang" + ) # set a custom user-agent, restore original settings on exit # required for #130 - BOM returns 403 for RStudio op <- options() @@ -78,9 +79,11 @@ get_weather_bulletin <- function(state = "qld", morning = TRUE) { paste0(http_base, tolower(the_state), "/observations/", url_suffix) - USERAGENT <- paste0("{bomrang} R package (", - utils::packageVersion("bomrang"), - ") https://github.com/ropensci/bomrang") + USERAGENT <- paste0( + "{bomrang} R package (", + utils::packageVersion("bomrang"), + ") https://github.com/ropensci/bomrang" + ) # set a custom user-agent, restore original settings on exit # required for #130 - BOM returns 403 for RStudio op <- options() @@ -99,14 +102,12 @@ get_weather_bulletin <- function(state = "qld", morning = TRUE) { TIMEOUT = 120L, USERAGENT = USERAGENT ) - + dat <- file.path(tempdir(), "bulletin.xml") - curl::curl_download( - url = wb_url, - handle = h, - destfile = dat - ) + curl::curl_download(url = wb_url, + handle = h, + destfile = dat) dat <- xml2::read_html(dat) %>% rvest::html_table() @@ -114,15 +115,15 @@ get_weather_bulletin <- function(state = "qld", morning = TRUE) { if (the_state == "WA") { dat[[length(dat)]] <- NULL } - + dat <- lapply(dat, tidy_bulletin_header) %>% dplyr::bind_rows() %>% janitor::clean_names(case = "old_janitor") %>% janitor::remove_empty("cols") - + names(dat) <- gsub("\\_nbsp", "", names (dat)) names(dat) <- gsub ("rainmm", "rain_mm", names (dat)) - + if (the_state %notin% c("WA", "SA")) { # vars for subsequent tidying: vars <- @@ -147,7 +148,7 @@ get_weather_bulletin <- function(state = "qld", morning = TRUE) { vars <- setdiff(names(dat), charvars) } windvar <- grep("wind", names(dat)) - + # Final manual cleaning: # bind_rows inserts NAs in all extra rows, so i <- grep("seastate", names (dat)) @@ -158,7 +159,7 @@ get_weather_bulletin <- function(state = "qld", morning = TRUE) { # A valid rain value is "Tce" for "Trace", which is here converted to 0.1 i <- grep("rain", names(dat)) dat[, i][dat[, i] == "Tce"] <- "0.1" - + # Then just the tidy stuff: out <- tidyr::separate( dat, @@ -170,28 +171,26 @@ get_weather_bulletin <- function(state = "qld", morning = TRUE) { ) %>% dplyr::mutate_at(.funs = as.numeric, .vars = vars) %>% - dplyr::mutate_all(list(~dplyr::na_if(., ""))) - - + dplyr::mutate_all(list(~ dplyr::na_if(., ""))) names(out) <- sub("current_details_", "", names(out)) names(out) <- sub("x24_hour_details_", "", names(out)) names(out) <- sub("x6_hour_details_", "", names(out)) - + out <- data.table::setDT(out) - + # DT auto-coverts most var types, but fails on these. # The code is written to avoid DT warnings on NA conversion col_convert <- function (x, colname, fn) { - i <- grep (colname, names (x)) - nm <- names (x) [i] - val <- do.call (fn, list (x [, get (nm)])) - x [, i] <- val - return (x) + i <- grep (colname, names (x)) + nm <- names (x) [i] + val <- do.call (fn, list (x [, get (nm)])) + x [, i] <- val + return (x) } - + out <- col_convert (out, "cld8ths", as.integer) out <- col_convert (out, "rain_mm", as.numeric) - + return (out) } @@ -208,14 +207,14 @@ tidy_bulletin_header <- function(bull) { if (nrow(bull) <= 1) { return(NULL) } - + # remove filled rows containing district names only: bull <- bull[apply(bull, 1, function(i) - any(i != i[1])), ] - + any(i != i[1])), ] + bull <- merge_first_two_rows (bull) bull <- merge_header_plus_row (bull) - + return (bull) } @@ -228,51 +227,48 @@ pad_white <- function(x) { # TWO rows of the table. This function checks if the first 2 rows are parts of # column names, and merges them into one row merge_first_two_rows <- function(x) { - - if (x [1, 1, drop = TRUE] != x [2, 1, drop = TRUE]) - return (x) - - row1 <- unname (unlist (x [1, ])) - row2 <- unname (unlist (x [2, ])) - row2 [row2 == row1] <- "" - row2 [which (row2 != "")] <- paste0 (" ", row2 [which (row2 != "")]) - - row1 <- paste0 (row1, row2) - - x <- x [-2, ] - for (r in seq_along (row1)) - x [1, r] <- row1 [r] - + if (x [1, 1, drop = TRUE] != x [2, 1, drop = TRUE]) return (x) + + row1 <- unname (unlist (x [1,])) + row2 <- unname (unlist (x [2,])) + row2 [row2 == row1] <- "" + row2 [which (row2 != "")] <- + paste0 (" ", row2 [which (row2 != "")]) + + row1 <- paste0(row1, row2) + + x <- x [-2,] + for (r in seq_along(row1)) + x [1, r] <- row1 [r] + + return(x) } -merge_header_plus_row <- function (x) { - - if (sum(x[,1] == names(x)[1]) != 1) - return (x) - - cnms <- names (x) - row1 <- unname (unlist (x [1, ])) - row1 [row1 == cnms] <- "" - row1 [row1 != ""] <- paste0 (" ", row1 [row1 != ""]) - - names (x) <- paste0 (cnms, row1) - x <- x [-1, ] +merge_header_plus_row <- function(x) { + if (sum(x[, 1] == names(x)[1]) != 1) + return(x) + + cnms <- names(x) + row1 <- unname(unlist(x [1,])) + row1 [row1 == cnms] <- "" + row1 [row1 != ""] <- paste0(" ", row1 [row1 != ""]) + names (x) <- paste0 (cnms, row1) + x <- x[-1,] } -convert_var_types <- function (x) { - - intvars <- c ("cld8ths", - "wind_speed", - "bar") - dblvars <- c ("temp_c") - - for (i in intvars) { - index <- grep (i, names (x)) - x [, index] <- as.integer (x [, index, drop = TRUE]) - } - for (i in dblvars) { - index <- grep (i, names (x)) - x [, index] <- as.numeric (x [, index]) - } +convert_var_types <- function(x) { + intvars <- c("cld8ths", + "wind_speed", + "bar") + dblvars <- c("temp_c") + + for (i in intvars) { + index <- grep(i, names (x)) + x [, index] <- as.integer(x [, index, drop = TRUE]) + } + for (i in dblvars) { + index <- grep(i, names (x)) + x [, index] <- as.numeric (x [, index]) + } } diff --git a/R/update_forecast_towns.R b/R/update_forecast_towns.R index d09b2d48..e4f7b7cb 100644 --- a/R/update_forecast_towns.R +++ b/R/update_forecast_towns.R @@ -7,8 +7,8 @@ #' codes used by \code{\link{get_precis_forecast}}. There is no need to use #' this unless you know that a forecast town exists in a more current version of #' the \acronym{BOM} précis forecast town name database that is not available in -#' the database distributed with \CRANpkg{bomrang}. In fact, for reproducibility -#' purposes, users are discouraged from using this function. +#' the database distributed with \CRANpkg{bomrang}. In fact, for +#' reproducibility purposes, users are discouraged from using this function. #' #' @examples #' \dontrun{ diff --git a/R/update_station_locations.R b/R/update_station_locations.R index d84d1b85..122e96fd 100644 --- a/R/update_station_locations.R +++ b/R/update_station_locations.R @@ -9,11 +9,11 @@ #' with \CRANpkg{bomrang}. In fact, for reproducibility purposes, users are #' discouraged from using this function. #' -#' If \CRANpkg{ASGS.foyer} is installed locally, this function will automatically -#' check and correct any invalid state values for stations located in Australia. -#' If \CRANpkg{ASGS.foyer} is not installed, the function will update the internal -#' database without validating the state values for stations by reported -#' longitude/latitude location. +#' If \CRANpkg{ASGS.foyer} is installed locally, this function will +#' automatically check and correct any invalid state values for stations located +#' in Australia. If \CRANpkg{ASGS.foyer} is not installed, the function will +#' update the internal database without validating the state values for stations +#' by reported longitude/latitude location. #' #' @examples #' \dontrun{ diff --git a/R/zzz.R b/R/zzz.R index b483e61d..d5cf28d9 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -13,6 +13,4 @@ manage_cache <- NULL # nocov start manage_cache <<- x } options(bomrang.connection = stdin()) - } - -# nocov end + } # nocov end diff --git a/man/get_satellite_imagery.Rd b/man/get_satellite_imagery.Rd index 2608d662..f5adf248 100644 --- a/man/get_satellite_imagery.Rd +++ b/man/get_satellite_imagery.Rd @@ -30,9 +30,10 @@ A \code{SpatRaster} object of GeoTIFF images with layers named by \description{ Fetch \acronym{BOM} satellite GeoTIFF imagery from \url{ftp://ftp.bom.gov.au/anon/gen/gms/} and return a raster -\code{\link[terra]{SpatRaster}} object of 'GeoTIFF' files. Files are available at -ten minute update frequency with a 24 hour delete time. Suggested to check -file availability first by using \code{\link{get_available_imagery}}. +\code{\link[terra]{SpatRaster}} object of 'GeoTIFF' files. Files are +available at ten minutes update frequency with a 24 hour delete time. +It is suggested to check file availability first by using +\code{\link{get_available_imagery}}. } \details{ Valid \acronym{BOM} satellite Product IDs for use with diff --git a/man/update_forecast_towns.Rd b/man/update_forecast_towns.Rd index 06451fbb..c99b0c4f 100644 --- a/man/update_forecast_towns.Rd +++ b/man/update_forecast_towns.Rd @@ -15,8 +15,8 @@ update internal database of précis forecast town names and \acronym{AAC} codes used by \code{\link{get_precis_forecast}}. There is no need to use this unless you know that a forecast town exists in a more current version of the \acronym{BOM} précis forecast town name database that is not available in -the database distributed with \CRANpkg{bomrang}. In fact, for reproducibility -purposes, users are discouraged from using this function. +the database distributed with \CRANpkg{bomrang}. In fact, for +reproducibility purposes, users are discouraged from using this function. } \examples{ \dontrun{ diff --git a/man/update_station_locations.Rd b/man/update_station_locations.Rd index 752a8472..f0eecf6d 100644 --- a/man/update_station_locations.Rd +++ b/man/update_station_locations.Rd @@ -20,11 +20,11 @@ with \CRANpkg{bomrang}. In fact, for reproducibility purposes, users are discouraged from using this function. } \details{ -If \CRANpkg{ASGS.foyer} is installed locally, this function will automatically -check and correct any invalid state values for stations located in Australia. -If \CRANpkg{ASGS.foyer} is not installed, the function will update the internal -database without validating the state values for stations by reported -longitude/latitude location. +If \CRANpkg{ASGS.foyer} is installed locally, this function will +automatically check and correct any invalid state values for stations located +in Australia. If \CRANpkg{ASGS.foyer} is not installed, the function will +update the internal database without validating the state values for stations +by reported longitude/latitude location. } \examples{ \dontrun{ diff --git a/tests/testthat/test-file_caching.R b/tests/testthat/test-file_caching.R index e4baeeed..bb82c2f3 100644 --- a/tests/testthat/test-file_caching.R +++ b/tests/testthat/test-file_caching.R @@ -57,7 +57,6 @@ test_that("caching utils list files in cache and delete when asked", { x = f, filename = file.path(cache_dir, "file2.tif") ) - # test bomrang cache list k <- basename(manage_cache$list()) expect_equal(basename(manage_cache$list()), k) diff --git a/tests/testthat/test-get_historical.R b/tests/testthat/test-get_historical.R index 47c0e741..f0aaed5f 100644 --- a/tests/testthat/test-get_historical.R +++ b/tests/testthat/test-get_historical.R @@ -18,18 +18,13 @@ test_that("Error handling", { x$warnings[1], "\nOnly one of `stationid` or `latlon` may be provided. \nUsing `stationid`\n." ) - # expect_equal( - # x$warnings[2], - # "The list of available stations for `type = rain` is currently empty.\nThis is likely a temporary error in the Bureau of Meteorology's\ndatabase and may cause requests for rain station data to fail." - # ) expect_error(get_historical_weather("023000", type = "sodiuhfosdhfoisdh"), regexp = "arg.*rain.*solar") }) test_that( "Query stationid = '023000', - type = 'rain' returns bomrang_tbl w/ correct station and some data", - { + type = 'rain' returns bomrang_tbl w/ correct station and some data", { skip_on_cran() ADLhistrain <- get_historical_weather("023000", type = "rain") expect_is(ADLhistrain, "bomrang_tbl") @@ -54,8 +49,7 @@ test_that("Query stationid = '023000'", { test_that( "Query latlon = c(-34.9285, 138.6007), - type = 'rain' returns bomrang_tbl w/ correct station and some data", - { + type = 'rain' returns bomrang_tbl w/ correct station and some data", { skip_on_cran() ADLhistrain <- get_historical_weather(latlon = c(-34.9285, 138.6007),