Description Usage Arguments Details Value See Also Examples
View source: R/pat_createAirSensor.R
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.
1 2 3 4 5 6 | pat_createAirSensor(
pat = NULL,
parameter = "pm25",
FUN = PurpleAirQC_hourly_AB_01,
...
)
|
pat |
PurpleAir Timeseries pat object. |
parameter |
Parameter for which to create an univariate airsensor object. See details. |
FUN |
Algorithm applied to pat object for hourly aggregation and quality control. See details. |
... |
(optional) Additional parameters passed into |
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 ...
.
An "airsensor" object of aggregated PurpleAir Timeseries data.
PurpleAirQC_hourly_AB_01
pat_aggregate
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.