Skip to content

Commit

Permalink
don't die on multiple WRCC TypeCodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathancallahan committed Feb 6, 2017
1 parent 2123a85 commit 8d38c94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion R/wrccDump_parseData.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ wrccDump_parseData <- function(fileString) {
# Sanity check
if ( length(monitorTypeCode) > 1 ) {
logger.warn("More than one monitor type detected: %s", paste(monitorTypeCode,sep=", "))
next
# Pick the most common Type
typeTable <- table(monitorTypeCode)
monitorTypeCode <- names(typeTable)[which(typeTable == max(typeTable))]
}

# 0=E-BAM PM2.5, 1=E-BAM PM10, 9=E-Sampler. We only want PM2.5 measurements
Expand Down
7 changes: 5 additions & 2 deletions R/wrcc_parseData.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ wrcc_parseData <- function(fileString) {
# NOTE: Conversion of -9999 to NA happens in the ~QualityControl scripts so that
# NOTE: all raw data modifications can be found in one place.
monitorTypeCode <- monitorTypeCode[monitorTypeCode >= 0]

# Sanity check
if ( length(monitorTypeCode) > 1 ) {
logger.error("More than one monitor type detected: %s", paste(monitorTypeCode,sep=", "))
stop(paste0("More than one monitor type detected: %s", paste(monitorTypeCode,sep=", ")))
logger.warn("More than one monitor type detected: %s", paste(monitorTypeCode,sep=", "))
# Pick the most common Type
typeTable <- table(monitorTypeCode)
monitorTypeCode <- names(typeTable)[which(typeTable == max(typeTable))]
}

# 0=E-BAM PM2.5, 1=E-BAM PM10, 9=E-Sampler. We only want PM2.5 measurements
Expand Down

0 comments on commit 8d38c94

Please sign in to comment.