diff --git a/DESCRIPTION b/DESCRIPTION index 69ff39ca..8fea9941 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,7 +26,7 @@ Depends: MazamaSpatialUtils (>= 0.4.4) Imports: cluster, - dygraphs, + dygraphs (>= 1.1.1.4), futile.logger, ggmap, httr, diff --git a/NAMESPACE b/NAMESPACE index 2d8753a4..f3a8a938 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,7 +16,6 @@ export(addLegend) export(addMazamaMetadata) export(addShadedBackground) export(addShadedNights) -export(adjustRange) export(airnow_createDataDataframes) export(airnow_createMetaDataframes) export(airnow_downloadData) @@ -35,7 +34,6 @@ export(airsis_createMonitorObject) export(airsis_createRawDataframe) export(airsis_downloadData) export(airsis_identifyMonitorType) -export(airsis_load) export(airsis_loadLatest) export(airsis_parseData) export(airsis_qualityControl) @@ -48,8 +46,9 @@ export(logger.setLevel) export(logger.setup) export(logger.trace) export(logger.warn) +export(monitorDygraph) export(monitorGoogleMap) -export(monitorInteractiveMap) +export(monitorLeaflet) export(monitorMap) export(monitorMap_performance) export(monitorPlot_dailyBarplot) @@ -59,11 +58,11 @@ export(monitorPlot_rollingMean) export(monitorPlot_timeOfDaySpaghetti) export(monitorPlot_timeseries) export(monitor_aqi) +export(monitor_collapse) export(monitor_combine) export(monitor_dailyStatistic) export(monitor_dailyThreshold) export(monitor_distance) -export(monitor_dygraph) export(monitor_isolate) export(monitor_nowcast) export(monitor_performance) @@ -81,7 +80,6 @@ export(openaq_assignStateCode) export(openaq_createDataDataframes) export(openaq_createMetaDataframes) export(openaq_downloadData) -export(openaq_load) export(parseDatetime) export(rawPlot_pollutionRose) export(rawPlot_timeOfDaySpaghetti) @@ -104,7 +102,7 @@ export(wrcc_createMonitorObject) export(wrcc_createRawDataframe) export(wrcc_downloadData) export(wrcc_identifyMonitorType) -export(wrcc_load) +export(wrcc_loadLatest) export(wrcc_parseData) export(wrcc_qualityControl) import(MazamaSpatialUtils) diff --git a/R/adjustRange.R b/R/adjustRange.R deleted file mode 100644 index f52bac6b..00000000 --- a/R/adjustRange.R +++ /dev/null @@ -1,30 +0,0 @@ -#' @keywords internal -#' @export -#' @title Create a Scaled Range -#' @param x vector of numeric values -#' @param factor scaling factor to be applied -#' @param minRange minimum range to be returned -#' @return Vector of low and high values of the adjusted range. -#' @description Scale the range of values by a given factor. The min and max values of the -#' original range of valus are adjusted so that the new range is larger or smaller by \code{factor}. -#' The returned range will always be equal to or greater than \code{minRange}. -#' @examples -#' \dontrun{ -#' x <- (1:10) -#' range(x) -#' [1] 1 10 -#' x_new <- adjustRange(x, factor = 2) -#' range(x_new) -#' [1] -3.5 14.5 -#' } -adjustRange <- function(x, factor=1.1, minRange=0.1) { - scaledWidth <- diff(range(x)) * (factor - 1) - low <- range(x)[1] - scaledWidth / 2 - high <- range(x)[2] + scaledWidth / 2 - if ( (high - low) < minRange ) { - mid <- (max(x)-min(x))/2 + min(x) - low <- mid - minRange / 2 - high <- mid + minRange / 2 - } - return(c(low, high)) -} diff --git a/R/airnow_downloadHourlyData.R b/R/airnow_downloadHourlyData.R index a151889f..7ac17872 100644 --- a/R/airnow_downloadHourlyData.R +++ b/R/airnow_downloadHourlyData.R @@ -1,11 +1,9 @@ -#' @keywords internal AirNow +#' @keywords AirNow #' @export #' @importFrom utils read.table #' @title Download Hourly Data from AirNow #' @param datestamp integer or character representing YYYYMMDDHH -#' @param tries number of download attempts in the face of timeouts #' @param baseUrl base URL for archived hourly data -#' @param curl previously initialized CURL context/handle (see RCurl::getURL()) #' @return Dataframe of AirNow hourly data. #' @description The \url{http://airnowtech.org} site provides both air pollution #' monitoring data as well as monitoring site location metadata. The \code{airnow_downloadHourlyData()} diff --git a/R/airnow_load.R b/R/airnow_load.R index 31cc3d0b..28430c66 100644 --- a/R/airnow_load.R +++ b/R/airnow_load.R @@ -15,7 +15,7 @@ #' \dontrun{ #' airnow <- airnow_load(20150901, 20150930) #' airnow_conus <- monitor_subset(airnow, stateCodes=CONUS) -#' monitorInteractiveMap(airnow_conus) +#' monitorLeaflet(airnow_conus) #' } airnow_load <- function(startdate, enddate, stateCodes=NULL, monitorIDs=NULL, diff --git a/R/airsisDump_createMonitorObject.R b/R/airsisDump_createMonitorObject.R index 11cfdfd8..3778ab12 100644 --- a/R/airsisDump_createMonitorObject.R +++ b/R/airsisDump_createMonitorObject.R @@ -1,4 +1,4 @@ -#' @keywords AIRSIS +#' @keywords internal #' @export #' @title Ingest AIRSIS Dump File and Create ws_monitor Object #' @param filepath absolute path of the AIRSIS dump file diff --git a/R/airsisDump_identifyMonitorType.R b/R/airsisDump_identifyMonitorType.R index c81c8691..c5bb9dd5 100644 --- a/R/airsisDump_identifyMonitorType.R +++ b/R/airsisDump_identifyMonitorType.R @@ -1,4 +1,4 @@ -#' @keywords AIRSIS +#' @keywords internal #' @export #' @title Identify AIRSIS Dump File Monitor Type #' @param df dataframe or raw character string containing AIRSIS data diff --git a/R/airsisDump_parseData.R b/R/airsisDump_parseData.R index 7cc75d84..e6093888 100644 --- a/R/airsisDump_parseData.R +++ b/R/airsisDump_parseData.R @@ -1,4 +1,4 @@ -#' @keywords AIRSIS +#' @keywords internal #' @export #' @title Parse AIRSIS Dump File Data String #' @param fileString character string containing AIRSIS data as a csv diff --git a/R/airsis_createMonitorObject.R b/R/airsis_createMonitorObject.R index 55550f77..89630ea6 100644 --- a/R/airsis_createMonitorObject.R +++ b/R/airsis_createMonitorObject.R @@ -31,6 +31,11 @@ #' @seealso \code{\link{addClustering}} #' @seealso \code{\link{airsis_createMetaDataframe}} #' @seealso \code{\link{airsis_createDataDataframe}} +#' @examples +#' \dontrun{ +#' usfs_1013 <- airsis_createMonitorObject(20150301, 20150831, 'USFS', unitID='1013') +#' monitorLeaflet(usfs_1013) +#' } airsis_createMonitorObject <- function(startdate=20020101, enddate=strftime(lubridate::now(),"%Y%m%d",tz="GMT"), @@ -49,6 +54,19 @@ airsis_createMonitorObject <- function(startdate=20020101, logger.error("Required parameter 'unitID' is missing") stop(paste0("Required parameter 'unitID' is missing")) } + + startdateCount <- stringr::str_count(as.character(startdate)) + if ( !startdateCount %in% c(8,10,12) ) { + logger.error("Cannot parse 'startdate' with %d characters", startdateCount) + stop(paste0("Cannot parse 'startdate' with ",startdateCount," characters")) + } + + enddateCount <- stringr::str_count(as.character(enddate)) + if ( !enddateCount %in% c(8,10,12) ) { + logger.error("Cannot parse 'enddate' with %d characters", enddateCount) + stop(paste0("Cannot parse 'enddate' with ",enddateCount," characters")) + } + # Read in AIRSIS .csv data logger.info("Downloading AIRSIS data ...") diff --git a/R/airsis_loadLatest.R b/R/airsis_loadLatest.R index 6d4f1553..93ad5682 100644 --- a/R/airsis_loadLatest.R +++ b/R/airsis_loadLatest.R @@ -2,7 +2,7 @@ #' @export #' @title Load Recent AIRSIS Monitoring Data #' @param baseUrl The location of the meta and data files -#' @description The most recent 10 days of AIRSIS data are updated in quasi-real time +#' @description The most recent 45 days of AIRSIS data are updated in real time #' at PWFSL and can be loaded with this function. #' @return A ws_monitor object with AIRSIS data. #' @examples @@ -10,30 +10,9 @@ #' airsis <- airsis_loadLatest() #' } -airsis_loadLatest <- function(baseUrl='http://tools.airfire.org/monitoring/v3/data') { +airsis_loadLatest <- function(baseUrl='https://haze.airfire.org/monitoring/RData/airsis_pm25_latest.RData') { - # Get the most recent data and metadata - data <- get(load(url(paste0(baseUrl,'/EBAM_PM2.5_Latest.RData')))) - meta <- get(load(url(paste0(baseUrl,'/EBAM_SitesMetadata.RData')))) - - # Only include metadata for sites found in data - meta <- monitor_subsetMeta(meta, monitorIDs=colnames(data)[-1]) - - # Add missing metadata to 'old-style' Latest data - # The columns are already present but may contain missing data - if ( any(is.na(meta$timezone)) || any(is.na(meta$countryCode)) || any(is.na(meta$stateCode)) ) { - meta <- addMazamaMetadata(meta) - } - if ( any(is.na(meta$elevation)) || any(is.na(meta$siteName)) ) { # OK if countyName is NA - meta <- addGoogleMetadata(meta) - } - - # Create the 'ws_monitor' object - ws_monitor <- list(meta=meta, data=data) - ws_monitor <- structure(ws_monitor, class = c("ws_monitor", "list")) - - # Run through subsetting to remove sites with all missing data - ws_monitor <- monitor_subset(ws_monitor, dropMonitors=TRUE) + ws_monitor <- get(load(url(baseUrl))) return(ws_monitor) } diff --git a/R/distance.R b/R/distance.R index 6b432af9..400b736f 100644 --- a/R/distance.R +++ b/R/distance.R @@ -9,6 +9,15 @@ #' than the spherical law of cosines for very short distances. #' @references \url{http://www.r-bloggers.com/great-circle-distance-calculations-in-r/} #' @return Vector of distances in km. +#' @examples +#' \dontrun{ +#' # Seattle to Portland airports +#' SEA_lon <- -122.3088 +#' SEA_lat <- 47.4502 +#' PDX_lon <- -122.5951 +#' PDX_lat <- 45.5898 +#' distance(SEA_lon, SEA_lat, PDX_lon, PDX_lat) +#' } distance <- function(targetLon, targetLat, lons, lats) { diff --git a/R/monitor_dygraph.R b/R/monitorDygraph.R similarity index 89% rename from R/monitor_dygraph.R rename to R/monitorDygraph.R index fc6a5ec7..36dc20f0 100644 --- a/R/monitor_dygraph.R +++ b/R/monitorDygraph.R @@ -13,11 +13,11 @@ #' \dontrun{ #' airnow <- airnow_load(20140913, 20141010) #' King_Fire <- monitor_subsetByDistance(airnow, lon=-120.604, lat=38.782, radius=50) -#' monitor_dygraph(King_Fire, title='KingFire/California/2014', rollPeriod=3) +#' monitorDygraph(King_Fire, title='KingFire/California/2014', rollPeriod=3) #' } -monitor_dygraph <- function(ws_monitor, title='title', ylab='PM2.5 Concentration', - dateWindow=NULL, rollPeriod=1, showLegend=TRUE) { +monitorDygraph <- function(ws_monitor, title='title', ylab='PM2.5 Concentration', + dateWindow=NULL, rollPeriod=1, showLegend=TRUE) { # Sanity check tzCount <- length(unique(ws_monitor$meta$timezone)) diff --git a/R/monitorInteractiveMap.R b/R/monitorLeaflet.R similarity index 92% rename from R/monitorInteractiveMap.R rename to R/monitorLeaflet.R index 51c66a88..302eab28 100644 --- a/R/monitorInteractiveMap.R +++ b/R/monitorLeaflet.R @@ -36,16 +36,16 @@ #' airnow <- airnow_load(20140913, 20141010) #' v_low <- AQI$breaks_24[4] #' CA_unhealthy_monitors <- monitor_subset(airnow, stateCodes='CA', vlim=c(v_low, Inf)) -#' monitorInteractiveMap(CA_unhealthy_monitors, maptype="toner") +#' monitorLeaflet(CA_unhealthy_monitors, maptype="toner") #' } -monitorInteractiveMap <- function(ws_monitor, slice=get('max'), - breaks=AQI$breaks_24, - colors=AQI$colors, - labels=AQI$names, - legendTitle='Max AQI Level', - radius=10, opacity=0.7, maptype="terrain", - popupInfo=c('siteName','monitorID','elevation')) { +monitorLeaflet <- function(ws_monitor, slice=get('max'), + breaks=AQI$breaks_24, + colors=AQI$colors, + labels=AQI$names, + legendTitle='Max AQI Level', + radius=10, opacity=0.7, maptype="terrain", + popupInfo=c('siteName','monitorID','elevation')) { # BEGIN verbatim from monitor_map.R ----------------------------------------- @@ -82,7 +82,7 @@ monitorInteractiveMap <- function(ws_monitor, slice=get('max'), } if ( missing(labels) ){ - labels <- paste(sprintf("%.1f",breaks[-length(breaks)]),'--',sprintf("%.1f",breaks[-1])) + labels <- paste(sprintf("%.1f",breaks[-length(breaks)]),'--',sprintf("%.1f",breaks[-1])) } else if ( length(labels) != length(colors) ) { stop("The number of labels should be equal to the number of colors") } diff --git a/R/monitorMap_performance.R b/R/monitorMap_performance.R index 516f9c72..050b8c69 100644 --- a/R/monitorMap_performance.R +++ b/R/monitorMap_performance.R @@ -30,11 +30,10 @@ #' @examples #' \dontrun{ #' # Spokane summer of 2015 -#' airnow <- airnow_load(20150701,20150930) -#' airnow <- monitor_rollingMean(airnow, width=3) -#' WA <- monitor_subset(airnow, stateCode='WA', countryCode="US") -#' MonroeSt <- monitor_subset(WA, monitorIDs=530630047) -#' monitorMap_performance(WA, MonroeSt, cex=2) +#' wa <- airnow_load(20150701, 20150930, stateCodes='WA') +#' wa <- monitor_rollingMean(wa, width=3) +#' MonroeSt <- monitor_subset(wa, monitorIDs=530630047) +#' monitorMap_performance(wa, MonroeSt, cex=2) #' title('Heidike Skill of monitors predicting another monitor.') #' } diff --git a/R/monitorPlot_noData.R b/R/monitorPlot_noData.R index fea29c66..6274cc4f 100644 --- a/R/monitorPlot_noData.R +++ b/R/monitorPlot_noData.R @@ -1,4 +1,4 @@ -#' @keywords ws_monitor +#' @keywords internal #' @export #' @import graphics #' @title Create Blank Plot with "No Data" Message diff --git a/R/monitor_collapse.R b/R/monitor_collapse.R index 4e9a2476..3405a846 100644 --- a/R/monitor_collapse.R +++ b/R/monitor_collapse.R @@ -1,5 +1,5 @@ -#' @keywords ws_monitor -# @export +#' @keywords internal +#' @export #' @title Collapse a ws_monitor Object into a ws_monitor Object with a Single Monitor #' @param ws_monitor ws_monitor object #' @param lon longitude of the collapsed monitoring station. (Default = mean of the longitudes) diff --git a/R/monitor_combine.R b/R/monitor_combine.R index b30a9c17..5c013730 100644 --- a/R/monitor_combine.R +++ b/R/monitor_combine.R @@ -13,7 +13,7 @@ #' monitorList[[3]] <- airsis_createMonitorObject(20160701, 20161231, 'USFS', '1033') #' monitorList[[4]] <- airsis_createMonitorObject(20160701, 20161231, 'USFS', '1034') #' ws_monitor <- monitor_combine(monitorList) -#' monitorInteractiveMap(ws_monitor) +#' monitorLeaflet(ws_monitor) #' } monitor_combine <- function(monitorList) { diff --git a/R/monitor_dailyThreshold.R b/R/monitor_dailyThreshold.R index e1601cbc..47908719 100644 --- a/R/monitor_dailyThreshold.R +++ b/R/monitor_dailyThreshold.R @@ -21,7 +21,7 @@ #' #' WA_IDS <- AirNow$meta$monitorID[AirNow$meta$stateCode == 'WA'] #' WA <- monitor_subset(AirNow, monitorIDs=WA_IDS) -#' monitorInteractiveMap(WA) +#' monitorLeaflet(WA) #' #' # Pull out specific locations #' Twisp <- monitor_subset(WA, monitorIDs='530470009') diff --git a/R/monitor_subsetBy.R b/R/monitor_subsetBy.R index ad2de334..d73f00e4 100644 --- a/R/monitor_subsetBy.R +++ b/R/monitor_subsetBy.R @@ -13,8 +13,8 @@ #' airnow <- airnow_load(20150101, 20151231) #' mySubset <- monitor_subsetBy(airnow, timezone == 'America/Los_Angeles') #' hazardousSubset <- monitor_subsetBy(mySubset, data > AQI$breaks_24[6]) -#' monitorInteractiveMap(hazardousSubset, -#' popupInfo=c('siteName', 'agencyName', 'elevation','monitorID')) +#' monitorLeaflet(hazardousSubset, +#' popupInfo=c('siteName', 'agencyName', 'elevation','monitorID')) #' } monitor_subsetBy <- function(ws_monitor, filter) { diff --git a/R/monitor_subsetByDistance.R b/R/monitor_subsetByDistance.R index 032496a8..1677ad8e 100644 --- a/R/monitor_subsetByDistance.R +++ b/R/monitor_subsetByDistance.R @@ -20,7 +20,7 @@ #' \dontrun{ #' airnow <- airnow_load(20140913, 20141010) #' KingFire <- monitor_subsetByDistance(airnow, lon=-120.604, lat=38.782, radius=50) -#' monitorInteractiveMap(KingFire) +#' monitorLeaflet(KingFire) #' } monitor_subsetByDistance <- function(ws_monitor, lon=NULL, lat=NULL, radius=50, count=NULL) { diff --git a/R/monitor_trim.R b/R/monitor_trim.R index a8f8cf2e..8da0c77f 100644 --- a/R/monitor_trim.R +++ b/R/monitor_trim.R @@ -5,7 +5,14 @@ #' @return A ws_monitor object with missing data trimmed. #' @description Trims the time axis of a ws_monitor object to exclude timestamps prior to the first and #' after the last valid datapoint for any monitor. - +#' @examples +#' \dontrun{ +#' sm13 <- wrcc_createMonitorObject(20150101, 20151231, stationID='sm13') +#' sm13$meta[,c('stateCode','countyName','siteName','monitorID')] +#' Deschutes <- monitor_subset(sm13, monitorIDs='Smoke..13__001') +#' Deschutes <- monitor_trim(Deschutes) +#' monitorPlot_dailyBarplot(Deschutes) +#' } monitor_trim <- function(ws_monitor) { # Vectors of first and last valid indices excluding 'datetime' diff --git a/R/wrccDump_createMonitorObject.R b/R/wrccDump_createMonitorObject.R index 88ed3fc6..907b7593 100644 --- a/R/wrccDump_createMonitorObject.R +++ b/R/wrccDump_createMonitorObject.R @@ -1,4 +1,4 @@ -#' @keywords WRCC +#' @keywords internal #' @export #' @title Ingest WRCC Dump File and Create ws_monitor Object #' @param filepath absolute path of the WRCC dump file diff --git a/R/wrccDump_identifyMonitorType.R b/R/wrccDump_identifyMonitorType.R index 2de1b31b..37f6c24f 100644 --- a/R/wrccDump_identifyMonitorType.R +++ b/R/wrccDump_identifyMonitorType.R @@ -1,4 +1,4 @@ -#' @keywords WRCC +#' @keywords internal #' @export #' @title Identify WRCC Dump File Monitor Type #' @param fileString character string containing WRCC dump file diff --git a/R/wrccDump_parseData.R b/R/wrccDump_parseData.R index 88dd2c21..367862cf 100644 --- a/R/wrccDump_parseData.R +++ b/R/wrccDump_parseData.R @@ -1,4 +1,4 @@ -#' @keywords WRCC +#' @keywords internal #' @export #' @title Parse WRCC Dump File String #' @param fileString character string containing WRCC dump file diff --git a/R/wrcc_createMonitorObject.R b/R/wrcc_createMonitorObject.R index 4239ccbe..a28adb94 100644 --- a/R/wrcc_createMonitorObject.R +++ b/R/wrcc_createMonitorObject.R @@ -30,6 +30,11 @@ #' @seealso \code{\link{addClustering}} #' @seealso \code{\link{wrcc_createMetaDataframe}} #' @seealso \code{\link{wrcc_createDataDataframe}} +#' @examples +#' \dontrun{ +#' sm13 <- wrcc_createMonitorObject(20150301, 20150831, stationID='sm13') +#' monitorLeaflet(sm13) +#' } wrcc_createMonitorObject <- function(startdate=20020101, enddate=strftime(lubridate::now(),"%Y%m%d",tz="GMT"), @@ -44,6 +49,18 @@ wrcc_createMonitorObject <- function(startdate=20020101, stop(paste0("Required parameter 'stationID' is missing")) } + startdateCount <- stringr::str_count(as.character(startdate)) + if ( !startdateCount %in% c(8,10,12) ) { + logger.error("Cannot parse 'startdate' with %d characters", startdateCount) + stop(paste0("Cannot parse 'startdate' with ",startdateCount," characters")) + } + + enddateCount <- stringr::str_count(as.character(enddate)) + if ( !enddateCount %in% c(8,10,12) ) { + logger.error("Cannot parse 'enddate' with %d characters", enddateCount) + stop(paste0("Cannot parse 'enddate' with ",enddateCount," characters")) + } + # Read in WRCC .csv data logger.info("Downloading WRCC data ...") fileString <- wrcc_downloadData(startdate, enddate, stationID, baseUrl) diff --git a/R/wrcc_loadLatest.R b/R/wrcc_loadLatest.R new file mode 100644 index 00000000..084f3276 --- /dev/null +++ b/R/wrcc_loadLatest.R @@ -0,0 +1,18 @@ +#' @keywords WRCC +#' @export +#' @title Load Recent WRCC Monitoring Data +#' @param baseUrl The location of the meta and data files +#' @description The most recent 45 days of WRCC data are updated in real time +#' at PWFSL and can be loaded with this function. +#' @return A ws_monitor object with WRCC data. +#' @examples +#' \dontrun{ +#' wrcc <- wrcc_loadLatest() +#' } + +wrcc_loadLatest <- function(baseUrl='https://haze.airfire.org/monitoring/RData/wrcc_pm25_latest.RData') { + + ws_monitor <- get(load(url(baseUrl))) + + return(ws_monitor) +} diff --git a/R/airsis_load.R b/localTODO/airsis_load.R similarity index 100% rename from R/airsis_load.R rename to localTODO/airsis_load.R diff --git a/R/openaq_load.R b/localTODO/openaq_load.R similarity index 100% rename from R/openaq_load.R rename to localTODO/openaq_load.R diff --git a/R/wrcc_load.R b/localTODO/wrcc_load.R similarity index 100% rename from R/wrcc_load.R rename to localTODO/wrcc_load.R diff --git a/man/adjustRange.Rd b/man/adjustRange.Rd deleted file mode 100644 index 7b2365d3..00000000 --- a/man/adjustRange.Rd +++ /dev/null @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/adjustRange.R -\name{adjustRange} -\alias{adjustRange} -\title{Create a Scaled Range} -\usage{ -adjustRange(x, factor = 1.1, minRange = 0.1) -} -\arguments{ -\item{x}{vector of numeric values} - -\item{factor}{scaling factor to be applied} - -\item{minRange}{minimum range to be returned} -} -\value{ -Vector of low and high values of the adjusted range. -} -\description{ -Scale the range of values by a given factor. The min and max values of the -original range of valus are adjusted so that the new range is larger or smaller by \code{factor}. -The returned range will always be equal to or greater than \code{minRange}. -} -\examples{ -\dontrun{ -x <- (1:10) -range(x) -[1] 1 10 -x_new <- adjustRange(x, factor = 2) -range(x_new) -[1] -3.5 14.5 -} -} -\keyword{internal} - diff --git a/man/airnow_downloadHourlyData.Rd b/man/airnow_downloadHourlyData.Rd index e40a000b..61cf0a13 100644 --- a/man/airnow_downloadHourlyData.Rd +++ b/man/airnow_downloadHourlyData.Rd @@ -11,10 +11,6 @@ airnow_downloadHourlyData(datestamp = "", \item{datestamp}{integer or character representing YYYYMMDDHH} \item{baseUrl}{base URL for archived hourly data} - -\item{tries}{number of download attempts in the face of timeouts} - -\item{curl}{previously initialized CURL context/handle (see RCurl::getURL())} } \value{ Dataframe of AirNow hourly data. @@ -39,5 +35,4 @@ df <- airnow_downloadHourlyData(2016070112) \link{airnow_downloadData} } \keyword{AirNow} -\keyword{internal} diff --git a/man/airnow_load.Rd b/man/airnow_load.Rd index ac33e401..cfedc622 100644 --- a/man/airnow_load.Rd +++ b/man/airnow_load.Rd @@ -33,7 +33,7 @@ meta and data files from the archive baseUrl (or local directory) and return the \dontrun{ airnow <- airnow_load(20150901, 20150930) airnow_conus <- monitor_subset(airnow, stateCodes=CONUS) -monitorInteractiveMap(airnow_conus) +monitorLeaflet(airnow_conus) } } \keyword{AirNow} diff --git a/man/airsisDump_createMonitorObject.Rd b/man/airsisDump_createMonitorObject.Rd index ce890378..4a962abe 100644 --- a/man/airsisDump_createMonitorObject.Rd +++ b/man/airsisDump_createMonitorObject.Rd @@ -44,5 +44,5 @@ Each dump file must contain data for only one type of monitor, e.g. EBAM or E-Sa \code{\link{airsis_createDataDataframe}} } -\keyword{AIRSIS} +\keyword{internal} diff --git a/man/airsisDump_identifyMonitorType.Rd b/man/airsisDump_identifyMonitorType.Rd index 6fb40098..7c20f47b 100644 --- a/man/airsisDump_identifyMonitorType.Rd +++ b/man/airsisDump_identifyMonitorType.Rd @@ -43,5 +43,5 @@ monitorTypeList <- airsisDump_identifyMonitorType(fileString) \references{ \href{http://usfs.airsis.com}{Interagency Real Time Smoke Monitoring} } -\keyword{AIRSIS} +\keyword{internal} diff --git a/man/airsisDump_parseData.Rd b/man/airsisDump_parseData.Rd index c3ba2f14..bc38c5ed 100644 --- a/man/airsisDump_parseData.Rd +++ b/man/airsisDump_parseData.Rd @@ -38,5 +38,5 @@ df <- airsisDump_parseData(fileString) \references{ \href{http://usfs.airsis.com}{Interagency Real Time Smoke Monitoring} } -\keyword{AIRSIS} +\keyword{internal} diff --git a/man/airsis_createMonitorObject.Rd b/man/airsis_createMonitorObject.Rd index b5b49252..9648cd04 100644 --- a/man/airsis_createMonitorObject.Rd +++ b/man/airsis_createMonitorObject.Rd @@ -47,6 +47,12 @@ Steps involved include: \note{ The downloaded CSV may be saved to a local file by providing an argument to the \code{saveFile} parameter. } +\examples{ +\dontrun{ +usfs_1013 <- airsis_createMonitorObject(20150301, 20150831, 'USFS', unitID='1013') +monitorLeaflet(usfs_1013) +} +} \seealso{ \code{\link{airsis_downloadData}} diff --git a/man/airsis_load.Rd b/man/airsis_load.Rd deleted file mode 100644 index 1ed88280..00000000 --- a/man/airsis_load.Rd +++ /dev/null @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/airsis_load.R -\name{airsis_load} -\alias{airsis_load} -\title{Load AIRSIS Monitoring Data} -\usage{ -airsis_load(startdate = 20000101, enddate = strftime(lubridate::now(), - "\%Y\%m\%d", tz = "GMT"), monitorIDs = NULL, stateCodes = NULL, - url = "https://smoke.airfire.org/RData/AIRSIS/AIRSIS_monitors.RData") -} -\arguments{ -\item{startdate}{desired start date (integer or character representing YYYYMMDD[HH])} - -\item{enddate}{desired end date (integer or character representing YYYYMMDD[HH])} - -\item{monitorIDs}{optional vector of monitorIDs used to subset the data} - -\item{stateCodes}{optional vector of stateCodes used to subset the data} - -\item{url}{location of the meta and data files (url or local file)} -} -\value{ -A ws_monitor object with AIRSIS data. -} -\description{ -When given the startdate, enddate, monitorIDs and parameter of interest, the function retrieves -data from the archive url and returns the subsetted ws_monitor object. -} -\examples{ -\dontrun{ -airsis <- airsis_load(20140901, 20141130) -} -} -\keyword{AIRSIS} - diff --git a/man/airsis_loadLatest.Rd b/man/airsis_loadLatest.Rd index 6eb7eea5..5b232cd5 100644 --- a/man/airsis_loadLatest.Rd +++ b/man/airsis_loadLatest.Rd @@ -4,7 +4,8 @@ \alias{airsis_loadLatest} \title{Load Recent AIRSIS Monitoring Data} \usage{ -airsis_loadLatest(baseUrl = "http://tools.airfire.org/monitoring/v3/data") + + airsis_loadLatest(baseUrl = "https://haze.airfire.org/monitoring/RData/airsis_pm25_latest.RData") } \arguments{ \item{baseUrl}{The location of the meta and data files} @@ -13,7 +14,7 @@ airsis_loadLatest(baseUrl = "http://tools.airfire.org/monitoring/v3/data") A ws_monitor object with AIRSIS data. } \description{ -The most recent 10 days of AIRSIS data are updated in quasi-real time +The most recent 45 days of AIRSIS data are updated in real time at PWFSL and can be loaded with this function. } \examples{ diff --git a/man/distance.Rd b/man/distance.Rd index 6ea78503..7a21588b 100644 --- a/man/distance.Rd +++ b/man/distance.Rd @@ -23,6 +23,16 @@ This funciton uses the Haversine forumula for calculating great circle distances between points. This formula is purpoted to work better than the spherical law of cosines for very short distances. } +\examples{ +\dontrun{ +# Seattle to Portland airports +SEA_lon <- -122.3088 +SEA_lat <- 47.4502 +PDX_lon <- -122.5951 +PDX_lat <- 45.5898 +distance(SEA_lon, SEA_lat, PDX_lon, PDX_lat) +} +} \references{ \url{http://www.r-bloggers.com/great-circle-distance-calculations-in-r/} } diff --git a/man/monitor_dygraph.Rd b/man/monitorDygraph.Rd similarity index 76% rename from man/monitor_dygraph.Rd rename to man/monitorDygraph.Rd index 940a2f5c..bdd46a33 100644 --- a/man/monitor_dygraph.Rd +++ b/man/monitorDygraph.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/monitor_dygraph.R -\name{monitor_dygraph} -\alias{monitor_dygraph} +% Please edit documentation in R/monitorDygraph.R +\name{monitorDygraph} +\alias{monitorDygraph} \title{Create Interactive Time Series Plot} \usage{ -monitor_dygraph(ws_monitor, title = "title", ylab = "PM2.5 Concentration", +monitorDygraph(ws_monitor, title = "title", ylab = "PM2.5 Concentration", dateWindow = NULL, rollPeriod = 1, showLegend = TRUE) } \arguments{ @@ -30,7 +30,7 @@ This function creates interactive graphs that will be displayed in RStudio's 'Vi \dontrun{ airnow <- airnow_load(20140913, 20141010) King_Fire <- monitor_subsetByDistance(airnow, lon=-120.604, lat=38.782, radius=50) -monitor_dygraph(King_Fire, title='KingFire/California/2014', rollPeriod=3) +monitorDygraph(King_Fire, title='KingFire/California/2014', rollPeriod=3) } } \keyword{ws_monitor} diff --git a/man/monitorInteractiveMap.Rd b/man/monitorLeaflet.Rd similarity index 83% rename from man/monitorInteractiveMap.Rd rename to man/monitorLeaflet.Rd index 9ab30367..f3a43f3e 100644 --- a/man/monitorInteractiveMap.Rd +++ b/man/monitorLeaflet.Rd @@ -1,13 +1,13 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/monitorInteractiveMap.R -\name{monitorInteractiveMap} -\alias{monitorInteractiveMap} +% Please edit documentation in R/monitorLeaflet.R +\name{monitorLeaflet} +\alias{monitorLeaflet} \title{Leaflet Interactive Map of Monitoring Stations} \usage{ -monitorInteractiveMap(ws_monitor, slice = get("max"), - breaks = AQI$breaks_24, colors = AQI$colors, labels = AQI$names, - legendTitle = "Max AQI Level", radius = 10, opacity = 0.7, - maptype = "terrain", popupInfo = c("siteName", "monitorID", "elevation")) +monitorLeaflet(ws_monitor, slice = get("max"), breaks = AQI$breaks_24, + colors = AQI$colors, labels = AQI$names, legendTitle = "Max AQI Level", + radius = 10, opacity = 0.7, maptype = "terrain", + popupInfo = c("siteName", "monitorID", "elevation")) } \arguments{ \item{ws_monitor}{ws_monitor object} @@ -61,7 +61,7 @@ to use as the background map. airnow <- airnow_load(20140913, 20141010) v_low <- AQI$breaks_24[4] CA_unhealthy_monitors <- monitor_subset(airnow, stateCodes='CA', vlim=c(v_low, Inf)) -monitorInteractiveMap(CA_unhealthy_monitors, maptype="toner") +monitorLeaflet(CA_unhealthy_monitors, maptype="toner") } } \keyword{ws_monitor} diff --git a/man/monitorMap_performance.Rd b/man/monitorMap_performance.Rd index aed5a1dd..591eba3f 100644 --- a/man/monitorMap_performance.Rd +++ b/man/monitorMap_performance.Rd @@ -58,11 +58,10 @@ the size/colors to remain constant. \examples{ \dontrun{ # Spokane summer of 2015 -airnow <- airnow_load(20150701,20150930) -airnow <- monitor_rollingMean(airnow, width=3) -WA <- monitor_subset(airnow, stateCode='WA', countryCode="US") -MonroeSt <- monitor_subset(WA, monitorIDs=530630047) -monitorMap_performance(WA, MonroeSt, cex=2) +wa <- airnow_load(20150701, 20150930, stateCodes='WA') +wa <- monitor_rollingMean(wa, width=3) +MonroeSt <- monitor_subset(wa, monitorIDs=530630047) +monitorMap_performance(wa, MonroeSt, cex=2) title('Heidike Skill of monitors predicting another monitor.') } } diff --git a/man/monitorPlot_noData.Rd b/man/monitorPlot_noData.Rd index f64da3bb..a6202586 100644 --- a/man/monitorPlot_noData.Rd +++ b/man/monitorPlot_noData.Rd @@ -16,5 +16,5 @@ monitorPlot_noData(ws_monitor, monitorID = NULL, cex = 2.5) \description{ Creates a blank plot that indicates there is no data for the monitor of interest } -\keyword{ws_monitor} +\keyword{internal} diff --git a/man/monitor_collapse.Rd b/man/monitor_collapse.Rd index eb84afc4..d6e966c5 100644 --- a/man/monitor_collapse.Rd +++ b/man/monitor_collapse.Rd @@ -29,5 +29,5 @@ the function provided in the \code{FUN} argument. The collapse applies to both w Intended for use with gridded model data, rather than actual monitor data itself (meta data is largely chopped; NAs propagate). } -\keyword{ws_monitor} +\keyword{internal} diff --git a/man/monitor_combine.Rd b/man/monitor_combine.Rd index b9edb871..cff2051c 100644 --- a/man/monitor_combine.Rd +++ b/man/monitor_combine.Rd @@ -24,7 +24,7 @@ monitorList[[2]] <- airsis_createMonitorObject(20160701, 20161231, 'USFS', '1032 monitorList[[3]] <- airsis_createMonitorObject(20160701, 20161231, 'USFS', '1033') monitorList[[4]] <- airsis_createMonitorObject(20160701, 20161231, 'USFS', '1034') ws_monitor <- monitor_combine(monitorList) -monitorInteractiveMap(ws_monitor) +monitorLeaflet(ws_monitor) } } \keyword{ws_monitor} diff --git a/man/monitor_dailyThreshold.Rd b/man/monitor_dailyThreshold.Rd index ee29f429..7f25ba8b 100644 --- a/man/monitor_dailyThreshold.Rd +++ b/man/monitor_dailyThreshold.Rd @@ -41,7 +41,7 @@ AirNow <- airnow_load(20150801, 20150930) WA_IDS <- AirNow$meta$monitorID[AirNow$meta$stateCode == 'WA'] WA <- monitor_subset(AirNow, monitorIDs=WA_IDS) -monitorInteractiveMap(WA) +monitorLeaflet(WA) # Pull out specific locations Twisp <- monitor_subset(WA, monitorIDs='530470009') diff --git a/man/monitor_subsetBy.Rd b/man/monitor_subsetBy.Rd index 53cc9d01..29c851ec 100644 --- a/man/monitor_subsetBy.Rd +++ b/man/monitor_subsetBy.Rd @@ -25,8 +25,8 @@ Either meta data or actual data can be filtered. airnow <- airnow_load(20150101, 20151231) mySubset <- monitor_subsetBy(airnow, timezone == 'America/Los_Angeles') hazardousSubset <- monitor_subsetBy(mySubset, data > AQI$breaks_24[6]) -monitorInteractiveMap(hazardousSubset, - popupInfo=c('siteName', 'agencyName', 'elevation','monitorID')) +monitorLeaflet(hazardousSubset, + popupInfo=c('siteName', 'agencyName', 'elevation','monitorID')) } } \keyword{ws_monitor} diff --git a/man/monitor_subsetByDistance.Rd b/man/monitor_subsetByDistance.Rd index a7b5baf1..72e18174 100644 --- a/man/monitor_subsetByDistance.Rd +++ b/man/monitor_subsetByDistance.Rd @@ -36,7 +36,7 @@ of monitors (or grid cells) returned may be less than the specified \code{count} \dontrun{ airnow <- airnow_load(20140913, 20141010) KingFire <- monitor_subsetByDistance(airnow, lon=-120.604, lat=38.782, radius=50) -monitorInteractiveMap(KingFire) +monitorLeaflet(KingFire) } } \seealso{ diff --git a/man/monitor_trim.Rd b/man/monitor_trim.Rd index 261014e9..3b2f4e42 100644 --- a/man/monitor_trim.Rd +++ b/man/monitor_trim.Rd @@ -16,5 +16,14 @@ A ws_monitor object with missing data trimmed. Trims the time axis of a ws_monitor object to exclude timestamps prior to the first and after the last valid datapoint for any monitor. } +\examples{ +\dontrun{ +sm13 <- wrcc_createMonitorObject(20150101, 20151231, stationID='sm13') +sm13$meta[,c('stateCode','countyName','siteName','monitorID')] +Deschutes <- monitor_subset(sm13, monitorIDs='Smoke..13__001') +Deschutes <- monitor_trim(Deschutes) +monitorPlot_dailyBarplot(Deschutes) +} +} \keyword{ws_monitor} diff --git a/man/openaq_load.Rd b/man/openaq_load.Rd deleted file mode 100644 index 2022f3d2..00000000 --- a/man/openaq_load.Rd +++ /dev/null @@ -1,57 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/openaq_load.R -\name{openaq_load} -\alias{openaq_load} -\title{Load OpenAQ Monitoring Data} -\usage{ -openaq_load(startdate, enddate, monitorIDs = NULL, parameter = "pm25", - baseUrl = "https://smoke.airfire.org/RData/OpenAQ/") -} -\arguments{ -\item{startdate}{desired start date (integer or character representing YYYYMMDD[HH])} - -\item{enddate}{desired end date (integer or character representing YYYYMMDD[HH])} - -\item{monitorIDs}{vector of monitor IDs used for subsetting -When set to NULL, the function returns all the monitor IDs available in the metadata} - -\item{parameter}{parameter of interest} - -\item{baseUrl}{base URL for OpenAQ meta and data files (note: the default baseURL cannot be used yet)} -} -\value{ -A ws_monitor object with OpenAQ data. -} -\description{ -When given the startdate, enddate, monitorIDs and parameter of interest, the function retrieves the -meta and data files from the archive baseUrl (or local directory) and return the subsetted ws_monitor object. - -Available parameters include: -\enumerate{ -\item{pm25}{ -- PM2.5} -\item{pm10}{ -- PM10} -\item{o3}{ -- ozone } -\item{so2}{ -- sulfer dioxide } -\item{no2}{ -- nitrogen dioxide} -\item{co}{ -- carbon monoxide} -\item{bc}{ -- black carbon} -} - -Note that data for some days in 2015 are missing and data only becomes available starting 06/29/2015, imcomplete -months with their available days are: -\enumerate{ -\item{201506}{: 6/29 - 6/30} -\item{201507}{: 7/1 - 7/4, 7/6 - 7/18, 7/20 - 7/24} -\item{201508}{: 8/2 - 8/31} -\item{201512}{: 12/1 - 12/30} -} -} -\examples{ -\dontrun{ -openaq <- openaq_load(20150901, 20150930) -openaq_conus <- monitor_subset(openaq, stateCodes=CONUS, countryCodes=US) -monitorInteractiveMap(openaq_conus) -} -} -\keyword{OpenAQ} - diff --git a/man/wrccDump_createMonitorObject.Rd b/man/wrccDump_createMonitorObject.Rd index 4bbe6957..23c07917 100644 --- a/man/wrccDump_createMonitorObject.Rd +++ b/man/wrccDump_createMonitorObject.Rd @@ -44,5 +44,5 @@ Each dump file must contain data for only one type of monitor, e.g. EBAM or E-Sa \code{\link{wrcc_createDataDataframe}} } -\keyword{WRCC} +\keyword{internal} diff --git a/man/wrccDump_identifyMonitorType.Rd b/man/wrccDump_identifyMonitorType.Rd index 4b25febd..a3c60d43 100644 --- a/man/wrccDump_identifyMonitorType.Rd +++ b/man/wrccDump_identifyMonitorType.Rd @@ -39,5 +39,5 @@ Fire Sciences Lab. \references{ \href{http://www.wrcc.dri.edu/cgi-bin/smoke.pl}{WRCC Fire Cache Smoke Monitor Archive} } -\keyword{WRCC} +\keyword{internal} diff --git a/man/wrccDump_parseData.Rd b/man/wrccDump_parseData.Rd index bcfc4296..893f9b45 100644 --- a/man/wrccDump_parseData.Rd +++ b/man/wrccDump_parseData.Rd @@ -20,5 +20,5 @@ file using \code{readr::read_file()}. This function is intended for internal use at the Pacific Wildland Fire Sciences Lab. } -\keyword{WRCC} +\keyword{internal} diff --git a/man/wrcc_createMonitorObject.Rd b/man/wrcc_createMonitorObject.Rd index 280768a3..cdffd847 100644 --- a/man/wrcc_createMonitorObject.Rd +++ b/man/wrcc_createMonitorObject.Rd @@ -44,6 +44,12 @@ Steps involved include: \note{ The downloaded CSV may be saved to a local file by providing an argument to the \code{saveFile} parameter. } +\examples{ +\dontrun{ +sm13 <- wrcc_createMonitorObject(20150301, 20150831, stationID='sm13') +monitorLeaflet(sm13) +} +} \seealso{ \code{\link{wrcc_downloadData}} diff --git a/man/wrcc_load.Rd b/man/wrcc_load.Rd deleted file mode 100644 index ac6d642d..00000000 --- a/man/wrcc_load.Rd +++ /dev/null @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/wrcc_load.R -\name{wrcc_load} -\alias{wrcc_load} -\title{Load WRCC Monitoring Data} -\usage{ -wrcc_load(startdate, enddate, monitorIDs = NULL, stateCodes = NULL, - url = "https://smoke.airfire.org/RData/WRCC/WRCC_monitors.RData") -} -\arguments{ -\item{startdate}{desired start date (integer or character representing YYYYMMDD[HH])} - -\item{enddate}{desired end date (integer or character representing YYYYMMDD[HH])} - -\item{monitorIDs}{optional vector of monitorIDs used to subset the data} - -\item{stateCodes}{optional vector of stateCodes used to subset the data} - -\item{url}{local file path or url containing the \code{ws_monitor} object to be loaded} -} -\value{ -A ws_monitor object with WRCC data. -} -\description{ -When given the startdate, enddate, monitorIDs and stateCodes, the function retrieves -data from url and returns the subsetted ws_monitor object. -} -\examples{ -\dontrun{ -wrcc <- wrcc_load(20150901, 20150930) -wrcc_conus <- monitor_subset(wrcc, stateCodes=CONUS) -monitorInteractiveMap(wrcc_conus) -} -} -\keyword{wrcc} - diff --git a/man/wrcc_loadLatest.Rd b/man/wrcc_loadLatest.Rd new file mode 100644 index 00000000..02e26b07 --- /dev/null +++ b/man/wrcc_loadLatest.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/wrcc_loadLatest.R +\name{wrcc_loadLatest} +\alias{wrcc_loadLatest} +\title{Load Recent WRCC Monitoring Data} +\usage{ + + wrcc_loadLatest(baseUrl = "https://haze.airfire.org/monitoring/RData/wrcc_pm25_latest.RData") +} +\arguments{ +\item{baseUrl}{The location of the meta and data files} +} +\value{ +A ws_monitor object with WRCC data. +} +\description{ +The most recent 45 days of WRCC data are updated in real time +at PWFSL and can be loaded with this function. +} +\examples{ +\dontrun{ +wrcc <- wrcc_loadLatest() +} +} +\keyword{WRCC} +