Learn R Programming

A dedicated Slack channel has been created for announcements, support and to help build a community of practice around this open source package. You may request an invitation to join from jonathan.callahan@dri.com.

AirMonitor

Utilities for working with hourly air quality monitoring data
with a focus on small particulates (PM2.5). A compact data model is 
structured as a list with two dataframes. A 'meta' dataframe contains 
spatial and measuring device metadata associated with deployments at known 
locations. A 'data' dataframe contains a 'datetime' column followed by 
columns of measurements associated with each "device-deployment".

Background

The USFS AirFire group is focused on air quality measurements associated with wildfire smoke and maintains both historical and real-time databases of PM2.5 monitoring data obtained from stationary monitors. This data is used in operational displays and for retrospective analysis. Data ingest and management of air quality “stationary time series” are both important ongoing activities.

Related Packages

The AirMonitorIngest package is used to create data archives for the AirMonitor package and isolates the work of meticulously cleaning, validating and harmonizing data from various sources.

The AirMonitor package contains data access functions to easily download harmonized data files as well as data manipulation functions that make it easy to create "recipe style" analysis pipelines. The combination allows analysts to work efficiently with short, readable R scripts. Interactive and base R plotting functions allow for visual review of the data.

The AirMonitorPlots package contains ggplot2 based plotting functions for advanced plots.

Installation

NOTE: This package has not yet been uploaded to CRAN

Install the latest version from GitHub with:

devtools::install_github('mazamascience/AirMonitor')

Data Model

The AirMonitor package uses the mts data model defined in MazamaTimeSeries.

In this data model, each unique time series is referred to as a "device-deployment" -- a timeseries collected by a particular device at a specific location. Multiple device-deployments are stored in memory as a monitor object -- an R list with two dataframes:

monitor$meta -- rows = unique device-deployments; cols = device/location metadata

monitor$data -- rows = UTC times; cols = device-deployments (plus an additional datetime column)

A key feature of this data model is the use of the deviceDeploymentID as a "foreign key" that allows data columns to be mapped onto the associated spatial and device metadata in a meta row. The following will always be true:

identical(names(monitor$data), c('datetime', monitor$meta$deviceDeploymentID))

Each column of monitor$data represents a timeseries associated with a particular device-deployment while each row represents a synoptic snapshot of all measurements made at a particular time.

In this manner, software can create both timeseries plots and maps from a single monitor object in memory.

Note: The monitor object time axis specified in data$datetime is guaranteed to be a regular hourly axis with no gaps.


This project is supported by the USFS AirFire group.

Copy Link

Version

Install

install.packages('AirMonitor')

Monthly Downloads

818

Version

0.4.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Jonathan Callahan

Last Published

September 27th, 2024

Functions in AirMonitor (0.4.2)

airsis_loadLatest

Load most recent AIRSIS monitoring data
addAQIStackedBar

Create stacked AQI bar
monitor_collapse

Collapse an mts_monitor object into a single time series
monitor_combine

Combine multiple mts_monitor objects
aqiCategories

Generate AQI categories
aqiColors

Generate AQI colors
epa_aqs_loadAnnual

Load annual AirNow monitoring data
airsis_loadAnnual

Load annual AIRSIS monitoring data
monitor_filterDatetime

Datetime filtering for mts_monitor objects
monitor_filterMeta

General purpose metadata filtering for mts_monitor objects
monitor_arrange

Order mts_monitor time series by metadata values
monitor_aqi

Calculate hourly NowCast-based AQI values
coreMetadataNames

Names of standard metadata columns
monitor_dropEmpty

Drop device deployments with all missing data
monitor_isEmpty

Test for an empty mts_monitor object
monitor_fromPWFSLSmoke

Convert a ws_monitor object from the PWFSLSmoke package
monitor_filterDate

Date filtering for mts_monitor objects
monitor_dygraph

Create Interactive Time Series Plot
monitor_getDataFrame

Extract dataframes from mts_monitor objects
monitor_leaflet

Leaflet interactive map of monitor locations
monitor_bestTimezone

Return the most common timezone
monitor_nowcast

Apply NowCast algorithm to mts_monitor data
monitor_filterByDistance

Filter by distance from a target location
monitor_load

Load monitoring data from all sources
monitor_dailyBarplot

Create daily barplot
monitor_getDistance

Calculate distances from mts_monitor locations to a location of interest
monitor_check

Check an mts_monitor object for validity.
monitor_isValid

Test mts_monitor object for correct structure
monitor_loadLatest

Load most recent monitoring data from all sources
monitor_mutate

Apply a function to mts_monitor time series
monitor_dailyStatistic

Create daily statistics for each monitor in an mts_monitor object
monitor_slice_head

Subset time series based on their position within an mts_monitor object
monitor_selectWhere

Data-based subsetting of time series within an mts_monitor object.
monitor_getCurrentStatus

Get current status of monitors
monitor_pull

Extract a column of metadata or data
monitor_replaceValues

Replace mts_monitor data with another value
monitor_select

Subset and reorder time series within an mts_monitor object
monitor_timeInfo

Get time related information for a monitor
monitor_dailyThreshold

Daily counts of values at or above a threshold
monitor_distinct

Retain only distinct data records in monitor$data
monitor_loadAnnual

Load annual monitoring data from all sources
monitor_trimDate

Trim a mts_monitor object to full days
wrcc_loadLatest

Load most recent WRCC monitoring data
monitor_toPWFSLSmoke

Convert a mts_monitor object to a ws_monitor object for the PWFSLSmoke package
wrcc_loadAnnual

Load annual WRCC monitoring data
monitor_toCSV

Convert monitor data as CSV
monitor_toAQCTable

Convert monitor data into an AQI category table
monitor_loadDaily

Load daily monitoring data from all sources
pollutantNames

Names of standard pollutants
monitor_timeRange

Get the time range for a monitor
monitor_timeseriesPlot

Create timeseries plot
%>%

Pipe operator
wrcc_loadDaily

Load daily WRCC monitoring data
monitor_setTimeAxis

Extend/contract mts_monitor time series to new start and end times
US_AQI

US EPA AQI Index levels, names, colors and action text
addAQILines

Add AQI lines to a plot
airsis_loadDaily

Load daily AIRSIS monitoring data
addAQILegend

Add an AQI legend to a map
addShadedNight

Add nighttime shading to a timeseries plot
airnow_loadAnnual

Load annual AirNow monitoring data
Carmel_Valley

Carmel Valley example dataset
NW_Megafires

NW_Megafires example dataset
CONUS

CONUS state codes
Camp_Fire

Camp Fire example dataset
QC_invalidateConsecutiveSuspectValues

Invalidate consecutive suspect values.
US_52

US state codes
airnow_loadDaily

Load daily AirNow monitoring data
AirMonitor-package

AirMonitor: Air Quality Data Analysis
airnow_loadMonthly

Load monthly AirNow monitoring data
AirFire_S3_archiveBaseUrl

USFS maintained archive base URL
airnow_loadLatest

Load most recent AirNow monitoring data