Converts data from a pat object with an irregular time axis to an airsensor object where the numeric data has been aggregated along a standardized hourly time axis, as well as adding additional required metadata for compatibility with the *PWFSLSmoke* package.

  pat = NULL,
  parameter = "pm25",
  FUN = PurpleAirQC_hourly_AB_01,



PurpleAir Timeseries pat object.


Parameter for which to create an univariate airsensor object. See details.


Algorithm applied to pat object for hourly aggregation and quality control. See details.


(optional) Additional parameters passed into FUN.


An "airsensor" object of aggregated PurpleAir Timeseries data.


FUN allows users to provide custom aggregation and quality-control functions that are used to create an airsensor object. The FUN must accept a pat object as the first argument and return a dataframe with a regular hourly datetime axis. FUN can access and utilize any component of a standard pat object (e.g pm25_A, temperature, etc.) as well as define new variables in the pat data. See examples.

parameter allows user to select which variable to use for the univariate airsensor object (e.g 'pm25_A', 'humidity', etc.). Furthermore the parameter can be a new variable created via FUN evaluation. See examples.

Additional named parameters can be be passed to FUN through ....

See also


# \donttest{ library(AirSensor) # Default FUN = PurpleAirQC_hourly_AB_00 sensor <- pat_createAirSensor(example_pat) PWFSLSmoke::monitor_timeseriesPlot(sensor, shadedNight = TRUE)
# Try out other package QC functions example_pat %>% pat_createAirSensor(FUN = PurpleAirQC_hourly_AB_01) %>% PWFSLSmoke::monitor_timeseriesPlot(shadedNight = TRUE)
example_pat %>% pat_createAirSensor(FUN = PurpleAirQC_hourly_AB_01) %>% PWFSLSmoke::monitor_timeseriesPlot(shadedNight = TRUE) # Custom FUN humidity_correction <- function(pat, z = 0) { # Default hourly aggregation hourlyData <- pat %>% pat_aggregate() %>% pat_extractData() # Create custom_pm variable pm25 <- (hourlyData$pm25_A + hourlyData$pm25_B) / 2 hum <- hourlyData$humidity temp <- hourlyData$temperature hourlyData$custom_pm <- pm25 - (pm25 * hum * z) return(hourlyData) } # Evaluate custom FUN sensor <- pat_createAirSensor( example_pat, parameter = "custom_pm", FUN = humidity_correction, z = .005 ) PWFSLSmoke::monitor_timeseriesPlot(sensor, shadedNight = TRUE)
# }