Downloads timeseries data for a specific PurpleAir sensor from the ThingSpeak API and parses the content into individual dataframes. This function will always return dataframes with the appropriate columns even if no data are returned from ThingSpeak.

The returned list contains the following dataframes:

  • meta -- pas records for the specified sensor

  • A_PRIMARY -- channel A primary dataset

  • A_SECONDARY -- channel A secondary dataset

  • B_PRIMARY -- channel B primary dataset

  • B_SECONDARY -- channel B secondary dataset

These dataframes contain ALL data available from ThingSpeak for the specified sensor and time period.

See the references.

pat_downloadParseRawData(
  id = NULL,
  label = NULL,
  pas = NULL,
  startdate = NULL,
  enddate = NULL,
  timezone = NULL,
  baseUrl = "https://api.thingspeak.com/channels/"
)

Arguments

id

PurpleAir sensor 'deviceDeploymentID'.

label

PurpleAir sensor 'label'.

pas

PurpleAir Synoptic pas object.

startdate

Desired start time (ISO 8601).

enddate

Desired end time (ISO 8601).

timezone

Timezone used to interpret start and end dates.

baseUrl

Base URL for Thingspeak API.

Value

List containing multiple timeseries dataframes.

References

https://www2.purpleair.com/community/faq#!hc-sd-card-csv-file-header

Examples

# \donttest{ library(AirSensor) setArchiveBaseUrl("http://data.mazamascience.com/PurpleAir/v1") pas <- pas_load() pat_rawList <- pat_downloadParseRawData( id = "78df3c292c8448f7_21257", pas = pas ) lapply(pat_rawList, head)
#> $meta #> # A tibble: 2 x 44 #> ID label DEVICE_LOCATION… THINGSPEAK_PRIM… THINGSPEAK_PRIM… #> <chr> <chr> <chr> <chr> <chr> #> 1 21257 Linc… outside 648716 6D84VW7006XE07J9 #> 2 21258 Linc… NA 648718 NQWFIW5HLDO0FBFG #> # … with 39 more variables: THINGSPEAK_SECONDARY_ID <chr>, #> # THINGSPEAK_SECONDARY_ID_READ_KEY <chr>, latitude <dbl>, longitude <dbl>, #> # pm25 <dbl>, lastSeenDate <dttm>, sensorType <chr>, flag_hidden <lgl>, #> # isOwner <int>, humidity <dbl>, temperature <dbl>, pressure <dbl>, #> # age <int>, parentID <chr>, flag_highValue <lgl>, #> # flag_attenuation_hardware <lgl>, Ozone1 <chr>, pm25_current <dbl>, #> # pm25_10min <dbl>, pm25_30min <dbl>, pm25_1hr <dbl>, pm25_6hr <dbl>, #> # pm25_1day <dbl>, pm25_1week <dbl>, statsLastModifiedDate <dttm>, #> # statsLastModifiedInterval <dbl>, countryCode <chr>, stateCode <chr>, #> # timezone <chr>, deviceID <chr>, locationID <chr>, deviceDeploymentID <chr>, #> # airDistrict <chr>, pwfsl_closestDistance <dbl>, #> # pwfsl_closestMonitorID <chr>, sensorManufacturer <chr>, #> # targetPollutant <chr>, technologyType <chr>, communityRegion <chr> #> #> $A_PRIMARY #> # A tibble: 6 x 10 #> created_at entry_id pm1.0_cf1 pm2.5_cf1 pm10.0_cf1 uptime rssi #> <dttm> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 2020-10-06 07:00:42 226489 10.1 16.8 18 18166 -92 #> 2 2020-10-06 07:02:44 226490 10.0 17.4 18.8 18168 -93 #> 3 2020-10-06 07:04:49 226491 9.64 17.3 18.7 18170 -93 #> 4 2020-10-06 07:06:42 226492 10.4 16.7 18.8 18172 -93 #> 5 2020-10-06 07:08:42 226493 10.1 18.9 21.3 18174 -93 #> 6 2020-10-06 07:10:42 226494 10.3 17.2 19.1 18176 -93 #> # … with 3 more variables: temperature <dbl>, humidity <dbl>, pm2.5_atm <dbl> #> #> $A_SECONDARY #> # A tibble: 6 x 10 #> created_at entry_id counts_0.3 counts_0.5 counts_1.0 counts_2.5 #> <dttm> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 2020-10-06 07:00:43 226501 1790. 523. 109. 8.48 #> 2 2020-10-06 07:02:45 226502 1859. 534. 115. 11.7 #> 3 2020-10-06 07:04:50 226503 1841. 521. 117. 9.47 #> 4 2020-10-06 07:06:43 226504 1864. 531. 111. 10.1 #> 5 2020-10-06 07:08:44 226505 1927. 549. 131. 11.0 #> 6 2020-10-06 07:10:43 226506 1917. 542. 115. 7.79 #> # … with 4 more variables: counts_5.0 <dbl>, counts_10.0 <dbl>, #> # pm1.0_atm <dbl>, pm10.0_atm <dbl> #> #> $B_PRIMARY #> # A tibble: 6 x 10 #> created_at entry_id pm1.0_cf1 pm2.5_cf1 pm10.0_cf1 memory adc0 #> <dttm> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 2020-10-06 07:00:45 226527 10.2 17.7 18.6 18256 0 #> 2 2020-10-06 07:02:47 226528 13.4 21.7 22.6 18424 0 #> 3 2020-10-06 07:04:52 226529 12.2 20.0 21.7 18592 0 #> 4 2020-10-06 07:06:45 226530 12.2 20.2 21.2 18088 0 #> 5 2020-10-06 07:08:45 226531 12.6 20.2 21.2 18088 0 #> 6 2020-10-06 07:10:45 226532 12.7 20.9 21.8 17920 0 #> # … with 3 more variables: pressure <dbl>, bsec_iaq <dbl>, pm2.5_atm <dbl> #> #> $B_SECONDARY #> # A tibble: 6 x 10 #> created_at entry_id counts_0.3 counts_0.5 counts_1.0 counts_2.5 #> <dttm> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 2020-10-06 07:00:46 226501 1887. 560. 113. 8.02 #> 2 2020-10-06 07:02:48 226502 3018. 753. 113. 11.0 #> 3 2020-10-06 07:04:53 226503 2698. 690. 112. 11.3 #> 4 2020-10-06 07:06:46 226504 2761. 701. 119. 8.21 #> 5 2020-10-06 07:08:47 226505 2709. 710. 114. 6.91 #> 6 2020-10-06 07:10:46 226506 2556. 700. 118. 11.9 #> # … with 4 more variables: counts_5.0 <dbl>, counts_10.0 <dbl>, #> # pm1.0_atm <dbl>, pm10.0_atm <dbl> #>
# }