Skip to content

Commit

Permalink
More o.o.s.
Browse files Browse the repository at this point in the history
  • Loading branch information
bpbond committed Dec 20, 2023
1 parent bc8d424 commit b212e8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 10 additions & 1 deletion synoptic/L1_normalize.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ files_to_process <- list.files(L0, pattern = "*.csv$", full.names = TRUE)
L1_NORMALIZE <- file.path(params$DATA_ROOT, params$L1_NORMALIZE)
source("helpers.R")
source("out-of-service.R")
# Read the Aquatroll out-of-service table
troll <- read_csv(file.path(params$DATA_ROOT, params$OOS,
Expand Down Expand Up @@ -203,9 +204,17 @@ f <- function(fn, out_dir, design_table) {
message("\tAdding OOB flags")
dat <- merge(dat, bt, by = c("research_name", "units"))
dat$OOB <- as.integer(with(dat, value < low_bound | value > high_bound))
dat$F_OOB <- as.integer(with(dat, value < low_bound | value > high_bound))
smry$`OOB%` <- round(sum(dat$OOB) / nrow(dat) * 100, 1)
# ------------- Out-of-service flags
message("\tAdding OOS flags")
x <- separate(dat, design_link, sep = "-",
into = c("What", "Site", "Location", "Sensor"))
browser()
# Remove unneeded columns unless needed for debugging
if(!params$debug) {
message("\tDropping bounds columns")
Expand Down
8 changes: 6 additions & 2 deletions synoptic/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ ret <- valid_entries(objects = c(1, 1),
stopifnot(ret == c(TRUE, FALSE))



# We read in a version of the Aquatroll Calibration/Removal Log
# (in Monitoring Documents on the COMPASS Google Drive) and restructure it
# into a form ready for out-of-service calculations in L1_normalize.qmd
prep_troll_oos_table <- function(troll) {
# If no time_pulled given, assume 6 AM
tp <- troll$Time_pulled
Expand All @@ -372,5 +374,7 @@ prep_troll_oos_table <- function(troll) {
# Per Peter R., we throw out all data for 24 hours after replacement
troll$oos_end <- troll$oos_end + 60 * 60 * 24

troll[c("Site", "Location", "Troll", "oos_begin", "oos_end")]
troll$Sensor <- troll$Troll
troll$What <- "GW_BattV"
troll[c("Site", "Location", "Sensor", "oos_begin", "oos_end")]
}

0 comments on commit b212e8d

Please sign in to comment.