diff --git a/R/airnow_loadAnnual.R b/R/airnow_loadAnnual.R index b9aa8b96..b4ef8101 100644 --- a/R/airnow_loadAnnual.R +++ b/R/airnow_loadAnnual.R @@ -71,7 +71,7 @@ airnow_loadAnnual <- function(year = NULL, baseUrl = 'https://haze.airfire.org/monitoring', dataDir = NULL) { - # Validate parameters -------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( is.null(year) ) { stop("Required parameter 'year' is missing.") diff --git a/R/airsis_createDataDataframe.R b/R/airsis_createDataDataframe.R index 23a096eb..ab02c66d 100644 --- a/R/airsis_createDataDataframe.R +++ b/R/airsis_createDataDataframe.R @@ -24,7 +24,7 @@ airsis_createDataDataframe <- function( logger.debug(" ----- airsis_createDataDataframe() ----- ") - # ----- Validate Parameters -------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- # Sanity check -- tbl must have deploymentID if ( !'deploymentID' %in% names(tbl) ) { diff --git a/R/airsis_createRawDataframe.R b/R/airsis_createRawDataframe.R index 90c254a8..f79b581e 100644 --- a/R/airsis_createRawDataframe.R +++ b/R/airsis_createRawDataframe.R @@ -67,7 +67,7 @@ airsis_createRawDataframe <- function( logger.debug(" ----- airsis_createRawDataframe() ----- ") - # Validate parameters -------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( is.null(provider) ) { logger.error("Required parameter 'provider' is missing") diff --git a/R/airsis_loadAnnual.R b/R/airsis_loadAnnual.R index 06b8c585..a209dcb6 100644 --- a/R/airsis_loadAnnual.R +++ b/R/airsis_loadAnnual.R @@ -71,7 +71,7 @@ airsis_loadAnnual <- function(year = NULL, baseUrl = 'https://haze.airfire.org/monitoring', dataDir = NULL) { - # Validate parameters -------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( is.null(year) ) { stop("Required parameter 'year' is missing.") diff --git a/R/downloadDataFile.R b/R/downloadDataFile.R index 9491cbde..41960586 100644 --- a/R/downloadDataFile.R +++ b/R/downloadDataFile.R @@ -23,7 +23,7 @@ downloadDataFile <- function( ... ) { - # Validate parameters -------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( is.null(filename) ) { stop("Required parameter 'filename' is missing.") diff --git a/R/epa_loadAnnual.R b/R/epa_loadAnnual.R index e2d8a3dd..b692f648 100644 --- a/R/epa_loadAnnual.R +++ b/R/epa_loadAnnual.R @@ -50,7 +50,7 @@ epa_loadAnnual <- function( dataDir = NULL ) { - # Validate parameters -------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- # Sanity Check -- validate parameter code # validParameterCodes <- c("44201", "42401", "42101", "42602", "88101", "88502", diff --git a/R/generic_parseData.R b/R/generic_parseData.R index c8a5e887..c867c4be 100644 --- a/R/generic_parseData.R +++ b/R/generic_parseData.R @@ -52,7 +52,7 @@ generic_parseData <- function( configList = NULL ) { - # Validate input ---------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- # Make sure fileString is a string (one element character vector) if ( diff --git a/R/monitor_collapse.R b/R/monitor_collapse.R index 557e77ce..04052977 100644 --- a/R/monitor_collapse.R +++ b/R/monitor_collapse.R @@ -83,7 +83,7 @@ monitor_collapse <- function( } - # Validate parameters -------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( monitor_isEmpty(ws_monitor) ) { stop("ws_monitor object contains zero monitors") diff --git a/R/monitor_dailyStatistic.R b/R/monitor_dailyStatistic.R index 8cbb9a30..b5704b8e 100644 --- a/R/monitor_dailyStatistic.R +++ b/R/monitor_dailyStatistic.R @@ -55,7 +55,7 @@ monitor_dailyStatistic <- function( minHours = 18 ) { - # Validate arguments --------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( monitor_isEmpty(ws_monitor) ) stop("ws_monitor object contains zero monitors") diff --git a/R/monitor_downloadAnnual.R b/R/monitor_downloadAnnual.R index 12846604..0cb95e06 100644 --- a/R/monitor_downloadAnnual.R +++ b/R/monitor_downloadAnnual.R @@ -71,7 +71,7 @@ monitor_downloadAnnual <- function( ... ) { - # Validate parameters -------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( is.null(year) ) { stop("Required parameter 'year' is missing.") diff --git a/R/monitor_getCurrentStatus.R b/R/monitor_getCurrentStatus.R index 24ffb1b0..f6ec49dc 100644 --- a/R/monitor_getCurrentStatus.R +++ b/R/monitor_getCurrentStatus.R @@ -107,7 +107,8 @@ monitor_getCurrentStatus <- function( logger.debug("----- monitor_getCurrentStatus() -----") - # Sanity checks -------------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- + logger.trace("Performing sanity checks on `ws_monitor` parameter.") if ( !monitor_isMonitor(ws_monitor) ) { diff --git a/R/monitor_getDailyMean.R b/R/monitor_getDailyMean.R index 8ab48949..352d9186 100644 --- a/R/monitor_getDailyMean.R +++ b/R/monitor_getDailyMean.R @@ -32,7 +32,7 @@ monitor_getDailyMean <- function( enddate = NULL ) { - # Validate arguments --------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( !monitor_isMonitor(ws_monitor) ) stop("Required parameter 'ws_monitor' is not a valid ws_monitor object.") diff --git a/R/monitor_leaflet.R b/R/monitor_leaflet.R index 12b87e8b..07be7295 100644 --- a/R/monitor_leaflet.R +++ b/R/monitor_leaflet.R @@ -43,6 +43,9 @@ #' #' @examples #' \dontrun{ +#' # Fail gracefully if any resources are not available +#' try({ +#' #' # Napa Fires -- October, 2017 #' ca <- airnow_load(2017) %>% #' monitor_subset(tlim = c(20171001,20171101), stateCodes = 'CA') @@ -51,6 +54,8 @@ #' monitor_leaflet(CA_very_unhealthy_monitors, #' legendTitle = "October, 2017", #' maptype = "toner") +#' +#' }, silent = FALSE) #' } monitor_leaflet <- function( diff --git a/R/monitor_load.R b/R/monitor_load.R index 81deaf42..00d6fcbc 100644 --- a/R/monitor_load.R +++ b/R/monitor_load.R @@ -26,18 +26,25 @@ #' @return A \emph{ws_monitor} object with PM2.5 monitoring data. #' @examples #' \dontrun{ +#' # Fail gracefully if any resources are not available +#' try({ +#' #' ca <- monitor_load(20170601,20171001) %>% monitor_subset(stateCodes='CA') +#' +#' }, silent = FALSE) #' } -monitor_load <- function(startdate = NULL, - enddate = NULL, - monitorIDs = NULL, - parameter="PM2.5", - baseUrl="https://haze.airfire.org/monitoring", - dataDir = NULL, - aqsPreference = "airnow") { - - # Validate parameters -------------------------------------------------------- +monitor_load <- function( + startdate = NULL, + enddate = NULL, + monitorIDs = NULL, + parameter = "PM2.5", + baseUrl = "https://haze.airfire.org/monitoring", + dataDir = NULL, + aqsPreference = "airnow" +) { + + # ----- Validate parameters -------------------------------------------------- if ( is.null(startdate) ) { stop(paste0("Required parameter 'startdate' is missing")) diff --git a/R/monitor_loadAnnual.R b/R/monitor_loadAnnual.R index 4e19090f..90f58ee2 100644 --- a/R/monitor_loadAnnual.R +++ b/R/monitor_loadAnnual.R @@ -56,18 +56,25 @@ #' @seealso \code{\link{monitor_loadLatest}} #' @examples #' \dontrun{ +#' # Fail gracefully if any resources are not available +#' try({ +#' #' monitor_loadAnnual(2014) %>% #' monitor_subset(stateCodes='MT', tlim=c(20140801,20140901)) %>% #' monitor_map() +#' +#' }, silent = FALSE) #' } -monitor_loadAnnual <- function(year = NULL, - parameter='PM2.5', - baseUrl='https://haze.airfire.org/monitoring', - dataDir = NULL, - aqsPreference = "airnow") { +monitor_loadAnnual <- function( + year = NULL, + parameter = 'PM2.5', + baseUrl = 'https://haze.airfire.org/monitoring', + dataDir = NULL, + aqsPreference = "airnow" +) { - # Validate parameters -------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( is.null(year) ) { stop("Required parameter 'year' is missing.") diff --git a/R/monitor_loadDaily.R b/R/monitor_loadDaily.R index d7bb7eaf..1825eeaa 100644 --- a/R/monitor_loadDaily.R +++ b/R/monitor_loadDaily.R @@ -60,14 +60,21 @@ #' @seealso \code{\link{monitor_loadAnnual}} #' @examples #' \dontrun{ +#' # Fail gracefully if any resources are not available +#' try({ +#' #' monitor_loadDaily() %>% #' monitor_subset(stateCodes=CONUS) %>% #' monitor_map() +#' +#' }, silent = FALSE) #' } -monitor_loadDaily <- function(parameter='PM2.5', - baseUrl='https://haze.airfire.org/monitoring/latest/RData', - dataDir = NULL) { +monitor_loadDaily <- function( + parameter = 'PM2.5', + baseUrl = 'https://haze.airfire.org/monitoring/latest/RData', + dataDir = NULL +) { airnow <- airnow_loadDaily(parameter, baseUrl, dataDir) airsis <- airsis_loadDaily(parameter, baseUrl, dataDir) diff --git a/R/monitor_loadLatest.R b/R/monitor_loadLatest.R index 8f81144d..a1f80f24 100644 --- a/R/monitor_loadLatest.R +++ b/R/monitor_loadLatest.R @@ -60,14 +60,21 @@ #' @seealso \code{\link{monitor_loadDaily}} #' @examples #' \dontrun{ +#' # Fail gracefully if any resources are not available +#' try({ +#' #' monitor_loadLatest() %>% #' monitor_subset(stateCodes=CONUS) %>% #' monitor_map() +#' +#' }, silent = FALSE) #' } -monitor_loadLatest <- function(parameter='PM2.5', - baseUrl='https://haze.airfire.org/monitoring/latest/RData/', - dataDir = NULL) { +monitor_loadLatest <- function( + parameter = 'PM2.5', + baseUrl = 'https://haze.airfire.org/monitoring/latest/RData/', + dataDir = NULL +) { airnow <- airnow_loadLatest(parameter, baseUrl, dataDir) airsis <- airsis_loadLatest(parameter, baseUrl, dataDir) diff --git a/R/monitor_performance.R b/R/monitor_performance.R index 79f8c1b3..fa8ac2b1 100644 --- a/R/monitor_performance.R +++ b/R/monitor_performance.R @@ -21,6 +21,9 @@ #' @seealso \link{skill_confusionMatrix} #' @examples #' \donttest{ +#' # Fail gracefully if any resources are not available +#' try({ +#' #' library(PWFSLSmoke) #' #' # If daily avg data were the prediciton and Spokane were @@ -43,9 +46,19 @@ #' skillful <- monitor_subset(wa_dailyAvg, monitorIDs=skillfulIDs) #' #' monitor_leaflet(skillful) +#' +#' }, silent = FALSE) #' } -monitor_performance <- function(predicted, observed, t1, t2, metric=NULL, FPCost=1, FNCost=1) { +monitor_performance <- function( + predicted, + observed, + t1, + t2, + metric=NULL, + FPCost = 1, + FNCost = 1 +) { # Run skill_confusionMatrix on fake data to get a list of all metrics metricNames <- names(skill_confusionMatrix(sample(c(TRUE,FALSE),10,replace=TRUE), sample(c(TRUE,FALSE),10,replace=TRUE))) diff --git a/R/monitor_performanceMap.R b/R/monitor_performanceMap.R index 61d0b11e..41487d61 100644 --- a/R/monitor_performanceMap.R +++ b/R/monitor_performanceMap.R @@ -42,6 +42,9 @@ #' @seealso \link{monitor_performance} #' @examples #' \dontrun{ +#' # Fail gracefully if any resources are not available +#' try({ +#' #' library(PWFSLSmoke) #' #' # Napa Fires -- October, 2017 @@ -54,6 +57,8 @@ #' radius = 50) #' monitor_performanceMap(ca, Vallejo, cex = 2) #' title('Heidke Skill of monitors predicting another monitor.') +#' +#' }, silent = FALSE) #' } monitor_performanceMap <- function( diff --git a/R/monitor_rollingMean.R b/R/monitor_rollingMean.R index 31af7844..53d20f51 100644 --- a/R/monitor_rollingMean.R +++ b/R/monitor_rollingMean.R @@ -33,7 +33,12 @@ #' col=c('black','red','blue'), lwd=c(1,1,2)) #' title('Smoky Monitors in Washington -- August, 2015') -monitor_rollingMean <- function(ws_monitor, width=8, data.thresh=75, align="center") { +monitor_rollingMean <- function( + ws_monitor, + width = 8, + data.thresh = 75, + align = "center" +) { data <- ws_monitor$data meta <- ws_monitor$meta diff --git a/R/monitor_rollingMeanPlot.R b/R/monitor_rollingMeanPlot.R index 93243346..e85be0c3 100644 --- a/R/monitor_rollingMeanPlot.R +++ b/R/monitor_rollingMeanPlot.R @@ -62,20 +62,22 @@ #' monitorIDs = c("410190002_01")) #' monitor_rollingMeanPlot(Roseburg, shadedNight = TRUE) -monitor_rollingMeanPlot <- function(ws_monitor, - monitorID = NULL, - width = 3, - align = "center", - data.thresh = 75, - tlim = NULL, - ylim = NULL, - localTime = TRUE, - shadedNight = FALSE, - aqiLines = TRUE, - gridHorizontal = FALSE, - grid24hr = FALSE, - grid3hr = FALSE, - showLegend = TRUE) { +monitor_rollingMeanPlot <- function( + ws_monitor, + monitorID = NULL, + width = 3, + align = "center", + data.thresh = 75, + tlim = NULL, + ylim = NULL, + localTime = TRUE, + shadedNight = FALSE, + aqiLines = TRUE, + gridHorizontal = FALSE, + grid24hr = FALSE, + grid3hr = FALSE, + showLegend = TRUE +) { # Sanity check if ( monitor_isEmpty(ws_monitor) ) { diff --git a/R/monitor_stamenmap.R b/R/monitor_stamenmap.R index b453e3b8..d2652950 100644 --- a/R/monitor_stamenmap.R +++ b/R/monitor_stamenmap.R @@ -43,6 +43,9 @@ #' #' @examples #' \donttest{ +#' # Fail gracefully if any resources are not available +#' try({ +#' #' library(PWFSLSmoke) #' #' N_M <- Northwest_Megafires @@ -50,6 +53,8 @@ #' Spokane <- monitor_subsetBy(N_M, stringr::str_detect(N_M$meta$monitorID,'^53063')) #' Spokane <- monitor_subset(Spokane, tlim=c(20150815, 20150831)) #' monitor_stamenmap(Spokane) +#' +#' }, silent = FALSE) #' } #' #' @seealso \code{\link{staticmap_getStamenmapBrick}} @@ -116,7 +121,7 @@ monitor_stamenmap <- function( } - # ----- Validate Parameters -------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( monitor_isEmpty(ws_monitor) ) stop("ws_monitor object contains zero monitors") diff --git a/R/monitor_staticmap.R b/R/monitor_staticmap.R index 012afaf1..e01c38c6 100644 --- a/R/monitor_staticmap.R +++ b/R/monitor_staticmap.R @@ -37,6 +37,9 @@ #' #' @examples #' \donttest{ +#' # Fail gracefully if any resources are not available +#' try({ +#' #' library(PWFSLSmoke) #' #' N_M <- Northwest_Megafires @@ -44,6 +47,8 @@ #' Spokane <- monitor_subsetBy(N_M, stringr::str_detect(N_M$meta$monitorID,'^53063')) #' Spokane <- monitor_subset(Spokane, tlim=c(20150815, 20150831)) #' monitor_staticmap(Spokane) +#' +#' }, silent = FALSE) #' } #' #' @seealso \code{\link{staticmap_getStamenmapBrick}} @@ -109,7 +114,7 @@ monitor_staticmap <- function( } - # ----- Validate Parameters -------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( monitor_isEmpty(ws_monitor) ) stop("ws_monitor object contains zero monitors") diff --git a/R/monitor_subset.R b/R/monitor_subset.R index 93581146..754fc5fb 100644 --- a/R/monitor_subset.R +++ b/R/monitor_subset.R @@ -32,16 +32,18 @@ # TODO: In the "details" section above, might want to mention whether the 'meta' data is retained for monitors w/o valid data after subsetting -monitor_subset <- function(ws_monitor, - xlim=NULL, - ylim=NULL, - tlim=NULL, - vlim=NULL, - monitorIDs=NULL, - stateCodes=NULL, - countryCodes=NULL, - dropMonitors=TRUE, - timezone="UTC") { +monitor_subset <- function( + ws_monitor, + xlim = NULL, + ylim = NULL, + tlim = NULL, + vlim = NULL, + monitorIDs = NULL, + stateCodes = NULL, + countryCodes = NULL, + dropMonitors = TRUE, + timezone = "UTC" +) { # Sanity check if ( monitor_isEmpty(ws_monitor) ) stop("ws_monitor object contains zero monitors") diff --git a/R/monitor_subsetByDistance.R b/R/monitor_subsetByDistance.R index 3bc5eeee..c9daa9df 100644 --- a/R/monitor_subsetByDistance.R +++ b/R/monitor_subsetByDistance.R @@ -18,6 +18,9 @@ #' @seealso monitorDistance #' @examples #' \donttest{ +#' # Fail gracefully if any resources are not available +#' try({ +#' #' library(PWFSLSmoke) #' #' # Napa Fires -- October, 2017 @@ -32,14 +35,16 @@ #' if ( interactive() ) { #' monitor_leaflet(Napa_Fires) #' } +#' +#' }, silent = FALSE) #' } monitor_subsetByDistance <- function( ws_monitor, - longitude=NULL, - latitude=NULL, - radius=50, - count=NULL + longitude = NULL, + latitude = NULL, + radius = 50, + count = NULL ) { # Sanity check diff --git a/R/monitor_trend.R b/R/monitor_trend.R deleted file mode 100644 index 9bb2adf2..00000000 --- a/R/monitor_trend.R +++ /dev/null @@ -1,62 +0,0 @@ -#' #' @keywords ws_monitor -#' #' -#' #' @export -#' #' -#' #' @title Calculate trends for ws_monitor bject -#' #' -#' #' @description This function calculates 'trend' metric timeseres for every -#' #' monitor in the \code{ws_monitor}. -#' #' -#' #' The initial "pwfsl" implementation calculates NowCast timeseries for each -#' #' monitor and then subtracts the hourly pm2.5 value from the damped NowCast -#' #' timeseries. -#' #' -#' #' @param ws_monitor \emph{ws_monitor} object -#' #' @param type Character string specifying the type of trend algorithm to be -#' #' used. -#' #' -#' #' @return A \emph{ws_monitor} object where all data values have been replaced -#' #' with 'trend' values. -#' -#' monitor_trend <- function(ws_monitor, -#' type = "pwfsl") { -#' -#' # Validate parameters -------------------------------------------------------- -#' -#' if ( monitor_isEmpty(ws_monitor) ) { -#' stop("ws_monitor object contains zero monitors") -#' } -#' -#' # type -#' validTypes <- c("pwfsl") -#' if ( !is.null(type) ) { -#' if ( !type %in% validTypes ) { -#' stop( -#' paste0( -#' "Invalid type: \"", type, "\". ", -#' "The following types are supported: \"", -#' paste0(validTypes, sep = "|"), "\"" -#' ) -#' ) -#' } -#' } else { -#' type <- "pwfsl" -#' } -#' -#' # Calculate trends ----------------------------------------------------------- -#' -#' # Comparison -#' a <- monitor_nowcast(ws_monitor) -#' b <- monitor_rollingMean(ws_monitor, 5, align = "right") -#' -#' a_data <- a$data[,-1] # omit datetime -#' b_data <- b$data[,-1] # omit datetime -#' trend_data <- a_data - b_data -#' -#' ws_monitor$data[,-1] <- trend_data -#' -#' # Return --------------------------------------------------------------------- -#' -#' return(ws_monitor) -#' -#' } diff --git a/R/monitor_trim.R b/R/monitor_trim.R index 1e39cda1..8e02a531 100644 --- a/R/monitor_trim.R +++ b/R/monitor_trim.R @@ -7,6 +7,9 @@ #' after the last valid datapoint for any monitor. #' @examples #' \dontrun{ +#' # Fail gracefully if any resources are not available +#' try({ +#' #' library(PWFSLSmoke) #' library(MazamaSpatialUtils) #' @@ -15,6 +18,8 @@ #' Deschutes <- monitor_subset(sm13, monitorIDs='lon_.121.453_lat_43.878_wrcc.sm13') #' Deschutes <- monitor_trim(Deschutes) #' monitor_dailyBarplot(Deschutes) +#' +#' }, silent = FALSE) #' } monitor_trim <- function(ws_monitor) { diff --git a/R/monitor_writeCurrentStatusGeoJSON.R b/R/monitor_writeCurrentStatusGeoJSON.R index c26723be..9e74d80d 100644 --- a/R/monitor_writeCurrentStatusGeoJSON.R +++ b/R/monitor_writeCurrentStatusGeoJSON.R @@ -30,6 +30,9 @@ #' #' @examples #' \donttest{ +#' # Fail gracefully if any resources are not available +#' try({ +#' #' library(PWFSLSmoke) #' #' wa <- @@ -42,7 +45,11 @@ #' wa_spdf <- rgdal::readOGR(dsn = geojson_file) #' map("state", "washington") #' points(wa_spdf) +#' +#' }, silent = FALSE) #' } +#' + monitor_writeCurrentStatusGeoJSON <- function( ws_monitor, filename, @@ -54,7 +61,7 @@ monitor_writeCurrentStatusGeoJSON <- function( logger.debug(" ----- monitor_writeCurrentStatusGeoJSON() ----- ") - # Sanity checks -------------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if (monitor_isEmpty(ws_monitor)) stop("ws_monitor object contains zero monitors.") diff --git a/R/staticmap_plotRasterBrick.R b/R/staticmap_plotRasterBrick.R index ed56f9d3..88278ed8 100644 --- a/R/staticmap_plotRasterBrick.R +++ b/R/staticmap_plotRasterBrick.R @@ -32,7 +32,7 @@ staticmap_plotRasterBrick <- function( ... ) { - # ----- Validate Parameters -------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( is.null(rasterBrick) ) stop("Required parameter 'rasterBrick' is missing") diff --git a/R/wrcc_createMonitorObject.R b/R/wrcc_createMonitorObject.R index 41138359..29767a3c 100644 --- a/R/wrcc_createMonitorObject.R +++ b/R/wrcc_createMonitorObject.R @@ -103,7 +103,7 @@ wrcc_createMonitorObject <- function( } - # ----- Validate Parameters -------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( is.null(unitID) ) { logger.error("Required parameter 'unitID' is missing") diff --git a/R/wrcc_createRawDataframe.R b/R/wrcc_createRawDataframe.R index 1804b1f6..5624b920 100644 --- a/R/wrcc_createRawDataframe.R +++ b/R/wrcc_createRawDataframe.R @@ -63,7 +63,7 @@ wrcc_createRawDataframe <- function( logger.debug(" ----- wrcc_createRawDatafram() ----- ") - # ----- Validate parameters --------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( is.null(unitID) ) { logger.error("Required parameter 'unitID' is missing") diff --git a/R/wrcc_loadAnnual.R b/R/wrcc_loadAnnual.R index b1bab7db..2ddbf3fa 100644 --- a/R/wrcc_loadAnnual.R +++ b/R/wrcc_loadAnnual.R @@ -79,7 +79,7 @@ wrcc_loadAnnual <- function( dataDir = NULL ) { - # Validate parameters -------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if ( is.null(year) ) { stop("Required parameter 'year' is missing.") diff --git a/local_TODO/generic_parseData.R b/local_TODO/generic_parseData.R index 1668f980..9d478ede 100644 --- a/local_TODO/generic_parseData.R +++ b/local_TODO/generic_parseData.R @@ -1,7 +1,7 @@ generic_parseData <- function(fileString = NULL, configList = NULL) { -# Validate input ---------------------------------------------------------- +# ----- Validate parameters -------------------------------------------------- # Make sure fileString is a string (one element character vector) if ( diff --git a/local_TODO/monitor_writeGeoJSON.R b/local_TODO/monitor_writeGeoJSON.R index f5b256f1..4d14885d 100644 --- a/local_TODO/monitor_writeGeoJSON.R +++ b/local_TODO/monitor_writeGeoJSON.R @@ -51,7 +51,7 @@ monitor_writeGeoJSON <- function( logger.debug(" ----- monitor_writeGeoJSON() ----- ") - # Sanity checks -------------------------------------------------------------- + # ----- Validate parameters -------------------------------------------------- if (monitor_isEmpty(ws_monitor)) stop("ws_monitor object contains zero monitors.") diff --git a/local_executables/EXAMPLE_exec.R b/local_executables/EXAMPLE_exec.R index 2fbe8365..cef9721e 100755 --- a/local_executables/EXAMPLE_exec.R +++ b/local_executables/EXAMPLE_exec.R @@ -189,7 +189,7 @@ if (opt$version) { quit() } -# ----- Validate parameters ---------------------------------------------------- +# ----- Validate parameters --------------------------------------------------- MazamaCoreUtils::stopIfNull(opt$satID) diff --git a/man/monitor_leaflet.Rd b/man/monitor_leaflet.Rd index f8843e88..c79047ff 100644 --- a/man/monitor_leaflet.Rd +++ b/man/monitor_leaflet.Rd @@ -70,6 +70,9 @@ underlying map tile if available. See } \examples{ \dontrun{ +# Fail gracefully if any resources are not available +try({ + # Napa Fires -- October, 2017 ca <- airnow_load(2017) \%>\% monitor_subset(tlim = c(20171001,20171101), stateCodes = 'CA') @@ -78,6 +81,8 @@ CA_very_unhealthy_monitors <- monitor_subset(ca, vlim = c(v_low, Inf)) monitor_leaflet(CA_very_unhealthy_monitors, legendTitle = "October, 2017", maptype = "toner") + +}, silent = FALSE) } } \keyword{ws_monitor} diff --git a/man/monitor_load.Rd b/man/monitor_load.Rd index fe161e5c..9a1349b0 100644 --- a/man/monitor_load.Rd +++ b/man/monitor_load.Rd @@ -49,7 +49,12 @@ loading recent data with this function. } \examples{ \dontrun{ +# Fail gracefully if any resources are not available +try({ + ca <- monitor_load(20170601,20171001) \%>\% monitor_subset(stateCodes='CA') + +}, silent = FALSE) } } \seealso{ diff --git a/man/monitor_loadAnnual.Rd b/man/monitor_loadAnnual.Rd index 8fd231e1..103d1500 100644 --- a/man/monitor_loadAnnual.Rd +++ b/man/monitor_loadAnnual.Rd @@ -53,9 +53,14 @@ Avaialble RData files can be seen at: } \examples{ \dontrun{ +# Fail gracefully if any resources are not available +try({ + monitor_loadAnnual(2014) \%>\% monitor_subset(stateCodes='MT', tlim=c(20140801,20140901)) \%>\% monitor_map() + +}, silent = FALSE) } } \seealso{ diff --git a/man/monitor_loadDaily.Rd b/man/monitor_loadDaily.Rd index 92f570a3..c892ffb1 100644 --- a/man/monitor_loadDaily.Rd +++ b/man/monitor_loadDaily.Rd @@ -52,9 +52,14 @@ Avaialble RData files can be seen at: } \examples{ \dontrun{ +# Fail gracefully if any resources are not available +try({ + monitor_loadDaily() \%>\% monitor_subset(stateCodes=CONUS) \%>\% monitor_map() + +}, silent = FALSE) } } \seealso{ diff --git a/man/monitor_loadLatest.Rd b/man/monitor_loadLatest.Rd index e1cf7c4a..50a509a2 100644 --- a/man/monitor_loadLatest.Rd +++ b/man/monitor_loadLatest.Rd @@ -52,9 +52,14 @@ Avaialble RData files can be seen at: } \examples{ \dontrun{ +# Fail gracefully if any resources are not available +try({ + monitor_loadLatest() \%>\% monitor_subset(stateCodes=CONUS) \%>\% monitor_map() + +}, silent = FALSE) } } \seealso{ diff --git a/man/monitor_performance.Rd b/man/monitor_performance.Rd index 2fa6928d..4579e09b 100644 --- a/man/monitor_performance.Rd +++ b/man/monitor_performance.Rd @@ -43,6 +43,9 @@ all available metrics are returned. } \examples{ \donttest{ +# Fail gracefully if any resources are not available +try({ + library(PWFSLSmoke) # If daily avg data were the prediciton and Spokane were @@ -65,6 +68,8 @@ skillfulIDs <- monitorIDs[mask] skillful <- monitor_subset(wa_dailyAvg, monitorIDs=skillfulIDs) monitor_leaflet(skillful) + +}, silent = FALSE) } } \seealso{ diff --git a/man/monitor_performanceMap.Rd b/man/monitor_performanceMap.Rd index 0b350468..ad9ced26 100644 --- a/man/monitor_performanceMap.Rd +++ b/man/monitor_performanceMap.Rd @@ -77,6 +77,9 @@ size/colors to remain constant. } \examples{ \dontrun{ +# Fail gracefully if any resources are not available +try({ + library(PWFSLSmoke) # Napa Fires -- October, 2017 @@ -89,6 +92,8 @@ Napa_Fires <- monitor_subsetByDistance(ca, radius = 50) monitor_performanceMap(ca, Vallejo, cex = 2) title('Heidke Skill of monitors predicting another monitor.') + +}, silent = FALSE) } } \seealso{ diff --git a/man/monitor_stamenmap.Rd b/man/monitor_stamenmap.Rd index 0c42838e..3e713b52 100644 --- a/man/monitor_stamenmap.Rd +++ b/man/monitor_stamenmap.Rd @@ -79,6 +79,9 @@ appropriate values will be calcualted using data from the } \examples{ \donttest{ +# Fail gracefully if any resources are not available +try({ + library(PWFSLSmoke) N_M <- Northwest_Megafires @@ -86,6 +89,8 @@ N_M <- Northwest_Megafires Spokane <- monitor_subsetBy(N_M, stringr::str_detect(N_M$meta$monitorID,'^53063')) Spokane <- monitor_subset(Spokane, tlim=c(20150815, 20150831)) monitor_stamenmap(Spokane) + +}, silent = FALSE) } } diff --git a/man/monitor_staticmap.Rd b/man/monitor_staticmap.Rd index eb6ae46e..5251e517 100644 --- a/man/monitor_staticmap.Rd +++ b/man/monitor_staticmap.Rd @@ -73,6 +73,9 @@ appropriate values will be calcualted using data from the } \examples{ \donttest{ +# Fail gracefully if any resources are not available +try({ + library(PWFSLSmoke) N_M <- Northwest_Megafires @@ -80,6 +83,8 @@ N_M <- Northwest_Megafires Spokane <- monitor_subsetBy(N_M, stringr::str_detect(N_M$meta$monitorID,'^53063')) Spokane <- monitor_subset(Spokane, tlim=c(20150815, 20150831)) monitor_staticmap(Spokane) + +}, silent = FALSE) } } diff --git a/man/monitor_subsetByDistance.Rd b/man/monitor_subsetByDistance.Rd index 9ea6eb4b..f393bd1f 100644 --- a/man/monitor_subsetByDistance.Rd +++ b/man/monitor_subsetByDistance.Rd @@ -39,6 +39,9 @@ of monitors (or grid cells) returned may be less than the specified \code{count} } \examples{ \donttest{ +# Fail gracefully if any resources are not available +try({ + library(PWFSLSmoke) # Napa Fires -- October, 2017 @@ -53,6 +56,8 @@ Napa_Fires <- monitor_subsetByDistance(ca, if ( interactive() ) { monitor_leaflet(Napa_Fires) } + +}, silent = FALSE) } } \seealso{ diff --git a/man/monitor_trim.Rd b/man/monitor_trim.Rd index 4fc18f2e..f6882907 100644 --- a/man/monitor_trim.Rd +++ b/man/monitor_trim.Rd @@ -18,6 +18,9 @@ after the last valid datapoint for any monitor. } \examples{ \dontrun{ +# Fail gracefully if any resources are not available +try({ + library(PWFSLSmoke) library(MazamaSpatialUtils) @@ -26,6 +29,8 @@ sm13$meta[,c('stateCode','countyName','siteName','monitorID')] Deschutes <- monitor_subset(sm13, monitorIDs='lon_.121.453_lat_43.878_wrcc.sm13') Deschutes <- monitor_trim(Deschutes) monitor_dailyBarplot(Deschutes) + +}, silent = FALSE) } } \keyword{ws_monitor} diff --git a/man/monitor_writeCurrentStatusGeoJSON.Rd b/man/monitor_writeCurrentStatusGeoJSON.Rd index a443e56e..31ae53e8 100644 --- a/man/monitor_writeCurrentStatusGeoJSON.Rd +++ b/man/monitor_writeCurrentStatusGeoJSON.Rd @@ -46,6 +46,9 @@ included, see \code{\link{monitor_getCurrentStatus}}. } \examples{ \donttest{ +# Fail gracefully if any resources are not available +try({ + library(PWFSLSmoke) wa <- @@ -58,6 +61,9 @@ wa_current_list <- jsonlite::fromJSON(wa_current_geojson) wa_spdf <- rgdal::readOGR(dsn = geojson_file) map("state", "washington") points(wa_spdf) + +}, silent = FALSE) } + } \keyword{ws_monitor}