Create a pat object for a specific sensor_index.
By default, the only variables included in an "hourly pat" are:
datetime, humidity, temperature, pm2.5_atm, pm2.5_atm_a, pm2.5_atm_b.
These are sufficient for simple QC using pm2.5_atm_a, pm2.5_atm_b and
simple correction using linear fit models based on
pm2.5_atm, temperature, humidity.
pat_createHourly(
api_key = NULL,
pas = NULL,
sensor_index = NULL,
startdate = NULL,
enddate = NULL,
timezone = "UTC",
fields = PurpleAir_HISTORY_HOURLY_PM25_FIELDS,
baseUrl = "https://api.purpleair.com/v1/sensors",
verbose = FALSE
)PurpleAir API Read Key. If api_key = NULL, it
will be obtained using getAPIKey("PurpleAir-read").
See MazamaCoreUtils::setAPIKey.
Previously generated pas object containing sensor_index.
PurpleAir sensor unique identifier.
Desired start time (ISO 8601) or POSIXct.
Desired end time (ISO 8601) or POSIXct.
Olson timezone used to interpret dates.
Character string with PurpleAir field names for the Get Sensor Data API.
Base URL for the PurpleAir API.
Logical controlling the generation of warning and error messages.
A PurpleAir Timeseries pat object.
# \donttest{
# Fail gracefully if any resources are not available
try({
library(AirSensor2)
pat <-
pat_createHourly(
api_key = PurpleAir_API_READ_KEY,
pas = MY_PAS,
sensor_index = "76545",
startdate = "2023-01-01",
enddate = "2023-01-08",
timezone = "UTC",
verbose = TRUE
)
View(pat$meta[1:100,])
}, silent = FALSE)
#> Error in pat_createHourly(api_key = PurpleAir_API_READ_KEY, pas = MY_PAS, :
#> object 'PurpleAir_API_READ_KEY' not found
# }