Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


AirSensor R Package

Process and display PM2.5 data from PurpleAir

Background

The AirSensor R package is being developed to help air quality analysts, scientists and interested members of the public more easily work with air quality data from consumer-grade air quality sensors. Initial focus is on PM2.5 measurements from sensors produced by PurpleAir.

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

  • download and easily work with PM2.5 data from PurpleAir
  • visualize raw "engineering-level" data from a PurpleAir sensor
  • visualize data quality using built-in analytics and plots
  • aggregate raw data onto an hourly axis
  • create interactive maps and time series plots
  • convert aggregated PurpleAir data into ws_monitor objects appropriate for

use with the PWFSLSmoke package

Institutional Support

The initial development of this package was funded by the South Coast Air Quality Management District with funds from an EPA STAR grant. The following disclaimer applies:

This package was prepared as part of a project funded through a Science to Achieve Results (STAR) grant award (RD83618401) from the U.S. Environmental Protection Agency to the South Coast Air Quality Management District (South Coast AQMD). The opinions, findings, conclusions, and recommendations are those of the author and do not necessarily represent the views of the U.S. EPA or the South Coast AQMD, nor does mention of trade names or commercial products constitute endorsement or recommendation for use. The U.S. EPA, the South Coast AQMD, their officers, employees, contractors, and subcontractors make no warranty, expressed or implied, and assume no legal liability for the information in this package. The U.S. EPA and South Coast AQMD have not approved or disapproved this package, and neither have passed upon the accuracy or adequacy of the information contained herein.

Additional funding was provided by the US Forest Service in support of the Interagency Wildland Fire Air Quality Response Program.

Mazama Science develops and maintains the package as part of its ongoing relationships with federal, state and local air quality agencies.

Installation

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

The package is available on CRAN or you get the latest development version from GitHub. To install the latest development version, users will want to install the devtools package and then type the following at the RStudio console:

# Note that vignettes require knitr and rmarkdown
install.packages('knitr')
install.packages('rmarkdown')
devtools::install_github("MazamaScience/AirSensor")

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("NaturalEarthAdm1")
installSpatialData("USCensusStates"")
installSpatialData("CA_AirBasins_01")

Copy Link

Version

Install

install.packages('AirSensor')

Monthly Downloads

45

Version

1.0.8

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Jonathan Callahan

Last Published

March 12th, 2021

Functions in AirSensor (1.0.8)

AirSensor

Data access and analysis functions for PurpleAir sensor data
PurpleAirQC_hourly_AB_00

Apply hourly aggregation QC using "AB_OO" algorithm
PurpleAirSoH_dailyMetFit

Daily fit values
PurpleAirSoH_dailyABFit

Daily linear model fit values
example_pas

Example Purple Air Synoptic dataset
example_pat

Example PurpleAir Timeseries dataset
PurpleAirSoH_dailyPctDC

Daily DC Signal percentage
PurpleAirSoH_dailyPctValid

Daily valid percentage
PurpleAirQC_hourly_AB_03

Apply hourly aggregation QC using "AB_O4" algorithm
pas_addCommunityRegion

Add an air district to PurpleAir Synoptic Data
example_pas_raw

Example raw Purple Air Synoptic dataset
PurpleAirQC_hourly_AB_01

Apply hourly aggregation QC using "AB_O1" algorithm
ArchiveBaseUrl

Base URL for pre-generated data
PurpleAirQC_hourly_AB_02

Apply hourly aggregation QC using "AB_O2" algorithm
ArchiveBaseDir

Base directory for pre-generated data
getArchiveBaseUrl

Get data archive base URL
PurpleAirSoH_dailyABtTest

Daily t-test
example_pat_failure_A

Example PurpleAir Timeseries dataset exhibiting moderate errors
PurpleAirSoH_dailyToIndex_00

Daily state of health index
initializeMazamaSpatialUtils

Initialize MazamaSpatialUtils package
.plotOutliers

Plot flagged outliers
.flagOutliers

Flag outliers in vectorized data
example_sensor_scaqmd

Example AirSensor Timeseries dataset
pas_upgrade

Upgrade pa_synoptic object format
pas_downloadParseRawData

Download synoptic data from PurpleAir
pas_getLabels

Return labels from filtered PurpleAir Synoptic objects
multi_ggplot

Display multiple plots on one page
.replaceOutliers

Replace outliers with rolling median
pas_filter

General purpose filtering for PurpleAir Synoptic objects
.sample

General table row sampling
pas_enhanceData

Enhance synoptic data from PurpleAir
pas_hasSpatial

Test for spatial metadata in pa_synoptic object
pas_addAirDistrict

Add an air district to PurpleAir Synoptic Data
getArchiveBaseDir

Get data archive base directory
pas_filterArea

Rectangle area filtering for PurpleAir Synoptic objects
pas_filterNear

Find PurpleAir sensors within radial distance
pat_aggregate

Aggregate PurpleAir Timeseries Object
patData_aggregate

Aggregate PurpleAir Timeseries Data
pat_internalFit

Linear model fitting of channel A and B time series data
pat_filterDatetime

Datetime filtering for PurpleAir Timeseries objects
pas_getColumn

Return column of data from filtered PurpleAir Synoptic objects
pas_staticMap

Static map of PurpleAir sensors
pwfsl_load

Get PWFSLSmoke monitoring data
pat_filterDate

Date filtering for PurpleAir Timeseries objects
pas_palette

Color palettes for PurpleAir
pat_filter

General purpose data filtering for PurpleAir Timeseries objects
pas_addSpatialMetadata

Add Spatial Metadata to PurpleAIr Synoptic Data
%>%

Pipe operator
pas_leaflet

Leaflet interactive map of PurpleAir sensors
sensor_filterDatetime

Datetime filtering for AirSensor objects
sensor_filterMeta

Metadata filtering for AirSensor objects
pas_load

Load PurpleAir synoptic data
pat_load

Load PurpleAir time series data for a time period
PurpleAirSoH_dailyPctReporting

Daily reporting percentage
pat_join

Join PurpleAir time series data for a single sensor
pat_sample

Sample PurpleAir time series data
example_pat_failure_B

Example PurpleAir Timeseries dataset exhibiting severe errors
pat_distinct

Retain only distinct data records in pat$data
pat_dailySoHPlot

Daily State of Health metric plot
pat_createAirSensor

Create an Air Sensor object
pas_getDeviceDeploymentIDs

Return timeseries identifiers from filtered PurpleAir Synoptic objects
pat_createPATimeseriesObject

Combine PurpleAir raw dataframes
pat_createNew

Load latest PurpleAir time series data
pat_monitorComparison

Comparison of Purple Air and federal monitoring data
pas_getIDs

Return IDs from filtered PurpleAir Synoptic objects
pat_dailySoH

Daily state of health
example_sensor

Example AirSensor Timeseries dataset
pat_isEmpty

Test for an empty pat object
pat_downloadParseRawData

Download PurpleAir timeseries data
pat_aggregateOutlierCounts

Aggregate data with count of outliers in each bin
pat_dygraph

Interactive time series plot
pwfsl_loadLatest

Get PWFSLSmoke monitoring data
sensor_filter

Data filtering for AirSensor objects
pat_isPat

Test for correct structure in a pat object
pas_addUniqueIDs

Add Unique Identifiers to PurpleAir Synoptic Data
removeArchiveBaseDir

Remove data archive base directory
pat_outliers

Detect and replace time series outliers
removeArchiveBaseUrl

Remove data archive base URL
sensor_isEmpty

Test for an empty sensor object
pat_qc

Apply quality control on PurpleAir Timeseries object
scatterPlot

Matrix scatter plot variables in a data frame
pat_scatterPlotMatrix

Draw a matrix of PurpleAir Timeseries data scatter plots
sensor_join

Join airsensor objects from different time periods
sensor_load

Load hourly-aggregated PurpleAir data
pas_createNew

Load latest PurpleAir synoptic data
pat_multiPlot

Display multiple plots on one page
pat_trimDate

Trim a PurpleAir Timeseries object to full days
sensor_filterDate

Date filtering for AirSensor objects
pat_upgrade

Upgrade PurpleAir Timeseries
sensor_pollutionRose

Pollution rose plot
setArchiveBaseDir

Set data archive base directory
timeseriesTbl_multiPlot

Faceted plot of a timeseries tibble
sensor_extractDataFrame

Extract dataframes from airsensor objects
sensor_calendarPlot

Plot time series values in conventional calendar format
pas_isEmpty

Test for an empty pa_synoptic object
sensor_isSensor

Test for correct structure in a sensor object
spatialIsInitialized

Check if MazamaSpatialUtils has been initialized
setArchiveBaseUrl

Set data archive base URL
sensor_loadYear

Load hourly-aggregated PurpleAir data for a month
pas_isPas

Test for correct structure in a pa_synoptic object
sensor_polarPlot

Plot bivariate polar plots with guassian smoothing
pat_dailySoHIndexPlot

Daily State of Health metric plot
pat_dailySoHIndex_00

State of Health index plot
pat_loadMonth

Load PurpleAir time series data for a month
pat_extractDataFrame

Extract dataframes from pat objects
pat_externalFit

Linear model fitting of PurpleAir and federal PWFSL time series data
pat_loadLatest

Load PurpleAir time series data for a week
sensor_loadLatest

Load hourly-aggregated PurpleAir data for a week
sensor_loadMonth

Load hourly-aggregated PurpleAir data for a month