Last updated: 2020-11-10
Checks: 7 0
Knit directory: Cant_eMLR/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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(20200707)
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 dacbb52. 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: .Rproj.user/
Ignored: data/GLODAPv1_1/
Ignored: data/GLODAPv2_2016b_MappedClimatologies/
Ignored: data/GLODAPv2_2020/
Ignored: data/Gruber_2019/
Ignored: data/WOCE/
Ignored: data/World_Ocean_Atlas_2013_Clement/
Ignored: data/World_Ocean_Atlas_2018/
Ignored: data/eMLR/
Ignored: data/mapping/
Ignored: data/pCO2_atmosphere/
Ignored: dump/
Untracked files:
Untracked: code/mapping_functions.R
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/analysis_this_study_vs_Gruber_2019.Rmd
) and HTML (docs/analysis_this_study_vs_Gruber_2019.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 |
---|---|---|---|---|
Rmd | dacbb52 | jens-daniel-mueller | 2020-11-10 | included estimate in offset plot |
html | 2e9293b | jens-daniel-mueller | 2020-11-10 | Build site. |
Rmd | 06b1b51 | jens-daniel-mueller | 2020-11-10 | updated offset section plots |
html | 41fba45 | jens-daniel-mueller | 2020-11-10 | Build site. |
Rmd | 5bd544d | jens-daniel-mueller | 2020-11-10 | reformated legend |
html | 4021bec | jens-daniel-mueller | 2020-11-10 | Build site. |
Rmd | 4849133 | jens-daniel-mueller | 2020-11-10 | divergent split section in external code |
html | 082e7e5 | jens-daniel-mueller | 2020-11-10 | Build site. |
Rmd | 5198b4b | jens-daniel-mueller | 2020-11-10 | divergent split section in external code |
html | 7a69d2c | jens-daniel-mueller | 2020-11-10 | Build site. |
Rmd | 58edcce | jens-daniel-mueller | 2020-11-10 | moved section plot function to code collection |
html | 6148088 | jens-daniel-mueller | 2020-11-10 | Build site. |
Rmd | 4156f70 | jens-daniel-mueller | 2020-11-10 | improved plotting routine |
html | 42a2c82 | jens-daniel-mueller | 2020-11-10 | Build site. |
Rmd | b13b596 | jens-daniel-mueller | 2020-11-10 | create and apply global base map layer |
html | 89a9c26 | jens-daniel-mueller | 2020-11-10 | Build site. |
Rmd | d4b3011 | jens-daniel-mueller | 2020-11-10 | updated plain text |
html | d4b3011 | jens-daniel-mueller | 2020-11-10 | updated plain text |
html | fc70a34 | jens-daniel-mueller | 2020-11-10 | Build site. |
html | f84ad34 | jens-daniel-mueller | 2020-11-09 | Build site. |
Rmd | bc94e5e | jens-daniel-mueller | 2020-11-09 | updated legend title in map |
html | ccf6623 | jens-daniel-mueller | 2020-11-09 | Build site. |
Rmd | 41acc9e | jens-daniel-mueller | 2020-11-09 | rescales plots |
html | 01461a9 | jens-daniel-mueller | 2020-11-09 | Build site. |
Rmd | 8d5695c | jens-daniel-mueller | 2020-11-09 | rescales plots |
html | 99e3391 | jens-daniel-mueller | 2020-11-09 | Build site. |
Rmd | b3eb762 | jens-daniel-mueller | 2020-11-09 | added offset all cant values |
html | d55beda | jens-daniel-mueller | 2020-11-09 | Build site. |
Rmd | b7cfc42 | jens-daniel-mueller | 2020-11-09 | added offset plots |
html | 042043c | jens-daniel-mueller | 2020-11-09 | Build site. |
Rmd | b21ea65 | jens-daniel-mueller | 2020-11-09 | added offset plots |
html | 3bdad86 | jens-daniel-mueller | 2020-11-09 | Build site. |
Rmd | d98acd6 | jens-daniel-mueller | 2020-11-09 | included diverging maps |
html | 7c7bb6c | jens-daniel-mueller | 2020-11-09 | Build site. |
Rmd | 1d87871 | jens-daniel-mueller | 2020-11-09 | included diverging maps |
html | 68c0bbd | jens-daniel-mueller | 2020-11-09 | Build site. |
Rmd | aa35b80 | jens-daniel-mueller | 2020-11-09 | included negative Cant data |
html | 280c425 | jens-daniel-mueller | 2020-11-09 | Build site. |
Rmd | 7786901 | jens-daniel-mueller | 2020-11-09 | created comparison plots |
html | b170b79 | jens-daniel-mueller | 2020-11-03 | Build site. |
Rmd | bfa7a21 | jens-daniel-mueller | 2020-11-03 | added comparison to Gruber 2019, revised basin mask |
library(tidyverse)
library(patchwork)
library(scico)
library(scales)
library(metR)
library(kableExtra)
library(collapse)
library(marelac)
library(gt)
Following Cant estimates from this study (JDM) and Gruber 2019 (G19) are used:
# cant_3d_JDM <-
# read_csv(here::here("data/mapping/_summarized_files",
# "cant_3d.csv"))
#
# cant_3d_JDM <- cant_3d_JDM %>%
# filter(eras == "JGOFS_GO") %>%
# select(lon,
# lat,
# depth,
# basin_AIP,
# cant,
# cant_pos) %>%
# mutate(estimate = "JDM")
cant_zonal_JDM <-
read_csv(here::here("data/mapping/_summarized_files",
"cant_zonal.csv"))
cant_zonal_JDM <- cant_zonal_JDM %>%
filter(eras == "JGOFS_GO") %>%
select(lat,
depth,
basin_AIP,
cant_mean,
cant_pos_mean,
cant_sd,
cant_pos_sd)
cant_inventory_JDM <-
read_csv(here::here("data/mapping/_summarized_files",
"cant_inv.csv"))
cant_inventory_JDM <- cant_inventory_JDM %>%
rename(cant_pos_inv = cant_inv_pos)
cant_inventory_JDM <- cant_inventory_JDM %>%
filter(eras == "JGOFS_GO") %>%
select(-c(eras, basin))
# cant_3d_G19 <-
# read_csv(here::here("data/Gruber_2019/_summarized_files",
# "G19_cant_3d.csv"))
#
# cant_3d_G19 <- cant_3d_G19 %>%
# mutate(estimate = "G19") %>%
# select(-eras)
cant_inventory_G19 <-
read_csv(here::here("data/Gruber_2019/_summarized_files",
"G19_cant_inv.csv"))
cant_inventory_G19 <- cant_inventory_G19 %>%
select(-eras)
cant_zonal_G19 <-
read_csv(here::here("data/Gruber_2019/_summarized_files",
"G19_cant_zonal.csv"))
cant_zonal_G19 <- cant_zonal_G19 %>%
filter(eras == "JGOFS_GO") %>%
select(lat,
depth,
basin_AIP,
cant_mean,
cant_pos_mean,
cant_sd,
cant_pos_sd)
cant_inventory_long <- bind_rows(
cant_inventory_JDM %>% mutate(estimate = "JDM"),
cant_inventory_G19 %>% mutate(estimate = "G19")
)
cant_inventory_wide <- cant_inventory_long %>%
pivot_wider(names_from = estimate, values_from = cant_pos_inv:cant_inv) %>%
drop_na()
cant_inventory_wide <- cant_inventory_wide %>%
mutate(cant_pos_inv_delta = cant_pos_inv_JDM - cant_pos_inv_G19,
cant_inv_delta = cant_inv_JDM - cant_inv_G19)
cant_zonal_long <- bind_rows(
cant_zonal_JDM %>% mutate(estimate = "JDM"),
cant_zonal_G19 %>% mutate(estimate = "G19")
)
cant_zonal_wide <- cant_zonal_long %>%
pivot_wider(names_from = estimate, values_from = cant_mean:cant_pos_sd) %>%
drop_na()
cant_zonal_wide <- cant_zonal_wide %>%
mutate(cant_pos_mean_delta = cant_pos_mean_JDM - cant_pos_mean_G19,
cant_mean_delta = cant_mean_JDM - cant_mean_G19,
estimate = "JDM - G19")
For ease of comparison with Gruber et al (2019) we adapt their color scale, including the ranges and breaks applied in various types of visualizations.
rgb2hex <- function(r, g, b)
rgb(r, g, b, maxColorValue = 100)
cols = c(rgb2hex(95, 95, 95),
rgb2hex(0, 0, 95),
rgb2hex(100, 0, 0),
rgb2hex(100, 100, 0))
Gruber_rainbow <- colorRampPalette(cols)
rm(rgb2hex, cols)
Global Cant inventories were estimated in Pg-C, based on all vs positive only Cant estimates. Please note that here we only added cant values in the upper 3000m and do not apply additional corrections for areas not covered.
cant_inventory_budget <- cant_inventory_long %>%
mutate(surface_area = earth_surf(lat, lon),
cant_inv_grid = cant_inv*surface_area,
cant_pos_inv_grid = cant_pos_inv*surface_area) %>%
group_by(basin_AIP, estimate) %>%
summarise(cant_total = sum(cant_inv_grid)*12*1e-15,
cant_total = round(cant_total,1),
cant_pos_total = sum(cant_pos_inv_grid)*12*1e-15,
cant_pos_total = round(cant_pos_total,1)) %>%
ungroup()
cant_inventory_budget %>%
gt(rowname_col = "basin_AIP",
groupname_col = c("estimate")) %>%
summary_rows(
groups = TRUE,
fns = list(total = "sum")
)
cant_total | cant_pos_total | |
---|---|---|
G19 | ||
Atlantic | 10.8 | 11.0 |
Indian | 5.6 | 6.9 |
Pacific | 12.5 | 13.2 |
total | 28.90 | 31.10 |
JDM | ||
Atlantic | 9.9 | 10.3 |
Indian | 10.1 | 10.3 |
Pacific | 17.5 | 18.1 |
total | 37.50 | 38.70 |
rm(cant_inventory_budget)
In a first series of plots we explore the distribution of cant, taking only positive estimates into account (positive here refers to the mean cant estimate across 10 eMLR model predictions available for each grid cell). Negative values were set to zero before calculating mean sections and inventories.
Column inventory of positive cant between the surface and 3000m water depth per horizontal grid cell (lat x lon).
breaks <- c(seq(0, 16, 2), Inf)
breaks_n <- length(breaks) - 1
cant_inventory_long <- cant_inventory_long %>%
mutate(cant_pos_inv_int = cut(cant_pos_inv,
breaks,
right = FALSE))
map +
geom_raster(data = cant_inventory_long,
aes(lon, lat, fill = cant_pos_inv_int)) +
scale_fill_manual(values = Gruber_rainbow(breaks_n),
name = expression(atop(Delta~C[ant],
(mol~m^{-2})))) +
# scale_fill_scico_d(palette = "lapaz", direction = -1) +
facet_wrap(~ estimate, ncol = 1)
Column inventory of positive cant between the surface and 3000m water depth per horizontal grid cell (lat x lon).
breaks <- c(-Inf, seq(-15, 15, 3), Inf)
map +
geom_raster(data = cant_inventory_wide,
aes(lon, lat, fill = cut(cant_pos_inv_delta, breaks))) +
scale_fill_scico_d(palette = "vik", drop = FALSE,
name = expression(atop(Delta~Delta~C[ant],
(mol~m^{-2})))) +
facet_wrap(~ "JDM - G19", ncol = 1)
df <- cant_zonal_long
breaks <- c(seq(0, 18, 1), Inf)
var <- "cant_pos_mean"
legend_title <- expression(atop(Delta * C[ant],
(mu * mol ~ kg ^ {-1})))
# i_basin_AIP <- unique(df$basin_AIP)[1]
# i_estimate <- unique(df$estimate)[1]
for (i_basin_AIP in unique(df$basin_AIP)) {
for (i_estimate in unique(df$estimate)) {
print(
section_zonal_layered_continous(
df,
i_basin_AIP = i_basin_AIP,
i_estimate = i_estimate,
var,
breaks,
legend_title
)
)
}
}
rm(df, var, breaks, legend_title, breaks_n)
df <- cant_zonal_wide
breaks <- c(-Inf,seq(-16,16,2),Inf)
var <- "cant_pos_mean_delta"
legend_title <- expression(atop(Offset~Delta * C[ant],
(mu * mol ~ kg ^ {-1})))
i_basin_AIP <- unique(df$basin_AIP)[1]
i_estimate <- unique(df$estimate)[1]
for (i_basin_AIP in unique(df$basin_AIP)) {
print(
section_zonal_layered_divergent(
df,
i_basin_AIP = i_basin_AIP,
i_estimate = i_estimate,
var,
breaks,
legend_title
)
)
}
rm(df, var, breaks, legend_title)
In a first series of plots we explore the distribution of cant, taking only positive estimates into account (positive here refers to the mean cant estimate across 10 eMLR model predictions available for each grid cell). Negative values were set to zero before calculating mean sections and inventories.
Column inventory of Cant (including positive and negative values) between the surface and 3000m water depth per horizontal grid cell (lat x lon).
breaks <- c(-Inf,seq(-16,16,2),Inf)
map +
geom_raster(data = cant_inventory_long,
aes(lon, lat, fill = cut(cant_inv, breaks))) +
scale_fill_scico_d(palette = "vik", drop = FALSE) +
facet_wrap(~ estimate, labeller = label_both, ncol = 1)
breaks <- c(-Inf,seq(-15,15,3),Inf)
map +
geom_raster(data = cant_inventory_wide,
aes(lon, lat, fill = cut(cant_inv_delta, breaks))) +
scale_fill_scico_d(palette = "vik", drop = FALSE,
name = expression(atop(Delta~C[ant],
"JDM-G19")))
breaks <- c(-Inf,seq(-16,16,2),Inf)
breaks_n <- length(breaks) - 1
zonal_section <- function(df, i_basin_AIP, i_estimate, var) {
# df <- cant_zonal_long
# i_basin_AIP <- unique(cant_zonal_long$basin_AIP)[1]
# i_estimate <- unique(cant_zonal_long$estimate)[1]
# var <- "cant_mean"
name_var <- var
var <- sym(var)
lat_max <- max(df$lat)
lat_min <- min(df$lat)
df_sub <- df %>%
filter(basin_AIP == i_basin_AIP,
estimate == i_estimate)
surface <- df_sub %>%
ggplot(aes(lat, depth, z = !!var)) +
geom_contour_filled(breaks = breaks) +
scale_fill_scico_d(palette = "vik", drop = FALSE) +
coord_cartesian(expand = 0,
ylim = c(500, 0),
xlim = c(lat_min, lat_max)) +
scale_y_reverse() +
scale_x_continuous(breaks = seq(-100,100,20)) +
theme(
axis.title.x = element_blank(),
axis.text.x = element_blank(),
axis.ticks.x = element_blank()
) +
labs(y = "Depth (m)",
title = paste("Basin:", i_basin_AIP))
deep <- df_sub %>%
ggplot(aes(lat, depth, z = !!var)) +
geom_contour_filled(breaks = breaks) +
scale_fill_scico_d(palette = "vik", drop = FALSE) +
scale_y_reverse() +
scale_x_continuous(breaks = seq(-100,100,20)) +
coord_cartesian(expand = 0,
ylim = c(3000, 500),
xlim = c(lat_min, lat_max)) +
labs(x = "latitude (°N)", y = "Depth (m)")
surface / deep +
plot_layout(guides = "collect")
}
for (i_basin_AIP in unique(cant_zonal_long$basin_AIP)) {
for (i_estimate in unique(cant_zonal_long$estimate)) {
print(zonal_section(cant_zonal_long,
i_basin_AIP = i_basin_AIP,
i_estimate = i_estimate,
"cant_mean"))
}
}
rm(breaks, breaks_n)
breaks <- c(-Inf,seq(-15,15,3),Inf)
breaks_n <- length(breaks) - 1
zonal_section <- function(df, i_basin_AIP, i_estimate, var) {
df <- cant_zonal_wide
i_basin_AIP <- unique(cant_zonal_long$basin_AIP)[1]
var <- "cant_mean_delta"
name_var <- var
var <- sym(var)
lat_max <- max(df$lat)
lat_min <- min(df$lat)
df_sub <- df %>%
filter(basin_AIP == i_basin_AIP)
surface <- df_sub %>%
ggplot(aes(lat, depth, z = !!var)) +
geom_contour_filled(breaks = breaks) +
scale_fill_scico_d(palette = "vik", drop = FALSE) +
coord_cartesian(expand = 0,
ylim = c(500, 0),
xlim = c(lat_min, lat_max)) +
scale_y_reverse() +
scale_x_continuous(breaks = seq(-100,100,20)) +
theme(
axis.title.x = element_blank(),
axis.text.x = element_blank(),
axis.ticks.x = element_blank()
) +
labs(y = "Depth (m)",
title = paste("Basin:", i_basin_AIP))
deep <- df_sub %>%
ggplot(aes(lat, depth, z = !!var)) +
geom_contour_filled(breaks = breaks) +
scale_fill_scico_d(palette = "vik", drop = FALSE) +
scale_y_reverse() +
scale_x_continuous(breaks = seq(-100,100,20)) +
coord_cartesian(expand = 0,
ylim = c(3000, 500),
xlim = c(lat_min, lat_max)) +
labs(x = "latitude (°N)", y = "Depth (m)")
surface / deep +
plot_layout(guides = "collect")
}
for (i_basin_AIP in unique(cant_zonal_long$basin_AIP)) {
print(zonal_section(cant_zonal_wide,
i_basin_AIP = i_basin_AIP,
"cant_mean_delta"))
}
rm(breaks, breaks_n)
Deviations between this study and the results by Gruber et al (2019), short G19, for the same period, might be attributable to following known differences in the implementation of the eMLR(C*) method:
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-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] gt_0.2.2 marelac_2.1.10 shape_1.4.4 collapse_1.3.2
[5] kableExtra_1.1.0 metR_0.7.0 scales_1.1.1 scico_1.2.0
[9] patchwork_1.0.1 forcats_0.5.0 stringr_1.4.0 dplyr_1.0.0
[13] purrr_0.3.4 readr_1.3.1 tidyr_1.1.0 tibble_3.0.3
[17] ggplot2_3.3.2 tidyverse_1.3.0 workflowr_1.6.2
loaded via a namespace (and not attached):
[1] fs_1.4.2 lubridate_1.7.9 gsw_1.0-5 webshot_0.5.2
[5] httr_1.4.2 rprojroot_1.3-2 tools_4.0.2 backports_1.1.8
[9] R6_2.4.1 DBI_1.1.0 colorspace_1.4-1 withr_2.2.0
[13] tidyselect_1.1.0 compiler_4.0.2 git2r_0.27.1 cli_2.0.2
[17] rvest_0.3.6 xml2_1.3.2 isoband_0.2.2 sandwich_2.5-1
[21] labeling_0.3 sass_0.2.0 checkmate_2.0.0 digest_0.6.25
[25] rmarkdown_2.3 oce_1.2-0 pkgconfig_2.0.3 htmltools_0.5.0
[29] dbplyr_1.4.4 rlang_0.4.7 readxl_1.3.1 rstudioapi_0.11
[33] generics_0.0.2 farver_2.0.3 zoo_1.8-8 jsonlite_1.7.0
[37] magrittr_1.5 Formula_1.2-3 Matrix_1.2-18 Rcpp_1.0.5
[41] munsell_0.5.0 fansi_0.4.1 lifecycle_0.2.0 stringi_1.4.6
[45] whisker_0.4 yaml_2.2.1 grid_4.0.2 blob_1.2.1
[49] parallel_4.0.2 promises_1.1.1 crayon_1.3.4 lattice_0.20-41
[53] haven_2.3.1 hms_0.5.3 seacarb_3.2.13 knitr_1.30
[57] pillar_1.4.6 reprex_0.3.0 glue_1.4.1 evaluate_0.14
[61] data.table_1.13.0 modelr_0.1.8 vctrs_0.3.2 httpuv_1.5.4
[65] testthat_2.3.2 cellranger_1.1.0 gtable_0.3.0 assertthat_0.2.1
[69] xfun_0.16 xtable_1.8-4 broom_0.7.0 lfe_2.8-5.1
[73] later_1.1.0.1 viridisLite_0.3.0 ellipsis_0.3.1 here_0.1