@@ -10,8 +10,14 @@ Note, the dropbox refreshes each month. You will also need the TEMPEST github pa
1010https://github.com/COMPASS-DOE/TEMPEST
1111
1212``` {r setup, include=FALSE}
13+
14+ if(!require("compasstools")) {
15+ stop("Need to remotes::install_github('COMPASS-DOE/compasstools')")
16+ }
17+
1318library(tidyverse)
1419library(googledrive)
20+ library(compasstools)
1521
1622knitr::opts_chunk$set(echo = F,
1723 message = F,
@@ -35,53 +41,79 @@ END_DATE = lubridate::as_date("2025-04-08")
3541
3642Filter to needed columns: plot, grid square, id, depth, Data Logger ID,and Terosdata table channel
3743``` {r teros inventory}
38- inventory_directory <- "https://docs.google.com/spreadsheets/d/10u29M5Dbkw54Z2DwkVBptVz6Td0SvSld/edit?gid=90806693#gid=90806693"
44+ # inventory_directory <- "https://docs.google.com/spreadsheets/d/10u29M5Dbkw54Z2DwkVBptVz6Td0SvSld/edit?gid=90806693#gid=90806693"
3945
40- directory= file.path(here::here() %>% dirname(), 'TEMPEST/Lysimeter/')
41- file_path = file.path(directory,"TEROSinventory.xlsx")
46+ # directory= file.path(here::here() %>% dirname(), 'TEMPEST/Lysimeter/')
47+ # file_path = file.path(directory,"TEROSinventory.xlsx")
4248
43- drive_download(inventory_directory, path= file_path, overwrite = TRUE)
49+ # drive_download(inventory_directory, path= file_path, overwrite = TRUE)
4450
45- teros_inv <- readxl::read_excel(file_path , sheet="Sheet1") %>%
51+ teros_inv <- readxl::read_excel("TEROSinventory.xlsx" , sheet="Sheet1") %>%
4652 select(Plot, 'Grid Square', 'Data Logger ID', ID, Depth, 'Terosdata table channel') %>%
4753 rename(Logger = 'Data Logger ID',
4854 Data_Table_ID = 'Terosdata table channel',
4955 Grid = 'Grid Square') %>%
5056 drop_na()
5157```
52- # 3. Bring in dropbox data
58+ # 3. Bring in dropbox data, merge with inventory sheet
5359``` {r dropbox}
54- ```
5560
56- # 4. Merge TEROS inventory with dropbox downloads
61+ datadir <- "~/Dropbox (Smithsonian)/TEMPEST_PNNL_Data/Current_data/"
5762
58- Only want the 15 cm VWC for this analysis.
59- ``` {r merge}
63+ teros_primitive <- compasstools::process_teros_dir(datadir, tz = "EST")
64+
65+ teros_primitive %>%
66+ left_join(teros_inv,
67+ by = c("Logger", "Data_Table_ID")) %>%
68+ mutate(Depth = as.factor(Depth)) %>%
69+ filter(!is.na(ID), Depth == 15, variable == "VWC") %>%
70+ select(-c("Logger", "Data_Table_ID")) ->
71+ teros
6072
6173```
6274
63- # 5 . Bring in porewater inventory
75+ # 4 . Bring in porewater inventory
6476
6577``` {r porewater inventory}
66- pwsite_key <- readxl::read_excel("~/GitHub/TEMPEST/Lysimeter/ porewater_sites_complete_key.xlsx")
78+ pwsite_key <- readxl::read_excel("porewater_sites_complete_key.xlsx")
6779
80+ #right or left join here??
81+ teros %>%
82+ right_join(pwsite_key, by = c("Plot", "Grid")) -> df
6883```
6984
70- # 6 . Filter the VWC for those plots/grids that have lysimeter data
85+ # 5 . Filter the VWC for those plots/grids that have lysimeter data
7186
7287``` {r filter}
7388```
7489
75- # 7 . Bring in GCREW loggernet rain data
90+ # 6 . Bring in GCREW loggernet rain data
7691
7792``` {r gcrew rain}
93+ #temp dataset
94+
95+ read_csv("sample_data/GCREW_MET_GCREW_MET_15min.dat", skip = 1, col_types = "Tdcd") %>%
96+ select(TIMESTAMP, Rain_in_Tot) -> rain1
97+
98+ read_csv("sample_data/GCREW_MET_GCREW_MET_15min_20250415005900.dat", skip = 1, col_types = "Tdcd") %>%
99+ select(TIMESTAMP, Rain_in_Tot) %>%
100+ rbind(rain1) %>%
101+ filter(!is.na(Rain_in_Tot)) -> rain
78102
79103```
80104
81- # 8 . Plot VWC through time
105+ # 7 . Plot VWC through time
82106for study period and by plot/grid facet wrap
83107Note, add thresholds for VWC where we are getting water later - may be able to base this off the DOC Fluxes datasets AMP is using for the Porewater DOC paper.
84108
85109``` {r plot}
110+ library(paletteer)
111+
112+ df %>%
113+ ggplot(aes(x = Timestamp, y = value, group = ID, color = Grid)) +
114+ geom_line() +
115+ facet_wrap(~Plot, ncol = 1, scales = "free_y") +
116+ scale_colour_paletteer_d("ggthemes::Tableau_10") +
117+ theme_minimal() -> p
86118
87119```
0 commit comments