knitr::opts_chunk$set(echo = FALSE) library(transducer) library(ggplot2) library(data.table) library(earthtide) # library(waterlevel) library(knitr) library(xtable) library(patchwork) library(here) library(plotly) library(DT)
meta_path <- '/media/jonathankennel/Seagate Expansion Drive/guelph_south/meta/' w <- unique(fread(file.path(meta_path, 'well_details.csv'))) xd <- unique(fread(file.path(meta_path, 'transducer_details.csv'))) ma <- unique(fread(file.path(meta_path, 'manual_wl.csv'))) subs <- unique(fread(file.path(meta_path, 'transducer_subsets.csv'))) subs[, start := as.POSIXct(start, tz = 'UTC')] subs[, end := as.POSIXct(end, tz = 'UTC')] w[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] ma[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] xd[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] w_elev <- unique(w[, list(well, port, elevation)]) xd <- w_elev[xd, on = c('well', 'port')] ma <- w[ma, on = c('well', 'port')] ma[, wl_elevation := elevation - value_manual] ma[, datetime := as.POSIXct(datetime, tz = 'UTC')] wn <- 'HBP-MPS1-19'
fn <- list.files('/media/jonathankennel/Seagate Expansion Drive/guelph_south', full.names = TRUE) fn <- fn[tools::file_ext(fn) == 'DAT'] y <- read_transducer(fn) fn <- list.files('/media/jonathankennel/Seagate Expansion Drive/guelph_south', full.names = TRUE) nm <- xd[tools::file_ext(xd$path) == 'MON']$path xd <- w[, list(well, port, port_depth)][xd, on = c('well', 'port'), nomatch = NA] ma <- w[, list(well, port, port_depth)][ma, on = c('well', 'port'), nomatch = NA] ma <- ma[well == wn] mf <- fn[basename(fn) %in% nm] add <- read_transducer(mf) add[parameter %chin% c('water_head_toc_cl', 'pressure'), channel := 'level'] add[parameter %chin% c('water_head_toc_cl', 'pressure'), parameter := 'level'] add[parameter %chin% c('level'), units := 'cmh2o'] add_p <- add[parameter == 'level'] add_t <- add[parameter == 'temperature'] add_p$data <- lapply(add_p$data, function(x) { x$value <- x$value * 100 x$datetime <- x$datetime +3600*5 x }) add_t$data <- lapply(add_t$data, function(x) { x$datetime <- x$datetime +3600*5 x }) class(y[[1]]) <- 'character' y <- rbind(y, rbind(add_p, add_t)) # y <- xd[path %in% basename(fn)] y[, path := basename(file)] y <- y[xd[, list(path, well, transducer_depth = depth, port, port_depth = port_depth, well_elevation = elevation, isbaro, timezone)], on = 'path', nomatch = 0] n_digits <- 1 y_table <- y[, list(type = parameter, file = basename(file), # median = round(sapply(data, function(x) median(x$value)), n_digits), mean = round(sapply(data, function(x) mean(x$value)), n_digits), max = round(sapply(data, function(x) max(x$value)), n_digits), min = round(sapply(data, function(x) min(x$value)), n_digits), # sd = round(sapply(data, function(x) sd(x$value)), n_digits), n = sapply(data, nrow)) ] setkey(y_table, type, file) lev <- copy(y_table)[type=='level'] lev[, type := NULL] knitr::kable(lev, rownames = FALSE, caption = 'Raw pressure (cm H2O)')
temp <- y_table[type=='temperature'] temp[, type := NULL] knitr::kable(temp, rownames = FALSE, caption = 'Raw temperature (degrees C)')
r wn
y <- y[parameter == 'level'] y <- y[well == wn] y[, data := lapply(data, filter_dates, subsets = subs)] y$data <- lapply(y$data, function(x) { x$value <- x$value / 100 x }) y <- y[, data := .(.(make_even_times(data[[1]], diff_time = dt))), by = 1:nrow(y)] y <- westbay_to_elevation(y, baro_port = 'Baro') y <- downsample_data(y, time_interval = 300) # y <- trim_downloads(y, n_vals = c(1800, 7200))
Six ports and barometric pressure were monitored at r wn
. The total monitoring period is r min(y$start)
to r max(y$start)
every r unique(y$dt)
seconds.
Pressure was output as meters $H_2O$ water level.
$z_{trans} = z_{toc} - y_{cable}$
$wl_{masl} = z_{trans} + (P_{wl} - P_{atm})$
where wl~masl~ is the equivalent water level elevation, z~toc~ is the elevation of the top of casing in m, y~cable~ is the distance from the top of casing to the transducer in m, z~trans~ is the transducer elevation in m, P~wl~ is the pressure at the port in m H~2~O, P~atm~ is the atmospheric pressure in m H~2~O.
tbl_ports <- unique(y[, list(`Port ID` = port, `Transducer Depth (m)` = round(transducer_depth, 2), `Port Elevation (masl)` = round(well_elevation-port_depth, 2), `Elevation (masl)` = round(well_elevation-transducer_depth, 2), Serial = serial)]) setkey(tbl_ports, 'Port ID') tbl_ports <- xtable(tbl_ports, caption = 'Port information.') print(tbl_ports, include.rownames = FALSE, comment = FALSE)
psia_conv = 1.0 # 1/psia_conv # 0.4335/1/.3048 aa <- unique(rbindlist(y$data)) aa[is.na(value), wl_elevation := NA_real_] aa[, flag := 'Submerged'] aa[value <= baro * 1.009, flag := 'In air'] # aa[flag == 'In air', wl_elevation := NA_real_] aa[, grp := paste(as.factor(round(port_elevation, 2)))] aa[, type := 'Water levels'] aa[is.na(port_elevation), type := 'Atmospheric'] aa[type == 'Atmospheric', wl_elevation := value / psia_conv] setkey(aa, datetime) ma[, grp := paste(as.factor(round(elevation - port_depth, 2)))] xlim <- range(aa$datetime) p1 <- ggplot(aa[type != 'Atmospheric'], aes(x = datetime, y = wl_elevation, group = grp, color = grp)) + ylab('Water level elevation (masl)') + scale_x_datetime(limits = xlim) + # scale_y_continuous(limits = c(300, 325)) + geom_line(na.rm = TRUE) + geom_point(data = ma, aes(x = datetime, y = wl_elevation, group = grp, color = grp), na.rm = TRUE)+ scale_color_brewer('Port Elevation', type = 'qual', palette = 'Set1') + theme_bw() p2 <- ggplot(aa[type == 'Atmospheric'], aes(x = datetime, y = value)) + ylab('Atm. pressure as m H2O') + scale_x_datetime(limits = xlim) + geom_line(na.rm = TRUE) + theme_bw() p1 + p2 + plot_layout(widths = c(1), heights = unit(c(9.5, 3.5), c('cm', 'cm')))
aa[, grp := paste('Port elevation (m):', grp)] p1 <- ggplot(aa[type != 'Atmospheric'], aes(x = datetime, y = wl_elevation, group = grp, color = grp)) + ylab('Water level elevation (masl)') + scale_color_brewer('Port Elevation', type = 'qual', palette = 'Set1') + scale_y_continuous(labels = scales::number_format(accuracy = 0.01), n.breaks = 4) + geom_line(na.rm = TRUE) + facet_wrap(grp~., scales = 'free_y', ncol = 1) + theme_bw() + theme(legend.position = "none") print(p1)
daily <- aa[as.numeric(datetime) %% (86400*5) == 0] # brks <- as.POSIXct(paste('2020', rep(1:12, each = 6), rep(c(1,5,10,15,20,25)), sep = '-'), tz = 'UTC') brks <- seq.POSIXt(as.POSIXct('2020-01-01', tz = 'UTC'), as.POSIXct('2021-01-01', tz = 'UTC'), by = '10 days') lbls <-as.character(brks) ggplot(daily[type != 'Atmospheric'], aes(y = wl_elevation, x = port_elevation, color = (datetime), group = (datetime))) + geom_line(na.rm = TRUE) + ylab('Water level elevation (masl)') + xlab('Port elevation (masl)') + geom_point(na.rm = TRUE) + coord_flip() + scale_color_viridis_c('Day', breaks = brks, labels = lbls, expand = c(0,0)) + guides(color = guide_colorbar(barheight = 20)) + theme_bw() # guide_colorbar()
meta_path <- '/media/jonathankennel/Seagate Expansion Drive/guelph_south/meta/' w <- unique(fread(file.path(meta_path, 'well_details.csv'))) xd <- unique(fread(file.path(meta_path, 'transducer_details.csv'))) ma <- unique(fread(file.path(meta_path, 'manual_wl.csv'))) subs <- unique(fread(file.path(meta_path, 'transducer_subsets.csv'))) subs[, start := as.POSIXct(start, tz = 'UTC')] subs[, end := as.POSIXct(end, tz = 'UTC')] w[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] ma[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] xd[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] w_elev <- unique(w[, list(well, port, elevation)]) xd <- w_elev[xd, on = c('well', 'port')] ma <- w[ma, on = c('well', 'port')] ma[, wl_elevation := elevation - value_manual] ma[, datetime := as.POSIXct(datetime, tz = 'UTC')] wn <- 'HBP-MPS2-19'
r wn
fn <- list.files('/media/jonathankennel/Seagate Expansion Drive/guelph_south', full.names = TRUE) fn <- fn[tools::file_ext(fn) == 'DAT'] y <- read_transducer(fn) fn <- list.files('/media/jonathankennel/Seagate Expansion Drive/guelph_south', full.names = TRUE) nm <- xd[tools::file_ext(xd$path) == 'MON']$path xd <- w[, list(well, port, port_depth)][xd, on = c('well', 'port'), nomatch = NA] ma <- w[, list(well, port, port_depth)][ma, on = c('well', 'port'), nomatch = NA] ma <- ma[well == wn] mf <- fn[basename(fn) %in% nm] add <- read_transducer(mf) add[parameter %chin% c('water_head_toc_cl', 'pressure'), channel := 'level'] add[parameter %chin% c('water_head_toc_cl', 'pressure'), parameter := 'level'] add[parameter %chin% c('level'), units := 'cmh2o'] add$data <- lapply(add$data, function(x) { x$value <- x$value * 100 x$datetime <- x$datetime +3600*5 x }) class(y[[1]]) <- 'character' y <- rbind(y, add) # y <- xd[path %in% basename(fn)] y[, path := basename(file)] y <- y[xd[, list(path, well, transducer_depth = depth, port, port_depth = port_depth, well_elevation = elevation, isbaro, timezone)], on = 'path', nomatch = 0] y <- y[parameter == 'level'] y <- y[well == wn] y[, data := lapply(data, filter_dates, subsets = subs)] y$data <- lapply(y$data, function(x) { x$value <- x$value / 100 x }) y <- y[, data := .(.(make_even_times(data[[1]], diff_time = dt))), by = 1:nrow(y)] y <- westbay_to_elevation(y, baro_port = 'Baro') y <- downsample_data(y, time_interval = 300) y <- trim_downloads(y, n_vals = c(1800, 7200))
Six ports and barometric pressure were monitored at r wn
. The total monitoring period is r min(y$start)
to r max(y$start)
every r unique(y$dt)
seconds.
Pressure was output as meters $H_2O$ water level.
$z_{trans} = z_{toc} - y_{cable}$
$wl_{masl} = z_{trans} + (P_{wl} - P_{atm})$
where wl~masl~ is the equivalent water level elevation, z~toc~ is the elevation of the top of casing in m, y~cable~ is the distance from the top of casing to the transducer in m, z~trans~ is the transducer elevation in m, P~wl~ is the pressure at the port in m H~2~O, P~atm~ is the atmospheric pressure in m H~2~O.
tbl_ports <- unique(y[, list(`Port ID` = port, `Transducer Depth (m)` = round(transducer_depth, 2), `Port Elevation (masl)` = round(well_elevation-port_depth, 2), `Elevation (masl)` = round(well_elevation-transducer_depth, 2), Serial = serial)]) setkey(tbl_ports, 'Port ID') tbl_ports <- xtable(tbl_ports, caption = 'Port information.') print(tbl_ports, include.rownames = FALSE, comment = FALSE)
psia_conv = 1.0 # 1/psia_conv # 0.4335/1/.3048 aa <- unique(rbindlist(y$data)) aa[is.na(value), wl_elevation := NA_real_] aa[, flag := 'Submerged'] aa[value <= baro *1.009, flag := 'In air'] # aa[flag == 'In air', wl_elevation := NA_real_] aa[, grp := paste(as.factor(round(port_elevation, 2)))] aa[, type := 'Water levels'] aa[is.na(port_elevation), type := 'Atmospheric'] aa[type == 'Atmospheric', wl_elevation := value / psia_conv] setkey(aa, datetime) ma[, grp := paste(as.factor(round(elevation - port_depth, 2)))] xlim <- range(aa$datetime) ma <- ma[port != 6] p1 <- ggplot(aa[type != 'Atmospheric'], aes(x = datetime, y = wl_elevation, group = grp, color = grp)) + ylab('Water level elevation (masl)') + scale_x_datetime(limits = xlim) + # scale_y_continuous(limits = c(300, 325)) + geom_line(na.rm = TRUE) + geom_point(data = ma, aes(x = datetime, y = wl_elevation, group = grp, color = grp), na.rm = TRUE)+ scale_color_brewer('Port Elevation', type = 'qual', palette = 'Set1') + theme_bw() p2 <- ggplot(aa[type == 'Atmospheric'], aes(x = datetime, y = value)) + ylab('Atm. pressure as m H2O') + scale_x_datetime(limits = xlim) + geom_line(na.rm = TRUE) + theme_bw() p1 + p2 + plot_layout(widths = c(1), heights = unit(c(9.5, 3.5), c('cm', 'cm')))
aa[, grp := paste('Port elevation (m):', grp)] p1 <- ggplot(aa[type != 'Atmospheric'], aes(x = datetime, y = wl_elevation, group = grp, color = grp)) + ylab('Water level elevation (masl)') + scale_color_brewer('Port Elevation', type = 'qual', palette = 'Set1') + scale_y_continuous(labels = scales::number_format(accuracy = 0.01), n.breaks = 4) + geom_line(na.rm = TRUE) + facet_wrap(grp~., scales = 'free_y', ncol = 1) + theme_bw() + theme(legend.position = "none") print(p1)
daily <- aa[as.numeric(datetime) %% (86400*5) == 0] # brks <- as.POSIXct(paste('2020', rep(1:12, each = 6), rep(c(1,5,10,15,20,25)), sep = '-'), tz = 'UTC') brks <- seq.POSIXt(as.POSIXct('2020-01-01', tz = 'UTC'), as.POSIXct('2021-01-01', tz = 'UTC'), by = '10 days') lbls <-as.character(brks) ggplot(daily[type != 'Atmospheric'], aes(y = wl_elevation, x = port_elevation, color = (datetime), group = (datetime))) + geom_line(na.rm = TRUE) + ylab('Water level elevation (masl)') + xlab('Port elevation (masl)') + geom_point(na.rm = TRUE) + coord_flip() + scale_color_viridis_c('Day', breaks = brks, labels = lbls, expand = c(0,0)) + guides(color = guide_colorbar(barheight = 20)) + theme_bw() # guide_colorbar()
meta_path <- '/media/jonathankennel/Seagate Expansion Drive/guelph_south/meta/' w <- unique(fread(file.path(meta_path, 'well_details.csv'))) xd <- unique(fread(file.path(meta_path, 'transducer_details.csv'))) ma <- unique(fread(file.path(meta_path, 'manual_wl.csv'))) subs <- unique(fread(file.path(meta_path, 'transducer_subsets.csv'))) subs[, start := as.POSIXct(start, tz = 'UTC')] subs[, end := as.POSIXct(end, tz = 'UTC')] w[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] ma[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] xd[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] w_elev <- unique(w[, list(well, port, elevation)]) xd <- w_elev[xd, on = c('well', 'port')] ma <- w[ma, on = c('well', 'port')] ma[, wl_elevation := elevation - value_manual] ma[, datetime := as.POSIXct(datetime, tz = 'UTC')] wn <- 'HBP-MPS3-19'
r wn
fn <- list.files('/media/jonathankennel/Seagate Expansion Drive/guelph_south', full.names = TRUE) fn <- fn[tools::file_ext(fn) == 'DAT'] y <- read_transducer(fn) fn <- list.files('/media/jonathankennel/Seagate Expansion Drive/guelph_south', full.names = TRUE) nm <- xd[tools::file_ext(xd$path) == 'MON']$path xd <- w[, list(well, port, port_depth)][xd, on = c('well', 'port'), nomatch = NA] ma <- w[, list(well, port, port_depth)][ma, on = c('well', 'port'), nomatch = NA] ma <- ma[well == wn] mf <- fn[basename(fn) %in% nm] add <- read_transducer(mf) add[parameter %chin% c('water_head_toc_cl', 'pressure'), channel := 'level'] add[parameter %chin% c('water_head_toc_cl', 'pressure'), parameter := 'level'] add[parameter %chin% c('level'), units := 'cmh2o'] add$data <- lapply(add$data, function(x) { x$value <- x$value * 100 x$datetime <- x$datetime +3600*5 x }) class(y[[1]]) <- 'character' y <- rbind(y, add) # y <- xd[path %in% basename(fn)] y[, path := basename(file)] y <- y[xd[, list(path, well, transducer_depth = depth, port, port_depth = port_depth, well_elevation = elevation, isbaro, timezone)], on = 'path', nomatch = 0] y <- y[parameter == 'level'] y <- y[well == wn] y[, data := lapply(data, filter_dates, subsets = subs)] y$data <- lapply(y$data, function(x) { x$value <- x$value / 100 x }) y <- y[, data := .(.(make_even_times(data[[1]], diff_time = dt))), by = 1:nrow(y)] y <- westbay_to_elevation(y, baro_port = 'Baro') y <- downsample_data(y, time_interval = 300) y <- trim_downloads(y, n_vals = c(1800, 7200))
Six ports and barometric pressure were monitored at r wn
. The total monitoring period is r min(y$start)
to r max(y$start)
every r unique(y$dt)
seconds.
Pressure was output as meters $H_2O$ water level.
$z_{trans} = z_{toc} - y_{cable}$
$wl_{masl} = z_{trans} + (P_{wl} - P_{atm})$
where wl~masl~ is the equivalent water level elevation, z~toc~ is the elevation of the top of casing in m, y~cable~ is the distance from the top of casing to the transducer in m, z~trans~ is the transducer elevation in m, P~wl~ is the pressure at the port in m H~2~O, P~atm~ is the atmospheric pressure in m H~2~O.
tbl_ports <- unique(y[, list(`Port ID` = port, `Transducer Depth (m)` = round(transducer_depth, 2), `Port Elevation (masl)` = round(well_elevation-port_depth, 2), `Elevation (masl)` = round(well_elevation-transducer_depth, 2), Serial = serial)]) setkey(tbl_ports, 'Port ID') tbl_ports <- xtable(tbl_ports, caption = 'Port information.') print(tbl_ports, include.rownames = FALSE, comment = FALSE)
psia_conv = 1.0 # 1/psia_conv # 0.4335/1/.3048 aa <- unique(rbindlist(y$data)) aa[is.na(value), wl_elevation := NA_real_] aa[, flag := 'Submerged'] aa[value <= baro *1.009, flag := 'In air'] # aa[flag == 'In air', wl_elevation := NA_real_] aa[, grp := paste(as.factor(round(port_elevation, 2)))] aa[, type := 'Water levels'] aa[is.na(port_elevation), type := 'Atmospheric'] aa[type == 'Atmospheric', wl_elevation := value / psia_conv] setkey(aa, datetime) ma[, grp := paste(as.factor(round(elevation - port_depth, 2)))] xlim <- range(aa$datetime) p1 <- ggplot(aa[type != 'Atmospheric'], aes(x = datetime, y = wl_elevation, group = grp, color = grp)) + ylab('Water level elevation (masl)') + scale_x_datetime(limits = xlim) + # scale_y_continuous(limits = c(300, 325)) + geom_line(na.rm = TRUE) + geom_point(data = ma, aes(x = datetime, y = wl_elevation, group = grp, color = grp), na.rm = TRUE)+ scale_color_brewer('Port Elevation', type = 'qual', palette = 'Set1') + theme_bw() p2 <- ggplot(aa[type == 'Atmospheric'], aes(x = datetime, y = value)) + ylab('Atm. pressure as m H2O') + scale_x_datetime(limits = xlim) + geom_line(na.rm = TRUE) + theme_bw() p1 + p2 + plot_layout(widths = c(1), heights = unit(c(9.5, 3.5), c('cm', 'cm'))) # aa <- rbindlist(y[port == '6']$data) # p1 <- plot_ly(aa, x = ~datetime, y = ~wl_elevation, type = 'scatter', mode = 'lines') # p1
aa[, grp := paste('Port elevation (m):', grp)] p1 <- ggplot(aa[type != 'Atmospheric'], aes(x = datetime, y = wl_elevation, group = grp, color = grp)) + ylab('Water level elevation (masl)') + scale_color_brewer('Port Elevation', type = 'qual', palette = 'Set1') + scale_y_continuous(labels = scales::number_format(accuracy = 0.01), n.breaks = 4) + geom_line(na.rm = TRUE) + facet_wrap(grp~., scales = 'free_y', ncol = 1) + theme_bw() + theme(legend.position = "none") print(p1)
daily <- aa[as.numeric(datetime) %% (86400*5) == 0] # brks <- as.POSIXct(paste('2020', rep(1:12, each = 6), rep(c(1,5,10,15,20,25)), sep = '-'), tz = 'UTC') brks <- seq.POSIXt(as.POSIXct('2020-01-01', tz = 'UTC'), as.POSIXct('2021-01-01', tz = 'UTC'), by = '10 days') lbls <-as.character(brks) ggplot(daily[type != 'Atmospheric'], aes(y = wl_elevation, x = port_elevation, color = (datetime), group = (datetime))) + geom_line(na.rm = TRUE) + ylab('Water level elevation (masl)') + xlab('Port elevation (masl)') + geom_point(na.rm = TRUE) + coord_flip() + scale_color_viridis_c('Day', breaks = brks, labels = lbls, expand = c(0,0)) + guides(color = guide_colorbar(barheight = 20)) + theme_bw() # guide_colorbar()
meta_path <- '/media/jonathankennel/Seagate Expansion Drive/guelph_south/meta/' w <- unique(fread(file.path(meta_path, 'well_details.csv'))) xd <- unique(fread(file.path(meta_path, 'transducer_details.csv'))) ma <- unique(fread(file.path(meta_path, 'manual_wl.csv'))) subs <- unique(fread(file.path(meta_path, 'transducer_subsets.csv'))) subs[, start := as.POSIXct(start, tz = 'UTC')] subs[, end := as.POSIXct(end, tz = 'UTC')] w[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] ma[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] xd[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] w_elev <- unique(w[, list(well, port, elevation)]) xd <- w_elev[xd, on = c('well', 'port')] ma <- w[ma, on = c('well', 'port')] ma[, wl_elevation := elevation - value_manual] ma[, datetime := as.POSIXct(datetime, tz = 'UTC')] wn <- 'HBP-MPS4-20'
r wn
fn <- list.files('/media/jonathankennel/Seagate Expansion Drive/guelph_south', full.names = TRUE) fn <- fn[tools::file_ext(fn) == 'DAT'] y <- read_transducer(fn) fn <- list.files('/media/jonathankennel/Seagate Expansion Drive/guelph_south', full.names = TRUE) nm <- xd[tools::file_ext(xd$path) == 'MON']$path xd <- w[, list(well, port, port_depth)][xd, on = c('well', 'port'), nomatch = NA] ma <- w[, list(well, port, port_depth)][ma, on = c('well', 'port'), nomatch = NA] ma <- ma[well == wn] mf <- fn[basename(fn) %in% nm] add <- read_transducer(mf) add[parameter %chin% c('water_head_toc_cl', 'pressure'), channel := 'level'] add[parameter %chin% c('water_head_toc_cl', 'pressure'), parameter := 'level'] add[parameter %chin% c('level'), units := 'cmh2o'] add$data <- lapply(add$data, function(x) { x$value <- x$value * 100 x$datetime <- x$datetime +3600*5 x }) class(y[[1]]) <- 'character' y <- rbind(y, add) # y <- xd[path %in% basename(fn)] y[, path := basename(file)] y <- y[xd[, list(path, well, transducer_depth = depth, port, port_depth = port_depth, well_elevation = elevation, isbaro, timezone)], on = 'path', nomatch = 0] y <- y[parameter == 'level'] y <- y[well == wn] y[, data := lapply(data, filter_dates, subsets = subs)] y$data <- lapply(y$data, function(x) { x$value <- x$value / 100 x }) y <- y[, data := .(.(make_even_times(data[[1]], diff_time = dt))), by = 1:nrow(y)] y <- westbay_to_elevation(y, baro_port = 'Baro') y <- downsample_data(y, time_interval = 300) y <- trim_downloads(y, n_vals = c(1800, 7200))
Six ports and barometric pressure were monitored at r wn
. The total monitoring period is r min(y$start)
to r max(y$start)
every r unique(y$dt)
seconds.
Pressure was output as meters $H_2O$ water level.
$z_{trans} = z_{toc} - y_{cable}$
$wl_{masl} = z_{trans} + (P_{wl} - P_{atm})$
where wl~masl~ is the equivalent water level elevation, z~toc~ is the elevation of the top of casing in m, y~cable~ is the distance from the top of casing to the transducer in m, z~trans~ is the transducer elevation in m, P~wl~ is the pressure at the port in m H~2~O, P~atm~ is the atmospheric pressure in m H~2~O.
tbl_ports <- unique(y[, list(`Port ID` = port, `Transducer Depth (m)` = round(transducer_depth, 2), `Port Elevation (masl)` = round(well_elevation-port_depth, 2), `Elevation (masl)` = round(well_elevation-transducer_depth, 2), Serial = serial)]) setkey(tbl_ports, 'Port ID') tbl_ports <- xtable(tbl_ports, caption = 'Port information.') print(tbl_ports, include.rownames = FALSE, comment = FALSE)
psia_conv = 1.0 # 1/psia_conv # 0.4335/1/.3048 aa <- unique(rbindlist(y$data)) aa[is.na(value), wl_elevation := NA_real_] aa[, flag := 'Submerged'] aa[value <= baro *1.009, flag := 'In air'] # aa[flag == 'In air', wl_elevation := NA_real_] aa[, grp := paste(as.factor(round(port_elevation, 2)))] aa[, type := 'Water levels'] aa[is.na(port_elevation), type := 'Atmospheric'] aa[type == 'Atmospheric', wl_elevation := value / psia_conv] setkey(aa, datetime) ma[, grp := paste(as.factor(round(elevation - port_depth, 2)))] xlim <- range(aa$datetime) p1 <- ggplot(aa[type != 'Atmospheric'], aes(x = datetime, y = wl_elevation, group = grp, color = grp)) + ylab('Water level elevation (masl)') + scale_x_datetime(limits = xlim) + # scale_y_continuous(limits = c(300, 325)) + geom_line(na.rm = TRUE) + geom_point(data = ma, aes(x = datetime, y = wl_elevation, group = grp, color = grp), na.rm = TRUE)+ scale_color_brewer('Port Elevation', type = 'qual', palette = 'Set1') + theme_bw() p2 <- ggplot(aa[type == 'Atmospheric'], aes(x = datetime, y = value)) + ylab('Atm. pressure as m H2O') + scale_x_datetime(limits = xlim) + geom_line(na.rm = TRUE) + theme_bw() p1 + p2 + plot_layout(widths = c(1), heights = unit(c(9.5, 3.5), c('cm', 'cm')))
aa[, grp := paste('Port elevation (m):', grp)] p1 <- ggplot(aa[type != 'Atmospheric'], aes(x = datetime, y = wl_elevation, group = grp, color = grp)) + ylab('Water level elevation (masl)') + scale_color_brewer('Port Elevation', type = 'qual', palette = 'Set1') + scale_y_continuous(labels = scales::number_format(accuracy = 0.01), n.breaks = 4) + geom_line(na.rm = TRUE) + facet_wrap(grp~., scales = 'free_y', ncol = 1) + theme_bw() + theme(legend.position = "none") print(p1)
daily <- aa[as.numeric(datetime) %% (86400*5) == 0] # brks <- as.POSIXct(paste('2020', rep(1:12, each = 6), rep(c(1,5,10,15,20,25)), sep = '-'), tz = 'UTC') brks <- seq.POSIXt(as.POSIXct('2020-01-01', tz = 'UTC'), as.POSIXct('2021-01-01', tz = 'UTC'), by = '10 days') lbls <-as.character(brks) ggplot(daily[type != 'Atmospheric'], aes(y = wl_elevation, x = port_elevation, color = (datetime), group = (datetime))) + geom_line(na.rm = TRUE) + ylab('Water level elevation (masl)') + xlab('Port elevation (masl)') + geom_point(na.rm = TRUE) + coord_flip() + scale_color_viridis_c('Day', breaks = brks, labels = lbls, expand = c(0,0)) + guides(color = guide_colorbar(barheight = 20)) + theme_bw() # guide_colorbar()
meta_path <- '/media/jonathankennel/Seagate Expansion Drive/guelph_south/meta/' w <- unique(fread(file.path(meta_path, 'well_details.csv'))) xd <- unique(fread(file.path(meta_path, 'transducer_details.csv'))) ma <- unique(fread(file.path(meta_path, 'manual_wl.csv'))) subs <- unique(fread(file.path(meta_path, 'transducer_subsets.csv'))) subs[, start := as.POSIXct(start, tz = 'UTC')] subs[, end := as.POSIXct(end, tz = 'UTC')] w[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] ma[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] xd[well == 'HBP-MW3-19', well := 'HBP-MPS3-19'] w_elev <- unique(w[, list(well, port, elevation)]) xd <- w_elev[xd, on = c('well', 'port')] ma <- w[ma, on = c('well', 'port')] ma[, wl_elevation := elevation - value_manual] ma[, datetime := as.POSIXct(datetime, tz = 'UTC')] wn <- 'GSTW1-08'
r wn
fn <- list.files('/media/jonathankennel/Seagate Expansion Drive/guelph_south', full.names = TRUE) fn <- fn[tools::file_ext(fn) == 'DAT'] y <- read_transducer(fn) fn <- list.files('/media/jonathankennel/Seagate Expansion Drive/guelph_south', full.names = TRUE) nm <- xd[tools::file_ext(xd$path) == 'MON']$path xd <- w[, list(well, port, port_depth)][xd, on = c('well', 'port'), nomatch = NA] ma <- w[, list(well, port, port_depth)][ma, on = c('well', 'port'), nomatch = NA] ma <- ma[well == wn] mf <- fn[basename(fn) %in% nm] add <- read_transducer(mf) add[parameter %chin% c('water_head_toc_cl', 'pressure'), channel := 'level'] add[parameter %chin% c('water_head_toc_cl', 'pressure'), parameter := 'level'] add[parameter %chin% c('level'), units := 'cmh2o'] add$data <- lapply(add$data, function(x) { x$value <- x$value * 100 x$datetime <- x$datetime +3600*5 x }) class(y[[1]]) <- 'character' y <- rbind(y, add) # y <- xd[path %in% basename(fn)] y[, path := basename(file)] y <- y[xd[, list(path, well, transducer_depth = depth, port, port_depth = port_depth, well_elevation = elevation, isbaro, timezone)], on = 'path', nomatch = 0] y <- y[parameter == 'level'] y <- y[well == wn] y[, data := lapply(data, filter_dates, subsets = subs)] y$data <- lapply(y$data, function(x) { x$value <- x$value / 100 x }) y <- y[, data := .(.(make_even_times(data[[1]], diff_time = dt))), by = 1:nrow(y)] y <- westbay_to_elevation(y, baro_port = 'Baro') y <- downsample_data(y, time_interval = 300) y <- trim_downloads(y, n_vals = c(1800, 7200))
Six ports and barometric pressure were monitored at r wn
. The total monitoring period is r min(y$start)
to r max(y$start)
every r unique(y$dt)
seconds.
Pressure was output as meters $H_2O$ water level.
$z_{trans} = z_{toc} - y_{cable}$
$wl_{masl} = z_{trans} + (P_{wl} - P_{atm})$
where wl~masl~ is the equivalent water level elevation, z~toc~ is the elevation of the top of casing in m, y~cable~ is the distance from the top of casing to the transducer in m, z~trans~ is the transducer elevation in m, P~wl~ is the pressure at the port in m H~2~O, P~atm~ is the atmospheric pressure in m H~2~O.
tbl_ports <- unique(y[, list(`Port ID` = port, `Transducer Depth (m)` = round(transducer_depth, 2), `Port Elevation (masl)` = round(well_elevation-port_depth, 2), `Elevation (masl)` = round(well_elevation-transducer_depth, 2), Serial = serial)]) setkey(tbl_ports, 'Port ID') tbl_ports <- xtable(tbl_ports, caption = 'Port information.') print(tbl_ports, include.rownames = FALSE, comment = FALSE)
psia_conv = 1.0 # 1/psia_conv # 0.4335/1/.3048 aa <- unique(rbindlist(y$data)) aa[is.na(value), wl_elevation := NA_real_] aa[, flag := 'Submerged'] aa[value <= baro *1.009, flag := 'In air'] # aa[flag == 'In air', wl_elevation := NA_real_] aa[, grp := paste(as.factor(round(port_elevation, 2)))] aa[, type := 'Water levels'] aa[is.na(port_elevation), type := 'Atmospheric'] aa[type == 'Atmospheric', wl_elevation := value / psia_conv] setkey(aa, datetime) ma[, grp := paste(as.factor(round(elevation - port_depth, 2)))] xlim <- range(aa$datetime) p1 <- ggplot(aa[type != 'Atmospheric'], aes(x = datetime, y = wl_elevation, group = grp, color = grp)) + ylab('Water level elevation (masl)') + scale_x_datetime(limits = xlim) + # scale_y_continuous(limits = c(300, 325)) + geom_line(na.rm = TRUE) + geom_point(data = ma, aes(x = datetime, y = wl_elevation, group = grp, color = grp), na.rm = TRUE)+ scale_color_brewer('Port Elevation', type = 'qual', palette = 'Set1') + theme_bw() p2 <- ggplot(aa[type == 'Atmospheric'], aes(x = datetime, y = value)) + ylab('Atm. pressure as m H2O') + scale_x_datetime(limits = xlim) + geom_line(na.rm = TRUE) + theme_bw() p1 + p2 + plot_layout(widths = c(1), heights = unit(c(9.5, 3.5), c('cm', 'cm')))
aa[, grp := paste('Port elevation (m):', grp)] p1 <- ggplot(aa[type != 'Atmospheric'], aes(x = datetime, y = wl_elevation, group = grp, color = grp)) + ylab('Water level elevation (masl)') + scale_color_brewer('Port Elevation', type = 'qual', palette = 'Set1') + scale_y_continuous(labels = scales::number_format(accuracy = 0.01), n.breaks = 4) + geom_line(na.rm = TRUE) + facet_wrap(grp~., scales = 'free_y', ncol = 1) + theme_bw() + theme(legend.position = "none") print(p1)
daily <- aa[as.numeric(datetime) %% (86400*5) == 0] # brks <- as.POSIXct(paste('2020', rep(1:12, each = 6), rep(c(1,5,10,15,20,25)), sep = '-'), tz = 'UTC') brks <- seq.POSIXt(as.POSIXct('2020-01-01', tz = 'UTC'), as.POSIXct('2021-01-01', tz = 'UTC'), by = '10 days') lbls <-as.character(brks) ggplot(daily[type != 'Atmospheric'], aes(y = wl_elevation, x = port_elevation, color = (datetime), group = (datetime))) + geom_line(na.rm = TRUE) + ylab('Water level elevation (masl)') + xlab('Port elevation (masl)') + geom_point(na.rm = TRUE) + coord_flip() + scale_color_viridis_c('Day', breaks = brks, labels = lbls, expand = c(0,0)) + guides(color = guide_colorbar(barheight = 20)) + theme_bw() # guide_colorbar()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.