Last updated: 2020-12-19

Checks: 7 0

Knit directory: emlr_mod_v_XXX/

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 b5fedce. 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/

Unstaged changes:
    Modified:   analysis/_site.yml
    Modified:   code/Workflowr_project_managment.R
    Deleted:    code/old_cstar_adjustment.Rmd

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.Rmd) and HTML (docs/analysis_this_study.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 b5fedce jens-daniel-mueller 2020-12-19 first build after creating model template
Rmd 8e8abf5 Jens Müller 2020-12-18 Initial commit

1 Data sources

Cant estimates from this sensitivity case:

  • Mean and SD per grid cell (lat, lon, depth)
  • Zonal mean and SD (basin, lat, depth)
  • Inventories (lat, lon)
cant_3d <-
  read_csv(paste(path_version_data,
                 "cant_3d.csv",
                 sep = ""))

cant_zonal <-
  read_csv(paste(path_version_data,
                 "cant_zonal.csv",
                 sep = ""))

cant_predictor_zonal <-
  read_csv(paste(path_version_data,
                 "cant_predictor_zonal.csv",
                 sep = ""))

cant_inv <-
  read_csv(paste(path_version_data,
                 "cant_inv.csv",
                 sep = ""))

Target variable (cstar_tref) estimates from this sensitivity case:

  • Mean and SD per grid cell (lat, lon, depth)
  • Zonal mean and SD (basin, lat, depth)
target_3d <-
  read_csv(paste(path_version_data,
                 "target_3d.csv",
                 sep = ""))

target_zonal <-
  read_csv(paste(path_version_data,
                 "target_zonal.csv",
                 sep = ""))

Cleaned GLODAPv2_2020 file as used in this sensitivity case

GLODAP <-
  read_csv(paste(
    path_version_data,
    "GLODAPv2.2020_MLR_fitting_ready.csv",
    sep = ""
  ))

2 Cant budgets

Global Cant inventories were estimated in units of Pg C. Please note that here we added Cant (all vs postitive only) values and do not apply additional corrections for areas not covered.

cant_inv_budget <- cant_inv %>% 
  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, eras, inv_depth) %>% 
  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()

2.1 Standard depth

Results integrated over the upper 3000 m

cant_inv_budget %>%
  filter(inv_depth == params_global$inventory_depth_standard) %>% 
  gt(rowname_col = "basin_AIP",
     groupname_col = c("eras", "inv_depth"),
     row_group.sep = " | Depth: ") %>% 
  summary_rows(
    groups = TRUE,
    fns = list(total = "sum")
  )
cant_total cant_pos_total
1982-1999 --> 2000-2012 | Depth: 3000
Atlantic 9.9 10.4
Indian 13.3 13.5
Pacific 12.6 13.4
total 35.80 37.30
2000-2012 --> 2013-2019 | Depth: 3000
Atlantic 5.1 6.5
Indian 2.1 5.7
Pacific 13.9 14.1
total 21.10 26.30

2.2 Other depths

Results integrated over the upper 100, 500, 1000, 3000, 10^{4} m

cant_inv_budget %>%
  filter(inv_depth != params_global$inventory_depth_standard) %>% 
  gt(rowname_col = "basin_AIP",
     groupname_col = c("eras", "inv_depth"),
     row_group.sep = " | Depth: ") %>% 
  summary_rows(
    groups = TRUE,
    fns = list(total = "sum")
  )
cant_total cant_pos_total
1982-1999 --> 2000-2012 | Depth: 100
Atlantic 1.4 1.4
Indian 1.1 1.2
Pacific 2.6 2.7
total 5.10 5.30
1982-1999 --> 2000-2012 | Depth: 500
Atlantic 4.2 4.3
Indian 4.7 4.8
Pacific 8.5 8.7
total 17.40 17.80
1982-1999 --> 2000-2012 | Depth: 1000
Atlantic 5.5 5.8
Indian 7.6 7.7
Pacific 10.6 10.9
total 23.70 24.40
1982-1999 --> 2000-2012 | Depth: 10000
Atlantic 12.9 13.6
Indian 14.7 15.1
Pacific 13.4 15.1
total 41.00 43.80
2000-2012 --> 2013-2019 | Depth: 100
Atlantic 0.7 0.9
Indian 0.9 0.9
Pacific 1.9 1.9
total 3.50 3.70
2000-2012 --> 2013-2019 | Depth: 500
Atlantic 3.2 3.5
Indian 1.8 2.6
Pacific 6.3 6.3
total 11.30 12.40
2000-2012 --> 2013-2019 | Depth: 1000
Atlantic 4.7 5.0
Indian 2.0 3.8
Pacific 9.2 9.2
total 15.90 18.00
2000-2012 --> 2013-2019 | Depth: 10000
Atlantic 6.3 8.6
Indian 3.5 7.1
Pacific 16.7 17.0
total 26.50 32.70
rm(cant_inv_budget)

The following analysis is restricted to the standard inventory depth of 3000 m.

cant_inv <- cant_inv %>%
  filter(inv_depth == params_global$inventory_depth_standard)

3 Cant - positive

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 MLR model predictions available for each grid cell). Negative values were set to zero before calculating mean sections and inventories.

3.1 Zonal mean sections

# i_basin_AIP <- unique(cant_zonal$basin_AIP)[2]
# i_eras <- unique(cant_zonal$eras)[1]

for (i_basin_AIP in unique(cant_zonal$basin_AIP)) {
  for (i_eras in unique(cant_zonal$eras)) {
   
     print(
      p_section_zonal(
        df = cant_zonal %>%
          filter(basin_AIP == i_basin_AIP,
                 eras == i_eras),
        var = "cant_pos_mean",
        subtitle_text =
          paste("Basin:", i_basin_AIP, "| eras:", i_eras))
    )
    
  }
}

3.2 Isoneutral slab distribution

Mean of positive cant within each horizontal grid cell (lon x lat) per isoneutral slab.

Please note that:

  • density slabs covering values >28.1 occur by definition only either in the Atlantic or Indo-Pacific basin
  • gaps in the maps represent areas where (thin) density layers fit between discrete depth levels used for mapping
cant_gamma_maps <- m_cant_slab(cant_3d)

cant_gamma_maps <- cant_gamma_maps %>% 
  arrange(gamma_slab, eras)
# i_eras <- unique(cant_gamma_maps$eras)[1]
# i_gamma_slab <- unique(cant_gamma_maps$gamma_slab)[1]

for (i_eras in unique(cant_gamma_maps$eras)) {
  for (i_gamma_slab in unique(cant_gamma_maps$gamma_slab)) {
    print(
      p_map_cant_slab(
        df = cant_gamma_maps %>%
          filter(eras == i_eras,
                 gamma_slab == i_gamma_slab),
        subtitle_text = paste(
          "Eras:", i_eras,
          "| Neutral density:", i_gamma_slab)
        )
    )
    
  }
}

3.3 Inventory map

Column inventory of positive cant between the surface and m water depth per horizontal grid cell (lat x lon).

# i_eras <- unique(cant_inv$eras)[1]

for (i_eras in unique(cant_inv$eras)) {
  
  print(
    p_map_cant_inv(
      df = cant_inv %>% filter(eras == i_eras),
      var = "cant_pos_inv",
      subtitle_text = paste("Eras:", i_eras))
  )
  
}

3.4 Global sections

for (i_eras in unique(cant_3d$eras)) {
  print(
    p_section_global(
      df = cant_3d %>% filter(eras == i_eras),
      var = "cant_pos",
      subtitle_text = paste("Eras:", i_eras)
    )
  )
  
}

4 Cant - all

In a second series of plots we explore the distribution of all Cant, taking positive and negative estimates into account.

4.1 Zonal mean sections

# i_eras <- unique(cant_zonal$eras)[1]
# i_basin_AIP <- unique(cant_zonal$basin_AIP)[1]

for (i_basin_AIP in unique(cant_zonal$basin_AIP)) {
  for (i_eras in unique(cant_zonal$eras)) {
    print(
      p_section_zonal(
        df = cant_zonal %>%
          filter(basin_AIP == i_basin_AIP,
                 eras == i_eras),
        var = "cant_mean",
        gamma = "gamma_mean",
        breaks = params_global$breaks_cant,
        col = "divergent",
        subtitle_text =
          paste("Basin:", i_basin_AIP, "| eras:", i_eras))
    )
    
  }
}

4.2 Isoneutral slab distribution

Mean of all Cant within each horizontal grid cell (lon x lat) per isoneutral slab.

Please note that:

  • density slabs covering values >28.1 occur by definition only either in the Atlantic or Indo-Pacific basin
  • gaps in the maps represent areas where (thin) density layers fit between discrete depth levels used for mapping
# i_eras <- unique(cant_gamma_maps$eras)[1]
# i_gamma_slab <- unique(cant_gamma_maps$gamma_slab)[5]

for (i_eras in unique(cant_gamma_maps$eras)) {
  for (i_gamma_slab in unique(cant_gamma_maps$gamma_slab)) {
    print(
      p_map_cant_slab(
        df = cant_gamma_maps %>%
          filter(eras == i_eras,
                 gamma_slab == i_gamma_slab),
        var = "cant",
        col = "divergent",
        subtitle_text = paste(
          "Eras:", i_eras,
          "| Neutral density:", i_gamma_slab))
    )
    
  }
}

4.3 Inventory map

Column inventory of all Cant between the surface and 3000m water depth per horizontal grid cell (lat x lon).

# i_eras <- unique(cant_inv$eras)[1]

for (i_eras in unique(cant_inv$eras)) {
  
  print(
    p_map_cant_inv(
      df = cant_inv %>% filter(eras == i_eras),
      var = "cant_inv",
      col = "divergent",
      subtitle_text = paste("Eras:", i_eras))
  )
  
}

5 Cant variability

5.1 Across models

Standard deviation across Cant from all MLR models was calculate for each grid cell (XYZ). The zonal mean of this standard deviation should reflect the uncertainty associated to the predictor selection within each slab and era.

# i_eras <- unique(cant_zonal$eras)[1]
# i_basin_AIP <- unique(cant_zonal$basin_AIP)[2]

for (i_basin_AIP in unique(cant_zonal$basin_AIP)) {
  for (i_eras in unique(cant_zonal$eras)) {
    print(
      p_section_zonal(
        df = cant_zonal %>%
          filter(basin_AIP == i_basin_AIP,
                 eras == i_eras),
        var = "cant_sd_mean",
        gamma = "gamma_mean",
        legend_title = "sd",
        title_text = "Zonal mean section of SD across models",
        subtitle_text =
          paste("Basin:", i_basin_AIP, "| eras:", i_eras))
    )
    
  }
}

5.2 Across basins

Standard deviation of mean cant values was calculate across all longitudes. This standard deviation should reflect the zonal variability of cant within the basin and era.

# i_eras <- unique(cant_zonal$eras)[1]
# i_basin_AIP <- unique(cant_zonal$basin_AIP)[2]

for (i_basin_AIP in unique(cant_zonal$basin_AIP)) {
  for (i_eras in unique(cant_zonal$eras)) {
    print(
      p_section_zonal(
        df = cant_zonal %>%
          filter(basin_AIP == i_basin_AIP,
                 eras == i_eras),
        var = "cant_sd",
        gamma = "gamma_mean",
        legend_title = "sd",
        title_text = "Zonal mean section of Cant SD",
        subtitle_text =
          paste("Basin:", i_basin_AIP, "| eras:", i_eras))
    )
    
  }
}

5.3 Correlation

5.3.1 Cant vs model SD

5.3.1.1 Era vs basin

cant_3d %>% 
  ggplot(aes(cant, cant_sd)) +
  geom_vline(xintercept = 0) +
  geom_hline(yintercept = 10) +
  geom_bin2d() +
  scale_fill_viridis_c(option = "magma",
                       direction = -1,
                       trans = "log10",
                       name = "log10(n)") +
  facet_grid(basin_AIP ~ eras)

5.3.1.2 Basin vs gamma

cant_3d %>% 
  ggplot(aes(cant, cant_sd)) +
  geom_vline(xintercept = 0) +
  geom_hline(yintercept = 10) +
  geom_bin2d() +
  scale_fill_viridis_c(option = "magma",
                       direction = -1,
                       trans = "log10",
                       name = "log10(n)") +
  facet_grid(gamma_slab ~ basin_AIP)

5.3.2 Cant vs regional SD

5.3.2.1 Era vs basin

cant_zonal %>% 
  ggplot(aes(cant_mean, cant_sd)) +
  geom_vline(xintercept = 0) +
  geom_hline(yintercept = 10) +
  geom_bin2d() +
  scale_fill_viridis_c(option = "magma",
                       direction = -1,
                       trans = "log10",
                       name = "log10(n)") +
  facet_grid(basin_AIP ~ eras)

5.3.2.2 Era vs basin

cant_zonal %>% 
  ggplot(aes(cant_mean, cant_sd)) +
  geom_vline(xintercept = 0) +
  geom_hline(yintercept = 10) +
  geom_bin2d() +
  scale_fill_viridis_c(option = "magma",
                       direction = -1,
                       trans = "log10",
                       name = "log10(n)") +
  facet_grid(gamma_slab ~ basin_AIP)

6 Cant - predictor contribution

for (i_var in paste("cant",
                    c("intercept", params_local$MLR_predictors),
                    sep = "_")) {

  print(
    p_section_zonal_divergent_gamma_eras_basin(df = cant_predictor_zonal,
                                               var = i_var,
                                               gamma = "gamma")
  )
  
}

rm(i_var)

7 Neutral density

7.1 Slab depth

The plot below shows the depths of individual gamma slabs (color) together with the observations available in the respective slab.

Please note that:

  • density slabs covering values >28.1 occur by definition only either in the Atlantic or Indo-Pacific basin
GLODAP_obs_coverage <- GLODAP %>% 
  count(lat, lon, gamma_slab, era)

map +
  geom_raster(data = cant_gamma_maps,
              aes(lon, lat, fill = depth_max)) +
  geom_raster(data = GLODAP_obs_coverage,
              aes(lon, lat), fill = "red") +
  facet_grid(gamma_slab ~ era) +
  scale_fill_viridis_c(direction = -1) +
  theme(axis.ticks = element_blank(),
        axis.text = element_blank(),
        legend.position = "top")

rm(GLODAP_obs_coverage)

8 Target variable

The predicted target variable (cstar_tref in this sensitivity case) is based on fitted MLRs and climatological fields of predictor variables, and calculated for each era.

8.1 Zonal mean sections

slab_breaks <- c(params_local$slabs_Atl[1:12], Inf)

target_zonal %>%
  ggplot(aes(lat, depth,
             z = !!sym(
               paste(params_local$MLR_target, "mean", sep = "_")
             ))) +
  geom_contour_filled(bins = 11) +
  scale_fill_viridis_d(name = params_local$MLR_target) +
  geom_contour(aes(lat, depth, z = gamma_mean),
               breaks = slab_breaks,
               col = "white") +
  geom_text_contour(
    aes(lat, depth, z = gamma_mean),
    breaks = slab_breaks,
    col = "white",
    skip = 1
  ) +
  scale_y_reverse() +
  coord_cartesian(expand = 0,
                  ylim = c(params_global$plotting_depth, 0)) +
  scale_x_continuous(breaks = seq(-100, 100, 20)) +
  guides(fill = guide_colorsteps(barheight = unit(10, "cm"))) +
  facet_grid(basin_AIP ~ era)

rm(slab_breaks)

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: openSUSE Leap 15.1

Matrix products: default
BLAS:   /usr/local/R-4.0.3/lib64/R/lib/libRblas.so
LAPACK: /usr/local/R-4.0.3/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] gt_0.2.2         kableExtra_1.3.1 marelac_2.1.10   shape_1.4.5     
 [5] scales_1.1.1     metR_0.9.0       scico_1.2.0      patchwork_1.1.0 
 [9] collapse_1.4.2   forcats_0.5.0    stringr_1.4.0    dplyr_1.0.2     
[13] purrr_0.3.4      readr_1.4.0      tidyr_1.1.2      tibble_3.0.4    
[17] ggplot2_3.3.2    tidyverse_1.3.0  workflowr_1.6.2 

loaded via a namespace (and not attached):
 [1] fs_1.5.0                 lubridate_1.7.9          gsw_1.0-5               
 [4] webshot_0.5.2            httr_1.4.2               rprojroot_2.0.2         
 [7] tools_4.0.3              backports_1.1.10         R6_2.5.0                
[10] DBI_1.1.0                colorspace_2.0-0         withr_2.3.0             
[13] tidyselect_1.1.0         compiler_4.0.3           git2r_0.27.1            
[16] cli_2.2.0                rvest_0.3.6              xml2_1.3.2              
[19] isoband_0.2.2            labeling_0.4.2           sass_0.2.0              
[22] checkmate_2.0.0          digest_0.6.27            rmarkdown_2.5           
[25] oce_1.2-0                pkgconfig_2.0.3          htmltools_0.5.0         
[28] dbplyr_1.4.4             rlang_0.4.9              readxl_1.3.1            
[31] rstudioapi_0.13          farver_2.0.3             generics_0.0.2          
[34] jsonlite_1.7.1           magrittr_2.0.1           Matrix_1.2-18           
[37] Rcpp_1.0.5               munsell_0.5.0            fansi_0.4.1             
[40] lifecycle_0.2.0          stringi_1.5.3            whisker_0.4             
[43] yaml_2.2.1               plyr_1.8.6               grid_4.0.3              
[46] blob_1.2.1               parallel_4.0.3           promises_1.1.1          
[49] crayon_1.3.4             lattice_0.20-41          haven_2.3.1             
[52] hms_0.5.3                seacarb_3.2.14           knitr_1.30              
[55] pillar_1.4.7             reprex_0.3.0             glue_1.4.2              
[58] evaluate_0.14            RcppArmadillo_0.10.1.2.0 data.table_1.13.2       
[61] modelr_0.1.8             vctrs_0.3.5              httpuv_1.5.4            
[64] testthat_3.0.0           cellranger_1.1.0         gtable_0.3.0            
[67] assertthat_0.2.1         xfun_0.18                broom_0.7.2             
[70] RcppEigen_0.3.3.7.0      later_1.1.0.1            viridisLite_0.3.0       
[73] memoise_1.1.0            ellipsis_0.3.1           here_0.1