Last updated: 2020-04-28
Checks: 7 0
Knit directory: BloomSail/
This reproducible R Markdown analysis was created with workflowr (version 1.6.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20191021)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 058c709. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: data/Finnmaid_2018/
Ignored: data/GETM/
Ignored: data/Maps/
Ignored: data/Ostergarnsholm/
Ignored: data/TinaV/
Ignored: data/_merged_data_files/
Ignored: data/_summarized_data_files/
Ignored: output/Plots/Figures_publication/.tmp.drivedownload/
Ignored: output/Plots/Figures_publication/Appendix/
Unstaged changes:
Modified: output/Plots/Figures_publication/Article/Hov_abs_profiles_cum.pdf
Modified: output/Plots/Figures_publication/Article/data_coverage.pdf
Modified: output/Plots/Figures_publication/Article/profiles_all.pdf
Modified: output/Plots/Figures_publication/Article/station_map.pdf
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/merging_interpolation.Rmd
) and HTML (docs/merging_interpolation.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
html | 472c2b4 | jens-daniel-mueller | 2020-04-21 | Build site. |
html | f8fcf50 | jens-daniel-mueller | 2020-04-19 | created pub figures for time series |
html | a6c4c22 | jens-daniel-mueller | 2020-03-30 | Build site. |
html | 80c78b3 | jens-daniel-mueller | 2020-03-30 | Build site. |
html | 5f8ca30 | jens-daniel-mueller | 2020-03-20 | Build site. |
html | 2a20453 | jens-daniel-mueller | 2020-03-20 | Build site. |
html | 473ab25 | jens-daniel-mueller | 2020-03-19 | Build site. |
html | 81f022e | jens-daniel-mueller | 2020-03-18 | Build site. |
html | 1e39d85 | jens-daniel-mueller | 2020-03-18 | Build site. |
html | 2105236 | jens-daniel-mueller | 2020-03-18 | Build site. |
html | 05b9bdc | jens-daniel-mueller | 2020-03-17 | Build site. |
html | 0202742 | jens-daniel-mueller | 2020-03-16 | Build site. |
html | 8e83afd | jens-daniel-mueller | 2020-03-12 | Build site. |
html | a3ddea4 | jens-daniel-mueller | 2020-03-12 | Build site. |
html | 52621ea | jens-daniel-mueller | 2020-03-12 | Build site. |
html | e43a6f2 | jens-daniel-mueller | 2019-12-19 | Build site. |
html | 3042ff3 | jens-daniel-mueller | 2019-12-19 | Build site. |
Rmd | 282c3ac | jens-daniel-mueller | 2019-12-19 | whole data set RT corrected |
html | 78710ee | jens-daniel-mueller | 2019-12-09 | Build site. |
Rmd | c6cfca5 | jens-daniel-mueller | 2019-12-09 | RT correction incl OGB data |
html | c6cfca5 | jens-daniel-mueller | 2019-12-09 | RT correction incl OGB data |
html | bc6f19b | jens-daniel-mueller | 2019-11-22 | Build site. |
Rmd | 03b1b97 | jens-daniel-mueller | 2019-11-22 | updated RT determination |
html | 874dac5 | jens-daniel-mueller | 2019-11-22 | Build site. |
Rmd | f875795 | jens-daniel-mueller | 2019-11-22 | now clean |
html | d921065 | jens-daniel-mueller | 2019-11-14 | Build site. |
Rmd | 252f84d | jens-daniel-mueller | 2019-11-14 | included EDA in data base |
html | d61a468 | jens-daniel-mueller | 2019-11-14 | Build site. |
html | f3277a5 | jens-daniel-mueller | 2019-11-08 | Build site. |
html | 4256bcf | jens-daniel-mueller | 2019-11-08 | Build site. |
html | 72687ee | jens-daniel-mueller | 2019-11-08 | Build site. |
html | 74212a6 | jens-daniel-mueller | 2019-11-08 | Build site. |
Rmd | 6cb1935 | jens-daniel-mueller | 2019-11-08 | response_time updated |
html | 33e3659 | jens-daniel-mueller | 2019-10-22 | Build site. |
Rmd | efcafd1 | jens-daniel-mueller | 2019-10-22 | Added data base, merging, and RT determination |
html | 1595fe9 | jens-daniel-mueller | 2019-10-21 | Build site. |
Rmd | 4131b9c | jens-daniel-mueller | 2019-10-21 | finisehd read CTD and HydroC, created merging Rmd |
library(tidyverse)
library(lubridate)
library(zoo)
# library(dygraphs)
# library(xts)
# Load Sensor and HydroC data ---------------------------------------------
CTD <- read_csv(here::here("Data/_summarized_data_files",
"Tina_V_Sensor_Profiles_Transects.csv"),
col_types = list("pCO2" = col_double())) %>%
rename(pCO2_analog = pCO2)
HC <- read_csv(here::here("Data/_summarized_data_files", "Tina_V_HydroC.csv"))
HC_full <- read_csv(here::here("Data/_summarized_data_files", "Tina_V_HydroC_full.csv"))
# Time offset correction ----------------------------------------------
# Time offset was determined by comparing zeroing reads from Sensor and HC
# in the plots produced in the section Time stamp synchronzity below
# before applying this correction
CTD <- CTD %>%
mutate(day = yday(date_time),
date_time = if_else(day >= 206 & day <= 220,
date_time - 80, date_time - 10)) %>%
select(-day)
# Merge Sensor and HydroC data --------------------------------------------
df <- full_join(CTD, HC) %>%
arrange(date_time)
df_full <- full_join(CTD, HC_full) %>%
arrange(date_time)
rm(HC, HC_full, CTD)
CTD and auxillary recordings (15 sec measurment interval) are interpolated to HydroC time stamps (first 10 sec, than 1 sec measurement interval) when gaps between observations are not larger than 20. Thereafter, HydroC readings not falling in regular transects/profilings are removed, by removing rows with NA depth values. Furthermore, CTD readings without corresponding HydroC reading are removed, except during periods when HydroC was not operating.
# Interpolate Sensor data to HydroC timestamp
df <-
df %>%
mutate(dep = na.approx(dep, na.rm = FALSE, maxgap = 20),
sal = na.approx(sal, na.rm = FALSE, maxgap = 20),
tem = na.approx(tem, na.rm = FALSE, maxgap = 20),
pCO2_analog = na.approx(pCO2_analog, na.rm = FALSE, maxgap = 20),
pH = na.approx(pH, na.rm = FALSE, maxgap = 20),
V_pH = na.approx(V_pH, na.rm = FALSE, maxgap = 20),
O2 = na.approx(O2, na.rm = FALSE, maxgap = 20),
Chl = na.approx(Chl, na.rm = FALSE, maxgap = 20)) %>%
filter(!is.na(dep)) %>% #remove HC readings not falling in regular transects/profilings
fill(ID, type, station) %>%
filter(!is.na(deployment) | is.na(pCO2_analog)) # removes CTD readings without corresponding HydroC reading, except during periods when HydroC was not operating
df_full <-
df_full %>%
mutate(dep = na.approx(dep, na.rm = FALSE, maxgap = 20),
sal = na.approx(sal, na.rm = FALSE, maxgap = 20),
tem = na.approx(tem, na.rm = FALSE, maxgap = 20),
pCO2_analog = na.approx(pCO2_analog, na.rm = FALSE, maxgap = 20),
pH = na.approx(pH, na.rm = FALSE, maxgap = 20),
V_pH = na.approx(V_pH, na.rm = FALSE, maxgap = 20),
O2 = na.approx(O2, na.rm = FALSE, maxgap = 20),
Chl = na.approx(Chl, na.rm = FALSE, maxgap = 20)) %>%
filter(!is.na(dep)) %>% #remove HC readings not falling in regular transects/profilings
fill(ID, type, station) %>%
filter(!is.na(deployment) | is.na(pCO2_analog)) # removes CTD readings without corresponding HydroC reading, except during periods when HydroC was not operating
# Time stamp synchronzity -------------------------------------------------
#
# df <- df %>%
# mutate(day = yday(date_time))
#
# for (dayID in unique(df$day)) {
#
# df %>%
# filter(day == dayID) %>%
# ggplot()+
# geom_point(aes(date_time, pCO2, col="HC"))+
# geom_point(aes(date_time, dep, col="dep"))+
# geom_point(aes(date_time, pH, col="pH"))+
# geom_point(aes(date_time, pCO2_analog, col="Sensor_int"))
#
# ggsave(here::here("/Plots/TinaV/Sensor/HydroC_diagnostics/Timing/day",
# paste(dayID,"_day_HydroC_merged.jpg", sep="")),
# width = 10, height = 4)
# }
#
#
# for (depID in unique(df$deployment)) {
#
# df_dep <- df %>%
# filter(deployment == depID, Zero == 1)
#
# for (zerID in unique(df_dep$Zero_ID)) {
#
# df_dep %>%
# filter(Zero_ID == zerID) %>%
# ggplot()+
# geom_point(aes(date_time, pCO2, col="HC"))+
# geom_point(aes(date_time, pCO2_analog, col="Sensor_int"))
#
# ggsave(here::here("/Plots/TinaV/Sensor/HydroC_diagnostics/Timing/Zeroing",
# paste(depID,"_deployment_",zerID,"_Zero_ID_HydroC.jpg", sep="")),
# width = 10, height = 4)
#
# }
# }
write_csv(df, here::here("Data/_merged_data_files", "BloomSail_CTD_HydroC.csv"))
write_csv(df_full, here::here("Data/_merged_data_files", "BloomSail_CTD_HydroC_full.csv"))
rm(df, df_full)
df <- read_csv(here::here("data/_merged_data_files",
"BloomSail_CTD_HydroC.csv"),
col_types = cols(ID = col_character(),
pCO2_analog = col_double(),
pCO2 = col_double(),
Zero = col_factor(),
Flush = col_factor(),
Zero_ID = col_integer(),
deployment = col_integer(),
duration = col_double(),
mixing = col_character()))
df %>%
filter(!is.na(pCO2)) %>%
ggplot()+
geom_path(aes(date_time, pCO2, col = "HydroC, drift corrected"))+
geom_path(aes(date_time, pCO2_analog, col = "analog CTD"))+
scale_color_brewer(palette = "Set1", name = "pCO2 record")+
labs(y=expression(pCO[2]~(µatm)), x="")+
facet_wrap(~ID, scales = "free_x", ncol = 1)
# ts <- xts(cbind(df$pCO2, df$dep), order.by = df$date_time)
# names(ts) <- c("pCO2", "Depth")
#
# ts %>%
# dygraph() %>%
# dyRangeSelector() %>% #dateWindow = c("2012-01-01", "2016-12-31")
# dySeries("pCO2", label = "pCO2") %>%
# dySeries("Depth", axis = 'y2', label = "Depth") %>%
# dyAxis("y", label = "pCO2 [µatm]") %>%
# dyAxis("y2", label = "Depth [m]") %>%
# dyOptions(drawPoints = TRUE, pointSize = 1)
Sensor <- read_csv(here::here("data/_merged_data_files",
"BloomSail_CTD_HydroC.csv"),
col_types = cols(ID = col_character(),
pCO2_analog = col_double(),
pCO2 = col_double(),
Zero = col_factor(),
Flush = col_factor(),
Zero_ID = col_integer(),
deployment = col_integer(),
duration = col_double(),
mixing = col_character()))
track <-
read_csv(here::here("Data/_summarized_data_files",
"TinaV_Track.csv"))
df <- full_join(Sensor, track) %>%
arrange(date_time)
# interpolate track data and than remove columns that originate from track time stamp
df <-
df %>%
mutate(lat = na.approx(lat, na.rm = FALSE, maxgap = 20),
lon = na.approx(lon, na.rm = FALSE, maxgap = 20)) %>%
filter(!is.na(dep))
df %>%
write_csv(here::here("Data/_merged_data_files", "BloomSail_CTD_HydroC_track.csv"))
rm(df)
# Tasks / open questions
- Check interpolation to CTD Sensor timestamp as alternative option
<br>
<p>
<button type="button" class="btn btn-default btn-workflowr btn-workflowr-sessioninfo"
data-toggle="collapse" data-target="#workflowr-sessioninfo"
style = "display: block;">
<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span>
Session information
</button>
</p>
<div id="workflowr-sessioninfo" class="collapse">
```r
sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_Germany.1252 LC_CTYPE=English_Germany.1252
[3] LC_MONETARY=English_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=English_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] zoo_1.8-7 lubridate_1.7.4 forcats_0.5.0 stringr_1.4.0
[5] dplyr_0.8.5 purrr_0.3.3 readr_1.3.1 tidyr_1.0.2
[9] tibble_3.0.0 ggplot2_3.3.0 tidyverse_1.3.0 workflowr_1.6.1
loaded via a namespace (and not attached):
[1] RColorBrewer_1.1-2 jsonlite_1.6.1 rstudioapi_0.11 generics_0.0.2
[5] magrittr_1.5 farver_2.0.3 gtable_0.3.0 rmarkdown_2.1
[9] vctrs_0.2.4 fs_1.4.0 hms_0.5.3 xml2_1.3.0
[13] pillar_1.4.3 htmltools_0.4.0 haven_2.2.0 later_1.0.0
[17] broom_0.5.5 cellranger_1.1.0 lattice_0.20-41 tidyselect_1.0.0
[21] knitr_1.28 git2r_0.26.1 whisker_0.4 lifecycle_0.2.0
[25] pkgconfig_2.0.3 R6_2.4.1 digest_0.6.25 xfun_0.12
[29] colorspace_1.4-1 rprojroot_1.3-2 stringi_1.4.6 yaml_2.2.1
[33] evaluate_0.14 labeling_0.3 fansi_0.4.1 httr_1.4.1
[37] compiler_3.6.3 here_0.1 cli_2.0.2 withr_2.1.2
[41] backports_1.1.5 munsell_0.5.0 DBI_1.1.0 modelr_0.1.6
[45] Rcpp_1.0.4 readxl_1.3.1 highr_0.8 dbplyr_1.4.2
[49] ellipsis_0.3.0 assertthat_0.2.1 tools_3.6.3 reprex_0.3.0
[53] httpuv_1.5.2 scales_1.1.0 crayon_1.3.4 glue_1.3.2
[57] rlang_0.4.5 nlme_3.1-145 rvest_0.3.5 promises_1.1.0
[61] grid_3.6.3