Skip to content

Commit

Permalink
fix: updated EBAM valid_RHi from 45 -> 50
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathancallahan committed Jul 7, 2021
1 parent bbb2f84 commit 397df1c
Show file tree
Hide file tree
Showing 200 changed files with 260 additions and 260 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Type: Package
Package: PWFSLSmoke
Version: 1.2.113
Version: 1.2.114
Title: Utilities for Working with Air Quality Monitoring Data
Authors@R: c(
person("Jonathan", "Callahan", email="[email protected]", role=c("aut","cre")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# PWFSLSmoke 1.2.114

* Updated AIRSIS EBAM QC RHi threshold from 45% to 50%.

# PWFSLSmoke 1.2.113

* Updated `docker/` files to use R 3.6.3.
Expand Down
24 changes: 12 additions & 12 deletions R/airsis_BAM1020QualityControl.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ airsis_BAM1020QualityControl <- function(
badRowCount <- sum(badRows)
if ( badRowCount > 0 ) {
logger.trace(paste(verb,"%s rows with invalid location information"), badRowCount)
badLocations <- paste('(',tbl$Longitude[badRows],',',tbl$Latitude[badRows],')',sep='')
badLocations <- paste('(',tbl$Longitude[badRows],',',tbl$Latitude[badRows],')',sep = '')
logger.trace("Bad locations: %s", unique(badLocations))
if ( flagAndKeep ) {
# apply flags
Expand All @@ -112,18 +112,18 @@ airsis_BAM1020QualityControl <- function(
if (nrow(tbl) < 1 && !flagAndKeep) {
err_msg <- paste0("No valid PM2.5 data for ", monitorName)
logger.warn(err_msg) # This is more of a warning than some error in the data.
stop(err_msg, call.=FALSE)
stop(err_msg, call. = FALSE)
}

# ----- Time ----------------------------------------------------------------

# Add a POSIXct datetime
tbl$datetime <- lubridate::floor_date(lubridate::mdy_hms(tbl$TimeStamp), unit="hour") - lubridate::dhours(1)
tbl$datetime <- lubridate::floor_date(lubridate::mdy_hms(tbl$TimeStamp), unit = "hour") - lubridate::dhours(1)
if ( flagAndKeep ) {
# TODO: Unable to get datetime moved from tbl to tblFlagged without timezone and/or display getting messed up.
# For now just duplicating the calculation, then assigning row values to NA after the fact for rows that were
# removed from tbl prior to calculating datetime above. Clean up later if possible.
tblFlagged$datetime <- lubridate::floor_date(lubridate::mdy_hms(tblFlagged$TimeStamp), unit="hour") - lubridate::dhours(1)
tblFlagged$datetime <- lubridate::floor_date(lubridate::mdy_hms(tblFlagged$TimeStamp), unit = "hour") - lubridate::dhours(1)
tblFlagged$datetime[ which(!(tblFlagged$rowID %in% tbl$rowID)) ] <- NA
}

Expand Down Expand Up @@ -165,15 +165,15 @@ airsis_BAM1020QualityControl <- function(
gooddatetime <- !is.na(tbl$datetime) & tbl$datetime < lubridate::now(tzone = "UTC") # saw a future date once

logger.trace("Flow has %s missing or out of range values", sum(!goodFlow))
if (sum(!goodFlow) > 0) logger.trace("Bad Flow values: %s", paste0(sort(unique(tbl$Qtot..m3.[!goodFlow]),na.last=TRUE), collapse=", "))
if (sum(!goodFlow) > 0) logger.trace("Bad Flow values: %s", paste0(sort(unique(tbl$Qtot..m3.[!goodFlow]),na.last = TRUE), collapse = ", "))
logger.trace("AT has %s missing or out of range values", sum(!goodAT))
if (sum(!goodAT) > 0) logger.trace("Bad AT values: %s", paste0(sort(unique(tbl$Ambient.Temp..C.[!goodAT]),na.last=TRUE), collapse=", "))
if (sum(!goodAT) > 0) logger.trace("Bad AT values: %s", paste0(sort(unique(tbl$Ambient.Temp..C.[!goodAT]),na.last = TRUE), collapse = ", "))
logger.trace("RHi has %s missing or out of range values", sum(!goodRHi))
if (sum(!goodRHi) > 0) logger.trace("Bad RHi values: %s", paste0(sort(unique(tbl$RH....[!goodRHi]),na.last=TRUE), collapse=", "))
if (sum(!goodRHi) > 0) logger.trace("Bad RHi values: %s", paste0(sort(unique(tbl$RH....[!goodRHi]),na.last = TRUE), collapse = ", "))
logger.trace("Conc has %s missing or out of range values", sum(!goodConcHr))
if (sum(!goodConcHr) > 0) logger.trace("Bad Conc values: %s", paste0(sort(unique(tbl$'Conc..\u00B5g.m3.'[!goodConcHr]),na.last=TRUE), collapse=", "))
if (sum(!goodConcHr) > 0) logger.trace("Bad Conc values: %s", paste0(sort(unique(tbl$'Conc..\u00B5g.m3.'[!goodConcHr]),na.last = TRUE), collapse = ", "))
logger.trace("datetime has %s missing or out of range values", sum(!gooddatetime))
if (sum(!gooddatetime) > 0) logger.trace("Bad datetime values: %s", paste0(sort(unique(tbl$datetime[!gooddatetime]),na.last=TRUE), collapse=", "))
if (sum(!gooddatetime) > 0) logger.trace("Bad datetime values: %s", paste0(sort(unique(tbl$datetime[!gooddatetime]),na.last = TRUE), collapse = ", "))

goodMask <- goodFlow & goodAT & goodRHi & goodConcHr & gooddatetime
badQCCount <- sum(!goodMask)
Expand Down Expand Up @@ -204,7 +204,7 @@ airsis_BAM1020QualityControl <- function(
if (nrow(tbl) < 1 && !flagAndKeep) {
err_msg <- paste0("No valid PM2.5 data for ", monitorName)
logger.warn(err_msg) # This is more of a warning than some error in the data.
stop(err_msg, call.=FALSE)
stop(err_msg, call. = FALSE)
}

# ----- Duplicate Hours -----------------------------------------------------
Expand All @@ -220,7 +220,7 @@ airsis_BAM1020QualityControl <- function(

if ( dupHrCount > 0 ) {
logger.trace(paste(verb,"%s duplicate time entries"), dupHrCount)
logger.trace("Duplicate Hours (may be >1 per timestamp): %s", paste0(sort(unique(tbl$TimeStamp[dupHrMask])), collapse=", "))
logger.trace("Duplicate Hours (may be >1 per timestamp): %s", paste0(sort(unique(tbl$TimeStamp[dupHrMask])), collapse = ", "))
if ( flagAndKeep ) {
# apply flags
tblFlagged$QCFlag_duplicateHr[tbl$rowID[dupHrMask]] <- TRUE
Expand All @@ -236,7 +236,7 @@ airsis_BAM1020QualityControl <- function(
if (nrow(tbl) < 1 && !flagAndKeep) {
err_msg <- paste0("No valid PM2.5 data for ", monitorName)
logger.warn(err_msg) # This is more of a warning than some error in the data.
stop(err_msg, call.=FALSE)
stop(err_msg, call. = FALSE)
}

# ----- More QC -------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion R/airsis_EBAMQualityControl.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ airsis_EBAMQualityControl <- function(
remove_Lat_zero = TRUE,
valid_Flow = c(16.7*0.95,16.7*1.05),
valid_AT = c(-Inf,45),
valid_RHi = c(-Inf,45),
valid_RHi = c(-Inf,50),
valid_Conc = c(-Inf,5.000),
flagAndKeep = FALSE
) {
Expand Down Expand Up @@ -176,6 +176,7 @@ airsis_EBAMQualityControl <- function(
# Leland Tarnay QC -----------------------------------------------------------

# NOTE: Override ConcHr high value with 5.000 as per conversation with Mike Broughton
# NOTE: 2021-07-07 Update RHi from 45 -> 50 as per conversation with Pete Lahm

###tmp.2014_YOSE_ebam1_ftp$concQA <- with(tmp.2014_YOSE_ebam1_ftp,
### ifelse(Flow < 16.7 * .95, "FlowLow",
Expand Down
3 changes: 2 additions & 1 deletion R/airsis_EBAM_MULTI2QualityControl.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ airsis_EBAM_MULTI2QualityControl <- function(
remove_Lat_zero = TRUE,
valid_Flow = c(16.7*0.95,16.7*1.05),
valid_AT = c(-Inf,45),
valid_RHi = c(-Inf,45),
valid_RHi = c(-Inf,50),
valid_Conc = c(-Inf,5.000),
flagAndKeep = FALSE
) {
Expand Down Expand Up @@ -178,6 +178,7 @@ airsis_EBAM_MULTI2QualityControl <- function(
# Leland Tarnay QC -----------------------------------------------------------

# NOTE: Override ConcHr high value with 5.000 as per conversation with Mike Broughton
# NOTE: 2021-07-07 Update RHi from 45 -> 50 as per conversation with Pete Lahm

###tmp.2014_YOSE_ebam1_ftp$concQA <- with(tmp.2014_YOSE_ebam1_ftp,
### ifelse(Flow < 16.7 * .95, "FlowLow",
Expand Down
19 changes: 2 additions & 17 deletions R/airsis_EBAM_PLUS_MULTIQualityControl.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ airsis_EBAM_PLUS_MULTIQualityControl <- function(
remove_Lat_zero = TRUE,
valid_Flow = c(16.7*0.95,16.7*1.05),
valid_AT = c(-Inf,45),
valid_RHi = c(-Inf,45),
valid_RHi = c(-Inf,50),
valid_Conc = c(-Inf,5.000),
flagAndKeep = FALSE
) {
Expand Down Expand Up @@ -180,6 +180,7 @@ airsis_EBAM_PLUS_MULTIQualityControl <- function(
# Leland Tarnay QC -----------------------------------------------------------

# NOTE: Override ConcHr high value with 5.000 as per conversation with Mike Broughton
# NOTE: 2021-07-07 Update RHi from 45 -> 50 as per conversation with Pete Lahm

###tmp.2014_YOSE_ebam1_ftp$concQA <- with(tmp.2014_YOSE_ebam1_ftp,
### ifelse(Flow < 16.7 * .95, "FlowLow",
Expand Down Expand Up @@ -297,19 +298,3 @@ airsis_EBAM_PLUS_MULTIQualityControl <- function(

}

# ===== DEBUGGING ==============================================================

if ( FALSE ) {

# tbl <- ...
valid_Longitude = c(-180,180)
valid_Latitude = c(-90,90)
remove_Lon_zero = TRUE
remove_Lat_zero = TRUE
valid_Flow = c(16.7*0.95,16.7*1.05)
valid_AT = c(-Inf,45)
valid_RHi = c(-Inf,45)
valid_Conc = c(-Inf,5.000)
flagAndKeep = FALSE

}
2 changes: 1 addition & 1 deletion R/airsis_createMonitorObject.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#' \item{\code{remove_Lat_zero = TRUE}}
#' \item{\code{valid_Flow = c(16.7*0.95,16.7*1.05)}}
#' \item{\code{valid_AT = c(-Inf,45)}}
#' \item{\code{valid_RHi = c(-Inf,45)}}
#' \item{\code{valid_RHi = c(-Inf,50)}}
#' \item{\code{valid_Conc = c(-Inf,5.000)}}
#' }
#'
Expand Down
2 changes: 1 addition & 1 deletion R/airsis_qualityControl.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' \item{\code{remove_Lat_zero = TRUE}}
#' \item{\code{valid_Flow = c(16.7*0.95,16.7*1.05)}}
#' \item{\code{valid_AT = c(-Inf,45)}}
#' \item{\code{valid_RHi = c(-Inf,45)}}
#' \item{\code{valid_RHi = c(-Inf,50)}}
#' \item{\code{valid_Conc = c(-Inf,5.000)}}
#' }
#'
Expand Down
3 changes: 2 additions & 1 deletion R/wrcc_EBAMQualityControl.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ wrcc_EBAMQualityControl <- function(
remove_Lat_zero = TRUE,
valid_Flow = c(16.7*0.95,16.7*1.05),
valid_AT = c(-Inf,45),
valid_RHi = c(-Inf,45),
valid_RHi = c(-Inf,50),
valid_Conc = c(-Inf,5000),
flagAndKeep = FALSE
) {
Expand Down Expand Up @@ -170,6 +170,7 @@ wrcc_EBAMQualityControl <- function(
# Leland Tarnay QC for E-BAM ------------------------------------------------

# NOTE: Override ConcHr high value with 5000 as per conversation with Mike Broughton
# NOTE: 2021-07-07 Update RHi from 45 -> 50 as per conversation with Pete Lahm

###tmp.2014_YOSE_ebam1_ftp$concQA <- with(tmp.2014_YOSE_ebam1_ftp,
### ifelse(Flow < 16.7 * .95, "FlowLow",
Expand Down
2 changes: 1 addition & 1 deletion R/wrcc_createMonitorObject.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#' \item{\code{remove_Lat_zero = TRUE}}
#' \item{\code{valid_Flow = c(16.7*0.95,16.7*1.05)}}
#' \item{\code{valid_AT = c(-Inf,45)}}
#' \item{\code{valid_RHi = c(-Inf,45)}}
#' \item{\code{valid_RHi = c(-Inf,50)}}
#' \item{\code{valid_Conc = c(-Inf,5000)}}
#' }
#'
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/Data_Model.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/Maps_and_Timeseries_Plots.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/NowCast.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions docs/articles/PWFSLSmoke.html

Large diffs are not rendered by default.

Loading

0 comments on commit 397df1c

Please sign in to comment.