This script further refines the diurnal signal previously cleaned in
Plot-psy-raw.Rmd with
data_raw/Psy-skip-dates.csv to produce
data_cleaned/psy_hourly.csv. Here, I am preparing the
dataset for analysis for diurnal patterns, including to assess the 3 am
to 7 am time period as reaching equilibrium (asymptotic) or not. Thus,
although psy_hourly.csv has formed the basis of calculating
daily values of predawn and midday, additional scrutiny of the diurnal
pattern is desired. Anomalies during the predawn window and/or loss of
diurnal signal qualifies for data removal.
psy <- read_csv(file = "../data_cleaned/psy_hourly.csv",
locale = locale(tz = "America/Denver")) %>%
mutate(Tree = as.factor(Tree),
Logger = as.factor(Logger))
col_names <- names(read_csv("../data_raw/Other-tower-data.csv",
skip = 1, n_max = 0))
met <- read_csv("../data_raw/Other-tower-data.csv",
skip = 4,
col_names = col_names,
na = c("-9999")) %>%
mutate(dt = as.POSIXct(TIMESTAMP, format = "%m/%d/%Y %H:%M",
tz = "America/Denver"),
VPD_Avg = RHtoVPD(RH_Avg, AirTemp_Avg)) %>%
select(dt, AirTemp_Avg, RH_Avg, VPD_Avg,
Precip_Tot, contains("VWC")) %>%
filter(dt >= min(psy$dt) & dt <= max(psy$dt))
# Make wide and join together
psy_wide <- psy %>%
select(Tree, Logger, dt, psy) %>%
tidyr::pivot_wider(names_from = c(Tree, Logger),
values_from = psy) %>%
left_join(met) %>%
mutate(date = as.Date(dt, tz = "America/Denver"))
Recreate dygraphs with cleaned hourly data and highlight the predawn period of interest (3 am to 7 am).
diurnal <- data.frame(date = seq(min(psy_wide$date), max(psy_wide$date),
by = 'day') %>%
force_tz(tzone = "America/Denver")) %>%
mutate(predawn_st = as.POSIXct(date, tz = "America/Denver") + 3*60*60,
predawn_en = as.POSIXct(date, tz = "America/Denver") + 7*60*60)