Learn R Programming

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

PWFSLSmoke R Package

Utilities for Working with 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

53

Version

1.0.16

License

GPL-3

Maintainer

Jonathan Callahan

Last Published

March 6th, 2018

Functions in PWFSLSmoke (1.0.16)

Northwest_Megafires

Northwest Megafires Example Dataset
airnow_load

Load Processed AirNow Monitoring Data
addIcon

Add Icons to a Map or RgoogleMap Plot
airsis_createRawDataframe

Obain AIRSIS Data and Create a Raw Tibble
airsis_downloadData

Download Data from AIRSIS
WRCC

WRCC Monitor Names and Unit IDs
addBullseye

Add a Bullseyes to a Map or RgoogleMap Plot
airnow_downloadParseData

Download and Aggregate Multiple Hourly Data Files from AirNow
addAQILines

Add AQI Lines to a Plot
airsis_createMetaDataframe

Create AIRSIS Site Location Metadata Dataframe
airsis_loadLatest

Load Recent AIRSIS Monitoring Data
airnow_createMonitorObjects

Obain AirNow Data and Create ws_monitor Objects
airnow_downloadHourlyData

Download Hourly Data from AirNow
epa_downloadData

Download Data from EPA
monitorGoogleMap

Create a Google Map of ws_monitor Object
airsis_BAM1020QualityControl

Apply Quality Control to Raw AIRSIS BAM1020 Dataframe
monitorLeaflet

Leaflet Interactive Map of Monitoring Stations
airsis_identifyMonitorType

Identify AIRSIS Monitor Type
monitor_join

Merge Data for Monitors with Shared monitorIDs
esriMap_getMap

Download a Spatial Raster Object from ESRI
monitor_nowcast

Apply Nowcast Algorithm to ws_monitor Object
epa_createMetaDataframe

Create Sites Metadata Dataframe
monitor_performance

Calculate Monitor Prediction Performance
rawPlot_timeseries

Create Timeseries Plot from a Raw Dataframe
rawPlot_windRose

Create Wind Rose Plot from a Raw Dataframe
wrcc_load

Load Processed WRCC Monitoring Data
monitorPlot_dailyBarplot

Create Daily Barplot
AQI

Official Air Quality Index Levels, Names and Colors
monitorDygraph

Create Interactive Time Series Plot
addShadedBackground

Add Shaded Background to a Plot
monitor_distance

Calculate Distances From ws_monitor Monitors to Location of Interest
monitorEsriMap

Create an ESRI Map of ws_monitor Object
monitor_isEmpty

Test for an Empty ws_monitor Object
monitorMap_performance

Create Map of Monitor Prediction Performance
monitor_collapse

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

Ingest AIRSIS Dump File and Create ws_monitor Object
airsisDump_identifyMonitorType

Identify AIRSIS Dump File Monitor Type
createEmptyMetaDataframe

Create Empty Site Location Metadata Dataframe
epa_load

Load Processed EPA Monitoring Data
parseDatetime

Parse Datetime Strings
monitor_subsetByDistance

Subset ws_monitor Object by Distance from Target Location
skill_ROC

ROC Curve
logger.warn

Python-Style Logging Statements
monitor_subsetBy

Subset ws_monitor Object with a Filter
monitor_timeAverage

Calculate Time Averages
wrcc_EBAMQualityControl

Apply Quality Control to Raw WRCC EBAM Titbble
monitorPlot_noData

Create Blank Plot with "No Data" Message
wrcc_createMonitorObject

Obtain WRCC Data and Create ws_monitor Object
wrcc_createRawDataframe

Obtain WRCC Data and Parse into Tibbler
wrcc_qualityControl

Apply Quality Control to Raw WRCC Tibble
wrcc_ESAMQualityControl

Apply Quality Control to Raw WRCC E-Sampler Tibble
wrcc_loadLatest

Load Recent WRCC Monitoring Data
Carmel_Valley

Carmel Valley Example Dataset
wrcc_parseData

Parse WRCC Data String
airnow_createMetaDataframes

Create Dataframes of AirNow Site Location Metadata
rawPlot_pollutionRose

Create Pollution Rose Plot from a Raw Dataframe
rawPlot_timeOfDaySpaghetti

Create Time of Day Spaghetti Plot from a Raw Dataframe
airsis_ESAMQualityControl

Apply Quality Control to Raw AIRSIS E-Sampler Dataframe
initializeMazamaSpatialUtils

Initialize Mazama Spatial Utils
skill_confusionMatrix

Confusion Matrix Statistics
airsis_qualityControl

Apply Quality Control to Raw AIRSIS Dataframe
wrcc_createDataDataframe

Create WRCC Data Dataframe
wrcc_createMetaDataframe

Create WRCC Site Location Metadata Dataframe
logger.setLevel

Set Console Log Level
monitorPlot_timeOfDaySpaghetti

Create Time of Day Spaghetti Plot
monitorPlot_timeseries

Create Timeseries Plot
monitor_rollingMean

Calculate Rolling Means
monitor_dailyStatistic

Calculate Daily Statistics
raw_enhance

Process Raw Monitoring Data to Create raw_enhance Object
raw_getHighlightDates

Return Day Stamps for Values Above a Threshold
wrccDump_identifyMonitorType

Identify WRCC Dump File Monitor Type
wrcc_identifyMonitorType

Identify WRCC Monitor Type
US_52

US State Codes
addShadedNight

Add Nighttime Shading to a Plot
airnow_loadDaily

Load Recent Processed AirNow Monitoring Data
airsis_availableUnits

Get Available Unit Identifiers from AIRSIS
airsis_createDataDataframe

Create AIRSIS Data Dataframe
addClustering

Add Clustering Information to a Dataframe
addMarker

Add Icons to a Map or RgoogleMap Plot
logger.info

Python-Style Logging Statements
airsis_createMonitorObject

Obain AIRSIS Data and Create ws_monitor Object
addAQILegend

Add an AQI Legend to a Map
epa_createMonitorObject

Download and Convert Hourly EPA Air Quality Data
epa_createDataDataframe

Create EPA Data Dataframe
logger.error

Python-Style Logging Statements
monitorPlot_hourlyBarplot

Create Hourly Barplot
AIRSIS

AIRSIS Unit Types
addMazamaMetadata

Add State, Country and Timezone to a Dataframe
airnow_loadLatest

Load Most Recent Processed AirNow Monitoring Data
airnow_qualityControl

Apply Quality Control to AirNow Dataframe
monitor_subset

Subset ws_monitor Object
monitorMap

Create Map of Monitoring Stations
distance

Calculate the Distance Between Points
monitor_subsetData

Subset ws_monitor Object 'data' Dataframe
skill_ROCPlot

ROC Plot
addGoogleMetadata

Add Elevation and Address Information to a Dataframe
monitor_replaceData

Replace ws_monitor Data with Another Value
airsis_EBAMQualityControl

Apply Quality Control to Raw AIRSIS EBAM Tibble
timeInfo

Get Time Related Information
logLevels

Log Levels
wrccDump_parseData

Parse WRCC Dump File String
addUSGSElevation

Add Elevation Data to a Dataframe
airsis_loadDaily

Load Recent AIRSIS Monitoring Data
logger.fatal

Python-Style Logging Statements
monitor_isolate

Isolate Individual Monitors
airsis_load

Load Processed AIRSIS Monitoring Data
upgradeMeta_v1.0

Upgrade ws_monitor Metadata to Version 1.0
logger.debug

Python-Style Logging Statements
monitor_combine

Combine List of ws_monitor Objects into Single ws_monitor Object
epa_parseData

Parse Data from EPA
logger.trace

Python-Style Logging Statements
monitor_subsetMeta

Subset ws_monitor Object 'meta' Dataframe
monitor_asDataframe

Return Monitor Data in a Single Dataframe
addGoogleElevation

Add Elevation Data to a Dataframe
airnow_createDataDataframes

Return Reshaped, Dataframes of AirNow Data
airsis_parseData

Parse AIRSIS Data String
logger.setup

Set Up Python-Style Logging
monitor_scaleData

Scale ws_monitor Data
addGoogleAddress

Add Address Information to a Dataframe
airsisDump_parseData

Parse AIRSIS Dump File Data String
esriMap_plotOnStaticMap

Plot a map from a RGB rasterBrick.
monitor_trim

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

Calculate hourly NowCast-based AQI values
CONUS

CONUS State Codes
monitor_dailyThreshold

Calculate Daily Counts of Values At or Above a Threshold
wrcc_downloadData

Download Data from WRCC
airnow_downloadSites

Download AirNow Site Location Metadata
wrccDump_createMonitorObject

Ingest WRCC Dump File and Create ws_monitor Object
wrcc_loadDaily

Load Recent WRCC Monitoring Data
monitorPlot_rollingMean

Create Rolling Mean Plot
monitor_reorder

Reorder a ws_monitor Object