Skip to content

Commit

Permalink
bug fix for AIRSIS/WRCC moved monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathancallahan committed Aug 15, 2017
1 parent db8b37d commit 280a992
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 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: 0.99.22
Version: 0.99.23
Title: Utilities for Working with Air Quality Monitoring Data
Authors@R: c(
person("Jonathan", "Callahan", email="[email protected]", role=c("aut","cre")),
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ from the US EPA, AirNow, AIRSIS, WRCC and others.

## Version 0.99 -- Regularized and Consistent (beta)

### PWFSLSmoke 0.99.21
### PWFSLSmoke 0.99.23

* bug fix for monitor assignment issues in WRCC and AIRSIS monitors that move

### PWFSLSmoke 0.99.22

* correction to monitor_nowcast() algorithm
* updated vignettes to use package datasets
Expand Down
5 changes: 3 additions & 2 deletions R/airsis_createDataDataframe.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ airsis_createDataDataframe <- function(df, meta) {
maxCount <- max(valueCountPerCell[,-1])
if (maxCount > 1) logger.warn("Up to %s measurements per hour -- median used",maxCount)

# NOTE: The resulting dataframe is [datetime,monitorID] with an extra first column containing datetime
# NOTE: The resulting dataframe is [datetime,monitorIDs] with monitorIDs in alphabetical order
pm25DF <- reshape2::dcast(melted, datetime ~ monitorID, stats::median)
colnames(pm25DF) <- c('datetime',meta$monitorID)
# Reorder data columns to match the order of monitorIDs in 'meta'
pm25DF <- pm25DF[,c('datetime',meta$monitorID)]

# Create an empty hourlyDF dataframe with a full time axis (no missing hours)
datetime <- seq(min(df$datetime), max(df$datetime), by="hours")
Expand Down
10 changes: 5 additions & 5 deletions R/wrcc_createDataDataframe.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ wrcc_createDataDataframe <- function(df, meta) {
if ( monitorType == 'ESAM' ) melted$value <- melted$value * 1 # no conversion needed

# Use median if multiple values are found

# Sanity check -- only one pm25DF measure per hour
valueCountPerCell <- reshape2::dcast(melted, datetime ~ monitorID, length)
maxCount <- max(valueCountPerCell[,-1])
if (maxCount > 1) logger.warn("Up to %s measurements per hour -- median used",maxCount)

# NOTE: The resulting dataframe is [datetime,monitorID] with an extra first column containing datetime
# NOTE: The resulting dataframe is [datetime,monitorIDs] with monitorIDs in alphabetical order
pm25DF <- reshape2::dcast(melted, datetime ~ monitorID, stats::median)
colnames(pm25DF) <- c('datetime',meta$monitorID)
rownames(pm25DF) <- format(pm25DF$datetime,"%Y%m%d%H",tz="GMT")
# Reorder data columns to match the order of monitorIDs in 'meta'
pm25DF <- pm25DF[,c('datetime',meta$monitorID)]

# Create an empty hourlyDF dataframe with a full time axis (no missing hours)
datetime <- seq(min(df$datetime), max(df$datetime), by="hours")
hourlyDF <- data.frame(datetime=datetime)
Expand Down
4 changes: 4 additions & 0 deletions man/monitor_nowcast.Rd

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

0 comments on commit 280a992

Please sign in to comment.