knitr::opts_chunk$set(echo = TRUE) golem::document_and_reload() library(dplyr) library(lubridate) library(plotly) library(readr) library(sear) library(tidyr)
SeaOWLCalFile <- sear:::app_sys("cal", "seaowl", "0144.cal") SeaOWLCal <- sear:::read_seaowl_cal()
Station <- interval(ymd_hms("2022-07-05 12:23:13"), ymd_hms("2022-07-05 12:23:15")) DataFile <- sear:::app_sys("extdata", "DATA_20220705_105732.txt") MTELog <- sear:::read_mtelog(DataFile) MTELog <- MTELog %>% filter(date_time %within% Station) SeaOWLData <- sear:::read_seaowl(MTELog)
cal_seaowl <- function(SeaOWLData, SeaOWLCal) { # Test that calibration and data have the same serial number if (!all(SeaOWLCal$SERIALNO == stringr::str_extract(SeaOWLData$sn, "(?<=-).*"))) { stop("Calibration and SeaOWL have different serial number") } SeaOWLData %>% mutate( vsf_700 = SeaOWLCal$vsf_scale_factor * (vsf_700_channel - SeaOWLCal$vsf_dark_count), chl = SeaOWLCal$chl_scale_factor * (chl_channel - SeaOWLCal$chl_dark_count), fdom = SeaOWLCal$fdom_scale_factor * (fdom_output - SeaOWLCal$fdom_dark_count), .after = sn ) %>% select(date_time, sn, vsf_700, chl, fdom) } seaowl_l1b <- cal_seaowl(SeaOWLData, SeaOWLCal) %>% mutate( id = seq_along(rownames(SeaOWLData)), qc = "1" )
SeaOWLL1bNest <- seaowl_l1b %>% select(!any_of(c("sn"))) %>% pivot_longer( cols = any_of(c("vsf_700", "chl", "fdom")), names_to = "parameter", values_to = "value" ) %>% group_by(parameter) %>% nest() PlyFont <- list(family = "times New Roman", size = 18) BlackSquare <- list( type = "rect", fillcolor = "transparent", line = list(width = 0.5), xref = "paper", yref = "paper", x0 = 0, x1 = 1, y0 = 0, y1 = 1 ) SeaOWLL1bNest <- SeaOWLL1bNest %>% mutate( Plot = purrr::map2(.x = data, .y = parameter, ~ plot_ly(.x, text = ~id) %>% add_markers(x = ~date_time, y = ~value) %>% layout( shapes = BlackSquare, yaxis = list(title = list(text = .y)) )) ) # format(SBE19nest[[2]][[1]]$date_time, "%Y-%m-%d %H:%M:%OS3") subplot(SeaOWLL1bNest$Plot, nrows = nrow(SeaOWLL1bNest), shareX = TRUE, titleY = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.