Skip to content

Commit

Permalink
Merge branch 'main' of github.com:MazamaScience/AirSensor2
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Callahan authored and Jonathan Callahan committed Sep 22, 2023
2 parents 4ece4a0 + 4c70d7d commit 2110cf7
Showing 1 changed file with 115 additions and 0 deletions.
115 changes: 115 additions & 0 deletions local_Rmd/PA_QC.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
title: "Test PurpleAir QC Report"
author: "Jonathan Callahan"
date: "2023-09-11"
output: html_document
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(fig.width = 7, fig.height = 5)
```

# Test PurpleAir QC REport

## Champaign Urbana on 2023-09-11

```{r champaign_pas, warning = FALSE, message = FALSE, echo = FALSE}
# AirSensor2 package
library(AirSensor2)
# Set user's PurpleAir_API_READ_KEY
source('/Users/jonathancallahan/Projects/MazamaScience/AirSensor2/global_vars.R')
# Initialize spatial datasets
initializeMazamaSpatialUtils()
# Create a new 'pas' object for Okanogan county
champaign_pas <-
pas_createNew(
api_key = PurpleAir_API_READ_KEY,
countryCodes = "US",
stateCodes = "IL",
counties = c("Champaign"),
lookbackDays = 365, # all sensors from the past year
location_type = 0 # outdoor sensors only
)
pas <-
champaign_pas %>%
pas_filter(sensor_index == "152934")
```

# PurpleAir Sensor \#152934 -- Poplar & Holts

```{r leaflet_map}
pas %>% pas_leaflet()
```

```{r create_pat, echo = FALSE}
# Poplar & Holts sensor occasionally has some very high values
# Create raw pat object
pat <-
pat_createNew(
api_key = PurpleAir_API_READ_KEY,
pas = champaign_pas,
sensor_index = "152934",
startdate = "2023-09-01",
enddate = "2023-09-12",
timezone = "UTC",
verbose = TRUE
)
tbl <- pat$data
```

----

## Sensor Electronics

```{r sensor_electroncs, fig.height = 10, echo = FALSE}
#plot(tbl[,c(1,2:5)], pch = 15, cex = 0.5, main = "Sensor Electronics")
layout(matrix(seq(4)))
plot(tbl[,c(1,3)], pch = 15, cex = 0.5, main = "uptime")
plot(tbl[,c(1,5)], pch = 15, cex = 0.5, main = "memory")
plot(tbl[,c(1,2)], pch = 15, cex = 0.5, main = "wifi strength")
plot(tbl[,c(1,4)], pch = 15, cex = 0.5, main = "latency")
layout(1)
```

## Atmospheric Variables

```{r atmospheric variables, fig.height = 10, echo = FALSE}
#plot(tbl[,c(1,6:8)], pch = 15, cex = 0.5, main = "Atmospheric Variables")
layout(matrix(seq(3)))
plot(tbl[,c(1,6)], pch = 15, cex = 0.5, main = "humidity")
plot(tbl[,c(1,7)], pch = 15, cex = 0.5, main = "temperature")
plot(tbl[,c(1,8)], pch = 15, cex = 0.5, main = "pressure")
layout(1)
```

## PM2.5 "atm"

```{r pm25_atm, echo = FALSE}
#plot(tbl[,c(1,12:14)], pch = 15, cex = 0.5, main = "PM2.5 'atm'")
plot(tbl[,c(1,12)], pch = 15, cex = 0.5, col = "transparent", main = "pm2.5_atm")
points(tbl[,c(1,13)], pch = 15, cex = 0.5, col = adjustcolor("blue", 0.3))
points(tbl[,c(1,14)], pch = 15, cex = 0.5, col = adjustcolor("red", 0.3))
```

## PM2.5 AB Correlation

```{r pm25_correlation, echo = FALSE}
correlation <- cor(tbl$pm2.5_atm_a, tbl$pm2.5_atm_b) %>% round(3)
title <- sprintf("A/B Channel Correlation = %0.3f", correlation)
plot(tbl[,c(13:14)], pch = 15, cex = 0.5, main = title)
```



<!-- # PM2.5 comparison -->
<!-- plot(tbl[,c(1,9,12,15)], pch = 15, cex = 0.5, main = "PM2.5 'alt' vs 'atm' vs 'cf1'") -->




0 comments on commit 2110cf7

Please sign in to comment.