Learn R Programming

⚠️There's a newer version (1.2.117) of this package.Take me there.

title: "PWFSLSmoke" pagetitle: PWFSLSmoke"

PWFSLSmoke R Package

Utilities for Working with PM2.5 Air Quality Monitoring Data

Background

The USFS Pacific Wildland Fire Sciences Lab AirFire team works to model wildland fire emissions and has created the BlueSky Modeling Framework. This system integrates a wide collection of models along a smoke modeling pipeline (fire information, fuel loadings, consumption modeling, emissions modeling, time rate of emissions modeling, plume height estimations, and smoke trajectory and dispersion modeling). The resulting model output has been integrated into many different smoke prediction systems and scientific modeling efforts.

The PWFSLSmoke R package is being developed for PWFSL to help modelers and scientists more easily work with PM2.5 data from monitoring locations across North America.

The package makes it easier to obtain data, perform analyses and generate reports. It includes functionality to:

  • download and easily work with regulatory PM2.5 data from the EPA and AirNow
  • download and quality control raw monitoring data from AIRSIS and WRCC
  • convert between UTC and local timezones
  • apply various algorithms to the data (nowcast, rolling means, aggregation, etc.)
  • provide interactive timeseries and maps through RStudio’s Viewer pane
  • create a variety of publication ready maps and timeseries plots

Installation

This package is designed to be used with R (>= 3.3) and RStudio so make sure you have those installed first.

Users will want to install the devtools package to have access to the latest version of the package from Github.

The following packages should be installed by typing the following at the RStudio console:

# Note that vignettes require knitr and rmarkdown
install.packages('knitr')
install.packages('rmarkdown')
install.packages('MazamaSpatialUtils')
devtools::install_github('MazamaScience/PWFSLSmoke', build_vignettes=TRUE)

Any work with spatial data, e.g. assigning countries, states and timezones, will require installation of required spatial datasets. To get these datasets you should type the following at the RStudio console:

library(MazamaSpatialUtils)
dir.create('~/Data/Spatial', recursive=TRUE)
setSpatialDataDir('~/Data/Spatial')
installSpatialData()

Examples

Additional R Notebooks that demonstrate the functionality of the package can be found in the localNotebooks directory on github. These notebooks are not part of the package because they require installation of the MazamaSpatialUtils datasets.

To run them you should:

  • make sure you have the proper spatial data installed in ~/Data/Spatial/
  • make sure you have both the knitr and rmarkdown packages installed
  • download the localNotebooks/ directory
  • open a notebook with RStudio
  • click the "Knit" or "Preview" button in RStudio

This R package was created by Mazama Science and is being funded by the USFS Pacific Wildland Fire Sciences Lab.

Copy Link

Version

Install

install.packages('PWFSLSmoke')

Monthly Downloads

81

Version

1.2.100

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Jonathan Callahan

Last Published

July 18th, 2019

Functions in PWFSLSmoke (1.2.100)

addGoogleAddress

Add address information to a dataframe
addEsriAddress

Add address information to a dataframe
addWindBarb

Add wind barb to a map
addUSGSElevation

Add Elevation Data to a Dataframe
addClustering

Add clustering information to a dataframe
addBullseye

Add a Bullseyes to a Map or RgoogleMap Plot
AQI

Official Air Quality Index Levels, Names and Colors
addMazamaMetadata

Add State, Country and Timezone to a Dataframe
addPolygon

Add a Colored Polygon to a Plot
addAQIStackedBar

Create Stacked AQI Bar
airnow_loadAnnual

Load annual AirNow monitoring data
airsis_BAM1020QualityControl

Apply Quality Control to raw AIRSIS BAM1020 dataframe
airsis_createMonitorObject

Obain AIRSIS data and create ws_monitor object
airsis_createRawDataframe

Obain AIRSIS data and parse into a raw tibble
addGoogleElevation

Add Elevation Data to a Dataframe
addShadedNight

Add Nighttime Shading to a Plot
addAQILines

Add AQI Lines to a Plot
addAQILegend

Add an AQI Legend to a Map
addShadedBackground

Add Shaded Background to a Plot
airnow_loadLatest

Load most recent AirNow monitoring data
addWindBarbs

Add wind barbs to a map
airsis_EBAMQualityControl

Apply Quality Control to raw AIRSIS EBAM tibble
aqiColors

Generate AQI Colors
airnow_loadDaily

Load recent AirNow monitoring data
airnow_qualityControl

Apply Quality Control to AirNow dataframe
airnow_createDataDataframes

Return reshaped dataframes of AirNow data
epa_parseData

Parse EPA data
aqiPalette

Color Palettes for Air Quality Monitoring Data
createEmptyMetaDataframe

Create Empty Site Location Metadata Dataframe
epa_createMonitorObject

Download and convert hourly EPA air quality data
createEmptyMonitor

Create empty monitor object
epa_downloadData

Download EPA air quality data
airsis_createDataDataframe

Create AIRSIS data dataframe
airsis_loadDaily

Load recent AIRSIS monitoring data
airsis_createMetaDataframe

Create AIRSIS site location metadata dataframe
airnow_downloadSites

Download AirNow Site Location Metadata
airsis_ESAMQualityControl

Apply Quality Control to raw AIRSIS E-Sampler dataframe
airsis_loadLatest

Load most recent AIRSIS monitoring data
airnow_load

Load Processed AirNow Monitoring Data
airsis_identifyMonitorType

Identify AIRSIS monitor type
airsis_downloadData

Download AIRSIS data
distance

Calculate distances between points
airsis_availableUnits

Get AIRSIS available unit identifiers
loadDaily

Load Recent PM2.5 Monitoring Data
epa_load

Load Processed EPA Monitoring Data
loadDataFile

Load data from URL or local file
epa_loadAnnual

Load annual EPA monitoring data
downloadDataFile

Download data from URL to local diredctory
monitor_dailyThreshold

Calculate Daily Counts of Values At or Above a Threshold
monitor_distance

Calculate distances from monitors to a location of interest
airsis_parseData

Parse AIRSIS data string
airsis_qualityControl

Apply Quality Control to raw AIRSIS dataframe
googleApiKey

API Key used for Google Geocoding Requests
initializeMazamaSpatialUtils

Initialize Mazama Spatial Utils
esriToken

Token used for ESRI Geocoding Requests
monitor_getCurrentStatus

Get current status of monitors
monitor_dygraph

Create Interactive Time Series Plot
monitor_downloadLatest

Download recent PM2.5 monitoring data
monitor_extractDataFrame

Extract dataframes from ws_monitor objects
monitor_getDailyMean

Calculate daily means for a ws_monitor object
airnow_createMetaDataframes

Create dataframes of AirNow site location metadata
monitor_downloadDaily

Download recent PM2.5 monitoring data
monitor_downloadAnnual

Download annual PM2.5 monitoring data
addIcon

Add Icons to a Map or RgoogleMap Plot
addMarker

Add Icons to a Map or RgoogleMap Plot
loadLatest

Load Recent PM2.5 Monitoring Data
monitor_hourlyBarplot

Create Hourly Barplot
epa_createMetaDataframe

Create dataframe of EPA site location metadata
epa_createDataDataframe

Create EPA data dataframe
monitor_rollingMean

Calculate Rolling Means
monitor_rollingMeanPlot

Create Rolling Mean Plot
parseDatetime

Parse Datetime Strings
monitor_loadAnnual

Load annual PM2.5 monitoring data
monitor_writeCurrentStatusGeoJSON

Write current monitor data to geojson file
monitor_load

Load PM2.5 monitoring data
monitor_join

Merge Data for Monitors with Shared monitorIDs
monitor_combine

Combine List of ws_monitor Objects into Single ws_monitor Object
monitor_loadDaily

Load recent PM2.5 monitoring data
monitor_aqi

Calculate hourly NowCast-based AQI values
monitor_dailyBarplot

Create Daily Barplot
monitor_asDataframe

Return Monitor Data in a Single Dataframe
airnow_downloadHourlyData

Download hourly data from AirNow
airnow_downloadParseData

Download and aggregate multiple hourly data files from AirNow
airnow_createMonitorObjects

Obain AirNow data and create ws_monitor objects
monitor_collapse

Collapse a ws_monitor Object into a ws_monitor Object with a Single Monitor
monitor_loadLatest

Load most recent PM2.5 monitoring data
monitor_isEmpty

Test for an Empty ws_monitor Object
monitor_staticmap

Create a static map of ws_monitor object
monitor_nowcast

Apply Nowcast Algorithm to ws_monitor Object
monitor_performance

Calculate Monitor Prediction Performance
monitor_leaflet

Leaflet interactive map of monitoring stations
monitor_subsetData

Subset ws_monitor Object 'data' Dataframe
monitor_map

Static map of monitoring stations
monitor_noDataPlot

Create Blank Plot with "No Data" Message
monitor_isMonitor

Test for an correct structure of ws_monitor Object
monitor_subset

Subset ws_monitor Object
airsis_load

Load Processed AIRSIS Monitoring Data
airsis_loadAnnual

Load annual AIRSIS monitoring data
generic_parseData

Parse generic air quality files
generic_downloadData

Download generic data
monitor_scaleData

Scale ws_monitor Data
getEsriToken

Get ESRI Token
monitor_timeAverage

Calculate Time Averages
monitor_timeInfo

Get time related information for a monitor
skill_ROC

ROC Curve
monitor_replaceData

Replace ws_monitor Data with Another Value
monitor_trim

Trim ws_monitor Time Axis to Remove NA Periods From Beginning and End
setGoogleApiKey

Set Google API Key
monitor_reorder

Reorder a ws_monitor bject
monitor_writeCSV

Write monitor data as CSV
rawPlot_timeOfDaySpaghetti

Create Time of Day Spaghetti Plot from a Raw Dataframe
rawPlot_timeseries

Create Timeseries Plot from a Raw Dataframe
raw_getHighlightDates

Return Day Stamps for Values Above a Threshold
wrcc_EBAMQualityControl

Apply Quality Control to raw WRCC EBAM tibble
upgradeMeta_v1.0

Upgrade ws_monitor Metadata to Version 1.0
setEsriToken

Set ESRI Token
skill_confusionMatrix

Confusion Matrix Statistics
skill_ROCPlot

ROC Plot
wrcc_createMonitorObject

Obtain WRCC data and create ws_monitor object
wrcc_createMetaDataframe

Create WRCC site location metadata dataframe
monitor_subsetMeta

Subset ws_monitor Object 'meta' Dataframe
monitor_stamenmap

Create a static map of ws_monitor object
staticmap_getEsrimapBrick

Create a rasterBrick from an Esri tiled image server
staticmap_getRasterBrick

Create a rasterBrick from a tiled image server
getGoogleApiKey

Get Google API Key
staticmap_plotRasterBrick

Plot an RGB rasterBrick
staticmap_getStamenmapBrick

Create a rasterBrick from stamenmap tiles
wrcc_ESAMQualityControl

Apply Quality Control to raw WRCC E-Sampler tibble
wrcc_createDataDataframe

Create WRCC data dataframe
monitor_dailyStatistic

Calculate daily statistics
monitor_dailyStatisticList

Calculate Daily Statistics
monitor_isTidy

Check if data is tidy-formatted ws_monitor data
%>%

Pipe operator
monitor_isolate

Isolate Individual Monitors
monitor_performanceMap

Create map of monitor prediction performance
wrcc_createRawDataframe

Obtain WRCC data and parse into a tibble
wrcc_downloadData

Download WRCC data
monitor_toTidy

Convert `ws_monitor` data to a tidy format
monitor_subsetByDistance

Subset ws_monitor Object by Distance from Target Location
monitor_subsetBy

Subset ws_monitor Object with a Filter
monitor_timeseriesPlot

Create Timeseries Plot
monitor_print

Print monitor data as CSV
rawPlot_windRose

Create Wind Rose Plot from a Raw Dataframe
rawPlot_pollutionRose

Create Pollution Rose Plot from a Raw Dataframe
wrcc_loadAnnual

Load annual WRCC monitoring data
raw_enhance

Process Raw Monitoring Data to Create raw_enhance Object
wrcc_loadLatest

Load most recent WRCC monitoring data
wrcc_loadDaily

Load recent WRCC monitoring data
wrcc_parseData

Parse WRCC data string
tidy_toMonitor

Convert `ws_tidy` data to a `ws_monitor` object
wrcc_identifyMonitorType

Identify WRCC monitor type
timeInfo

Get time related information
wrcc_load

Load Processed WRCC Monitoring Data
wrcc_qualityControl

Apply Quality Control to raw WRCC tibble
AQI_es

Official Air Quality Index Levels, Names and Colors
PWFSLSmoke-deprecated

Deprecated functions in PWFSLSmoke
US_52

US State Codes
AIRSIS

AIRSIS Unit Types
CONUS

CONUS State Codes
WRCC

WRCC Monitor Names and Unit IDs
Northwest_Megafires

Northwest Megafires Example Dataset
AQI_en

Official Air Quality Index Levels, Names and Colors
Carmel_Valley

Carmel Valley Example Dataset