Last updated: 2022-11-06

Checks: 7 0

Knit directory: emlr_obs_analysis/analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). 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(20210412) 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 820fff8. 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/
    Ignored:    output/other/
    Ignored:    output/presentation/
    Ignored:    output/publication/

Untracked files:
    Untracked:  code/visualization_equal_earth.R
    Untracked:  code/visualization_equal_earth_cleaned.R
    Untracked:  code/visualization_equal_earth_cleaned_jdm.R

Unstaged changes:
    Modified:   analysis/_site.yml
    Modified:   code/Workflowr_project_managment.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/results_publication.Rmd) and HTML (docs/results_publication.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 7275091 jens-daniel-mueller 2022-11-05 Build site.
Rmd ba55b15 jens-daniel-mueller 2022-11-05 include run with C*(P only)
html 99610ed jens-daniel-mueller 2022-11-01 Build site.
Rmd c972beb jens-daniel-mueller 2022-11-01 updated reoccupation run
html 7060801 jens-daniel-mueller 2022-10-31 Build site.
html ecb84c1 jens-daniel-mueller 2022-10-30 Build site.
html 2345935 jens-daniel-mueller 2022-10-29 Build site.
html 0b40366 jens-daniel-mueller 2022-10-26 Build site.
Rmd 0465788 jens-daniel-mueller 2022-10-26 implemented additive uncertainty assesment
html 91052ae jens-daniel-mueller 2022-10-20 Build site.
Rmd 33486a1 jens-daniel-mueller 2022-10-20 updated plots
html 084a41c jens-daniel-mueller 2022-10-13 Build site.
Rmd ffef558 jens-daniel-mueller 2022-10-13 land sink assesment
html 46c163a jens-daniel-mueller 2022-10-10 Build site.
Rmd 78161f9 jens-daniel-mueller 2022-10-10 revised figures
html 8105380 jens-daniel-mueller 2022-10-07 Build site.
Rmd d663118 jens-daniel-mueller 2022-10-07 penetration depth analysis
html e93fdfd jens-daniel-mueller 2022-09-23 Build site.
Rmd f01db23 jens-daniel-mueller 2022-09-23 added uncertainty to dcant maps and section
html 8dc5a3b jens-daniel-mueller 2022-09-09 Build site.
Rmd 25bff3d jens-daniel-mueller 2022-09-09 added global section location to maps
html 77e6a80 jens-daniel-mueller 2022-09-08 Build site.
Rmd 188dc63 jens-daniel-mueller 2022-09-08 added uncertainty to global section
html 7cf954e jens-daniel-mueller 2022-09-08 Build site.
Rmd 6f53c28 jens-daniel-mueller 2022-09-08 column inventory uncertainty stippling added
html 051b911 jens-daniel-mueller 2022-09-07 Build site.
Rmd c87415f jens-daniel-mueller 2022-09-07 testrun integration 3000
html 75bd58c jens-daniel-mueller 2022-09-07 Build site.
Rmd 1024099 jens-daniel-mueller 2022-09-07 testrun integration 1000
html 1c6de0d jens-daniel-mueller 2022-09-07 Build site.
Rmd 4106aa4 jens-daniel-mueller 2022-09-07 testrun integration 10000
html 5ca8778 jens-daniel-mueller 2022-09-07 Build site.
Rmd 784849d jens-daniel-mueller 2022-09-07 included uncertainty assesment for column inventories
html 4eb9ed2 jens-daniel-mueller 2022-08-29 Build site.
html 392f3d7 jens-daniel-mueller 2022-08-29 Build site.
Rmd 282421f jens-daniel-mueller 2022-08-29 added contour line to global section
html c975141 jens-daniel-mueller 2022-08-29 Build site.
Rmd 8f5c3c2 jens-daniel-mueller 2022-08-29 finalized global section
html cf69673 jens-daniel-mueller 2022-08-29 Build site.
html 4810db6 jens-daniel-mueller 2022-08-26 Build site.
Rmd 88ce2d9 jens-daniel-mueller 2022-08-26 added global section
html 74dca9d jens-daniel-mueller 2022-08-17 Build site.
Rmd 37ab61f jens-daniel-mueller 2022-08-17 added adjustment delta map
html ec4f1d0 jens-daniel-mueller 2022-08-11 Build site.
Rmd d1cd39a jens-daniel-mueller 2022-08-11 revised figure aspect ratio
html 78dbb27 jens-daniel-mueller 2022-08-11 Build site.
Rmd 2155209 jens-daniel-mueller 2022-08-11 rebuild with 3 basin separation as standard case
html 302d289 jens-daniel-mueller 2022-08-11 Build site.
Rmd 77719db jens-daniel-mueller 2022-08-11 rebuild with 5 basin separation as standard case
html 318fefe jens-daniel-mueller 2022-08-11 Build site.
Rmd 60dae4b jens-daniel-mueller 2022-08-11 delta dcant budget analysis
html 5b77c4f jens-daniel-mueller 2022-08-10 Build site.
Rmd c25333a jens-daniel-mueller 2022-08-10 bias sections and maps added
html 9c3be27 jens-daniel-mueller 2022-08-09 Build site.
Rmd a940880 jens-daniel-mueller 2022-08-09 improve delta dcant bias assesment
html a691b29 jens-daniel-mueller 2022-08-09 Build site.
Rmd d136a86 jens-daniel-mueller 2022-08-09 include delta dcant bias assesment
html 910f96e jens-daniel-mueller 2022-08-08 Build site.
Rmd e064958 jens-daniel-mueller 2022-08-08 include bias assesment
html e99640e jens-daniel-mueller 2022-07-29 Build site.
html f68fcfa jens-daniel-mueller 2022-07-26 Build site.
Rmd abec0de jens-daniel-mueller 2022-07-26 changed color scale back
html f2615fb jens-daniel-mueller 2022-07-26 Build site.
Rmd 8da318e jens-daniel-mueller 2022-07-26 changed color scale
html 99a82db jens-daniel-mueller 2022-07-25 Build site.
Rmd 1d6985d jens-daniel-mueller 2022-07-25 stat analysis of layer budgets and CIs
html 4af29f9 jens-daniel-mueller 2022-07-24 Build site.
Rmd b2c4ff6 jens-daniel-mueller 2022-07-24 revised GCB plot
html e2adac6 jens-daniel-mueller 2022-07-22 Build site.
Rmd a9c8af4 jens-daniel-mueller 2022-07-22 revised section plots and tables
html 9bbc6a4 jens-daniel-mueller 2022-07-20 Build site.
Rmd f937de2 jens-daniel-mueller 2022-07-20 revised plots
html 0c6db30 jens-daniel-mueller 2022-07-20 Build site.
Rmd a42e52d jens-daniel-mueller 2022-07-20 revised plots
html b18b250 jens-daniel-mueller 2022-07-20 Build site.
Rmd 36691bf jens-daniel-mueller 2022-07-20 revised plots
html a80b59b jens-daniel-mueller 2022-07-20 Build site.
Rmd f9c0545 jens-daniel-mueller 2022-07-20 revised budget stats
html fea41c1 jens-daniel-mueller 2022-07-20 Build site.
Rmd b27e42f jens-daniel-mueller 2022-07-20 rerun with corrected Canyon-B talk gap-filling in standard case
html 9ce772d jens-daniel-mueller 2022-07-19 Build site.
Rmd aaf37cf jens-daniel-mueller 2022-07-19 coverage maps with gap filling
html d803308 jens-daniel-mueller 2022-07-19 Build site.
Rmd 933285c jens-daniel-mueller 2022-07-19 revised plots
html b1f7ab3 jens-daniel-mueller 2022-07-18 Build site.
Rmd ab5220b jens-daniel-mueller 2022-07-18 revised budget over atm pCO2 plot
html d2ae54c jens-daniel-mueller 2022-07-18 Build site.
Rmd 85f482c jens-daniel-mueller 2022-07-18 include scaled Sabine data for budgets
html 2695085 jens-daniel-mueller 2022-07-17 Build site.
Rmd 8624c93 jens-daniel-mueller 2022-07-17 use global output from MLR basins
html 535196a jens-daniel-mueller 2022-07-17 Build site.
html d20faeb jens-daniel-mueller 2022-07-17 Build site.
Rmd b6ef86b jens-daniel-mueller 2022-07-17 revised budget plots
html 0160c40 jens-daniel-mueller 2022-07-16 Build site.
Rmd d2b1090 jens-daniel-mueller 2022-07-16 cleaned code
html efa414b jens-daniel-mueller 2022-07-16 Build site.
Rmd e84b169 jens-daniel-mueller 2022-07-16 added bias global analysis
html 7267b08 jens-daniel-mueller 2022-07-16 Build site.
Rmd b91f619 jens-daniel-mueller 2022-07-16 analysed dcant budget stats
html 08c00b4 jens-daniel-mueller 2022-07-16 Build site.
html 692c937 jens-daniel-mueller 2022-07-16 Build site.
html afb27ad jens-daniel-mueller 2022-07-15 Build site.
Rmd 53e63d5 jens-daniel-mueller 2022-07-15 plot no surface data equi
html b492b46 jens-daniel-mueller 2022-07-15 Build site.
Rmd 31f29fe jens-daniel-mueller 2022-07-15 plot decadal sink trends as boxplots
html bd24a0f jens-daniel-mueller 2022-07-15 Build site.
Rmd efbb1dc jens-daniel-mueller 2022-07-15 include no surface equi cases
html 022fd60 jens-daniel-mueller 2022-07-14 Build site.
Rmd 5a9e419 jens-daniel-mueller 2022-07-14 implemented beta budget analysis
Rmd d2092c1 jens-daniel-mueller 2022-07-14 implemented beta budget analysis
html f1d7f80 jens-daniel-mueller 2022-07-13 Build site.
Rmd 6811ae4 jens-daniel-mueller 2022-07-13 refined profil plots
html ea46812 jens-daniel-mueller 2022-07-13 Build site.
Rmd defdcfe jens-daniel-mueller 2022-07-13 additional analyis
html 17cd1d1 jens-daniel-mueller 2022-07-13 Build site.
Rmd 1bf1708 jens-daniel-mueller 2022-07-13 rerun reoccupation
html 26e9496 jens-daniel-mueller 2022-07-12 Build site.
Rmd 5d121f0 jens-daniel-mueller 2022-07-12 applied dcant scaling and improved ensemble member analysis
html 8fb595c jens-daniel-mueller 2022-07-12 Build site.
Rmd e2d97ef jens-daniel-mueller 2022-07-12 excluded no adjustment from ensemble
html 003b161 jens-daniel-mueller 2022-07-12 Build site.
Rmd 54a0d14 jens-daniel-mueller 2022-07-12 added cruise based adjustment
html b44c72a jens-daniel-mueller 2022-07-03 Build site.
html 37f56b3 jens-daniel-mueller 2022-07-01 Build site.
Rmd 8c4a9f8 jens-daniel-mueller 2022-07-01 added basin separation analysis
html 232909e jens-daniel-mueller 2022-07-01 Build site.
Rmd 7f85db3 jens-daniel-mueller 2022-07-01 added basin separation analysis
html df21d31 jens-daniel-mueller 2022-07-01 Build site.
Rmd 2bbfba0 jens-daniel-mueller 2022-07-01 rebuild
html 6be73e0 jens-daniel-mueller 2022-06-30 Build site.
Rmd 6e173bf jens-daniel-mueller 2022-06-30 updated regional budget plots
html 6e173bf jens-daniel-mueller 2022-06-30 updated regional budget plots
html 8ab4a87 jens-daniel-mueller 2022-06-29 Build site.
Rmd d8c7cb9 jens-daniel-mueller 2022-06-29 ensemble with unadjusted data
html 7629c78 jens-daniel-mueller 2022-06-29 Build site.
Rmd 4758911 jens-daniel-mueller 2022-06-29 ensemble without unadjusted data
html f6786c8 jens-daniel-mueller 2022-06-29 Build site.
Rmd 6f694a1 jens-daniel-mueller 2022-06-29 included Cstar N in ensemble
html f09080e jens-daniel-mueller 2022-06-28 Build site.
Rmd d457610 jens-daniel-mueller 2022-06-28 save figures for publication
html ee30748 jens-daniel-mueller 2022-06-28 Build site.
Rmd fe42644 jens-daniel-mueller 2022-06-28 GCB emissions ratio included
html 9393c07 jens-daniel-mueller 2022-06-28 Build site.
Rmd 2a3cf97 jens-daniel-mueller 2022-06-28 included basin-hemisphere bias, and bias contributions
html 0825298 jens-daniel-mueller 2022-06-28 Build site.
Rmd d35ddb1 jens-daniel-mueller 2022-06-28 included GCB ocean sink data as boxplot
html a13a7cf jens-daniel-mueller 2022-06-28 Build site.
html fb59a6f jens-daniel-mueller 2022-06-27 Build site.
Rmd 7ff568c jens-daniel-mueller 2022-06-27 included GCB ocean sink data
html a26a21d jens-daniel-mueller 2022-06-27 Build site.
Rmd 9425709 jens-daniel-mueller 2022-06-27 scaled sabine 2004 to full area
html 748aa43 jens-daniel-mueller 2022-06-27 Build site.
Rmd 82d5793 jens-daniel-mueller 2022-06-27 ensemble scatter plot
html 457e640 jens-daniel-mueller 2022-06-27 Build site.
Rmd 426c5bf jens-daniel-mueller 2022-06-27 cleaned read-in section
html 16dc3af jens-daniel-mueller 2022-06-27 Build site.
Rmd dd2063a jens-daniel-mueller 2022-06-27 ensemble member analysis added
html 87e9eb8 jens-daniel-mueller 2022-06-27 Build site.
Rmd 09a3348 jens-daniel-mueller 2022-06-27 1 as standard case and new ensemble members
html b52b159 jens-daniel-mueller 2022-06-27 Build site.
html 09b0780 jens-daniel-mueller 2022-05-24 Build site.
html 25da2fb jens-daniel-mueller 2022-05-24 Build site.
html 1d73ec9 jens-daniel-mueller 2022-05-16 Build site.
Rmd e117b7b jens-daniel-mueller 2022-05-16 rerun w/o data adjustments
html 2ffbdda jens-daniel-mueller 2022-05-16 Build site.
Rmd 6fc8438 jens-daniel-mueller 2022-05-16 plot individual zonal sections
html c71227f jens-daniel-mueller 2022-05-16 Build site.
Rmd 55e9ac6 jens-daniel-mueller 2022-05-16 plot individual zonal sections
html 3c1100c jens-daniel-mueller 2022-05-16 Build site.
Rmd fdb111d jens-daniel-mueller 2022-05-16 plot individual zonal sections
html 2ca0109 jens-daniel-mueller 2022-05-02 Build site.
Rmd 63d51bd jens-daniel-mueller 2022-05-02 rerun with adjusted data
html dcf2eaf jens-daniel-mueller 2022-05-02 Build site.
Rmd a3a2cf9 jens-daniel-mueller 2022-05-02 IO sections seperate
html eff4fd7 jens-daniel-mueller 2022-05-02 Build site.
Rmd 39e920a jens-daniel-mueller 2022-05-02 IO sections seperate
html 08607eb jens-daniel-mueller 2022-05-02 Build site.
Rmd 0791c1b jens-daniel-mueller 2022-05-02 modified plots
html b018a9a jens-daniel-mueller 2022-04-29 Build site.
Rmd 02ede93 jens-daniel-mueller 2022-04-29 standard case uncorrected data
html e09320d jens-daniel-mueller 2022-04-12 Build site.
Rmd 0dec180 jens-daniel-mueller 2022-04-12 3 data adjustment procedures implemented
html 8dca96a jens-daniel-mueller 2022-04-12 Build site.
Rmd e5e9288 jens-daniel-mueller 2022-04-12 3 data adjustment procedures implemented
html 2f20ea6 jens-daniel-mueller 2022-04-11 Build site.
html 209c9b6 jens-daniel-mueller 2022-04-10 Build site.
Rmd 537aff7 jens-daniel-mueller 2022-04-10 no data adjustment implemented
html acad2e2 jens-daniel-mueller 2022-04-09 Build site.
html 3d81135 jens-daniel-mueller 2022-04-07 Build site.
html 0f5d372 jens-daniel-mueller 2022-04-04 Build site.
Rmd ac5121f jens-daniel-mueller 2022-04-04 added zonal mean beta distribution new figure
html 1b5a309 jens-daniel-mueller 2022-04-04 Build site.
Rmd 8b96a9d jens-daniel-mueller 2022-04-04 added zonal mean beta distribution new figure
html a74e341 jens-daniel-mueller 2022-04-04 Build site.
Rmd c0432be jens-daniel-mueller 2022-04-04 added zonal mean beta distribution ensemble sd
html b599680 jens-daniel-mueller 2022-04-04 Build site.
Rmd e406c39 jens-daniel-mueller 2022-04-04 added zonal mean beta distribution
html ca7e590 jens-daniel-mueller 2022-03-22 Build site.
Rmd 8cb4b78 jens-daniel-mueller 2022-03-22 use 1800 as tref for sabine estimates
html 5a6be34 jens-daniel-mueller 2022-03-22 Build site.
Rmd cee203c jens-daniel-mueller 2022-03-22 rerun with NP 2021 talk correction
html bd9e11d jens-daniel-mueller 2022-03-22 Build site.
html 2501978 jens-daniel-mueller 2022-03-21 Build site.
Rmd 9e12898 jens-daniel-mueller 2022-03-21 use 1800 as tref for sabine estimates
html c3a6238 jens-daniel-mueller 2022-03-08 Build site.
Rmd 775eb4f jens-daniel-mueller 2022-03-08 moving eras analysis implemented
html 094bfa0 jens-daniel-mueller 2022-02-18 Build site.
Rmd fa258cc jens-daniel-mueller 2022-02-18 updated plots
html ba2d62e jens-daniel-mueller 2022-02-17 Build site.
Rmd 5420131 jens-daniel-mueller 2022-02-17 added Seaflux data
html 192504c jens-daniel-mueller 2022-02-17 Build site.
Rmd 2394302 jens-daniel-mueller 2022-02-17 added Seaflux data
html 251c7cf jens-daniel-mueller 2022-02-17 Build site.
Rmd 9ea0d8c jens-daniel-mueller 2022-02-17 adapted beta factor
html 565224d jens-daniel-mueller 2022-02-17 Build site.
Rmd 33422e3 jens-daniel-mueller 2022-02-17 scaled budgets to global coverage
html 2116dd3 jens-daniel-mueller 2022-02-09 Build site.
Rmd e281bf3 jens-daniel-mueller 2022-02-09 updated plots
html 6fe70a1 jens-daniel-mueller 2022-02-05 Build site.
Rmd 8955c85 jens-daniel-mueller 2022-02-05 cleaned plots
html a6b33aa jens-daniel-mueller 2022-02-04 Build site.
Rmd 73efef8 jens-daniel-mueller 2022-02-04 atm co2 time series plotted, uncertainties revised
html 4b48475 jens-daniel-mueller 2022-02-04 Build site.
Rmd 6afd7b1 jens-daniel-mueller 2022-02-04 calculated uncertainty of basin budget changes
html fec5a1e jens-daniel-mueller 2022-02-04 Build site.
Rmd 325da3a jens-daniel-mueller 2022-02-04 calculated uncertainty of basin budget changes
html d2191ad jens-daniel-mueller 2022-02-04 Build site.
Rmd 79a54fe jens-daniel-mueller 2022-02-04 new coaverage map
html 4c5b079 jens-daniel-mueller 2022-02-03 Build site.
Rmd 66d89a9 jens-daniel-mueller 2022-02-03 added surface flux model products
html 4077397 jens-daniel-mueller 2022-02-03 Build site.
Rmd c0c3be1 jens-daniel-mueller 2022-02-03 added surface flux products
html 0d0f790 jens-daniel-mueller 2022-02-02 Build site.
Rmd 049346f jens-daniel-mueller 2022-02-02 shifted year labels
html 4673df5 jens-daniel-mueller 2022-02-02 Build site.
Rmd 1185397 jens-daniel-mueller 2022-02-02 rearranged plots
html 60727e6 jens-daniel-mueller 2022-02-02 Build site.
Rmd db5308b jens-daniel-mueller 2022-02-02 rearranged plots
html c7b4984 jens-daniel-mueller 2022-02-02 Build site.
Rmd a3d8469 jens-daniel-mueller 2022-02-02 ensemble uncertainties in global buget
html 7fb28a2 jens-daniel-mueller 2022-02-02 Build site.
Rmd a332fe6 jens-daniel-mueller 2022-02-02 ensemble uncertainties in time series
html 49097e8 jens-daniel-mueller 2022-02-02 Build site.
Rmd f98c33b jens-daniel-mueller 2022-02-02 incl ensemble uncertainties in plot
html fe11bfd jens-daniel-mueller 2022-02-02 Build site.
Rmd d3f7f05 jens-daniel-mueller 2022-02-02 incl ensemble uncertainties
html fa46251 jens-daniel-mueller 2022-02-02 Build site.
Rmd 33feacf jens-daniel-mueller 2022-02-02 incl sabine budgets
html 7655085 jens-daniel-mueller 2022-02-02 Build site.
Rmd 09dd555 jens-daniel-mueller 2022-02-02 incl sabine budgets
html 226d67d jens-daniel-mueller 2022-02-02 Build site.
Rmd ed056e2 jens-daniel-mueller 2022-02-02 incl sabine budgets
html ed903f7 jens-daniel-mueller 2022-02-02 Build site.
Rmd 9d11695 jens-daniel-mueller 2022-02-02 scaled budget to atm pco2 increase
html 32e9682 jens-daniel-mueller 2022-02-02 Build site.
Rmd 5cc5572 jens-daniel-mueller 2022-02-02 included Sabine column inventory as reference
html 913e42f jens-daniel-mueller 2022-02-01 Build site.
Rmd c4b2de9 jens-daniel-mueller 2022-02-01 updated profile plots
html 189de95 jens-daniel-mueller 2022-02-01 Build site.
Rmd b0c17bc jens-daniel-mueller 2022-02-01 updated profile plots
html ab001eb jens-daniel-mueller 2022-01-31 Build site.
Rmd ccf6723 jens-daniel-mueller 2022-01-31 filled step plot for layer budgets
html d2ae5fe jens-daniel-mueller 2022-01-31 Build site.
Rmd 278523c jens-daniel-mueller 2022-01-31 step plot for layer budgets
html b62308d jens-daniel-mueller 2022-01-31 Build site.
Rmd 714c5cc jens-daniel-mueller 2022-01-31 step plot for layer budgets
html ec7fe7e jens-daniel-mueller 2022-01-31 Build site.
Rmd 5c948ae jens-daniel-mueller 2022-01-31 added time series vs atm pco2
html de557de jens-daniel-mueller 2022-01-28 Build site.
html 5f2aed0 jens-daniel-mueller 2022-01-27 Build site.
Rmd 54c9e26 jens-daniel-mueller 2022-01-27 added layer budget profiles
html eccd82b jens-daniel-mueller 2022-01-26 Build site.
Rmd c5577d3 jens-daniel-mueller 2022-01-26 added meand sd to offset mean concentrations profiles
html c6fe495 jens-daniel-mueller 2022-01-26 Build site.
Rmd e0e7974 jens-daniel-mueller 2022-01-26 added offset mean concentrations profiles
html 9753eb8 jens-daniel-mueller 2022-01-26 Build site.
html b1d7720 jens-daniel-mueller 2022-01-21 Build site.
Rmd 0210ed5 jens-daniel-mueller 2022-01-21 added mean concentrations profiles per 5 basins
html d6b399a jens-daniel-mueller 2022-01-21 Build site.
Rmd da17a07 jens-daniel-mueller 2022-01-21 added mean concentrations profiles
html c499be8 jens-daniel-mueller 2022-01-21 Build site.
Rmd d941871 jens-daniel-mueller 2022-01-21 run color map test
html e572075 jens-daniel-mueller 2022-01-21 Build site.
Rmd 99b6c92 jens-daniel-mueller 2022-01-21 run color map test
html 4fe7150 jens-daniel-mueller 2022-01-21 Build site.
Rmd 0379e99 jens-daniel-mueller 2022-01-21 script cleaning
html 49b41cf jens-daniel-mueller 2022-01-21 Build site.
Rmd 2c82651 jens-daniel-mueller 2022-01-21 added map of scaled absolute change
html c0807e8 jens-daniel-mueller 2022-01-21 Build site.
Rmd 5dd3d7a jens-daniel-mueller 2022-01-21 added map of scaled relative change
html 22b421f jens-daniel-mueller 2022-01-21 Build site.
Rmd 2c3fa75 jens-daniel-mueller 2022-01-21 cleaned alluvial plots
html 1a35f1f jens-daniel-mueller 2022-01-20 Build site.
Rmd e58f510 jens-daniel-mueller 2022-01-20 added relative changes to alluvial plots
html b503ae1 jens-daniel-mueller 2022-01-20 Build site.
Rmd 2eb2567 jens-daniel-mueller 2022-01-20 added relative changes to alluvial plots
html cc31f4b jens-daniel-mueller 2022-01-20 Build site.
Rmd 416e107 jens-daniel-mueller 2022-01-20 added delta dcant map
html 11a800b jens-daniel-mueller 2022-01-20 Build site.
Rmd 81a40d5 jens-daniel-mueller 2022-01-20 updated alluvial plots
html 3087804 jens-daniel-mueller 2022-01-20 Build site.
Rmd 2ae5966 jens-daniel-mueller 2022-01-20 updated alluvial plots
html 6d566d5 jens-daniel-mueller 2022-01-20 Build site.
Rmd 4901b0f jens-daniel-mueller 2022-01-20 updated alluvial plots
html 44796b1 jens-daniel-mueller 2022-01-20 Build site.
Rmd cdbd92c jens-daniel-mueller 2022-01-20 created alluvial plots
html 48ec4c6 jens-daniel-mueller 2022-01-19 Build site.
Rmd 0fb2ae5 jens-daniel-mueller 2022-01-19 printed column inv from AIP standard runs
html f347cd7 jens-daniel-mueller 2022-01-18 Build site.
Rmd 86b711c jens-daniel-mueller 2022-01-18 plot hemisphere budgets and publication results

1 Libraries

2 Read files

2.1 integration depth

params_global$inventory_depth_standard <- 1000

2.2 Paths and Versions

version_id_pattern <- "1"

# identify required version IDs

Version_IDs_1 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_1", version_id_pattern))

Version_IDs_2 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_2", version_id_pattern))

Version_IDs_3 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_3", version_id_pattern))

Version_IDs_x <- c(Version_IDs_1, Version_IDs_2, Version_IDs_3)

version_id_pattern <- "o"

# identify required version IDs

Version_IDs_1 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_1", version_id_pattern))

Version_IDs_2 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_2", version_id_pattern))

Version_IDs_3 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_3", version_id_pattern))

Version_IDs_o <- c(Version_IDs_1, Version_IDs_2, Version_IDs_3)

version_id_pattern <- "d"

# identify required version IDs

Version_IDs_1 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_1", version_id_pattern))

Version_IDs_2 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_2", version_id_pattern))

Version_IDs_3 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_3", version_id_pattern))

Version_IDs_d <- c(Version_IDs_1, Version_IDs_2, Version_IDs_3)

version_id_pattern <- "g"

# identify required version IDs

Version_IDs_1 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_1", version_id_pattern))

Version_IDs_2 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_2", version_id_pattern))

Version_IDs_3 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_3", version_id_pattern))

Version_IDs_g <- c(Version_IDs_1, Version_IDs_2, Version_IDs_3)

version_id_pattern <- "n"

# identify required version IDs

Version_IDs_1 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_1", version_id_pattern))

Version_IDs_2 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_2", version_id_pattern))

Version_IDs_3 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_3", version_id_pattern))

Version_IDs_n <- c(Version_IDs_1, Version_IDs_2, Version_IDs_3)
rm(Version_IDs_1, Version_IDs_2, Version_IDs_3)

version_id_pattern <- "c"

# identify required version IDs

Version_IDs_1 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_1", version_id_pattern))

Version_IDs_2 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_2", version_id_pattern))

Version_IDs_3 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_3", version_id_pattern))

Version_IDs_c <- c(Version_IDs_1, Version_IDs_2, Version_IDs_3)
rm(Version_IDs_1, Version_IDs_2, Version_IDs_3)

version_id_pattern <- "e"

# identify required version IDs

Version_IDs_1 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_1", version_id_pattern))

Version_IDs_2 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_2", version_id_pattern))

Version_IDs_3 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_3", version_id_pattern))

Version_IDs_e <- c(Version_IDs_1, Version_IDs_2, Version_IDs_3)
rm(Version_IDs_1, Version_IDs_2, Version_IDs_3)

version_id_pattern <- "a"

# identify required version IDs

Version_IDs_1 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_1", version_id_pattern))

Version_IDs_2 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_2", version_id_pattern))

Version_IDs_3 <- list.files(path = "/nfs/kryo/work/jenmueller/emlr_cant/observations",
                            pattern = paste0("v_3", version_id_pattern))

Version_IDs_a <- c(Version_IDs_1, Version_IDs_2, Version_IDs_3)
rm(Version_IDs_1, Version_IDs_2, Version_IDs_3)

Version_IDs_ensemble <- c(Version_IDs_x, Version_IDs_o, Version_IDs_d, Version_IDs_g, Version_IDs_n, Version_IDs_c, Version_IDs_e, Version_IDs_a)

rm(Version_IDs_x, Version_IDs_o, Version_IDs_g, Version_IDs_n, Version_IDs_c, Version_IDs_e)
# subset Standard case
Version_IDs <- Version_IDs_ensemble[str_detect(Version_IDs_ensemble, "103")]

2.3 Parameters

for (i_Version_IDs in Version_IDs_ensemble) {
  
  path_version_data     <-
    paste(path_observations,
          i_Version_IDs,
          "/data/",
          sep = "")
  
  params_local <-
    read_rds(paste(path_version_data,
                   "params_local.rds",
                   sep = ""))
  
  params_local <- bind_cols(
    Version_ID = i_Version_IDs,
    tref1 = params_local$tref1,
    tref2 = params_local$tref2,
    MLR_basins = params_local$MLR_basins
  )
  
  tref <- read_csv(paste(path_version_data,
                         "tref.csv",
                         sep = ""))
  
  params_local <- params_local %>%
    mutate(
      median_year_1 = sort(tref$median_year)[1],
      median_year_2 = sort(tref$median_year)[2],
      duration = median_year_2 - median_year_1,
      period = paste(median_year_1, "-", median_year_2)
    )
  
  if (exists("params_local_all_ensemble")) {
    params_local_all_ensemble <- bind_rows(params_local_all_ensemble, params_local)
  }
  
  if (!exists("params_local_all_ensemble")) {
    params_local_all_ensemble <- params_local
  }
  
  
}

rm(params_local,
   tref)


params_local_all_ensemble <- params_local_all_ensemble %>%
  select(Version_ID, period, MLR_basins, tref1, tref2)

params_local_all_ensemble <-
  params_local_all_ensemble %>%
  mutate(
    Version_ID_group = str_sub(Version_ID, 4, 4),
    Version_ID_group = case_when(
      Version_ID_group == "1" ~ "Bulk adjustment",
      Version_ID_group == "c" ~ "Cruise adjustment",
      Version_ID_group == "d" ~ "No adjustment",
      Version_ID_group == "g" ~ "No gap filling",
      Version_ID_group == "o" ~ "Reoccupation filter",
      Version_ID_group == "e" ~ "Surface eMLR(C*)",
      Version_ID_group == "n" ~ "C*(N,AT)",
      Version_ID_group == "a" ~ "C*(P)",
      TRUE ~ Version_ID_group
    )
  )

params_local_all_ensemble <-
  params_local_all_ensemble %>%
  mutate(
    MLR_basins = case_when(
      MLR_basins == "AIP" ~ "3",
      MLR_basins == "SO_AIP" ~ "3+SO",
      MLR_basins == "SO_5" ~ "5+SO",
      TRUE ~ MLR_basins
    )
  )
params_local_all <- params_local_all_ensemble %>% 
  filter(Version_ID %in% Version_IDs)
path_version_data     <-
  paste(path_observations,
        Version_IDs[1],
        "/data/",
        sep = "")

params_local <-
  read_rds(paste(path_version_data,
                 "params_local.rds",
                 sep = ""))

2.4 eMLR stats

for (i_Version_IDs in Version_IDs) {
  # i_Version_IDs <- Version_IDs[1]
  
  path_version_data     <-
    paste(path_observations,
          i_Version_IDs,
          "/data/",
          sep = "")
  
  # load and join data files
  
  # Model performance: RMSE, n_predictors, VIF
  GLODAP_glanced <-
    read_csv(paste(path_version_data,
                   "lm_model_metrics.csv",
                   sep = ""))
  
  GLODAP_glanced <- GLODAP_glanced %>%
    mutate(Version_ID = i_Version_IDs)
  
  if (exists("GLODAP_glanced_all")) {
    GLODAP_glanced_all <-
      bind_rows(GLODAP_glanced_all, GLODAP_glanced)
  }
  
  if (!exists("GLODAP_glanced_all")) {
    GLODAP_glanced_all <- GLODAP_glanced
  }
  
  # The chosen models
  lm_best_target <-
    read_csv(paste(path_version_data,
                   "lm_best_target.csv",
                   sep = ""))
  
  lm_best_target <- lm_best_target %>%
    mutate(Version_ID = i_Version_IDs)
  
  if (exists("lm_best_target_all")) {
    lm_best_target_all <-
      bind_rows(lm_best_target_all, lm_best_target)
  }
  
  if (!exists("lm_best_target_all")) {
    lm_best_target_all <- lm_best_target
  }
  
  lm_best_predictor_counts <-
    read_csv(paste(path_version_data,
                   "lm_best_predictor_counts.csv",
                   sep = ""))
  
  lm_best_predictor_counts <- lm_best_predictor_counts %>%
    mutate(Version_ID = i_Version_IDs)
  
  if (exists("lm_best_predictor_counts_all")) {
    lm_best_predictor_counts_all <-
      bind_rows(lm_best_predictor_counts_all, lm_best_predictor_counts)
  }
  
  if (!exists("lm_best_predictor_counts_all")) {
    lm_best_predictor_counts_all <- lm_best_predictor_counts
  }
  
  lat_residual <-
    read_csv(paste(path_version_data,
                   "lm_lat_residual.csv",
                   sep = ""))
  
  lat_residual <- lat_residual %>%
    mutate(Version_ID = i_Version_IDs)
  
  if (exists("lat_residual_all")) {
    lat_residual_all <-
      bind_rows(lat_residual_all, lat_residual)
  }
  
  if (!exists("lat_residual_all")) {
    lat_residual_all <- lat_residual
  }
  
  lat_residual_offset <-
    read_csv(paste(path_version_data,
                   "lm_lat_residual_offset.csv",
                   sep = ""))
  
  lat_residual_offset <- lat_residual_offset %>%
    mutate(Version_ID = i_Version_IDs)
  
  if (exists("lat_residual_offset_all")) {
    lat_residual_offset_all <-
      bind_rows(lat_residual_offset_all, lat_residual_offset)
  }
  
  if (!exists("lat_residual_offset_all")) {
    lat_residual_offset_all <- lat_residual_offset
  }
  
  
  spatial_residual <-
    read_csv(paste(path_version_data,
                   "lm_spatial_residual.csv",
                   sep = ""))
  
  spatial_residual <- spatial_residual %>%
    mutate(Version_ID = i_Version_IDs)
  
  if (exists("spatial_residual_all")) {
    spatial_residual_all <-
      bind_rows(spatial_residual_all, spatial_residual)
  }
  
  if (!exists("spatial_residual_all")) {
    spatial_residual_all <- spatial_residual
  }
  
  spatial_residual_offset <-
    read_csv(paste(path_version_data,
                   "lm_spatial_residual_offset.csv",
                   sep = ""))
  
  spatial_residual_offset <- spatial_residual_offset %>%
    mutate(Version_ID = i_Version_IDs)
  
  if (exists("spatial_residual_offset_all")) {
    spatial_residual_offset_all <-
      bind_rows(spatial_residual_offset_all, spatial_residual_offset)
  }
  
  if (!exists("spatial_residual_offset_all")) {
    spatial_residual_offset_all <- spatial_residual_offset
  }
  
  

  
}

rm(GLODAP_glanced,
   lat_residual,
   lat_residual_offset,
   spatial_residual,
   spatial_residual_offset,
   lm_best_predictor_counts,
   lm_best_target)

2.5 Budgets

for (i_Version_IDs in Version_IDs_ensemble) {
  # i_Version_IDs <- Version_IDs[1]
  
  path_version_data     <-
    paste(path_observations,
          i_Version_IDs,
          "/data/",
          sep = "")
  
  # load and join data files
  
  dcant_budget_global <-
    read_csv(paste(path_version_data,
                   "dcant_budget_global.csv",
                   sep = ""))
  
  dcant_budget_global_mod_truth <-
    read_csv(paste(
      path_version_data,
      "dcant_budget_global_mod_truth.csv",
      sep = ""
    ))
  
  dcant_budget_global <- bind_rows(dcant_budget_global,
                                   dcant_budget_global_mod_truth)
  
  dcant_budget_global <- dcant_budget_global %>%
    mutate(Version_ID = i_Version_IDs)
  
  if (exists("dcant_budget_global_all")) {
    dcant_budget_global_all <-
      bind_rows(dcant_budget_global_all, dcant_budget_global)
  }
  
  if (!exists("dcant_budget_global_all")) {
    dcant_budget_global_all <- dcant_budget_global
  }
  
}

rm(dcant_budget_global,
   dcant_budget_global_mod_truth)
for (i_Version_IDs in Version_IDs_ensemble) {
  # i_Version_IDs <- Version_IDs[1]
  
  # print(i_Version_IDs)
  
  path_version_data     <-
    paste(path_observations,
          i_Version_IDs,
          "/data/",
          sep = "")
  
  # load and join data files
  
  dcant_budget_basin_MLR <-
    read_csv(paste(path_version_data,
                   "dcant_budget_basin_MLR.csv",
                   sep = ""))
  
  dcant_budget_basin_MLR_mod_truth <-
    read_csv(paste(
      path_version_data,
      "dcant_budget_basin_MLR_mod_truth.csv",
      sep = ""
    ))
  
    
  dcant_budget_basin_MLR <- bind_rows(dcant_budget_basin_MLR,
                                      dcant_budget_basin_MLR_mod_truth)
  
  dcant_budget_basin_MLR <- dcant_budget_basin_MLR %>%
    mutate(Version_ID = i_Version_IDs)
  

  if (exists("dcant_budget_basin_MLR_all")) {
    dcant_budget_basin_MLR_all <-
      bind_rows(dcant_budget_basin_MLR_all, dcant_budget_basin_MLR)
  }
  
  if (!exists("dcant_budget_basin_MLR_all")) {
    dcant_budget_basin_MLR_all <- dcant_budget_basin_MLR
  }
  
  
  dcant_budget_basin_MLR_bias_decomposition <-
    read_csv(
      paste(
        path_version_data,
        "dcant_budget_basin_MLR_bias_decomposition.csv",
        sep = ""
      )
    )
  
  
  dcant_budget_basin_MLR_bias_decomposition <-
    dcant_budget_basin_MLR_bias_decomposition %>%
    mutate(Version_ID = i_Version_IDs)
  
  
  if (exists("dcant_budget_basin_MLR_bias_all_decomposition")) {
    dcant_budget_basin_MLR_bias_all_decomposition <-
      bind_rows(
        dcant_budget_basin_MLR_bias_all_decomposition,
        dcant_budget_basin_MLR_bias_decomposition
      )
  }
  
  if (!exists("dcant_budget_basin_MLR_bias_all_decomposition")) {
    dcant_budget_basin_MLR_bias_all_decomposition <-
      dcant_budget_basin_MLR_bias_decomposition
  }

}

rm(
  dcant_budget_basin_MLR,
  dcant_budget_basin_MLR_mod_truth,
  dcant_budget_basin_MLR_bias_decomposition
)
dcant_budget_global_all <- dcant_budget_global_all %>%
  filter(estimate == "dcant", 
         method == "total") %>% 
  select(-c(estimate, method)) %>% 
  rename(dcant = value)

dcant_budget_global_all <- dcant_budget_global_all %>%
  filter(inv_depth == params_global$inventory_depth_standard)
dcant_budget_basin_MLR_all <- dcant_budget_basin_MLR_all %>%
  filter(estimate == "dcant", 
         method == "total") %>% 
  select(-c(estimate, method)) %>% 
  rename(dcant = value)

dcant_budget_basin_MLR_all_1000 <- dcant_budget_basin_MLR_all %>%
  filter(inv_depth == 1000)

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

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

2.6 Column inventories

for (i_Version_IDs in Version_IDs_ensemble) {
  # i_Version_IDs <- Version_IDs_ensemble[19]
  
  path_version_data     <-
    paste(path_observations,
          i_Version_IDs,
          "/data/",
          sep = "")
  
  # load and join data files
  
  dcant_inv <-
    read_csv(paste(path_version_data,
                   "dcant_inv.csv",
                   sep = ""))
  
  p_map_cant_inv(dcant_inv %>% filter(data_source == "obs"))
  
  
  dcant_inv_mod_truth <-
    read_csv(paste(path_version_data,
                   "dcant_inv_mod_truth.csv",
                   sep = "")) %>%
    filter(method == "total") %>%
    select(-method)
  
  dcant_inv_bias <-
    read_csv(paste(path_version_data,
                   "dcant_inv_bias.csv",
                   sep = "")) %>%
    mutate(Version_ID = i_Version_IDs)
  
  dcant_inv <- bind_rows(dcant_inv,
                         dcant_inv_mod_truth) %>%
    mutate(Version_ID = i_Version_IDs)
  
  dcant_budget_lat_grid <-
    read_csv(paste(path_version_data,
                   "dcant_budget_lat_grid.csv",
                   sep = "")) %>%
    mutate(Version_ID = i_Version_IDs)
  
  dcant_budget_lon_grid <-
    read_csv(paste(path_version_data,
                   "dcant_budget_lon_grid.csv",
                   sep = "")) %>%
    mutate(Version_ID = i_Version_IDs)
  if (exists("dcant_inv_all")) {
    dcant_inv_all <- bind_rows(dcant_inv_all, dcant_inv)
  }
  
  if (!exists("dcant_inv_all")) {
    dcant_inv_all <- dcant_inv
  }
  
  if (exists("dcant_inv_bias_all")) {
    dcant_inv_bias_all <- bind_rows(dcant_inv_bias_all, dcant_inv_bias)
  }
  
  if (!exists("dcant_inv_bias_all")) {
    dcant_inv_bias_all <- dcant_inv_bias
  }
  
  if (exists("dcant_budget_lat_grid_all")) {
    dcant_budget_lat_grid_all <- bind_rows(dcant_budget_lat_grid_all, dcant_budget_lat_grid)
  }
  
  if (!exists("dcant_budget_lat_grid_all")) {
    dcant_budget_lat_grid_all <- dcant_budget_lat_grid
  }
  
  if (exists("dcant_budget_lon_grid_all")) {
    dcant_budget_lon_grid_all <- bind_rows(dcant_budget_lon_grid_all, dcant_budget_lon_grid)
  }
  
  if (!exists("dcant_budget_lon_grid_all")) {
    dcant_budget_lon_grid_all <- dcant_budget_lon_grid
  }
}

rm(dcant_inv,
   dcant_inv_bias,
   dcant_inv_mod_truth,
   dcant_budget_lat_grid,
   dcant_budget_lon_grid)
dcant_inv_all <- dcant_inv_all %>%
  filter(inv_depth == params_global$inventory_depth_standard)

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

dcant_budget_lon_grid_all <- dcant_budget_lon_grid_all %>% 
  filter(inv_depth == params_global$inventory_depth_standard)
dcant_budget_lat_grid_all <- dcant_budget_lat_grid_all %>%
  pivot_wider(names_from = estimate,
              values_from = value) %>%
  filter(period != "1994 - 2014",
         method == "total")

dcant_budget_lon_grid_all <- dcant_budget_lon_grid_all %>%
  pivot_wider(names_from = estimate,
              values_from = value) %>%
  filter(period != "1994 - 2014",
         method == "total")
dcant_inv_all %>% 
  filter(Version_ID == "v_1103",
         data_source == "obs") %>% 
  select(lon, lat, dcant) %>% 
  write_csv(here::here("output/dcant_column_inventor_example.csv"))

2.7 Sections / profiles

for (i_Version_IDs in Version_IDs_ensemble) {

  path_version_data     <-
  paste(path_observations,
        i_Version_IDs,
        "/data/",
        sep = "")
  
  # load and join data files
  
  dcant_zonal <-
    read_csv(paste(path_version_data,
                   "dcant_zonal.csv",
                   sep = ""))
  
  dcant_zonal_mod_truth <-
    read_csv(paste(path_version_data,
                   "dcant_zonal_mod_truth.csv",
                   sep = ""))
  
  dcant_zonal <- bind_rows(dcant_zonal,
                           dcant_zonal_mod_truth)
  
  dcant_global_section <-
    read_csv(paste(path_version_data,
                   "dcant_global_section.csv",
                   sep = ""))
  
  dcant_profile <-
    read_csv(paste(path_version_data,
                   "dcant_profile.csv",
                   sep = ""))
  
  dcant_profile_mod_truth <-
    read_csv(paste(path_version_data,
                   "dcant_profile_mod_truth.csv",
                   sep = ""))
  
  dcant_profile <- bind_rows(dcant_profile,
                             dcant_profile_mod_truth)
  
  
  dcant_profile_basin_MLR <-
    read_csv(paste(path_version_data,
                   "dcant_profile_basin_MLR.csv",
                   sep = ""))
  
  
  dcant_profile_basin_MLR_mod_truth <-
    read_csv(paste(
      path_version_data,
      "dcant_profile_basin_MLR_mod_truth.csv",
      sep = ""
    ))

  dcant_profile_basin_MLR <- bind_rows(dcant_profile_basin_MLR,
                                       dcant_profile_basin_MLR_mod_truth)
  
  
  dcant_budget_basin_AIP_layer <-
    read_csv(paste(path_version_data,
                   "dcant_budget_basin_AIP_layer.csv",
                   sep = ""))

  dcant_budget_basin_MLR_layer <-
    read_csv(paste(path_version_data,
                   "dcant_budget_basin_MLR_layer.csv",
                   
                   sep = ""))
  
  dcant_budget_basin_MLR_layer_mod_truth <-
    read_csv(paste(
      path_version_data,
      "dcant_budget_basin_MLR_layer_mod_truth.csv",
      sep = ""
    ))
  
  dcant_budget_basin_MLR_layer <-
    bind_rows(dcant_budget_basin_MLR_layer,
              dcant_budget_basin_MLR_layer_mod_truth)
  
  dcant_zonal_bias <-
    read_csv(paste(path_version_data,
                   "dcant_zonal_bias.csv",
                   sep = ""))
  
  dcant_penetration_depth_all_lat_mean <-
    read_csv(paste0(path_version_data,
                   "dcant_penetration_depth_all_lat_mean.csv"))
  

  dcant_zonal <- dcant_zonal %>% 
    mutate(Version_ID = i_Version_IDs)

  dcant_global_section <- dcant_global_section %>% 
    mutate(Version_ID = i_Version_IDs)
  
  dcant_profile <- dcant_profile %>% 
    mutate(Version_ID = i_Version_IDs)

  dcant_profile_basin_MLR <- dcant_profile_basin_MLR %>% 
    mutate(Version_ID = i_Version_IDs)
  
  dcant_budget_basin_AIP_layer <- dcant_budget_basin_AIP_layer %>% 
    mutate(Version_ID = i_Version_IDs)
  
  dcant_budget_basin_MLR_layer <- dcant_budget_basin_MLR_layer %>% 
    mutate(Version_ID = i_Version_IDs)
  
  dcant_zonal_bias <- dcant_zonal_bias %>% 
    mutate(Version_ID = i_Version_IDs)
  
  dcant_penetration_depth_all_lat_mean <-
    dcant_penetration_depth_all_lat_mean %>%
    mutate(Version_ID = i_Version_IDs)
  
  
  if (exists("dcant_zonal_all")) {
    dcant_zonal_all <- bind_rows(dcant_zonal_all, dcant_zonal)
  }
  
  if (!exists("dcant_zonal_all")) {
    dcant_zonal_all <- dcant_zonal
  }

  
  if (exists("dcant_global_section_all")) {
    dcant_global_section_all <- bind_rows(dcant_global_section_all, dcant_global_section)
  }
  
  if (!exists("dcant_global_section_all")) {
    dcant_global_section_all <- dcant_global_section
  }

  if (exists("dcant_profile_all")) {
    dcant_profile_all <- bind_rows(dcant_profile_all, dcant_profile)
  }
  
  if (!exists("dcant_profile_all")) {
    dcant_profile_all <- dcant_profile
  }

  if (exists("dcant_profile_basin_MLR_all")) {
    dcant_profile_basin_MLR_all <- bind_rows(dcant_profile_basin_MLR_all, dcant_profile_basin_MLR)
  }
  
  if (!exists("dcant_profile_basin_MLR_all")) {
    dcant_profile_basin_MLR_all <- dcant_profile_basin_MLR
  }

  if (exists("dcant_budget_basin_AIP_layer_all")) {
    dcant_budget_basin_AIP_layer_all <-
      bind_rows(dcant_budget_basin_AIP_layer_all,
                dcant_budget_basin_AIP_layer)
  }
  
  if (!exists("dcant_budget_basin_AIP_layer_all")) {
    dcant_budget_basin_AIP_layer_all <- dcant_budget_basin_AIP_layer
  }

  if (exists("dcant_budget_basin_MLR_layer_all")) {
    dcant_budget_basin_MLR_layer_all <-
      bind_rows(dcant_budget_basin_MLR_layer_all,
                dcant_budget_basin_MLR_layer)
  }
  
  if (!exists("dcant_budget_basin_MLR_layer_all")) {
    dcant_budget_basin_MLR_layer_all <- dcant_budget_basin_MLR_layer
  }

  if (exists("dcant_zonal_bias_all")) {
    dcant_zonal_bias_all <- bind_rows(dcant_zonal_bias_all, dcant_zonal_bias)
  }
  
  if (!exists("dcant_zonal_bias_all")) {
    dcant_zonal_bias_all <- dcant_zonal_bias
  }

  if (exists("dcant_penetration_depth_all_lat_mean_all")) {
    dcant_penetration_depth_all_lat_mean_all <-
      bind_rows(
        dcant_penetration_depth_all_lat_mean_all,
        dcant_penetration_depth_all_lat_mean
      )
  }
  
  if (!exists("dcant_penetration_depth_all_lat_mean_all")) {
    dcant_penetration_depth_all_lat_mean_all <-
      dcant_penetration_depth_all_lat_mean
  }

}

rm(dcant_zonal, dcant_global_section, dcant_zonal_bias, dcant_zonal_mod_truth,
   dcant_budget_basin_AIP_layer, dcant_budget_basin_MLR_layer,
   dcant_profile, dcant_profile_basin_MLR, dcant_penetration_depth_all_lat_mean)

2.8 Observations coverage

for (i_Version_IDs in Version_IDs) {
  path_version_data     <-
    paste(path_observations,
          i_Version_IDs,
          "/data/",
          sep = "")
  
  # load and join data files
  
  GLODAP_grid_era  <-
    read_csv(paste(
      path_version_data,
      "GLODAPv2.2020_clean_obs_grid_era.csv",
      sep = ""
    ))

  
  GLODAP_grid_era <- GLODAP_grid_era %>%
    mutate(Version_ID = i_Version_IDs)
  
  if (exists("GLODAP_grid_era_all")) {
    GLODAP_grid_era_all <-
      bind_rows(GLODAP_grid_era_all, GLODAP_grid_era)
  }
  
  if (!exists("GLODAP_grid_era_all")) {
    GLODAP_grid_era_all <- GLODAP_grid_era
  }
  
  
  
  GLODAP <- read_csv(paste(
    path_version_data,
    "GLODAPv2.2020_clean.csv",
    sep = ""
  ))
  
  GLODAP <- GLODAP %>%
    mutate(Version_ID = i_Version_IDs)
  
  if (exists("GLODAP_all")) {
    GLODAP_all <-
      bind_rows(GLODAP_all, GLODAP)
  }
  
  if (!exists("GLODAP_all")) {
    GLODAP_all <- GLODAP
  }
  
}

rm(GLODAP_grid_era, GLODAP)


GLODAP_grid_era_all <- full_join(GLODAP_grid_era_all,
                                 params_local_all)

GLODAP_all <- full_join(GLODAP_all,
                        params_local_all)


GLODAP_expocodes <-
  read_tsv(
    paste(
      "/nfs/kryo/work/updata/glodapv2_2021/",
      "EXPOCODES.txt",
      sep = ""
    ),
    col_names = c("cruise", "cruise_expocode")
  )

GLODAP_all <-
  left_join(GLODAP_all, GLODAP_expocodes)

2.9 Atm CO2

co2_atm <-
  read_csv(paste(path_preprocessing,
                 "co2_atm.csv",
                 sep = ""))

co2_atm_reccap2 <-
  read_csv(paste(path_preprocessing,
                  "co2_atm_reccap2.csv",
                  sep = ""))

2.10 Sabine total Cant

tcant_inv <-
  read_csv(paste(path_preprocessing,
                  "S04_tcant_inv.csv", sep = ""))

tcant_inv <- tcant_inv %>% 
  filter(inv_depth == 3000) %>% 
  rename(dcant = tcant,
         dcant_pos = tcant_pos) %>% 
  mutate(tref1 = 1800,
         tref2 = 1994)

2.11 GCB carbon sink

Ocean_Sink <-
  read_csv(paste(path_preprocessing,
                  "Ocean_Sink.csv",
                  sep = ""))

Global_Carbon_Budget <-
  read_csv(paste(path_preprocessing,
                  "GCB_Global_Carbon_Budget.csv",
                  sep = ""))

2.12 Periods

two_decades <- unique(params_local_all_ensemble$period)[1:2]

3 Define labels

dcant_pgc_label <- expression(Delta * C["ant"]~(PgC))
dcant_bias_pgc_label <- expression(Delta * C["ant"]~ bias ~(PgC))
delta_dcant_bias_pgc_label <- expression(Delta * Delta * C["ant"]~bias~(PgC))
dcant_pgc_scaled_label <- expression(beta~(mol~m^{-2}~µatm^{-1}))

dcant_umol_label <- expression(Delta * C[ant]~(mu * mol ~ kg ^ {-1}))
ddcant_umol_label <- expression(Delta * Delta * C[ant]~(mu * mol ~ kg ^ {-1}))

dcant_layer_budget_label <- 
  expression(Delta ~ C[ant] ~ "budget per 500m depth layer (PgC)")

dcant_CI_label <- expression(Delta * C[ant]~(mol ~ m ^ {-2}))
delta_dcant_CI_label <- expression(Delta * Delta * C[ant]~(mol ~ m ^ {-2}))
beta_CI_label <- expression(atop(beta,
                                 (mol ~ m ^ {-2} ~ µatm ^ {-1})))

4 Coverage maps

cruises_phosphate_gap_fill <-
  c("33MW19930704",
    "33RO20030604",
    "33RO20050111",
    "33RO19980123")

cruises_talk_gap_fill <-
  c("06AQ19980328")

cruises_talk_calc <-
  c("06MT19900123",
    "316N19920502",
    "316N19921006")

GLODAP_all_coverage <- GLODAP_all %>% 
  distinct(lat, lon, era, cruise_expocode) %>% 
  mutate(gap_filling = case_when(
    cruise_expocode %in% cruises_phosphate_gap_fill ~ "Phosphate from CANYON-B",
    cruise_expocode %in% cruises_talk_gap_fill ~ "TA from CANYON-B",
    cruise_expocode %in% cruises_talk_calc ~ "TA calculated from other variables",
    cruise_expocode %in% "31DS19940126" ~ "Nitrate qc-flag not met",
    TRUE ~ "All quality criteria fulfilled"
  )) %>% 
  distinct(lat, lon, era, gap_filling)

colour("bright")(7)
     blue       red     green    yellow      cyan    purple      grey 
"#4477AA" "#EE6677" "#228833" "#CCBB44" "#66CCEE" "#AA3377" "#BBBBBB" 
attr(,"missing")
[1] NA
coverage_map <- map +
  geom_tile(data = GLODAP_all_coverage,
            aes(lon, lat)) +
  facet_wrap( ~ era, ncol = 1) +
  scale_color_okabeito() +
  scale_fill_okabeito() +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank(),
        legend.position = c(0.7,0.3),
        legend.title = element_blank())

coverage_map

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
fea41c1 jens-daniel-mueller 2022-07-20
9ce772d jens-daniel-mueller 2022-07-19
16dc3af jens-daniel-mueller 2022-06-27
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
ggsave(plot = coverage_map,
       path = here::here("output/presentation"),
       filename = "Fig_observations_coverage_map.png",
       height = 6,
       width = 4)


GLODAP_all_coverage <- GLODAP_all %>% 
  filter(between(depth, 250, 750)) %>% 
  group_by(lat, lon, era) %>%
  summarise(tco2 = mean(tco2, na.rm = TRUE)) %>% 
  ungroup()

library(colorspace)


coverage_map <- map +
  geom_tile(data = GLODAP_all_coverage,
            aes(lon, lat, fill = tco2, col = tco2,
                height = 2, width = 2)) +
  facet_wrap( ~ era, ncol = 1) +
  scale_fill_viridis_c(name = expression(
    atop(DIC~at~"500m",(µmol~kg^{-1})))) +
  scale_color_viridis_c(guide = "none") +
  labs(title = "Observations",
       subtitle = "Decadal coverage") +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank(),
        legend.position = "bottom")

coverage_map

Version Author Date
0b40366 jens-daniel-mueller 2022-10-26
91052ae jens-daniel-mueller 2022-10-20
ggsave(plot = coverage_map,
       path = here::here("output/presentation"),
       filename = "Fig_observations_coverage_map_dic.png",
       height = 7,
       width = 4)

rm(coverage_map, 
   GLODAP_all, GLODAP_all_coverage, GLODAP_expocodes,
   GLODAP_grid_era_all)

rm(cruises_phosphate_gap_fill,
   cruises_talk_gap_fill,
   cruises_talk_calc)

5 Atm CO2

co2_atm_roll <- co2_atm %>% 
  mutate(pCO2_roll = zoo::rollmean(pCO2, 10, fill = NA))

p_pco2_atm <- co2_atm_roll %>% 
  ggplot() +
  geom_point(aes(year, pCO2, col="annual")) +
  geom_path(aes(year, pCO2, col="annual")) +
  geom_point(aes(year, pCO2_roll, col="10yr roll")) +
  geom_path(aes(year, pCO2_roll, col="10yr roll"))

co2_atm_roll <- co2_atm_roll %>% 
  mutate(delta_pCO2_roll = pCO2_roll - lag(pCO2_roll,10),
         delta_pCO2 = pCO2 - lag(pCO2,10))

p_delta_pCO2_atm <- co2_atm_roll %>% 
  ggplot() +
  geom_point(aes(year, delta_pCO2, col="annual")) +
  geom_path(aes(year, delta_pCO2, col="annual")) +
  geom_point(aes(year, delta_pCO2_roll, col="10yr roll")) +
  geom_path(aes(year, delta_pCO2_roll, col="10yr roll"))

p_pco2_atm / p_delta_pCO2_atm

Version Author Date
0160c40 jens-daniel-mueller 2022-07-16
022fd60 jens-daniel-mueller 2022-07-14
rm(p_pco2_atm, p_delta_pCO2_atm)

delta_pCO2_atm <-
  left_join(
    params_local_all %>%
      distinct(period, tref1, tref2),
    co2_atm_roll %>%
      select(
        tref1 = year,
        pCO2_1 = pCO2,
        pCO2_roll_1 = pCO2_roll
      )
  )

delta_pCO2_atm <-
  left_join(
    delta_pCO2_atm,
    co2_atm_roll %>%
      select(
        tref2 = year,
        pCO2_2 = pCO2,
        pCO2_roll_2 = pCO2_roll
      )
  )

delta_pCO2_atm <- delta_pCO2_atm %>% 
  mutate(delta_pCO2 = pCO2_2 - pCO2_1,
         delta_pCO2_roll = pCO2_roll_2 - pCO2_roll_1) %>% 
  select(period, delta_pCO2, delta_pCO2_roll)

delta_pCO2_atm <- delta_pCO2_atm %>%
  select(period, delta_pCO2)

delta_pCO2_atm <- 
  bind_rows(
    delta_pCO2_atm,
    tibble(period = "1800 - 1994",
           delta_pCO2 = co2_atm %>% filter(year==1994) %>% pull(pCO2) - 280)
  )

rm(co2_atm_roll)

6 Globale scaling

  • storage beneath 3000m: +2%
  • unmapped regions south of 65N: +1.5%
  • Nordic Seas: +1%
  • Arctic Ocean: +2%
dcant_scaling <- 1.02*1.015*1.01*1.02
dcant_scaling_uncertainty <- 0.5

7 Uncertainty factor

sd_factor <- 2

8 eMLR stats

8.1 Predictor selection

lm_best_predictor_counts_all %>% 
  filter(period %in% two_decades,
         data_source == "obs") %>% 
  pivot_longer(aou:temp,
               names_to = "predictor",
               values_to = "count") %>% 
  # mutate(count = as.factor(count)) %>% 
  group_by(predictor, count, period, Version_ID_group) %>% 
  summarise(n = n()) %>% 
  ungroup() %>% 
  ggplot(aes(x = count, y = n)) +
  scale_color_manual(values = c("#EE7733", "#009988"), name = "Decade") +
  scale_fill_manual(values = c("#EE7733", "#009988"), name = "Decade") +
  geom_path(aes(col = period)) +
    geom_point(aes(fill = period), shape = 21) +
  coord_flip() +
  scale_x_continuous(breaks = seq(0,10,2),
                     limits = c(0,10),
                     name = "Presence among 10 best models") +
  labs(y = "Counts across density slabs, regional clusters and basins") +
  facet_wrap(~predictor)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01

8.2 Residual distribution

spatial_residual_all %>%
  filter(gamma_slab %in% params_local$plot_slabs[2],
         data_source == "obs",
         period %in% two_decades) %>%
  p_map_dcant_slab(
    var = ".resid_mean",
    col = "divergent",
    title_text = "Residual distribution"
    ) +
  facet_grid(era ~ period) +
  theme_dark()

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
spatial_residual_offset_all %>%
  filter(
    gamma_slab %in% params_local$plot_slabs[1],
    data_source == "obs",
    period %in% two_decades
  ) %>%
  p_map_dcant_slab(var = ".resid_mean_offset",
                   col = "divergent",
                   title_text = "Residual offset distribution (era 2 - era 1)") +
  facet_grid(. ~ period) +
  theme_dark()

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
lat_residual_all %>%
  filter(data_source == "obs",
         period %in% two_decades) %>%
  ggplot(aes(
    .resid_mean,
    lat_grid,
    col = era,
    group = interaction(basin, era, gamma_slab, Version_ID)
  )) +
  geom_vline(xintercept = 0) +
  # geom_point() +
  geom_path(alpha = 0.5) +
  facet_grid(. ~ period)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
lat_residual_all %>%
  filter(data_source == "obs",
         period %in% two_decades) %>%
  select(-c(Version_ID, tref1, tref2)) %>% 
  mutate(sampling_period = if_else(period == "2004 - 2014" & 
                                     era == "2000-2009",
                                   "first",
                                   "second"),
         sampling_period = if_else(period == "1994 - 2004" & 
                                     era == "1989-1999",
                                   "first",
                                   sampling_period)) %>% 
  select(-era) %>% 
  pivot_wider(names_from = sampling_period,
              values_from = .resid_mean) %>% 
  ggplot(aes(first, second)) +
  geom_vline(xintercept = 0) +
  geom_hline(yintercept = 0) +
  geom_bin2d(binwidth = 1) +
  geom_abline(slope = 1, col = "red") +
  geom_smooth(method = "lm") +
  scale_fill_viridis_c(trans = "log10") +
  coord_fixed(ylim = c(-15, 15),
              xlim = c(-15, 15)) +
  labs(
    y = "First sampling period\nmean MLR residual in 5° latitude bin (µmol/kg)",
    x = "Second sampling period\nmean MLR residual in 5° latitude bin (µmol/kg)"
    ) +
  facet_wrap(~period)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
lat_residual_all %>%
  filter(data_source == "obs",
         period %in% two_decades) %>%
  select(-c(Version_ID, tref1, tref2)) %>% 
  mutate(sampling_period = if_else(period == "2004 - 2014" & 
                                     era == "2000-2009",
                                   "first",
                                   "second"),
         sampling_period = if_else(period == "1994 - 2004" & 
                                     era == "1989-1999",
                                   "first",
                                   sampling_period)) %>% 
  select(-era) %>% 
  pivot_wider(names_from = sampling_period,
              values_from = .resid_mean) %>% 
  nest_by(period) %>%
  mutate(mod = list(lm(second ~ first, data = data))) %>%
  summarize(broom::tidy(mod))
# A tibble: 4 × 6
# Groups:   period [2]
  period      term        estimate std.error statistic  p.value
  <chr>       <chr>          <dbl>     <dbl>     <dbl>    <dbl>
1 1994 - 2004 (Intercept)   -0.140    0.0842     -1.66 9.75e- 2
2 1994 - 2004 first          0.647    0.0465     13.9  2.23e-36
3 2004 - 2014 (Intercept)    0.142    0.0899      1.58 1.15e- 1
4 2004 - 2014 first          0.604    0.0415     14.6  3.76e-39
lat_residual_all %>%
  filter(data_source == "obs",
         period %in% two_decades) %>%
  select(-c(Version_ID, tref1, tref2)) %>% 
  mutate(sampling_period = if_else(period == "2004 - 2014" & 
                                     era == "2000-2009",
                                   "first",
                                   "second"),
         sampling_period = if_else(period == "1994 - 2004" & 
                                     era == "1989-1999",
                                   "first",
                                   sampling_period)) %>% 
  select(-era) %>% 
  pivot_wider(names_from = sampling_period,
              values_from = .resid_mean) %>% 
  drop_na() %>% 
  group_by(period) %>%
  summarize(correlation = cor(first, second))
# A tibble: 2 × 2
  period      correlation
  <chr>             <dbl>
1 1994 - 2004       0.566
2 2004 - 2014       0.580
lat_residual_all_mean <- lat_residual_all %>%
  filter(data_source == "obs",
         period %in% two_decades) %>% 
  group_by(period, era, lat_grid) %>% 
  summarise(residual_mean = mean(abs(.resid_mean)),
            residual_sd = sd(.resid_mean),
            residual_iqr = IQR(.resid_mean)) %>% 
  ungroup()

lat_residual_offset_all_mean <- lat_residual_offset_all %>%
  filter(data_source == "obs",
         period %in% two_decades) %>% 
  group_by(period, lat_grid) %>% 
  summarise(residual_mean = mean(abs(.resid_mean_offset)),
            residual_sd = sd(.resid_mean_offset),
            residual_iqr = IQR(.resid_mean)) %>% 
  ungroup()

p_residual_lat <- 
ggplot() +
  geom_vline(xintercept = 0) +
  geom_ribbon(
    data = lat_residual_all_mean,
    aes(
      xmin = residual_mean - residual_iqr,
      xmax = residual_mean + residual_iqr,
      y = lat_grid,
      fill = era
    ),
    alpha = 0.3
  ) +
  geom_path(data = lat_residual_all_mean,
            aes(residual_mean,
                lat_grid,
                col = era)) +
  scale_fill_highcontrast() +
  scale_color_highcontrast() +
  coord_cartesian(xlim = c(-3,7)) +
  facet_grid(. ~ period)


p_residual_lat_offset <- 
ggplot() +
  geom_vline(xintercept = 0) +
  geom_ribbon(
    data = lat_residual_offset_all_mean,
    aes(
      xmin = residual_mean - residual_iqr,
      xmax = residual_mean + residual_iqr,
      y = lat_grid
    ),
    alpha = 0.3
  ) +
  geom_path(data = lat_residual_offset_all_mean,
            aes(residual_mean,
                lat_grid)) +
  coord_cartesian(xlim = c(-3,7)) +
  facet_grid(. ~ period)

p_residual_lat / p_residual_lat_offset

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
rm(p_residual_lat, p_residual_lat_offset)


p_residual_lat <-
ggplot() +
  geom_vline(xintercept = 0) +
  geom_path(data = lat_residual_all %>% 
              filter(data_source == "obs",
                     period %in% two_decades,
                     gamma_slab %in% params_local$plot_slabs[2]),
            aes(.resid_mean,
                lat_grid,
                col = era)) +
  scale_fill_highcontrast() +
  scale_color_highcontrast() +
  coord_cartesian(xlim = c(-3,7)) +
  facet_grid(basin ~ period)

p_residual_lat_offset <-
ggplot() +
  geom_vline(xintercept = 0) +
  geom_path(data = lat_residual_offset_all %>% 
              filter(data_source == "obs",
                     period %in% two_decades,
                     gamma_slab %in% params_local$plot_slabs[2]),
            aes(.resid_mean_offset,
                lat_grid)) +
  scale_fill_highcontrast() +
  scale_color_highcontrast() +
  coord_cartesian(xlim = c(-3,7)) +
  facet_grid(basin ~ period)


p_residual_lat / p_residual_lat_offset

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
rm(p_residual_lat, p_residual_lat_offset)

lat_residual_offset_all %>% 
  ggplot(aes(.resid_mean, .resid_mean_offset)) +
  geom_bin_2d() +
  scale_fill_viridis_c(trans = "log10")

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
lat_residual_offset_all %>%
  pivot_longer(starts_with(".resid"),
               names_to = "type",
               values_to = "residual") %>%
  ggplot(aes(residual, fill = type, col = type)) +
  coord_cartesian(xlim = c(-5,5)) +
  geom_density(alpha = 0.5)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
left_join(lm_best_target_all,
          GLODAP_glanced_all) %>% 
  summarise(mean_rmse = mean(rmse, na.rm = TRUE),
            sd_rmse = sd(rmse, na.rm = TRUE))
# A tibble: 1 × 2
  mean_rmse sd_rmse
      <dbl>   <dbl>
1      3.10    1.63

9 Inventory maps

dcant_inv_all <- bind_rows(
  dcant_inv_all,
  tcant_inv %>% mutate(period = paste(tref1, tref2, sep = " - "),
                       data_source = "obs")
)


dcant_inv_all <- left_join(dcant_inv_all,
                           delta_pCO2_atm)


dcant_inv_all <- dcant_inv_all %>% 
  mutate(beta = dcant / delta_pCO2,
         beta_pos = dcant_pos / delta_pCO2) %>% 
  select(-starts_with("pCO2"))

dcant_inv_all_ensemble <- dcant_inv_all

dcant_inv_all <- dcant_inv_all %>% 
  filter(Version_ID %in% Version_IDs | is.na(Version_ID))

9.1 Ensemble uncertainty

dcant_inv_all_ensemble_sd <-
  dcant_inv_all_ensemble %>%
  filter(period %in% two_decades,
         data_source != "mod_truth") %>%
  group_by(data_source, period, lon, lat) %>%
  summarise(dcant_sd = sd(dcant) * sd_factor) %>%
  ungroup()


dcant_inv_all_ensemble_sd %>%
  mutate(
    data_source = case_when(
      data_source == "mod" ~ "Synthetic data",
      data_source == "obs" ~ "Observations"
    )
  ) %>%
  p_map_cant_inv(var = "dcant_sd",
                 breaks = c(seq(0, 8, 1), Inf),
                 title_text = NULL) +
  facet_grid(period ~ data_source) +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank())

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
7cf954e jens-daniel-mueller 2022-09-08
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
5ca8778 jens-daniel-mueller 2022-09-07
f68fcfa jens-daniel-mueller 2022-07-26
f2615fb jens-daniel-mueller 2022-07-26
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
0160c40 jens-daniel-mueller 2022-07-16
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
003b161 jens-daniel-mueller 2022-07-12
8ab4a87 jens-daniel-mueller 2022-06-29
7629c78 jens-daniel-mueller 2022-06-29
f6786c8 jens-daniel-mueller 2022-06-29
f09080e jens-daniel-mueller 2022-06-28
16dc3af jens-daniel-mueller 2022-06-27
delta_dcant_inv_all_ensemble_RSS <-
  dcant_inv_all_ensemble_sd %>%
  arrange(period) %>%
  group_by(data_source, lat, lon) %>%
  mutate(RSS = sqrt(dcant_sd ^ 2 + lag(dcant_sd ^ 2))) %>%
  ungroup() %>%
  drop_na()  

delta_dcant_inv_all_ensemble_RSS %>% 
  p_map_cant_inv(var = "RSS",
                 breaks = c(seq(0, 8, 1), Inf),
                 title_text = NULL) +
  facet_grid(data_source ~ .) +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank())

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
7cf954e jens-daniel-mueller 2022-09-08
delta_dcant_inv_all_ensemble_sd <-
  dcant_inv_all_ensemble %>%
  filter(period %in% two_decades,
         data_source != "mod_truth") %>%
  arrange(period) %>%
  group_by(MLR_basins, Version_ID_group, data_source, lat, lon) %>%
  mutate(delta_dcant = dcant - lag(dcant)) %>%
  ungroup()

delta_dcant_inv_all_ensemble_sd <-
  delta_dcant_inv_all_ensemble_sd %>%
  filter(!is.na(delta_dcant)) %>%
  group_by(data_source, lon, lat) %>%
  summarise(delta_dcant_sd = sd(delta_dcant) * sd_factor,
            delta_dcant = mean(delta_dcant)) %>%
  ungroup()


delta_dcant_inv_all_ensemble_sd %>% 
  p_map_cant_inv(var = "delta_dcant_sd",
                 breaks = c(seq(0, 8, 1), Inf),
                 title_text = NULL) +
  facet_grid(data_source ~ .) +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank())

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
7cf954e jens-daniel-mueller 2022-09-08
dcant_inv_all_uncertainty <-
  full_join(
    dcant_inv_all %>%
      select(data_source, lon, lat, period, dcant),
    dcant_inv_all_ensemble_sd %>% select(data_source, lon, lat, period, dcant_sd)
  )

dcant_inv_all_uncertainty <-dcant_inv_all_uncertainty %>% 
  filter(period %in%two_decades,
         data_source %in% c("mod", "obs"))

dcant_inv_all_uncertainty <-
  m_grid_horizontal_coarse(dcant_inv_all_uncertainty)

dcant_inv_all_uncertainty <-
  dcant_inv_all_uncertainty %>%
  group_by(lat_grid, lon_grid, data_source, period) %>% 
  summarise(dcant = mean(dcant),
            dcant_sd = mean(dcant_sd),
            n = n()) %>% 
  ungroup() %>% 
  filter(n == 25) %>% 
  rename(lon = lon_grid,
         lat = lat_grid) %>% 
  mutate(dcant_sign = abs(dcant) - dcant_sd)

dcant_inv_all_uncertainty %>% 
  mutate(dcant = abs(dcant)) %>% 
  p_map_cant_inv(
    var = "dcant",
    title_text = NULL,
    subtitle_text = NULL,
    col = "bias"
  ) +
  facet_grid(data_source~period)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
dcant_inv_all_uncertainty %>% 
  p_map_cant_inv(
    var = "dcant_sd",
    title_text = NULL,
    subtitle_text = NULL,
    col = "bias"
  ) +
  facet_grid(data_source~period)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
dcant_inv_all_uncertainty %>% 
  p_map_cant_inv(
    var = "dcant_sign",
    title_text = NULL,
    subtitle_text = NULL,
    col = "bias"
  ) +
  facet_grid(data_source~period)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
map +
  geom_point(
    data = dcant_inv_all_uncertainty %>%
      filter(dcant_sign < 0),
    aes(lon, lat),
    shape = 20,
    size = 0.1
  ) +
  facet_grid(data_source ~ period)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05

9.2 dCant - absolute

p_CI_absolute <- dcant_inv_all %>%
  filter(period %in% two_decades,
         data_source %in% c("obs")) %>%
  p_map_cant_inv(var = "dcant",
                 title_text = NULL) +
  facet_wrap(~ period, ncol = 1) +
  theme(axis.text.x = element_blank()) +
  geom_point(
    data = dcant_inv_all_uncertainty %>%
      filter(dcant_sign < 0,
             data_source == "obs"),
    aes(lon, lat),
    shape = 20,
    size = 0.1,
    col = "grey"
  )

p_CI_absolute +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank())

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
ggsave(path = here::here("output/presentation"),
       filename = "Fig_dcant_column_inventory.png",
       height = 5,
       width = 6)
p_CI_absolute_mod <- dcant_inv_all %>%
  filter(period %in% two_decades,
         data_source %in% c("mod")) %>%
  p_map_cant_inv(var = "dcant",
                 title_text = NULL) +
  facet_wrap(~ period, ncol = 1) +
  theme(axis.text.x = element_blank()) +
  geom_point(
    data = dcant_inv_all_uncertainty %>%
      filter(dcant_sign < 0,
             data_source == "mod"),
    aes(lon, lat),
    shape = 20,
    size = 0.1,
    col = "grey"
  )

p_CI_absolute_mod +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank())

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
# ggsave(path = here::here("output/presentation"),
#        filename = "Fig_dcant_column_inventory.png",
#        height = 5,
#        width = 6)

9.3 Inventory stats

9.3.1 Basin

dcant_inv_stat_mean <-
  full_join(basinmask,
            dcant_inv_all) %>%
  mutate(surf_area = earth_surf(lat, lon)) %>%
  group_by(basin, period, data_source) %>%
  summarise(dcant = weighted.mean(dcant, surf_area)) %>%
  ungroup() %>%
  filter(!is.na(dcant))

dcant_inv_stat_ensemble <-
  full_join(basinmask,
            dcant_inv_all_ensemble) %>%
  mutate(surf_area = earth_surf(lat, lon)) %>%
  group_by(basin, data_source, period, MLR_basins, Version_ID_group) %>%
  summarise(dcant = weighted.mean(dcant, surf_area)) %>%
  ungroup() %>%
  filter(!is.na(dcant)) %>%
  group_by(basin, data_source, period) %>%
  summarise(dcant_sd = sd(dcant) * 2) %>%
  ungroup()

dcant_inv_stat <-
  full_join(dcant_inv_stat_mean,
            dcant_inv_stat_ensemble)

rm(dcant_inv_stat_mean,
   dcant_inv_stat_ensemble)

dcant_inv_stat %>%
  filter(period %in% two_decades) %>%
  group_by(data_source, basin) %>%
  mutate(delta_dcant = dcant - lag(dcant),
         RSS = sqrt(dcant_sd ^ 2 + lag(dcant_sd ^ 2))) %>%
  ungroup() %>%
  kable() %>%
  kable_styling() %>%
  scroll_box(height = "300px")
basin period data_source dcant dcant_sd delta_dcant RSS
N. Pacific 1994 - 2004 mod 3.363703 0.6715443 NA NA
N. Pacific 1994 - 2004 mod_truth 2.915800 0.0000000 NA NA
N. Pacific 1994 - 2004 obs 3.076873 2.2208966 NA NA
N. Pacific 2004 - 2014 mod 3.614817 0.7914575 0.2511143 1.037968
N. Pacific 2004 - 2014 mod_truth 3.352012 0.0000000 0.4362120 0.000000
N. Pacific 2004 - 2014 obs 3.415398 3.0147796 0.3385254 3.744500
S. Pacific 1994 - 2004 mod 4.826130 1.2679823 NA NA
S. Pacific 1994 - 2004 mod_truth 4.931744 0.0000000 NA NA
S. Pacific 1994 - 2004 obs 7.482479 1.8744773 NA NA
S. Pacific 2004 - 2014 mod 6.476528 1.0607614 1.6503976 1.653177
S. Pacific 2004 - 2014 mod_truth 6.060215 0.0000000 1.1284704 0.000000
S. Pacific 2004 - 2014 obs 6.402648 1.7580644 -1.0798310 2.569914
N. Atlantic 1994 - 2004 mod 4.616514 0.8940472 NA NA
N. Atlantic 1994 - 2004 mod_truth 4.057536 0.0000000 NA NA
N. Atlantic 1994 - 2004 obs 9.867769 0.7502779 NA NA
N. Atlantic 2004 - 2014 mod 5.075378 0.7758116 0.4588643 1.183725
N. Atlantic 2004 - 2014 mod_truth 4.878549 0.0000000 0.8210126 0.000000
N. Atlantic 2004 - 2014 obs 8.025765 1.6212880 -1.8420048 1.786475
S. Atlantic 1994 - 2004 mod 5.064488 1.1310498 NA NA
S. Atlantic 1994 - 2004 mod_truth 4.706655 0.0000000 NA NA
S. Atlantic 1994 - 2004 obs 7.252470 2.1850233 NA NA
S. Atlantic 2004 - 2014 mod 6.393315 1.1736069 1.3288264 1.629916
S. Atlantic 2004 - 2014 mod_truth 5.251166 0.0000000 0.5445113 0.000000
S. Atlantic 2004 - 2014 obs 9.960798 2.3259181 2.7083280 3.191273
Indian 1994 - 2004 mod 5.899824 2.0053288 NA NA
Indian 1994 - 2004 mod_truth 5.570926 0.0000000 NA NA
Indian 1994 - 2004 obs 8.154922 3.8623952 NA NA
Indian 2004 - 2014 mod 7.583920 1.4320692 1.6840960 2.464177
Indian 2004 - 2014 mod_truth 6.501337 0.0000000 0.9304108 0.000000
Indian 2004 - 2014 obs 6.519972 1.8028388 -1.6349503 4.262432

9.3.2 Gyres

dcant_inv_stat_mean <-
  full_join(basinmask,
            dcant_inv_all) %>%
  mutate(surf_area = earth_surf(lat, lon),
         lat_grid = cut(lat, c(-50, -20, 20, 50))) %>%
  group_by(basin, period, data_source, lat_grid) %>%
  summarise(dcant = weighted.mean(dcant, surf_area)) %>%
  ungroup() %>%
  filter(!is.na(dcant),
         !is.na(lat_grid),
         lat_grid != "(-20,20]")
  
dcant_inv_stat_ensemble <-
  full_join(basinmask,
            dcant_inv_all_ensemble) %>%
  mutate(surf_area = earth_surf(lat, lon),
         lat_grid = cut(lat, c(-50, -20, 20, 50))) %>%
  group_by(basin, data_source, period, MLR_basins, Version_ID_group, lat_grid) %>%
  summarise(dcant = weighted.mean(dcant, surf_area)) %>%
  ungroup() %>%
  filter(!is.na(dcant),
         !is.na(lat_grid),
         lat_grid != "(-20,20]") %>%
  group_by(basin, data_source, period, lat_grid) %>%
  summarise(dcant_sd = sd(dcant) * 2) %>%
  ungroup()

dcant_inv_stat <-
  full_join(dcant_inv_stat_mean,
            dcant_inv_stat_ensemble)

dcant_inv_stat %>%
  filter(period %in% two_decades) %>%
  group_by(data_source, basin, lat_grid) %>%
  mutate(delta_dcant = dcant - lag(dcant),
         RSS = sqrt(dcant_sd ^ 2 + lag(dcant_sd ^ 2))) %>%
  ungroup() %>%
  kable() %>%
  kable_styling() %>%
  scroll_box(height = "300px")
basin period data_source lat_grid dcant dcant_sd delta_dcant RSS
N. Pacific 1994 - 2004 mod (20,50] 3.9084642 0.6244865 NA NA
N. Pacific 1994 - 2004 mod_truth (20,50] 3.4984361 0.0000000 NA NA
N. Pacific 1994 - 2004 obs (20,50] 3.9829040 2.1195077 NA NA
N. Pacific 2004 - 2014 mod (20,50] 3.9223699 1.0708606 0.0139057 1.239647
N. Pacific 2004 - 2014 mod_truth (20,50] 3.9043518 0.0000000 0.4059158 0.000000
N. Pacific 2004 - 2014 obs (20,50] 3.3833004 3.5827047 -0.5996036 4.162702
S. Pacific 1994 - 2004 mod (-50,-20] 6.5209038 1.4477818 NA NA
S. Pacific 1994 - 2004 mod_truth (-50,-20] 6.4761945 0.0000000 NA NA
S. Pacific 1994 - 2004 obs (-50,-20] 9.8048932 2.5587912 NA NA
S. Pacific 2004 - 2014 mod (-50,-20] 8.3203549 1.1121833 1.7994510 1.825657
S. Pacific 2004 - 2014 mod_truth (-50,-20] 7.9621161 0.0000000 1.4859216 0.000000
S. Pacific 2004 - 2014 obs (-50,-20] 8.5667582 2.4335945 -1.2381350 3.531260
N. Atlantic 1994 - 2004 mod (20,50] 5.6510208 1.0213838 NA NA
N. Atlantic 1994 - 2004 mod_truth (20,50] 4.6144491 0.0000000 NA NA
N. Atlantic 1994 - 2004 obs (20,50] 12.1361324 1.0459766 NA NA
N. Atlantic 2004 - 2014 mod (20,50] 5.6292473 0.9244144 -0.0217735 1.377595
N. Atlantic 2004 - 2014 mod_truth (20,50] 6.1398829 0.0000000 1.5254338 0.000000
N. Atlantic 2004 - 2014 obs (20,50] 8.4461849 1.8377634 -3.6899474 2.114578
S. Atlantic 1994 - 2004 mod (-50,-20] 7.7366367 1.4125504 NA NA
S. Atlantic 1994 - 2004 mod_truth (-50,-20] 6.3774635 0.0000000 NA NA
S. Atlantic 1994 - 2004 obs (-50,-20] 8.4912458 2.1905872 NA NA
S. Atlantic 2004 - 2014 mod (-50,-20] 8.3424057 2.1467637 0.6057690 2.569804
S. Atlantic 2004 - 2014 mod_truth (-50,-20] 7.2252841 0.0000000 0.8478205 0.000000
S. Atlantic 2004 - 2014 obs (-50,-20] 13.1557314 3.2499600 4.6644856 3.919300
Indian 1994 - 2004 mod (-50,-20] 8.8067366 1.9049125 NA NA
Indian 1994 - 2004 mod (20,50] 6.3172021 5.5056000 NA NA
Indian 1994 - 2004 mod_truth (-50,-20] 8.1443384 0.0000000 NA NA
Indian 1994 - 2004 mod_truth (20,50] 2.6253949 0.0000000 NA NA
Indian 1994 - 2004 obs (-50,-20] 10.7970711 3.4693880 NA NA
Indian 1994 - 2004 obs (20,50] -0.3174586 8.7399190 NA NA
Indian 2004 - 2014 mod (-50,-20] 10.2876458 1.8622366 1.4809092 2.663948
Indian 2004 - 2014 mod (20,50] 1.3781176 2.5857828 -4.9390844 6.082590
Indian 2004 - 2014 mod_truth (-50,-20] 9.4334367 0.0000000 1.2890983 0.000000
Indian 2004 - 2014 mod_truth (20,50] 3.5697855 0.0000000 0.9443906 0.000000
Indian 2004 - 2014 obs (-50,-20] 8.2468486 2.7638471 -2.5502226 4.435708
Indian 2004 - 2014 obs (20,50] 7.0876343 3.8995579 7.4050929 9.570409
rm(dcant_inv_stat, dcant_inv_stat_mean, dcant_inv_stat_ensemble)
delta_dcant_inv_all <-
  dcant_inv_all %>%
  filter(data_source %in% c("obs", "mod"),
         period %in% two_decades) %>%
  select(data_source, lon, lat, basin_AIP, period, dcant) %>%
  pivot_wider(names_from = period,
              values_from = dcant) %>%
  mutate(dcant_offset = `2004 - 2014` - `1994 - 2004`,
         period = "(2004 - 2014) - (1994 - 2004)")


delta_dcant_inv_all_uncertainty <-
  full_join(
    delta_dcant_inv_all %>% select(data_source, lon, lat, dcant_offset),
    delta_dcant_inv_all_ensemble_RSS %>% select(data_source, lon, lat, RSS)
  )

delta_dcant_inv_all_uncertainty <-
  m_grid_horizontal_coarse(delta_dcant_inv_all_uncertainty)

delta_dcant_inv_all_uncertainty <-
  delta_dcant_inv_all_uncertainty %>%
  group_by(lat_grid, lon_grid, data_source) %>% 
  summarise(dcant_offset = mean(dcant_offset),
            RSS = mean(RSS),
            n = n()) %>% 
  ungroup() %>% 
  filter(n == 25) %>% 
  rename(lon = lon_grid,
         lat = lat_grid) %>% 
  mutate(dcant_offset_sign = abs(dcant_offset) - RSS)

delta_dcant_inv_all_uncertainty %>% 
  mutate(dcant_offset = abs(dcant_offset)) %>% 
  p_map_cant_inv(
    var = "dcant_offset",
    title_text = NULL,
    subtitle_text = NULL,
    col = "bias"
  ) +
  facet_grid(data_source~.)

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
e93fdfd jens-daniel-mueller 2022-09-23
delta_dcant_inv_all_uncertainty %>% 
  p_map_cant_inv(
    var = "RSS",
    title_text = NULL,
    subtitle_text = NULL,
    col = "bias"
  ) +
  facet_grid(data_source~.)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
e93fdfd jens-daniel-mueller 2022-09-23
delta_dcant_inv_all_uncertainty %>% 
  p_map_cant_inv(
    var = "dcant_offset_sign",
    title_text = NULL,
    subtitle_text = NULL,
    col = "bias"
  ) +
  facet_grid(data_source~.)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
e93fdfd jens-daniel-mueller 2022-09-23
map +
  geom_point(
    data = delta_dcant_inv_all_uncertainty %>%
      filter(dcant_offset_sign < 0),
    aes(lon, lat),
    shape = 20,
    size = 0.1,
    col = "black"
  ) + 
  facet_wrap(~data_source)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
e93fdfd jens-daniel-mueller 2022-09-23
p_CI_absolute_mod_delta <- dcant_inv_all %>%
  filter(period %in% two_decades,
         data_source != "obs") %>%
  mutate(
    data_source = case_when(
      data_source == "mod" ~ "Reconstruction",
      data_source == "mod_truth" ~ "Model truth"
    )
  ) %>%
  p_map_cant_inv(var = "dcant",
                 title_text = NULL) +
  facet_grid(period ~ data_source) +
  theme(axis.text.x = element_blank()) +
  geom_point(
    data = dcant_inv_all_uncertainty %>%
      filter(dcant_sign < 0,
             data_source == "mod") %>%
      mutate(data_source = case_when(data_source == "mod" ~ "Reconstruction")),
    aes(lon, lat),
    shape = 20,
    size = 0.1,
    col = "grey"
  )

p_CI_bias_delta <-
  dcant_inv_all %>%
  filter(period %in% two_decades,
         data_source != "obs") %>%
  select(data_source, lon, lat, basin_AIP, period, dcant) %>%
  pivot_wider(names_from = period,
              values_from = dcant) %>%
  mutate(dcant_offset = `2004 - 2014` - `1994 - 2004`,
         period = "Decadal offset") %>%
  mutate(
    data_source = case_when(
      data_source == "mod" ~ "Reconstruction",
      data_source == "mod_truth" ~ "Model truth"
    )
  ) %>%
  p_map_cant_inv(
    var = "dcant_offset",
    title_text = NULL,
    subtitle_text = NULL,
    col = "bias"
  ) +
  facet_grid(period ~ data_source) +
  geom_point(
    data = delta_dcant_inv_all_uncertainty %>%
      filter(dcant_offset_sign < 0,
             data_source == "mod") %>%
      mutate(data_source = case_when(data_source == "mod" ~ "Reconstruction")),
    aes(lon, lat),
    shape = 20,
    size = 0.1,
    col = "black"
  )

p_CI_absolute_mod_delta / p_CI_bias_delta + 
  plot_annotation(tag_levels = 'A')

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
ggsave(path = here::here("output/publication"),
       filename = "FigS_delta_dcant_column_inventory_synthetic_data.png",
       height = 7,
       width = 8)

rm(p_CI_absolute_mod_delta, p_CI_bias_delta)

p_CI_bias_delta_delta <-
  dcant_inv_all %>%
  filter(period %in% two_decades,
         data_source != "obs") %>%
  select(data_source, lon, lat, basin_AIP, period, dcant) %>%
  pivot_wider(names_from = period,
              values_from = dcant) %>%
  mutate(dcant_offset = `2004 - 2014` - `1994 - 2004`,
         period = "Decadal offset") %>%
  select(lon, lat, data_source, dcant_offset) %>% 
  pivot_wider(names_from = data_source,
              values_from = dcant_offset) %>% 
  mutate(delta_dcant_bias = mod - mod_truth) %>% 
  p_map_cant_inv(
    var = "delta_dcant_bias",
    title_text = NULL,
    subtitle_text = NULL,
    col = "bias"
  )
# theme(strip.text.x = element_blank(),
#       strip.background.x = element_blank())

p_CI_bias_delta_delta

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
rm(p_CI_bias_delta_delta)

9.4 dCant - delta

p_CI_delta <-
  delta_dcant_inv_all %>%
  filter(data_source == "obs") %>%
  p_map_cant_inv(
    var = "dcant_offset",
    title_text = NULL,
    subtitle_text = NULL,
    col = "bias"
  ) +
  geom_point(
    data = delta_dcant_inv_all_uncertainty %>%
      filter(dcant_offset_sign < 0,
             data_source == "obs"),
    aes(lon, lat),
    shape = 20,
    size = 0.1,
    col = "black"
  ) +
  facet_wrap(~ period)

p_CI_absolute / p_CI_delta + 
  plot_annotation(tag_levels = 'A')

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
e2adac6 jens-daniel-mueller 2022-07-22
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
ea46812 jens-daniel-mueller 2022-07-13
f09080e jens-daniel-mueller 2022-06-28
16dc3af jens-daniel-mueller 2022-06-27
87e9eb8 jens-daniel-mueller 2022-06-27
b52b159 jens-daniel-mueller 2022-06-27
1d73ec9 jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
094bfa0 jens-daniel-mueller 2022-02-18
d2191ad jens-daniel-mueller 2022-02-04
5f2aed0 jens-daniel-mueller 2022-01-27
9753eb8 jens-daniel-mueller 2022-01-26
b1d7720 jens-daniel-mueller 2022-01-21
d6b399a jens-daniel-mueller 2022-01-21
ggsave(path = here::here("output/publication"),
       filename = "Fig_dcant_column_inventory.png",
       height = 10,
       width = 8)

p_CI_delta +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank())

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
e2adac6 jens-daniel-mueller 2022-07-22
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
ea46812 jens-daniel-mueller 2022-07-13
f09080e jens-daniel-mueller 2022-06-28
16dc3af jens-daniel-mueller 2022-06-27
87e9eb8 jens-daniel-mueller 2022-06-27
b52b159 jens-daniel-mueller 2022-06-27
1d73ec9 jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
094bfa0 jens-daniel-mueller 2022-02-18
d2191ad jens-daniel-mueller 2022-02-04
5f2aed0 jens-daniel-mueller 2022-01-27
9753eb8 jens-daniel-mueller 2022-01-26
b1d7720 jens-daniel-mueller 2022-01-21
d6b399a jens-daniel-mueller 2022-01-21
ggsave(path = here::here("output/presentation"),
       filename = "Fig_dcant_column_inventory_delta.png",
       height = 3.2,
       width = 6)

rm(p_CI_absolute, p_CI_delta)

9.5 Bias

p_CI_absolute_mod <- dcant_inv_all %>%
  filter(period %in% two_decades,
         data_source != "obs") %>%
  mutate(
    data_source = case_when(
      data_source == "mod" ~ "Reconstruction",
      data_source == "mod_truth" ~ "Model truth"
    )
  ) %>%
  p_map_cant_inv(var = "dcant",
                 title_text = NULL) +
  facet_grid(data_source ~ period) +
  theme(axis.text.x = element_blank()) +
  geom_point(
    data = dcant_inv_all_uncertainty %>%
      filter(dcant_sign < 0,
             data_source == "mod") %>%
      mutate(
        data_source = case_when(
          data_source == "mod" ~ "Reconstruction"
        )
      ),
    aes(lon, lat),
    shape = 20,
    size = 0.1,
    col = "grey"
  )

p_CI_absolute_mod

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
5b77c4f jens-daniel-mueller 2022-08-10
p_CI_bias <-
  dcant_inv_all %>%
  filter(period %in% two_decades,
         data_source != "obs") %>%
  select(data_source, lon, lat, basin_AIP, period, dcant) %>%
  pivot_wider(names_from = data_source,
              values_from = dcant) %>%
  mutate(dcant_bias = mod - mod_truth,
         data_source = "Reconstruction bias") %>%
  p_map_cant_inv(
    var = "dcant_bias",
    title_text = NULL,
    subtitle_text = NULL,
    col = "bias"
  ) +
  facet_grid(data_source ~ period) +
  theme(strip.text.x = element_blank(),
        strip.background.x = element_blank())

p_CI_absolute_mod / p_CI_bias + 
  plot_annotation(tag_levels = 'A')

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
46c163a jens-daniel-mueller 2022-10-10
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
5b77c4f jens-daniel-mueller 2022-08-10
ggsave(path = here::here("output/publication"),
       filename = "FigS_dcant_column_inventory_synthetic_data.png",
       height = 7,
       width = 8)

rm(p_CI_absolute_mod, p_CI_bias)
p_CI_bias_decade <-
  dcant_inv_all %>%
  filter(period %in% two_decades,
         data_source != "obs") %>%
  select(data_source, lon, lat, basin_AIP, period, dcant) %>%
  pivot_wider(names_from = data_source,
              values_from = dcant) %>%
  mutate(dcant_bias = mod - mod_truth,
         data_source = "Reconstruction bias") %>%
  arrange(period) %>% 
  group_by(lon, lat) %>% 
  summarise(delta_dcant_bias = dcant_bias - lag(dcant_bias)) %>% 
  ungroup() %>% 
  drop_na() %>% 
  p_map_cant_inv(
    var = "delta_dcant_bias",
    title_text = NULL,
    subtitle_text = NULL,
    col = "bias"
  ) +
  theme(strip.text.x = element_blank(),
        strip.background.x = element_blank())

p_CI_bias_decade

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
ggsave(path = here::here("output/publication"),
       filename = "FigS_delta_dcant_column_inventory_synthetic_data_bias.png",
       height = 3.5,
       width = 5)

rm(p_CI_bias_decade)

9.6 Density distributions

bind_rows(
  dcant_inv_all %>%
    filter(period %in% two_decades) %>%
    mutate(
      data_source = case_when(
        data_source == "mod" ~ "Reconstruction",
        data_source == "obs" ~ "Observations",
        data_source == "mod_truth" ~ "Model truth"
      )
    ) %>%
    select(data_source, dcant, period),
  dcant_inv_bias_all %>%
    filter(period %in% two_decades) %>%
    mutate(data_source = "Reconstruction bias") %>%
    select(data_source, dcant = dcant_pos_bias, period)
) %>%
  ggplot(aes(dcant, col = data_source)) +
  scale_color_brewer(palette = "Dark2") +
  scale_fill_brewer(palette = "Dark2") +
  geom_vline(xintercept = 0) +
  geom_density(alpha = 0.3) +
  coord_cartesian(xlim = c(-2, 18)) +
  facet_grid(period ~ .) +
  labs(x = dcant_CI_label) +
  theme(legend.title = element_blank())

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
5ca8778 jens-daniel-mueller 2022-09-07
# ggsave(path = here::here("output/publication"),
#        filename = "FigS_dcant_column_inventory_density_distribution.png",
#        height = 4,
#        width = 7)
bind_rows(
  dcant_inv_all %>%
    filter(period %in% two_decades) %>%
    select(data_source, lon, lat, period, dcant) %>%
    pivot_wider(names_from = period,
                values_from = dcant) %>%
    mutate(dcant_offset = `2004 - 2014` - `1994 - 2004`,
           period = "(2004 - 2014) - (1994 - 2004)")  %>%
    mutate(
      data_source = case_when(
        data_source == "mod" ~ "Reconstruction",
        data_source == "obs" ~ "Observations",
        data_source == "mod_truth" ~ "Model truth"
      )
    ) %>%
    select(data_source, dcant_offset, period),
  dcant_inv_bias_all %>%
    filter(period %in% two_decades) %>%
    select(lon, lat, period, dcant_bias) %>%
    pivot_wider(names_from = period,
                values_from = dcant_bias) %>%
    mutate(dcant_offset = `2004 - 2014` - `1994 - 2004`,
           period = "(2004 - 2014) - (1994 - 2004)")  %>%
    mutate(data_source = "Reconstruction bias") %>%
    select(data_source, dcant_offset, period)
) %>%
  ggplot(aes(dcant_offset, col = data_source)) +
  scale_color_brewer(palette = "Dark2") +
  scale_fill_brewer(palette = "Dark2") +
  geom_vline(xintercept = 0) +
  geom_density(alpha = 0.3) +
  coord_cartesian(xlim = c(-10, 10)) +
  labs(x = delta_dcant_CI_label) +
  theme(legend.title = element_blank())

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
5ca8778 jens-daniel-mueller 2022-09-07
# ggsave(
#   path = here::here("output/publication"),
#   filename = "FigS_delta_dcant_column_inventory_density_distribution.png",
#   height = 3,
#   width = 7
# )

9.7 Unadjusted data

dcant_inv_all_unadjusted <-
  dcant_inv_all_ensemble %>%
  filter(period %in% two_decades,
         data_source == "obs",
         MLR_basins == "3",
         Version_ID %in% Version_IDs |
           Version_ID %in% Version_IDs_d)

p_CI_unadjusted <- 
dcant_inv_all_unadjusted %>%
  p_map_cant_inv(var = "dcant",
                 title_text = NULL) +
  facet_grid(Version_ID_group ~ period)

p_CI_unadjusted_bias <-
  dcant_inv_all_unadjusted %>%
  select(Version_ID_group, lon, lat, basin_AIP, period, dcant) %>%
  pivot_wider(names_from = Version_ID_group,
              values_from = dcant) %>%
  mutate(dcant_offset = `Bulk adjustment` - `No adjustment`,
         data_source = "Adjustment impact") %>%
  p_map_cant_inv(
    var = "dcant_offset",
    title_text = NULL,
    subtitle_text = NULL,
    col = "bias",
    legend_title = 
  ) +
  facet_grid(data_source ~ period) +
  theme(strip.text.x = element_blank(),
        strip.background.x = element_blank())

p_CI_unadjusted / p_CI_unadjusted_bias + 
  plot_annotation(tag_levels = 'A')

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
74dca9d jens-daniel-mueller 2022-08-17
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
f68fcfa jens-daniel-mueller 2022-07-26
f2615fb jens-daniel-mueller 2022-07-26
fea41c1 jens-daniel-mueller 2022-07-20
9ce772d jens-daniel-mueller 2022-07-19
ggsave(path = here::here("output/publication"),
       filename = "FigS_dcant_column_inventory_unadjusted_data.png",
       height = 7,
       width = 8)

rm(p_CI_unadjusted, p_CI_unadjusted_bias)

9.8 Beta

dcant_inv_all %>%
  filter(data_source %in% c("obs")) %>% 
  p_map_cant_inv(var = "beta",
                 breaks = c(-Inf, seq(0, 1, 0.1), Inf),
                 title_text = NULL,
                 legend_title = beta_CI_label) +
  facet_grid(period ~ .)

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
46c163a jens-daniel-mueller 2022-10-10
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
f68fcfa jens-daniel-mueller 2022-07-26
f2615fb jens-daniel-mueller 2022-07-26
fea41c1 jens-daniel-mueller 2022-07-20
b1f7ab3 jens-daniel-mueller 2022-07-18
d2ae54c jens-daniel-mueller 2022-07-18
efa414b jens-daniel-mueller 2022-07-16
ggsave(path = here::here("output/publication"),
       filename = "FigS_beta_column_inventory.png",
       height = 8,
       width = 6)

9.9 Zonal means

dcant_inv_all <- m_grid_horizontal_coarse(dcant_inv_all)

dcant_inv_all_lat_mean <- dcant_inv_all %>% 
  group_by(basin_AIP, period, lat_grid, data_source) %>% 
  summarise(beta = mean(beta, na.rm = TRUE),
            dcant = mean(dcant, na.rm = TRUE)) %>% 
  ungroup()

dcant_inv_all_ensemble <- m_grid_horizontal_coarse(dcant_inv_all_ensemble)

dcant_inv_all_ensemble_lat_mean <- dcant_inv_all_ensemble %>% 
  group_by(basin_AIP, period, lat_grid, Version_ID, data_source) %>% 
  summarise(beta_mean = mean(beta, na.rm = TRUE),
            dcant_mean = mean(dcant, na.rm = TRUE)) %>% 
  ungroup()

dcant_inv_all_ensemble_lat_mean_average <- dcant_inv_all_ensemble_lat_mean %>% 
  group_by(basin_AIP, period, lat_grid, data_source) %>% 
  summarise(beta_sd = sd(beta_mean, na.rm = TRUE),
            beta_mean = mean(beta_mean, na.rm = TRUE),
            dcant_sd = sd(dcant_mean, na.rm = TRUE),
            dcant_mean = mean(dcant_mean, na.rm = TRUE)) %>% 
  ungroup()

dcant_inv_all_lat_mean <- full_join(dcant_inv_all_lat_mean,
                                    dcant_inv_all_ensemble_lat_mean_average)

9.9.1 dcant

dcant_inv_all_lat_mean %>%
  filter(period != "1800 - 1994") %>% 
  ggplot(aes(lat_grid, dcant, fill = period)) +
  geom_hline(yintercept = c(0,10)) +
  geom_vline(xintercept = c(-10,10)) +
  geom_vline(xintercept = c(-40,-30,30,40)) +
  geom_ribbon(aes(ymin = dcant - dcant_sd,
                  ymax = dcant + dcant_sd),
              alpha = 0.3) +
  geom_path(aes(col = period)) +
  geom_point(shape = 21) +
  scale_color_brewer(palette = "Dark2", name = "Mean ± SD") +
  scale_fill_brewer(palette = "Dark2", name = "Mean ± SD") +
  coord_flip() +
  facet_grid(data_source ~ basin_AIP) +
  labs(x = "Latitude (°N)",
       y = dcant_CI_label) +
  scale_x_continuous(breaks = seq(-75,75, 15))

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
5b77c4f jens-daniel-mueller 2022-08-10
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
ea46812 jens-daniel-mueller 2022-07-13
dcant_inv_all_lat_mean %>%
  filter(period != "1800 - 1994") %>% 
  mutate(lat_grid = cut(lat_grid, c(-40,-30,-10,10,30,40))) %>% 
  group_by(lat_grid, data_source) %>% 
  summarise(dcant_mean = mean(dcant_mean, na_rm = TRUE)) %>% 
  ungroup()
# A tibble: 18 × 3
   lat_grid  data_source dcant_mean
   <fct>     <chr>            <dbl>
 1 (-40,-30] mod              11.8 
 2 (-40,-30] mod_truth        10.9 
 3 (-40,-30] obs              14.2 
 4 (-30,-10] mod               8.72
 5 (-30,-10] mod_truth         7.73
 6 (-30,-10] obs              11.5 
 7 (-10,10]  mod               4.66
 8 (-10,10]  mod_truth         4.09
 9 (-10,10]  obs               7.42
10 (10,30]   mod               5.39
11 (10,30]   mod_truth         5.03
12 (10,30]   obs               7.23
13 (30,40]   mod               6.29
14 (30,40]   mod_truth         6.46
15 (30,40]   obs              11.0 
16 <NA>      mod               5.62
17 <NA>      mod_truth         5.59
18 <NA>      obs               7.13
dcant_inv_all_lat_mean %>%
  filter(period != "1800 - 1994") %>% 
  mutate(lat_grid = cut(lat_grid, c(-40,-30,-10,10,30,40))) %>% 
  group_by(lat_grid, basin_AIP, data_source) %>% 
  summarise(dcant_mean = mean(dcant_mean, na_rm = TRUE)) %>% 
  ungroup()
# A tibble: 51 × 4
   lat_grid  basin_AIP data_source dcant_mean
   <fct>     <chr>     <chr>            <dbl>
 1 (-40,-30] Atlantic  mod              11.5 
 2 (-40,-30] Atlantic  mod_truth        10.1 
 3 (-40,-30] Atlantic  obs              15.4 
 4 (-40,-30] Indian    mod              13.4 
 5 (-40,-30] Indian    mod_truth        12.6 
 6 (-40,-30] Indian    obs              14.5 
 7 (-40,-30] Pacific   mod              10.5 
 8 (-40,-30] Pacific   mod_truth         9.97
 9 (-40,-30] Pacific   obs              12.7 
10 (-30,-10] Atlantic  mod               7.58
# … with 41 more rows
dcant_inv_all_lat_mean %>%
  filter(period != "1800 - 1994") %>% 
  mutate(lat_grid = cut(lat_grid, c(-90,0,90))) %>% 
  group_by(lat_grid, basin_AIP, period, data_source) %>% 
  summarise(dcant_mean = mean(dcant_mean, na_rm = TRUE)) %>% 
  ungroup()
# A tibble: 54 × 5
   lat_grid basin_AIP period      data_source dcant_mean
   <fct>    <chr>     <chr>       <chr>            <dbl>
 1 (-90,0]  Atlantic  1994 - 2004 mod               4.26
 2 (-90,0]  Atlantic  1994 - 2004 mod_truth         4.06
 3 (-90,0]  Atlantic  1994 - 2004 obs               7.06
 4 (-90,0]  Atlantic  1994 - 2014 mod               9.59
 5 (-90,0]  Atlantic  1994 - 2014 mod_truth         8.72
 6 (-90,0]  Atlantic  1994 - 2014 obs              14.6 
 7 (-90,0]  Atlantic  2004 - 2014 mod               5.38
 8 (-90,0]  Atlantic  2004 - 2014 mod_truth         4.66
 9 (-90,0]  Atlantic  2004 - 2014 obs               7.59
10 (-90,0]  Indian    1994 - 2004 mod               5.84
# … with 44 more rows
dcant_inv_all_lat_mean %>%
  filter(period != "1800 - 1994") %>% 
  mutate(lat_grid = cut(lat_grid, c(-50,-20,20,50))) %>% 
  group_by(lat_grid, basin_AIP, period, data_source) %>% 
  summarise(dcant_mean = mean(dcant_mean, na_rm = TRUE)) %>% 
  ungroup() %>% 
  filter(data_source == "obs") %>% 
  arrange(basin_AIP)
# A tibble: 36 × 5
   lat_grid  basin_AIP period      data_source dcant_mean
   <fct>     <chr>     <chr>       <chr>            <dbl>
 1 (-50,-20] Atlantic  1994 - 2004 obs               9.05
 2 (-50,-20] Atlantic  1994 - 2014 obs              20.4 
 3 (-50,-20] Atlantic  2004 - 2014 obs              11.2 
 4 (-20,20]  Atlantic  1994 - 2004 obs               5.56
 5 (-20,20]  Atlantic  1994 - 2014 obs              14.1 
 6 (-20,20]  Atlantic  2004 - 2014 obs               8.30
 7 (20,50]   Atlantic  1994 - 2004 obs              12.1 
 8 (20,50]   Atlantic  1994 - 2014 obs              20.5 
 9 (20,50]   Atlantic  2004 - 2014 obs               8.33
10 <NA>      Atlantic  1994 - 2004 obs               7.53
# … with 26 more rows
dcant_inv_all_ensemble_lat_mean %>% 
  ggplot(aes(lat_grid, dcant_mean, fill=period, group=Version_ID)) +
  geom_hline(yintercept = 0) +
  geom_path(aes(col=period), alpha = 0.3) +
  scale_color_brewer(palette = "Dark2") +
  scale_fill_brewer(palette = "Dark2") +
  coord_flip() +
  facet_grid(data_source ~ basin_AIP) +
  labs(x = "Latitude (°N)",
       y = dcant_CI_label)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
5b77c4f jens-daniel-mueller 2022-08-10
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
0160c40 jens-daniel-mueller 2022-07-16
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
ea46812 jens-daniel-mueller 2022-07-13

9.9.2 beta

dcant_inv_all_lat_mean %>%
  ggplot(aes(lat_grid, beta, fill = period)) +
  geom_hline(yintercept = 0) +
  geom_ribbon(aes(ymin = beta - beta_sd,
                  ymax = beta + beta_sd),
              alpha = 0.3) +
  geom_path(aes(col = period)) +
  geom_point(shape = 21) +
  scale_color_brewer(palette = "Dark2", name = "Mean ± SD") +
  scale_fill_brewer(palette = "Dark2", name = "Mean ± SD") +
  coord_flip() +
  facet_grid(data_source ~ basin_AIP) +
  labs(x = "Latitude (°N)",
       y = beta_CI_label) +
  scale_x_continuous(breaks = seq(-75,75, 15))

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
46c163a jens-daniel-mueller 2022-10-10
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
5b77c4f jens-daniel-mueller 2022-08-10
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
ea46812 jens-daniel-mueller 2022-07-13
dcant_inv_all_ensemble_lat_mean %>% 
  ggplot(aes(lat_grid, beta_mean, fill=period, group=Version_ID)) +
  geom_hline(yintercept = 0) +
  geom_path(aes(col=period), alpha = 0.3) +
  scale_color_brewer(palette = "Dark2") +
  scale_fill_brewer(palette = "Dark2") +
  coord_flip() +
  facet_grid(data_source ~ basin_AIP) +
  labs(x = "Latitude (°N)",
       y = beta_CI_label)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
46c163a jens-daniel-mueller 2022-10-10
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
5b77c4f jens-daniel-mueller 2022-08-10
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
0160c40 jens-daniel-mueller 2022-07-16
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
ea46812 jens-daniel-mueller 2022-07-13

10 Global section

10.1 Ensemble uncertainty

delta_dcant_global_section_all <-
  dcant_global_section_all %>%
  filter(data_source %in% c("obs", "mod"),
         period %in% two_decades) %>%
  select(data_source, dist, depth, period, dcant) %>%
  drop_na() %>% 
  pivot_wider(names_from = period,
              values_from = dcant) %>%
  mutate(dcant_offset = `2004 - 2014` - `1994 - 2004`,
         period = "(2004 - 2014) - (1994 - 2004)")

dcant_global_section_all_ensemble_sd <-
  dcant_global_section_all_ensemble %>%
  filter(period %in% two_decades,
         data_source != "mod_truth") %>%
  group_by(data_source, period, dist, depth) %>%
  summarise(dcant_sd = sd(dcant) * sd_factor) %>%
  ungroup()


dcant_global_section_all_uncertainty <-
  left_join(
    dcant_global_section_all %>% select(data_source, period, dist, depth, dcant),
    dcant_global_section_all_ensemble_sd %>% select(data_source, period, dist, depth, dcant_sd)
  )

dcant_global_section_all_uncertainty <-
  dcant_global_section_all_uncertainty %>%
  mutate(dist_grid = as.numeric(as.character(cut(
    dist, seq(0, 50, 2), seq(1, 49, 2)
  ))),
  depth_grid = as.numeric(as.character(cut(
    depth,
    c(seq(0, 500, 100), seq(1000, 10000, 500)),
    c(seq(50, 450, 100), seq(750, 10000, 500)),
    right = FALSE
  ))))


dcant_global_section_all_uncertainty <-
  dcant_global_section_all_uncertainty %>%
  group_by(dist_grid, period, depth_grid, data_source) %>% 
  summarise(dcant = mean(dcant),
            dcant_sd = mean(dcant_sd),
            n = n()) %>% 
  ungroup() %>% 
  rename(dist = dist_grid,
         depth = depth_grid) %>%
  mutate(dcant_sign = abs(dcant) - dcant_sd,
         band = "dummy")


dcant_global_section_all_uncertainty  %>% 
  filter(data_source == "obs",
         period == "1994 - 2004") %>% 
  p_section_global(
    var = "dcant",
    plot_slabs = "n",
    title_text = NULL,
    subtitle_text = NULL,
    col = "div"
  )

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
e93fdfd jens-daniel-mueller 2022-09-23
77e6a80 jens-daniel-mueller 2022-09-08
dcant_global_section_all_uncertainty  %>% 
  filter(data_source == "obs",
         period == "1994 - 2004") %>% 
  p_section_global(
    var = "dcant_sd",
    plot_slabs = "n",
    title_text = NULL,
    subtitle_text = NULL,
    col = "div"
  )

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
e93fdfd jens-daniel-mueller 2022-09-23
77e6a80 jens-daniel-mueller 2022-09-08
dcant_global_section_all_uncertainty  %>%
  filter(data_source == "obs",
         period == "1994 - 2004") %>%
  rename(delta_dcant = dcant_sign) %>%
  p_section_global(
    var = "delta_dcant",
    plot_slabs = "n",
    title_text = NULL,
    subtitle_text = NULL,
    col = "div"
  )

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
e93fdfd jens-daniel-mueller 2022-09-23
77e6a80 jens-daniel-mueller 2022-09-08
ggplot() +
  geom_point(
    data = dcant_global_section_all_uncertainty %>%
      filter(dcant_sign < 0),
    aes(dist, depth),
    shape = 4
  ) +
  facet_grid(data_source~period) +
  scale_y_reverse()

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
e93fdfd jens-daniel-mueller 2022-09-23
77e6a80 jens-daniel-mueller 2022-09-08
dcant_global_section_all_uncertainty <-
  dcant_global_section_all_uncertainty %>%
  filter(dcant_sign < 0)


delta_dcant_global_section_all_ensemble_RSS <-
  dcant_global_section_all_ensemble_sd %>%
  arrange(period) %>%
  group_by(data_source, dist, depth) %>%
  mutate(RSS = sqrt(dcant_sd ^ 2 + lag(dcant_sd ^ 2))) %>%
  ungroup() %>%
  drop_na()

delta_dcant_global_section_all_uncertainty <-
  left_join(
    delta_dcant_global_section_all %>% select(data_source, dist, depth, dcant_offset),
    delta_dcant_global_section_all_ensemble_RSS %>% select(data_source, dist, depth, RSS)
  )

delta_dcant_global_section_all_uncertainty <-
  delta_dcant_global_section_all_uncertainty %>%
  mutate(dist_grid = as.numeric(as.character(cut(
    dist, seq(0, 50, 2), seq(1, 49, 2)
  ))),
  depth_grid = as.numeric(as.character(cut(
    depth,
    c(seq(0, 500, 100), seq(1000, 10000, 500)),
    c(seq(50, 450, 100), seq(750, 10000, 500)),
    right = FALSE
  ))))

delta_dcant_global_section_all_uncertainty <-
  delta_dcant_global_section_all_uncertainty %>%
  group_by(dist_grid, depth_grid, data_source) %>% 
  summarise(dcant_offset = mean(dcant_offset),
            RSS = mean(RSS),
            n = n()) %>% 
  ungroup() %>% 
  rename(dist = dist_grid,
         depth = depth_grid) %>%
  mutate(dcant_offset_sign = abs(dcant_offset) - RSS,
         band = "dummy")


delta_dcant_global_section_all_uncertainty  %>% 
  mutate(dcant_offset = dcant_offset) %>% 
  filter(data_source == "obs") %>% 
  rename(delta_dcant = dcant_offset) %>% 
  p_section_global(
    var = "delta_dcant",
    plot_slabs = "n",
    title_text = NULL,
    subtitle_text = NULL,
    col = "div"
  )

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
e93fdfd jens-daniel-mueller 2022-09-23
delta_dcant_global_section_all_uncertainty  %>% 
  filter(data_source == "obs") %>% 
  rename(delta_dcant = RSS) %>% 
  p_section_global(
    var = "delta_dcant",
    plot_slabs = "n",
    title_text = NULL,
    subtitle_text = NULL,
    col = "div"
  )

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
e93fdfd jens-daniel-mueller 2022-09-23
delta_dcant_global_section_all_uncertainty  %>%
  filter(data_source == "obs") %>%
  rename(delta_dcant = dcant_offset_sign) %>%
  p_section_global(
    var = "delta_dcant",
    plot_slabs = "n",
    title_text = NULL,
    subtitle_text = NULL,
    col = "div"
  )

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
e93fdfd jens-daniel-mueller 2022-09-23
ggplot() +
  geom_point(
    data = delta_dcant_global_section_all_uncertainty %>%
      filter(dcant_offset_sign < 0),
    aes(dist, depth),
    shape = 4
  ) +
  scale_y_reverse() +
  facet_grid(data_source~.)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
e93fdfd jens-daniel-mueller 2022-09-23
delta_dcant_global_section_all_uncertainty <-
  delta_dcant_global_section_all_uncertainty %>%
  filter(dcant_offset_sign < 0)

10.2 Observations

p_dcant_global_section_dec1 <-
  dcant_global_section_all %>%
  filter(data_source == "obs",
         period %in% "1994 - 2004") %>%
  p_section_global(var = "dcant",
                   title_text = "1994 - 2004",
                   df_uncertainty = dcant_global_section_all_uncertainty %>% 
                     filter(period %in% "1994 - 2004",
                            data_source == "obs"),
                   col_uncertainty = "grey",
                   subtitle_text = NULL,
                   plot_slabs = "n",
                   contour_level = 5) +
  theme(
    axis.title.x = element_blank(),
    axis.text.x.bottom = element_blank()
  )


p_dcant_global_section_dec2 <-
  dcant_global_section_all %>%
  filter(data_source == "obs",
         period %in% "2004 - 2014") %>%
  p_section_global(
    var = "dcant",
    title_text = NULL,
    subtitle_text = NULL,
    plot_slabs = "n",
    contour_level = 5,
    df_uncertainty = dcant_global_section_all_uncertainty %>%
      filter(period %in% "2004 - 2014",
                            data_source == "obs"),
    col_uncertainty = "grey"
  ) &
  theme(
    legend.position = "none"
  )

p_dcant_global_section_offset <-
  dcant_global_section_all %>%
  filter(data_source == "obs",
         period %in% two_decades) %>%
  arrange(depth, dist) %>%
  select(depth, dist, dcant, period, gamma_mean) %>%
  drop_na() %>%
  pivot_wider(names_from = period,
              values_from = dcant) %>%
  mutate(delta_dcant = `2004 - 2014` - `1994 - 2004`) %>%
  p_section_global(
    var = "delta_dcant",
    df_uncertainty = delta_dcant_global_section_all_uncertainty %>% 
      filter(data_source == "obs"),
    plot_slabs = "y",
    col = "div",
    title_text = NULL,
    subtitle_text = NULL
  )



wrap_plots(
  p_dcant_global_section_dec1,
  p_dcant_global_section_dec2 &
    theme(axis.title.x = element_blank(),
          axis.text.x = element_blank()),
  p_dcant_global_section_offset &
    theme(axis.title.x.top = element_blank(),
          axis.text.x.top = element_blank()),
  ncol = 1
)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
ggsave(path = here::here("output/publication"),
       filename = "Fig_dcant_global_section.png",
       height = 10,
       width = 8)

ggsave(path = here::here("output/presentation"),
       filename = "Fig_dcant_global_section.png",
       height = 9,
       width = 10)

rm(p_dcant_global_section_dec1, p_dcant_global_section_dec2,
   p_dcant_global_section_offset)

10.3 Synthetic data

p_dcant_global_section_dec1 <-
  dcant_global_section_all %>%
  filter(data_source == "mod",
         period %in% "1994 - 2004") %>%
  p_section_global(var = "dcant",
                   title_text = "1994 - 2004",
                   df_uncertainty = dcant_global_section_all_uncertainty %>% 
                     filter(period %in% "1994 - 2004",
                            data_source == "mod"),
                   col_uncertainty = "grey",
                   subtitle_text = NULL,
                   plot_slabs = "n",
                   contour_level = 5) +
  theme(
    axis.title.x = element_blank(),
    axis.text.x.bottom = element_blank()
  )


p_dcant_global_section_dec2 <-
  dcant_global_section_all %>%
  filter(data_source == "mod",
         period %in% "2004 - 2014") %>%
  p_section_global(
    var = "dcant",
    title_text = NULL,
    subtitle_text = NULL,
    plot_slabs = "n",
    contour_level = 5,
    df_uncertainty = dcant_global_section_all_uncertainty %>%
      filter(period %in% "2004 - 2014",
                            data_source == "mod"),
    col_uncertainty = "grey"
  ) &
  theme(
    legend.position = "none"
  )

p_dcant_global_section_offset <-
  dcant_global_section_all %>%
  filter(data_source == "mod",
         period %in% two_decades) %>%
  arrange(depth, dist) %>%
  select(depth, dist, dcant, period, gamma_mean) %>%
  drop_na() %>%
  group_by(depth, dist) %>% 
  mutate(gamma_mean = mean(gamma_mean)) %>% 
  ungroup() %>% 
  pivot_wider(names_from = period,
              values_from = dcant) %>%
  mutate(delta_dcant = `2004 - 2014` - `1994 - 2004`) %>%
  p_section_global(
    var = "delta_dcant",
    df_uncertainty = delta_dcant_global_section_all_uncertainty %>%
      filter(data_source == "mod"),
    col = "div",
    plot_slabs = "y",
    title_text = NULL,
    subtitle_text = NULL
  )



wrap_plots(
  p_dcant_global_section_dec1,
  p_dcant_global_section_dec2 &
    theme(axis.title.x = element_blank(),
          axis.text.x = element_blank()),
  p_dcant_global_section_offset &
    theme(axis.title.x.top = element_blank(),
          axis.text.x.top = element_blank()),
  ncol = 1
)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
ggsave(path = here::here("output/publication"),
       filename = "FigS_dcant_global_section_synthetic_data.png",
       height = 10,
       width = 8)

rm(p_dcant_global_section_dec1, p_dcant_global_section_dec2,
   p_dcant_global_section_offset)

11 Zonal sections

11.1 dcant - absolut

p_dcant_zonal_absolute <-
  dcant_zonal_all %>%
  filter(
    data_source == "obs",
    period %in% two_decades,
    depth <= params_global$inventory_depth_standard
  ) %>%
  p_section_zonal_continous_depth(var = "dcant",
                                  plot_slabs = "n",
                                  title_text = NULL) +
  geom_contour(aes(lat, depth, z = dcant),
               breaks = 5,
               col = "white") +
  # geom_text_contour(
  #   aes(lat, depth, z = dcant),
  #   breaks = 5,
  #   stroke = 0.2,
  #   stroke.colour = "white",
  #   rotate = FALSE,
  #   label.placer = label_placer_n(n = 1)
  # ) +
  facet_grid(period ~ basin_AIP) +
  theme(
    axis.text.x = element_blank(),
    axis.title.x = element_blank(),
    legend.position = "top"
  ) +
  guides(fill = guide_colorsteps(
    barheight = unit(0.5, "cm"),
    barwidth = unit(7, "cm"),
    show.limits = FALSE
  ))

p_dcant_zonal_absolute

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
f68fcfa jens-daniel-mueller 2022-07-26
f2615fb jens-daniel-mueller 2022-07-26
e2adac6 jens-daniel-mueller 2022-07-22
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
ea46812 jens-daniel-mueller 2022-07-13
16dc3af jens-daniel-mueller 2022-06-27
87e9eb8 jens-daniel-mueller 2022-06-27
b52b159 jens-daniel-mueller 2022-06-27
09b0780 jens-daniel-mueller 2022-05-24
1d73ec9 jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
094bfa0 jens-daniel-mueller 2022-02-18
d2191ad jens-daniel-mueller 2022-02-04
5f2aed0 jens-daniel-mueller 2022-01-27
9753eb8 jens-daniel-mueller 2022-01-26
b1d7720 jens-daniel-mueller 2022-01-21
e572075 jens-daniel-mueller 2022-01-21
dcant_zonal_all %>%
  filter(
    data_source == "obs",
    period != "1994 - 2014",
    depth <= params_global$inventory_depth_standard
  ) %>%
  group_split(basin_AIP) %>%
  # head(1) %>%
  map(
    ~ p_section_zonal_continous_depth(
      df = .x,
      var = "dcant",
      breaks = c(-Inf, -1, 0, 1, seq(2,16,2), Inf),
      plot_slabs = "n",
      title_text = .x$basin_AIP,
      subtitle_text = NULL
    ) +
      facet_grid(period ~ .)
  )

11.2 dcant - absolute delta

dcant_zonal_all %>%
  filter(data_source %in% c("mod", "obs"),
         period != "1994 - 2014") %>%
  select(data_source, lat, depth, basin_AIP, period, dcant) %>%
  pivot_wider(names_from = period,
              values_from = dcant) %>%
  mutate(delta_dcant = `2004 - 2014` - `1994 - 2004`) %>%
  group_by(data_source) %>%
  group_split() %>%
  # head(1) %>%
  map(
    ~ p_section_zonal_continous_depth(
      df = .x,
      var = "delta_dcant",
      plot_slabs = "n",
      subtitle_text = unique(.x$data_source),
      col = "bias"
    ) +
      facet_grid(basin_AIP ~ .)
  )
[[1]]

Version Author Date
7275091 jens-daniel-mueller 2022-11-05

[[2]]

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
p_dcant_zonal_delta <-
  dcant_zonal_all %>%
  filter(data_source %in% c("obs"),
         period != "1994 - 2014") %>%
  select(data_source, lat, depth, basin_AIP, period, gamma_mean, dcant) %>%
  pivot_wider(names_from = period,
              values_from = dcant) %>%
  mutate(delta_dcant = `2004 - 2014` - `1994 - 2004`) %>%
  group_by(data_source) %>%
  group_split() %>%
  # head(1) %>%
  map(
    ~ p_section_zonal_continous_depth(
      df = .x,
      var = "delta_dcant",
      plot_slabs = "y",
      drop_slabs = 1,
      subtitle_text = NULL,
      title_text = NULL,
      col = "bias"
    ) +
      facet_grid("Dec. diff." ~ basin_AIP) +
      theme(
        strip.text.x = element_blank(),
        strip.background.x = element_blank(),
        legend.position = "bottom"
      ) +
      guides(fill = guide_colorsteps(
        barheight = unit(0.5, "cm"),
        barwidth = unit(10, "cm"),
        show.limits = FALSE
      ))
  )

p_dcant_zonal_absolute / p_dcant_zonal_delta + 
  plot_layout(heights = c(2,1)) +
  plot_annotation(tag_levels = 'A')

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
ggsave(path = here::here("output/publication"),
       filename = "FigS_dcant_zonal_mean_section.png",
       height = 6,
       width = 8)

rm(p_dcant_zonal_absolute, p_dcant_zonal_delta)

11.3 Bias

p_dcant_zonal_absolute_mod <-
  dcant_zonal_all %>%
  filter(
    data_source != "obs",
    period %in% two_decades,
    depth <= params_global$inventory_depth_standard
  ) %>%
    mutate(data_source = case_when(
    data_source == "mod" ~ "Reconstruction",
    data_source == "mod_truth" ~ "Model truth"
  )) %>%  
  p_section_zonal_continous_depth(var = "dcant",
                                  plot_slabs = "n",
                                  title_text = NULL) +
  geom_contour(aes(lat, depth, z = dcant),
               breaks = 5,
               col = "white") +
  facet_nested(data_source+period ~ basin_AIP) +
  theme(
    axis.text.x = element_blank(),
    axis.title.x = element_blank(),
    legend.position = "top"
  ) +
  guides(fill = guide_colorsteps(
    barheight = unit(0.5, "cm"),
    barwidth = unit(7, "cm"),
    show.limits = FALSE
  ))

p_dcant_zonal_absolute_mod

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
5b77c4f jens-daniel-mueller 2022-08-10
p_dcant_zonal_bias <-
  dcant_zonal_all %>%
  filter(data_source != "obs",
         period %in% two_decades) %>%
  select(data_source, lat, depth, basin_AIP, period, dcant) %>%
  pivot_wider(names_from = data_source,
              values_from = dcant) %>%
  mutate(dcant_bias = mod - mod_truth) %>%
  p_section_zonal_continous_depth(
    var = "dcant_bias",
    plot_slabs = "n",
    drop_slabs = 1,
    subtitle_text = NULL,
    title_text = NULL,
    col = "bias"
  ) +
  facet_grid(period ~ basin_AIP) +
  theme(
    strip.text.x = element_blank(),
    strip.background.x = element_blank(),
    legend.position = "bottom"
  ) +
  guides(fill = guide_colorsteps(
    barheight = unit(0.5, "cm"),
    barwidth = unit(10, "cm"),
    show.limits = FALSE
  ))

p_dcant_zonal_absolute_mod / p_dcant_zonal_bias + 
  plot_layout(heights = c(2,1)) +
  plot_annotation(tag_levels = 'A')

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
46c163a jens-daniel-mueller 2022-10-10
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
5b77c4f jens-daniel-mueller 2022-08-10
ggsave(
  path = here::here("output/publication"),
  filename = "FigS_dcant_zonal_mean_section_synthetic_data.png",
  height = 9,
  width = 8
)

rm(p_dcant_zonal_absolute_mod, 
   p_dcant_zonal_bias)

12 Penetration depth

dcant_penetration_depth_all_lat_mean_all_ensemble %>%
  filter(dcant_lim == 5,
         period %in% two_decades,
         data_source != "obs") %>%
  mutate(
    data_source = case_when(
      data_source == "mod" ~ "Reconstruction\nensemble",
      data_source == "mod_truth" ~ "Model truth"
    ),
    data_source = fct_reorder(data_source, desc(data_source))
  ) %>%
  ggplot(aes(
    lat,
    depth_mean,
    group = interaction(MLR_basins, Version_ID_group, data_source)
  )) +
  geom_path(aes(col = data_source)) +
  geom_path(
    data = dcant_penetration_depth_all_lat_mean_all %>%
      filter(dcant_lim == 5,
             period %in% two_decades,
             data_source == "mod") %>%
      mutate(
        data_source = case_when(data_source == "mod" ~ "Standard case"),
        data_source = fct_reorder(data_source, desc(data_source))
      ),
    aes(lat,
        depth_mean,
        col = data_source)
  ) +
  scale_colour_manual(values = c("red", "grey", "black")) +
  labs(y = "Depth (m)",
       x = "Latitude (°N)") +
  theme(legend.title = element_blank()) +
  scale_y_reverse() +
  facet_grid(basin_AIP ~ period, scales = "free_x") +
  coord_cartesian(ylim = c(1500,0))

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
46c163a jens-daniel-mueller 2022-10-10
8105380 jens-daniel-mueller 2022-10-07
ggsave(
  path = here::here("output/publication"),
  filename = "FigS_dcant_penetration_depth_synthetic_data.png",
  height = 9,
  width = 8
)


dcant_penetration_depth_all_lat_mean_all_ensemble %>%
  filter(dcant_lim == 5,
         period %in% two_decades,
         data_source == "mod") %>%
  mutate(
    data_source = case_when(
      data_source == "mod" ~ "Reconstruction\nensemble",
      data_source == "mod_truth" ~ "Model truth"
    ),
    data_source = fct_reorder(data_source, desc(data_source))
  ) %>%
  ggplot(aes(
    lat,
    depth_mean,
    group = interaction(MLR_basins, Version_ID_group, data_source)
  )) +
  geom_path(aes(col = MLR_basins)) +
  geom_path(
    data = dcant_penetration_depth_all_lat_mean_all_ensemble %>%
      filter(
        dcant_lim == 5,
        period %in% two_decades,
        data_source == "mod_truth"
      ),
    aes(
      lat,
      depth_mean,
      group = interaction(MLR_basins, Version_ID_group, data_source)
    ),
    col = "black"
  ) +
  scale_color_vibrant() +
  labs(y = "Depth (m)",
       x = "Latitude (°N)") +
  theme(legend.title = element_blank()) +
  scale_y_reverse() +
  facet_grid(basin_AIP ~ period, scales = "free_x") +
  coord_cartesian(ylim = c(1500, 0))

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
46c163a jens-daniel-mueller 2022-10-10
8105380 jens-daniel-mueller 2022-10-07
ggsave(
  path = here::here("output/publication"),
  filename = "FigS_dcant_penetration_depth_synthetic_data_MLR_basins.png",
  height = 9,
  width = 8
)


dcant_penetration_depth_all_lat_mean_all_ensemble %>%
  filter(dcant_lim == 5,
         period %in% two_decades,
         data_source != "mod_truth") %>%
  mutate(
    data_source = case_when(
      data_source == "mod" ~ "Synthetic data",
      data_source == "obs" ~ "Observations"
    ),
    data_source = fct_reorder(data_source, desc(data_source))
  ) %>%
  ggplot(aes(
    lat,
    depth_mean,
    group = interaction(MLR_basins, Version_ID_group, data_source)
  )) +
  geom_path(aes(col = data_source)) +
  scale_colour_highcontrast() +
  labs(y = "Depth (m)",
       x = "Latitude (°N)") +
  theme(legend.title = element_blank()) +
  scale_y_reverse() +
  facet_grid(basin_AIP ~ period, scales = "free_x") +
  coord_cartesian(ylim = c(1500,0))

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
46c163a jens-daniel-mueller 2022-10-10
ggsave(
  path = here::here("output/publication"),
  filename = "FigS_dcant_penetration_depth_synthetic_data_vs_observations.png",
  height = 9,
  width = 8
)

dcant_penetration_depth_all_lat_mean_all_ensemble %>%
  filter(dcant_lim == 5,
         period %in% two_decades,
         data_source == "obs") %>%
  mutate(
    data_source = case_when(
      data_source == "obs" ~ "Observations"
    ),
    data_source = fct_reorder(data_source, desc(data_source))
  ) %>%
  ggplot(aes(
    lat,
    depth_mean,
    group = interaction(MLR_basins, Version_ID_group, data_source)
  )) +
  geom_path(aes(col = MLR_basins)) +
  scale_color_vibrant() +
  labs(y = "Depth (m)",
       x = "Latitude (°N)") +
  theme(legend.title = element_blank()) +
  scale_y_reverse() +
  facet_grid(basin_AIP ~ period, scales = "free_x") +
  coord_cartesian(ylim = c(1500,0))

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
46c163a jens-daniel-mueller 2022-10-10

13 Concentration profiles

13.1 dCant, absolute

13.1.1 Standard case

dcant_profile_basin_MLR_all %>%
  arrange(depth) %>%
  filter(period != "1994 - 2014",
         depth <= params_global$inventory_depth_standard) %>%
  group_split(data_source) %>%
  # head(1) %>%
  map(
    ~ ggplot(data = .x,
             aes(dcant,
                 depth)) +
      geom_hline(yintercept = params_global$inventory_depth_standard) +
      geom_vline(xintercept = 0) +
      geom_ribbon(
        aes(
          xmin = dcant - dcant_sd,
          xmax = dcant + dcant_sd,
          fill = period
        ),
        alpha = 0.3
      ) +
      geom_path(aes(col = period)) +
      scale_y_continuous(trans = trans_reverser("sqrt"),
                         breaks = c(0, 100, 500, seq(1500, 5000, 1000))) +
      coord_cartesian(expand = 0) +
      scale_color_brewer(
        palette = "Set1",
        name = "mean \u00B1 regional SD",
        direction = -1
      ) +
      scale_fill_brewer(
        palette = "Set1",
        name = "mean \u00B1 regional SD",
        direction = -1
      ) +
      labs(
        title = paste("data_source", unique(.x$data_source)),
        y = "Depth (m)",
        x = dcant_umol_label
      ) +
      facet_wrap( ~ basin, ncol = 3, dir = "v") +
      theme(legend.position = c(0.8, 0.2))
  )
[[1]]

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
87e9eb8 jens-daniel-mueller 2022-06-27
b52b159 jens-daniel-mueller 2022-06-27
1d73ec9 jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
d2191ad jens-daniel-mueller 2022-02-04
4673df5 jens-daniel-mueller 2022-02-02
60727e6 jens-daniel-mueller 2022-02-02
913e42f jens-daniel-mueller 2022-02-01
189de95 jens-daniel-mueller 2022-02-01
b62308d jens-daniel-mueller 2022-01-31
5f2aed0 jens-daniel-mueller 2022-01-27
c6fe495 jens-daniel-mueller 2022-01-26
9753eb8 jens-daniel-mueller 2022-01-26
b1d7720 jens-daniel-mueller 2022-01-21

[[2]]

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
318fefe jens-daniel-mueller 2022-08-11
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
748aa43 jens-daniel-mueller 2022-06-27
16dc3af jens-daniel-mueller 2022-06-27
87e9eb8 jens-daniel-mueller 2022-06-27
b52b159 jens-daniel-mueller 2022-06-27
1d73ec9 jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
d2191ad jens-daniel-mueller 2022-02-04
4673df5 jens-daniel-mueller 2022-02-02
60727e6 jens-daniel-mueller 2022-02-02
913e42f jens-daniel-mueller 2022-02-01
189de95 jens-daniel-mueller 2022-02-01
b62308d jens-daniel-mueller 2022-01-31
5f2aed0 jens-daniel-mueller 2022-01-27
c6fe495 jens-daniel-mueller 2022-01-26
9753eb8 jens-daniel-mueller 2022-01-26
b1d7720 jens-daniel-mueller 2022-01-21

[[3]]

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
318fefe jens-daniel-mueller 2022-08-11

13.1.2 Ensemble members

dcant_profile_basin_MLR_all_ensemble %>%
  arrange(depth) %>%
  filter(
    period != "1994 - 2014",
    depth <= params_global$inventory_depth_standard,
    data_source == "obs"
  ) %>%
  group_split(data_source) %>%
  map(
    ~ ggplot() +
      geom_hline(yintercept = params_global$inventory_depth_standard) +
      geom_vline(xintercept = 0) +
      geom_path(
        data = .x,
        aes(
          dcant,
          depth,
          col = period,
          group = Version_ID,
          linetype = "Ensemble member",
          size = "Ensemble member",
          alpha = "Ensemble member"
        )
      ) +
      geom_path(
        data = .x %>% filter(Version_ID %in% Version_IDs),
        aes(
          dcant,
          depth,
          col = period,
          group = Version_ID,
          linetype = "Standard case",
          alpha = "Standard case",
          size = "Standard case"
        )
      ) +
      geom_path(
        data = .x %>% filter(Version_ID %in% Version_IDs),
        aes(
          dcant,
          depth,
          group = Version_ID
        )
      ) +
      scale_size_manual(values = c(0.7, 1.5), name=" ") +
      scale_linetype_manual(values = c(1, 1), name=" ") +
      scale_alpha_manual(values = c(0.4, 1), name=" ") +
      scale_y_continuous(trans = trans_reverser("sqrt"),
                         breaks = c(0, 100, 500, seq(1500, 5000, 1000))) +
      coord_cartesian(expand = 0) +
      scale_color_brewer(
        palette = "Set1",
        direction = -1
      ) +
      scale_fill_brewer(
        palette = "Set1",
        direction = -1
      ) +
      labs(
        # title = paste("data_source", unique(.x$data_source)),
        y = "Depth (m)",
        x = dcant_umol_label
      ) +
      facet_wrap( ~ basin, ncol = 3, dir = "v") +
      theme(legend.position = "top")
  )
[[1]]

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
f1d7f80 jens-daniel-mueller 2022-07-13

13.1.3 Surface dCant

mean_surface_dcant <- dcant_profile_basin_MLR_all %>%
  arrange(depth) %>%
  filter(depth <= 50) %>%
  group_by(basin, period, data_source) %>% 
  summarise(mean_surface_dcant = mean(dcant)) %>% 
  ungroup()

full_join(dcant_profile_basin_MLR_all_ensemble %>%
            filter(depth <= 50),
          mean_surface_dcant) %>%
  group_by(basin, period, data_source) %>%
  summarise(
    mean_surface_dcant = mean(mean_surface_dcant, na.rm = TRUE),
    sd_surface_dcant = sd(dcant) * sd_factor
  ) %>%
  ungroup() %>%
  kable() %>%
  kable_styling() %>%
  scroll_box(height = "300px")
basin period data_source mean_surface_dcant sd_surface_dcant
Global 1994 - 2004 mod 10.233057 0.4937456
Global 1994 - 2004 mod_truth 9.119623 0.0941725
Global 1994 - 2004 obs 10.514606 0.9893247
Global 1994 - 2014 mod 20.680491 2.2805383
Global 1994 - 2014 mod_truth 19.512012 0.1485241
Global 1994 - 2014 obs 21.476974 2.4572465
Global 2004 - 2014 mod 10.499135 2.3217247
Global 2004 - 2014 mod_truth 10.392390 0.0545478
Global 2004 - 2014 obs 11.062672 1.7246762
Indian 1994 - 2004 mod 10.013093 1.3524350
Indian 1994 - 2004 mod_truth 9.186885 0.0579891
Indian 1994 - 2004 obs 9.538497 1.6295962
Indian 1994 - 2014 mod 20.628019 1.4435803
Indian 1994 - 2014 mod_truth 19.386323 0.1378481
Indian 1994 - 2014 obs 20.779644 2.0705697
Indian 2004 - 2014 mod 10.844700 1.8647167
Indian 2004 - 2014 mod_truth 10.199438 0.0805557
Indian 2004 - 2014 obs 11.363610 3.0846136
N. Pacific 1994 - 2004 mod 10.276179 1.1192555
N. Pacific 1994 - 2004 mod_truth 9.221239 0.1726426
N. Pacific 1994 - 2004 obs 10.753290 1.5712356
N. Pacific 1994 - 2014 mod 21.011574 2.9500115
N. Pacific 1994 - 2014 mod_truth 19.988747 0.2794554
N. Pacific 1994 - 2014 obs 21.697415 3.9464635
N. Pacific 2004 - 2014 mod 10.713098 3.7085900
N. Pacific 2004 - 2014 mod_truth 10.767508 0.1072143
N. Pacific 2004 - 2014 obs 11.101775 2.5343954
S. Pacific 1994 - 2004 mod 9.818618 1.8878074
S. Pacific 1994 - 2004 mod_truth 8.898910 0.0712533
S. Pacific 1994 - 2004 obs 10.303636 0.9897165
S. Pacific 1994 - 2014 mod 20.051396 3.2910508
S. Pacific 1994 - 2014 mod_truth 19.346396 0.0775661
S. Pacific 1994 - 2014 obs 20.689650 1.6118138
S. Pacific 2004 - 2014 mod 10.186799 1.9305865
S. Pacific 2004 - 2014 mod_truth 10.447486 0.0106002
S. Pacific 2004 - 2014 obs 10.478757 1.0735422
N. Atlantic 1994 - 2004 mod 11.385040 1.2570558
N. Atlantic 1994 - 2004 mod_truth 9.693375 0.0623036
N. Atlantic 1994 - 2004 obs 11.600352 1.7598243
N. Atlantic 1994 - 2014 mod 21.747759 2.2345831
N. Atlantic 1994 - 2014 mod_truth 20.378481 0.0628048
N. Atlantic 1994 - 2014 obs 23.286845 3.6722347
N. Atlantic 2004 - 2014 mod 10.449947 2.9661843
N. Atlantic 2004 - 2014 mod_truth 10.685107 0.0125613
N. Atlantic 2004 - 2014 obs 11.721643 2.1707058
S. Atlantic 1994 - 2004 mod 10.372162 1.1679142
S. Atlantic 1994 - 2004 mod_truth 8.791151 0.0908405
S. Atlantic 1994 - 2004 obs 11.168167 1.5919138
S. Atlantic 1994 - 2014 mod 20.581578 6.9648029
S. Atlantic 1994 - 2014 mod_truth 18.459719 0.1556806
S. Atlantic 1994 - 2014 obs 22.288130 2.3707626
S. Atlantic 2004 - 2014 mod 10.278645 8.2626677
S. Atlantic 2004 - 2014 mod_truth 9.668568 0.0651656
S. Atlantic 2004 - 2014 obs 11.158470 1.1563198

13.1.4 Penetration depth

full_join(dcant_profile_basin_MLR_all_ensemble,
          mean_surface_dcant) %>%
  arrange(depth) %>%
  filter(dcant >= mean_surface_dcant / 2) %>%
  group_by(period, basin, Version_ID, data_source) %>%
  summarise(max_depth = max(depth)) %>%
  ungroup() %>%
  group_by(basin, period, data_source) %>%
  summarise(sd_max_depth = sd(max_depth) * 2,
            mean_max_depth = mean(max_depth)) %>%
  ungroup() %>%
  kable() %>%
  kable_styling() %>%
  scroll_box(height = "300px")
basin period data_source sd_max_depth mean_max_depth
Global 1994 - 2004 mod 62.64907 320.5714
Global 1994 - 2004 mod_truth 0.00000 351.0000
Global 1994 - 2004 obs 59.42035 309.5238
Global 1994 - 2014 mod 39.53375 331.0476
Global 1994 - 2014 mod_truth 0.00000 351.0000
Global 1994 - 2014 obs 0.00000 300.0000
Global 2004 - 2014 mod 37.12205 335.9762
Global 2004 - 2014 mod_truth 0.00000 351.0000
Global 2004 - 2014 obs 15.43033 298.8095
Indian 1994 - 2004 mod 124.43606 408.4524
Indian 1994 - 2004 mod_truth 0.00000 483.0000
Indian 1994 - 2004 obs 199.94192 497.6190
Indian 1994 - 2014 mod 96.46457 407.5238
Indian 1994 - 2014 mod_truth 0.00000 443.0000
Indian 1994 - 2014 obs 90.93654 380.9524
Indian 2004 - 2014 mod 95.93485 379.8333
Indian 2004 - 2014 mod_truth 0.00000 443.0000
Indian 2004 - 2014 obs 106.38719 294.0476
N. Pacific 1994 - 2004 mod 76.97264 257.2143
N. Pacific 1994 - 2004 mod_truth 0.00000 268.0000
N. Pacific 1994 - 2004 obs 81.36467 242.8571
N. Pacific 1994 - 2014 mod 44.98778 258.6905
N. Pacific 1994 - 2014 mod_truth 0.00000 251.0000
N. Pacific 1994 - 2014 obs 54.74044 228.5714
N. Pacific 2004 - 2014 mod 28.32403 259.7857
N. Pacific 2004 - 2014 mod_truth 0.00000 251.0000
N. Pacific 2004 - 2014 obs 68.33000 207.1429
S. Pacific 1994 - 2004 mod 75.03243 373.7381
S. Pacific 1994 - 2004 mod_truth 0.00000 409.0000
S. Pacific 1994 - 2004 obs 137.33823 366.6667
S. Pacific 1994 - 2014 mod 67.86796 384.7381
S. Pacific 1994 - 2014 mod_truth 0.00000 409.0000
S. Pacific 1994 - 2014 obs 100.17406 357.1429
S. Pacific 2004 - 2014 mod 79.94942 401.2143
S. Pacific 2004 - 2014 mod_truth 0.00000 378.0000
S. Pacific 2004 - 2014 obs 126.87616 350.0000
N. Atlantic 1994 - 2004 mod 30.82994 294.8095
N. Atlantic 1994 - 2004 mod_truth 0.00000 327.0000
N. Atlantic 1994 - 2004 obs 43.10805 404.7619
N. Atlantic 1994 - 2014 mod 26.50076 314.5238
N. Atlantic 1994 - 2014 mod_truth 0.00000 351.0000
N. Atlantic 1994 - 2014 obs 75.43909 416.6667
N. Atlantic 2004 - 2014 mod 52.43391 333.8095
N. Atlantic 2004 - 2014 mod_truth 0.00000 351.0000
N. Atlantic 2004 - 2014 obs 89.00012 473.8095
S. Atlantic 1994 - 2004 mod 73.25987 311.8333
S. Atlantic 1994 - 2004 mod_truth 0.00000 351.0000
S. Atlantic 1994 - 2004 obs 43.10805 288.0952
S. Atlantic 1994 - 2014 mod 56.65512 326.1905
S. Atlantic 1994 - 2014 mod_truth 0.00000 378.0000
S. Atlantic 1994 - 2014 obs 100.75211 345.2381
S. Atlantic 2004 - 2014 mod 56.50395 338.8571
S. Atlantic 2004 - 2014 mod_truth 0.00000 378.0000
S. Atlantic 2004 - 2014 obs 198.71831 452.3810
rm(mean_surface_dcant)

13.1.5 Uncertainty range

dcant_profile_basin_MLR_range <- dcant_profile_basin_MLR_all_ensemble %>%
  group_by(basin, depth, period, data_source) %>% 
  summarise(dcant_sd = sd(dcant)*sd_factor) %>%
  ungroup()

dcant_profile_basin_MLR_all_ensemble <-
full_join(dcant_profile_basin_MLR_all_ensemble %>% select(-dcant_sd),
          dcant_profile_basin_MLR_range)

p_dcant_profiles <-
  dcant_profile_basin_MLR_all_ensemble %>%
  arrange(depth) %>%
  filter(
    period != "1994 - 2014",
    depth <= params_global$inventory_depth_standard,
    data_source == "obs",
    Version_ID %in% Version_IDs
  ) %>%
  ggplot() +
  geom_vline(xintercept = 0, size = 0.1) +
  geom_hline(yintercept = 1000, size = 0.1) +
  geom_ribbon(
    aes(
      xmin = dcant - dcant_sd,
      xmax = dcant + dcant_sd,
      y = depth,
      fill = period,
      group = Version_ID
    ),
    alpha = 0.5
  ) +
  geom_path(
    aes(dcant,
        depth,
        col = period,
        group = Version_ID,)
  ) +
  scale_y_continuous(trans = trans_reverser("sqrt"),
                     breaks = c(0, 100, 500, seq(1000, 5000, 1000))) +
  coord_cartesian(expand = 0) +
  scale_color_manual(values = c("#EE7733", "#009988"), name = "Mean \u00B1 2σ") +
  scale_fill_manual(values = c("#EE7733", "#009988"), name = "Mean \u00B1 2σ") +
  labs(y = "Depth (m)",
       x = dcant_umol_label) +
  facet_wrap(~ basin, ncol = 3, dir = "v") +
  theme(legend.position = c(0.9, 0.1))

p_dcant_profiles

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
fea41c1 jens-daniel-mueller 2022-07-20
d803308 jens-daniel-mueller 2022-07-19
b1f7ab3 jens-daniel-mueller 2022-07-18
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
f1d7f80 jens-daniel-mueller 2022-07-13
p_dcant_profiles_mod <-
  dcant_profile_basin_MLR_all_ensemble %>%
  arrange(depth) %>%
  filter(
    period != "1994 - 2014",
    depth <= params_global$inventory_depth_standard,
    data_source != "obs",
    Version_ID %in% Version_IDs
  ) %>%
    mutate(data_source = case_when(
    data_source == "mod" ~ "Reconstruction",
    data_source == "mod_truth" ~ "Model truth"
  )) %>%  
  ggplot() +
  geom_vline(xintercept = 0, size = 0.1) +
  geom_hline(yintercept = 1000, size = 0.1) +
  geom_ribbon(
    aes(
      xmin = dcant - dcant_sd,
      xmax = dcant + dcant_sd,
      y = depth,
      fill = data_source,
      group = interaction(Version_ID,data_source)
    ),
    alpha = 0.5
  ) +
  geom_path(
    aes(dcant,
        depth,
        col = data_source,
        group = interaction(Version_ID,data_source))
  ) +
  scale_y_continuous(trans = trans_reverser("sqrt"),
                     breaks = c(0, 100, 500, seq(1000, 5000, 1000))) +
  coord_cartesian(expand = 0) +
  scale_color_manual(values = c("#009988", "#EE7733"), name = "Mean \u00B1 2σ") +
  scale_fill_manual(values = c("#009988", "#EE7733"), name = "Mean \u00B1 2σ") +
  labs(y = "Depth (m)",
       x = dcant_umol_label) +
  facet_grid(period ~ basin) +
  theme(legend.position = "top")

p_dcant_profiles_mod

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
318fefe jens-daniel-mueller 2022-08-11
dcant_profile_basin_MLR_all_ensemble %>%
  arrange(depth) %>%
  filter(
    period != "1994 - 2014",
    depth <= params_global$inventory_depth_standard,
    data_source == "obs"
  ) %>%
  group_split(data_source) %>%
  map(
    ~ ggplot() +
      geom_hline(yintercept = params_global$inventory_depth_standard) +
      geom_vline(xintercept = 0) +
      geom_path(
        data = .x,
        aes(dcant,
            depth,
            col = MLR_basins,
            group = Version_ID)
      ) +
      scale_size_manual(values = c(0.5, 2), name = "x") +
      scale_linetype_manual(values = c(2, 1), name = "x") +
      scale_y_continuous(trans = trans_reverser("sqrt"),
                         breaks = c(0, 100, 500, seq(1500, 5000, 1000))) +
      coord_cartesian(expand = 0) +
      scale_color_brewer(palette = "Dark2", name = "regional\nclustering") +
      labs(y = "Depth (m)",
           x = dcant_umol_label) +
      facet_grid(basin ~ period)
  )
[[1]]

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
232909e jens-daniel-mueller 2022-07-01
dcant_profile_basin_MLR_all_ensemble %>%
  arrange(depth) %>%
  filter(
    period != "1994 - 2014",
    depth <= params_global$inventory_depth_standard,
    data_source != "mod_truth"
  ) %>%
  group_split(data_source) %>%
  # head(1) %>%
  map(
    ~ ggplot() +
      geom_hline(yintercept = params_global$inventory_depth_standard) +
      geom_vline(xintercept = 0) +
      geom_path(
        data = .x,
        aes(
          dcant,
          depth,
          col = Version_ID_group,
          group = Version_ID
        )) +
      scale_y_continuous(trans = trans_reverser("sqrt"),
                         breaks = c(0, 100, 500, seq(1500, 5000, 1000))) +
      coord_cartesian(expand = 0) +
      scale_color_brewer(
        palette = "Dark2",
        name = "configuration"
      ) +
      labs(
        y = "Depth (m)",
        x = dcant_umol_label,
        title = paste("data_source", unique(.x$data_source))
      ) +
      facet_grid(basin ~ period)
  )
[[1]]

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
6be73e0 jens-daniel-mueller 2022-06-30

[[2]]

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
318fefe jens-daniel-mueller 2022-08-11
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
6be73e0 jens-daniel-mueller 2022-06-30
bind_rows(
  dcant_profile_basin_MLR_all_ensemble %>%
    filter(
      period %in% two_decades,
      depth <= params_global$inventory_depth_standard,
      data_source == "obs",
      Version_ID_group == "Bulk adjustment"
    ),
  dcant_profile_basin_MLR_all_no_adj %>%
    filter(
      period %in% two_decades,
      depth <= params_global$inventory_depth_standard,
      data_source == "obs"
    )
) %>%
  group_by(depth,
           period,
           basin,
           Version_ID_group) %>% 
  summarise(dcant_sd = sd(dcant),
            dcant = mean(dcant)) %>% 
  ungroup() %>% 
  filter(basin %in% c("N. Pacific", "Indian")) %>%
  ggplot() +
  geom_hline(yintercept = params_global$inventory_depth_standard) +
  geom_vline(xintercept = 0) +
  geom_ribbon(
    aes(
      xmin = dcant - dcant_sd,
      xmax = dcant + dcant_sd,
      y = depth,
      fill = Version_ID_group
    ),
    alpha = 0.5
  )+
  geom_path(aes(dcant,
                depth,
                col = Version_ID_group,
                group = Version_ID_group)) +
  scale_y_continuous(trans = trans_reverser("sqrt"),
                     breaks = c(0, 100, 500, seq(1500, 5000, 1000))) +
  coord_cartesian(expand = 0) +
  scale_color_manual(values = colour("high contrast", names = FALSE)(3)[c(1,3)],
                     name = "Mean \u00B1 1σ") +
  scale_fill_manual(values = colour("high contrast", names = FALSE)(3)[c(1,3)],
                    name = "Mean \u00B1 1σ") +
  labs(y = "Depth (m)",
       x = dcant_umol_label) +
  facet_grid(basin ~ period) +
  theme(legend.position = c(0.85,0.15))

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
46c163a jens-daniel-mueller 2022-10-10
ggsave(path = here::here("output/publication"),
       filename = "FigS_dcant_profiles_data_adjustments.png",
       height = 6,
       width = 8)

13.2 dCant - delta

delta <- dcant_profile_basin_MLR_all_ensemble %>%
  arrange(depth) %>%
  filter(period != "1994 - 2014",
         Version_ID %in% Version_IDs) %>%
  select(data_source, depth, basin, period, dcant) %>%
  pivot_wider(names_from = period,
              values_from = dcant) %>%
  mutate(delta_dcant = `2004 - 2014` - `1994 - 2004`) %>%
  select(-c(`2004 - 2014`, `1994 - 2004`))

delta_sd <- dcant_profile_basin_MLR_all_ensemble %>%
  arrange(depth) %>%
  filter(period != "1994 - 2014",
         Version_ID %in% Version_IDs) %>%
  select(data_source, depth, basin, period, dcant_sd) %>% 
  pivot_wider(names_from = period,
              values_from = dcant_sd) %>%
  mutate(delta_dcant_sd = sqrt(`2004 - 2014`^2 + `1994 - 2004`^2)) %>% 
  select(-c(`2004 - 2014`, `1994 - 2004`))

dcant_profile_basin_MLR_all_delta <- full_join(delta, delta_sd)
rm(delta, delta_sd)



dcant_profile_basin_MLR_all_delta %>%
  group_split(data_source) %>%
  # head(3) %>%
  map(
    ~ ggplot(data = .x,
             aes(delta_dcant,
                 depth)) +
      geom_hline(yintercept = params_global$inventory_depth_standard) +
      geom_vline(xintercept = 0) +
      geom_ribbon(
        aes(
          xmin = delta_dcant - delta_dcant_sd,
          xmax = delta_dcant + delta_dcant_sd
        ),
        alpha = 0.3
      ) +
      geom_path() +
      scale_y_continuous(trans = trans_reverser("sqrt"),
                         breaks = c(0, 100, 500, seq(1500, 5000, 1000))) +
      coord_cartesian(expand = 0) +
      scale_color_brewer(palette = "Set1", name = "mean \u00B1 sd") +
      scale_fill_brewer(palette = "Set1", name = "mean \u00B1 sd") +
      labs(
        title = paste("data_source", unique(.x$data_source)),
        y = "Depth (m)",
        x = ddcant_umol_label
      ) +
      facet_wrap(~ basin, ncol = 3)
  )
[[1]]

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
87e9eb8 jens-daniel-mueller 2022-06-27
b52b159 jens-daniel-mueller 2022-06-27
1d73ec9 jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
d2191ad jens-daniel-mueller 2022-02-04
913e42f jens-daniel-mueller 2022-02-01
189de95 jens-daniel-mueller 2022-02-01
b62308d jens-daniel-mueller 2022-01-31
5f2aed0 jens-daniel-mueller 2022-01-27
eccd82b jens-daniel-mueller 2022-01-26
c6fe495 jens-daniel-mueller 2022-01-26

[[2]]

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
318fefe jens-daniel-mueller 2022-08-11
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
87e9eb8 jens-daniel-mueller 2022-06-27
b52b159 jens-daniel-mueller 2022-06-27
1d73ec9 jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
d2191ad jens-daniel-mueller 2022-02-04
913e42f jens-daniel-mueller 2022-02-01
189de95 jens-daniel-mueller 2022-02-01
b62308d jens-daniel-mueller 2022-01-31
5f2aed0 jens-daniel-mueller 2022-01-27
eccd82b jens-daniel-mueller 2022-01-26
c6fe495 jens-daniel-mueller 2022-01-26

[[3]]

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
318fefe jens-daniel-mueller 2022-08-11

14 Inventories

dcant_budget_ensemble_stat <-
  dcant_budget_basin_MLR_all_ensemble %>% 
  filter(period != "1994 - 2014",
         data_source != "mod_truth") %>%
  group_by(period, basin, data_source) %>%
  summarise(
    median = median(dcant),
    sd = sd(dcant),
    n = n()
  ) %>%
  ungroup() 


dcant_budget_ensemble_stat <-
  full_join(
    dcant_budget_ensemble_stat,
    dcant_budget_basin_MLR_all_ensemble %>%
      filter(
        Version_ID %in% Version_IDs,
        period != "1994 - 2014",
        data_source != "mod_truth"
      ) %>%
      select(period,
             basin,
             data_source,
             std_case = dcant)
  )

dcant_budget_ensemble_significance <- dcant_budget_ensemble_stat %>% 
  pivot_longer(c(median,std_case),
               names_to = "estimate",
               values_to = "dcant") %>%
  group_by(estimate, basin, data_source) %>%
  mutate(
    delta_dcant = dcant - lag(dcant),
    delta_dcant_uncert = sqrt(sd_factor * sd ^ 2 + lag(sd_factor * sd ^ 2)),
    error_prop_ratio = abs(delta_dcant_uncert / delta_dcant),
    ttest_p = tsum.test(
      mean.x = dcant,
      s.x = sd,
      n.x = n,
      mean.y = lag(dcant),
      s.y = lag(sd),
      n.y = lag(n)
    )$p.value
  ) %>%
  ungroup() %>% 
  drop_na()
  
dcant_budget_ensemble_stat_significance <-
  full_join(
    dcant_budget_ensemble_stat %>%
      select(-n) %>%
      pivot_wider(
        names_from = period,
        values_from = median:std_case,
        names_sep = " "
      ),
    dcant_budget_ensemble_significance %>%
      select(basin, estimate, delta_dcant, delta_dcant_uncert, ttest_p, data_source) %>%
      pivot_wider(names_from = estimate,
                  values_from = delta_dcant:ttest_p) %>%
      rename(delta_dcant_uncert = delta_dcant_uncert_std_case) %>%
      select(-delta_dcant_uncert_median)
  )


dcant_budget_ensemble_stat_significance %>% 
  kable() %>%
  kable_styling() %>%
  scroll_box(height = "300px")
basin data_source median 1994 - 2004 median 2004 - 2014 sd 1994 - 2004 sd 2004 - 2014 std_case 1994 - 2004 std_case 2004 - 2014 delta_dcant_median delta_dcant_std_case delta_dcant_uncert ttest_p_median ttest_p_std_case
Global mod 19.2635 21.7170 1.3153522 1.3521508 18.679 23.188 2.4535 4.509 2.6677568 0.0000000 0.0000000
Global obs 27.2165 25.5760 1.5385767 1.5309161 27.388 25.583 -1.6405 -1.805 3.0695024 0.0000048 0.0000007
Indian mod 5.1055 5.8765 0.8588370 0.6363305 5.106 6.563 0.7710 1.457 1.5116332 0.0000126 0.0000000
Indian obs 6.9340 5.7120 0.8501347 0.8143064 7.156 5.722 -1.2220 -1.434 1.6648267 0.0000000 0.0000000
N. Pacific mod 3.2195 3.3385 0.3291825 0.3870243 3.133 3.367 0.1190 0.234 0.7185387 0.1329905 0.0037644
N. Pacific obs 2.9005 3.7540 0.9488079 0.7788312 2.897 3.216 0.8535 0.319 1.7359806 0.0000226 0.0960966
S. Pacific mod 6.1915 7.2435 0.7225522 0.6254259 5.531 7.423 1.0520 1.892 1.3514727 0.0000000 0.0000000
S. Pacific obs 8.6760 7.5945 0.9977995 0.9258863 8.635 7.389 -1.0815 -1.246 1.9250295 0.0000018 0.0000001
N. Atlantic mod 2.2235 2.1715 0.2141452 0.1904960 2.219 2.440 -0.0520 0.221 0.4053317 0.2431244 0.0000033
N. Atlantic obs 4.7555 3.9160 0.1786911 0.3878363 4.805 3.908 -0.8395 -0.897 0.6038998 0.0000000 0.0000000
S. Atlantic mod 2.6875 3.1390 0.3049506 0.3255103 2.690 3.396 0.4515 0.706 0.6307961 0.0000000 0.0000000
S. Atlantic obs 3.9260 4.9040 0.5655845 0.6303071 3.895 5.350 0.9780 1.455 1.1976417 0.0000000 0.0000000
dcant_budget_ensemble_significance %>% 
  ggplot(aes(error_prop_ratio, ttest_p, col = basin)) +
  geom_vline(xintercept = 1) +
  geom_hline(yintercept = 0.05) +
  geom_point() +
  scale_y_log10() +
  scale_color_brewer(palette = "Dark2") +
  facet_grid(data_source ~ estimate)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
0b40366 jens-daniel-mueller 2022-10-26
MLR_basins_reference <- unique(params_local_all$MLR_basins)

MLR_basins_sensitivity <- unique(params_local_all_ensemble$MLR_basins)
MLR_basins_sensitivity <- MLR_basins_sensitivity[!MLR_basins_sensitivity %in% MLR_basins_reference]

unique(params_local_all_ensemble$Version_ID_group)
[1] "Bulk adjustment"     "Reoccupation filter" "No adjustment"      
[4] "No gap filling"      "C*(N,AT)"            "Cruise adjustment"  
[7] "Surface eMLR(C*)"    "C*(P)"              
dcant_budget_ensemble_stat_basin <-
  dcant_budget_basin_MLR_all_ensemble %>%
  filter(data_source != "mod_truth",
         period != "1994 - 2014") %>%
  select(-c(inv_depth, Version_ID, tref1, tref2)) %>% 
  pivot_wider(names_from = MLR_basins,
              values_from = dcant) %>% 
  pivot_longer(all_of(MLR_basins_sensitivity),
               names_to = "MLR_basins",
               values_to = "dcant") %>% 
  mutate(delta_dcant = dcant - !!sym(MLR_basins_reference))

dcant_budget_ensemble_stat_basin %>%
  filter(data_source == "obs",
         Version_ID_group == unique(params_local_all$Version_ID_group)) %>% 
  ggplot(aes(period, delta_dcant, fill = MLR_basins)) +
  geom_point(shape = 21, size = 2, alpha = 0.7) +
  scale_fill_muted(name = "Regional clustering") +
  labs(y = "Offset (PgC)",
       title = "Offset for regional clusterings schemes",
       subtitle = "Note: Only the bulk adjustment cases are shown") +
  theme(axis.title.x = element_blank()) +
  facet_wrap(. ~ basin)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
0b40366 jens-daniel-mueller 2022-10-26
dcant_budget_ensemble_stat_basin_SD <-
  dcant_budget_ensemble_stat_basin %>% 
  group_by(period, basin, Version_ID_group, data_source) %>%
  summarise(MAO = mean(abs(delta_dcant)),
            SD_AO = sd(abs(delta_dcant))) %>%
  ungroup()

dcant_budget_ensemble_stat_basin_SD %>%
  filter(data_source == "obs") %>% 
  ggplot(aes(x = period, y = MAO, fill = Version_ID_group)) +
  geom_col(position = "dodge", col = "black") +
  geom_errorbar(aes(ymin = MAO, ymax = MAO + SD_AO),
                position = "dodge") +
  scale_fill_bright(name = "Configuration") +
  labs(y = "Mean + SD of absolute offset (PgC)",
       title = "Absolute offsets for regional clusterings schemes",
       subtitle = "Note: Only offsets for the bulk adjustment cases will be used, but all configurations are shown") +
  theme(axis.title.x = element_blank()) +
  scale_y_continuous(expand = c(0, 0.1)) +
  facet_wrap(. ~ basin)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
0b40366 jens-daniel-mueller 2022-10-26
rm(MLR_basins_reference, MLR_basins_sensitivity)

# dcant_budget_ensemble_stat_basin_SD <-
#   dcant_budget_basin_MLR_all_ensemble %>%
#   filter(data_source != "mod_truth",
#          period != "1994 - 2014") %>%
#   group_by(period, basin, Version_ID_group, data_source) %>%
#   summarise(median = median(dcant),
#             sd = sd(dcant),
#             n = n()) %>%
#   ungroup() 
# 
# dcant_budget_ensemble_stat_basin_SD %>%
#   ggplot(aes(period, sd, fill = Version_ID_group)) +
#   geom_col(position = "dodge", col = "black") +
#   scale_fill_bright(name = "Configuration") +
#   labs(y = "SD (PgC)",
#        title = "Standard deviation across regional clusterings schemes",
#        subtitle = "Note: Only the SD of bulk adjustment cases will be used, but all configurations are shown") +
#   theme(axis.title.x = element_blank()) +
#   scale_y_continuous(expand = c(0, 0)) +
#   facet_grid(data_source ~ basin)
# 
ggsave(
  path = here::here("output/publication"),
  filename = "FigS_dcant_inventory_additive_uncertainty_regional_clustering_contributions.png",
  height = 6,
  width = 8
)

dcant_budget_ensemble_stat_basin_SD <-
  dcant_budget_ensemble_stat_basin_SD %>%
  filter(Version_ID_group == unique(params_local_all$Version_ID_group)) %>%
  select(-Version_ID_group)

dcant_budget_ensemble_stat_sensitvity_cases <-
  dcant_budget_basin_MLR_all_ensemble %>%
  filter(data_source != "mod_truth",
         period != "1994 - 2014") %>%
  select(basin, dcant, period, MLR_basins, Version_ID_group, data_source) %>%
  pivot_wider(names_from = Version_ID_group,
              values_from = dcant) %>%
  pivot_longer(
    `Reoccupation filter`:`Surface eMLR(C*)`,
    names_to = "Version_ID_group",
    values_to = "dcant"
  ) %>% 
  mutate(delta_dcant = `Bulk adjustment` - dcant)

dcant_budget_ensemble_stat_sensitvity_cases %>%
  filter(data_source == "mod") %>% 
  ggplot(aes(period, delta_dcant, fill = MLR_basins)) +
  geom_hline(yintercept = 0) +
  geom_col(position = "dodge", col = "black") +
  scale_fill_bright(name = "Regional clustering") +
  labs(y = "Offset (PgC)",
       title = "Inventory offset compared to standard configuration | mod",
       subtitle = "Note: Only regional clustering scheme 3 will be used, but all options are shown") +
  theme(axis.title.x = element_blank()) +
  scale_y_continuous(expand = c(0, 0)) +
  facet_grid(Version_ID_group ~ basin)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
0b40366 jens-daniel-mueller 2022-10-26
dcant_budget_ensemble_stat_sensitvity_cases %>%
  filter(data_source == "obs") %>% 
  ggplot(aes(period, delta_dcant, fill = MLR_basins)) +
  geom_hline(yintercept = 0) +
  geom_col(position = "dodge", col = "black") +
  scale_fill_bright(name = "Regional clustering") +
  labs(y = "Offset (PgC)",
       title = "Inventory offset compared to standard configuration | obs",
       subtitle = "Note: Only regional clustering scheme 3 will be used, but all options are shown") +
  theme(axis.title.x = element_blank()) +
  scale_y_continuous(expand = c(0, 0)) +
  facet_grid(Version_ID_group ~ basin)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
ggsave(path = here::here("output/publication"),
       filename = "FigS_dcant_inventory_additive_uncertainty_configuration_contributions.png",
       height = 9,
       width = 12)


dcant_budget_ensemble_stat_sensitvity_cases <-
  dcant_budget_ensemble_stat_sensitvity_cases %>%
  filter(MLR_basins == unique(params_local_all$MLR_basins)) %>%
  select(period, basin, Version_ID_group, sd = delta_dcant, data_source)

dcant_budget_ensemble_stat_factorial <-
  bind_rows(
    dcant_budget_ensemble_stat_basin_SD %>%
      mutate(type = "regional clustering",
             Version_ID_group = "Bulk adjustment") %>%
      rename(sd = MAO) %>% 
      select(-SD_AO),
    dcant_budget_ensemble_stat_sensitvity_cases  %>% mutate(type = "configuration")
  )

dcant_budget_ensemble_stat_factorial %>%
  filter(data_source == "obs") %>%
  ggplot(aes(period, abs(sd), pattern = type, fill = Version_ID_group)) +
  # geom_col(
  #   position = position_dodge(preserve = "single")
  # ) +
  geom_col_pattern(
    position = position_dodge(preserve = "single"),
    color = "black",
    pattern_fill = "black",
    pattern_angle = 45,
    pattern_density = 0.1,
    pattern_spacing = 0.025,
    pattern_key_scale_factor = 0.6
  ) +
  scale_fill_bright(name = "Configuration") +
  scale_pattern_manual(
    values = c(`regional clustering` = "stripe", configuration = "none"),
    name = "Uncertainty\ncontribution"
  ) +
  scale_color_manual(
    values = c("white", "black"),
    name = "Uncertainty\ncontribution"
  ) +
  labs(
    y = expression("Absolute uncertainty contribution (PgC)"),
    title = "Uncertainty contributions from configuration and regional clustering",
    subtitle = "Note: The regional clustering contribution is based on bulk adjustment cases,\nand configuration changes are evaluated for the regional clustering scheme 3"
  ) +
  theme(axis.title.x = element_blank()) +
  guides(pattern = guide_legend(override.aes = list(fill = "white")),
         fill = guide_legend(override.aes = list(pattern = "none"))) +
  scale_y_continuous(
    expand = c(0, 0)
  ) +
  facet_wrap(. ~ basin)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
ggsave(path = here::here("output/publication"),
       filename = "FigS_dcant_inventory_additive_uncertainty_combined_contributions.png",
       height = 6,
       width = 9) 
  
dcant_budget_ensemble_stat_factorial <-
  dcant_budget_ensemble_stat_factorial %>% 
  group_by(basin, period, data_source) %>% 
  summarise(sd = sqrt(sum(sd^2))) %>% 
  ungroup()

dcant_budget_ensemble_stat_factorial <-
  full_join(
    dcant_budget_ensemble_stat_factorial,
    dcant_budget_basin_MLR_all_ensemble %>%
        filter(Version_ID %in% Version_IDs,
               period != "1994 - 2014") %>%
        select(period,
               basin,
               data_source,
               std_case = dcant)
  )
# inventory scaling

dcant_budget_basin_MLR_all_ensemble <- dcant_budget_basin_MLR_all_ensemble %>% 
  mutate(dcant = if_else(basin == "Global",
                         dcant * dcant_scaling,
                         dcant))

dcant_budget_basin_MLR_all <- dcant_budget_basin_MLR_all %>% 
  mutate(dcant = if_else(basin == "Global",
                         dcant * dcant_scaling,
                         dcant))

dcant_budget_basin_MLR_all_no_adj <- dcant_budget_basin_MLR_all_no_adj %>% 
  mutate(dcant = if_else(basin == "Global",
                         dcant * dcant_scaling,
                         dcant))
# uncertainty scaling

dcant_budget_ensemble_stat_factorial <-
dcant_budget_ensemble_stat_factorial %>%
  mutate(
    sd = if_else(basin == "Global",
      sqrt(sd ^ 2 + 
          (std_case * (dcant_scaling - 1) * dcant_scaling_uncertainty)^2),
          sd),
    std_case = if_else(basin == "Global",
                       std_case * dcant_scaling,
                       std_case)
  )

dcant_budget_ensemble_stat <-
dcant_budget_ensemble_stat %>%
  mutate(
    sd = if_else(basin == "Global",
      sqrt(sd ^ 2 + 
          (std_case * (dcant_scaling - 1) * dcant_scaling_uncertainty)^2),
          sd),
    std_case = if_else(basin == "Global",
                       std_case * dcant_scaling,
                       std_case)
  )
# estimate area scaling factor to achieve identical coverage

tcant_inv <-
  inner_join(tcant_inv, basinmask)

dcant_inv_all <-
  inner_join(dcant_inv_all, basinmask)

area_scaling <-
  bind_rows(
    tcant_inv %>% distinct(lat, lon, basin) %>%
      mutate(source = "SO4"),
    dcant_inv_all %>% distinct(lat, lon, basin) %>%
      mutate(source = "M22")
  )


map +
  geom_tile(data = area_scaling,
            aes(lon, lat, fill = basin)) +
  facet_wrap( ~ source)

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
5b77c4f jens-daniel-mueller 2022-08-10
d2ae54c jens-daniel-mueller 2022-07-18
area_scaling <- area_scaling %>% 
  mutate(area = earth_surf(lat, lon)) %>% 
  group_by(basin, source) %>% 
  summarise(area_total = sum(area)) %>% 
  ungroup() %>% 
  pivot_wider(values_from = area_total,
              names_from = source) %>% 
  mutate(scaling_factor = M22 / SO4)


tcant_budget_basin_MLR <-
  tcant_inv %>%
  mutate(method = "layer",
         data_source = "obs") %>% 
  group_by(basin) %>%
  nest() %>% 
  mutate(budget = map(.x = data, ~m_dcant_budget(.x))) %>% 
  select(-data) %>%
  unnest(budget)

tcant_budget_basin_MLR <-
  full_join(tcant_budget_basin_MLR,
            area_scaling %>% select(basin, scaling_factor)) %>%
  mutate(value = value * scaling_factor) %>%
  select(-scaling_factor)



tcant_budget_basin_MLR <-
  left_join(tcant_budget_basin_MLR %>%
              mutate(period = "1800 - 1994"),
            delta_pCO2_atm)


tcant_budget_basin_MLR <- tcant_budget_basin_MLR %>% 
  filter(estimate == "dcant") %>% 
  select(-estimate) %>% 
  rename(dcant = value)

tcant_budget_basin_MLR <- tcant_budget_basin_MLR %>% 
  mutate(beta_1994 = dcant / delta_pCO2) %>% 
  select(basin, beta_1994)

tcant_budget_basin_MLR <-
  bind_rows(tcant_budget_basin_MLR,
            tibble(basin = "Global", beta_1994 = 118 / 78.3))

14.1 Scatterplots

14.1.1 Ensemble uncertainty

dcant_budget_basin_MLR_all_ensemble %>%
  ggplot(aes(period, dcant, col = Version_ID_group)) +
  geom_jitter(alpha = 0.5) +
  scale_color_brewer(palette = "Dark2") +
  facet_grid(basin ~ data_source, scales = "free_y")

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
tcant_budget_basin_MLR <- expand_grid(
  tcant_budget_basin_MLR,
  delta_pCO2_atm %>% filter(period %in% two_decades)
)

tcant_budget_basin_MLR <- tcant_budget_basin_MLR %>% 
  mutate(dcant = beta_1994 * delta_pCO2)

tcant_budget_basin_MLR <- tcant_budget_basin_MLR %>%
  mutate(
    basin = fct_relevel(
      basin,
      "Global",
      "Indian",
      "N. Pacific",
      "S. Pacific",
      "N. Atlantic",
      "S. Atlantic"
    )
  )

dcant_budget_basin_MLR_all_ensemble %>%
  filter(data_source == "obs",
         period != "1994 - 2014",
         !(Version_ID %in% Version_IDs)) %>%
  ggplot(aes(period, dcant)) +
  geom_errorbar(
    data = tcant_budget_basin_MLR,
    aes(x = period,
        ymax = dcant, ymin = dcant,
        col = "Scaled 1994\nestimate"),
    width = 0.8,
    size = 1,
    linetype = 1,
    position = position_nudge(x = 0.05)
  ) +
  geom_jitter(
    data = dcant_budget_basin_MLR_all_no_adj %>%
      filter(data_source == "obs",
             period != "1994 - 2014"),
    aes(fill = "Unadjusted data",
        alpha = "Unadjusted data"),
    shape = 21,
    position = position_jitter(width = 0.1, height = 0)
  ) +
  geom_point(
    aes(fill = "Ensemble member",
        alpha = "Ensemble member"),
    shape = 21,
    position = position_jitter(width = 0.1, height = 0)
  ) +
  geom_crossbar(
    data = dcant_budget_ensemble_stat %>% filter(data_source == "obs"),
    aes(
      x = period,
      y = std_case,
      ymin = std_case - 2*sd,
      ymax = std_case + 2*sd,
      linetype = "Ensemble SD"
    ),
    width = 0.1,
    fill = "#AA3377",
    alpha = 0.2,
    position = position_nudge(x = 0.2)
  ) +
  geom_crossbar(
    data = dcant_budget_ensemble_stat %>% filter(data_source == "obs"),
    aes(
      x = period,
      y = std_case,
      ymin = std_case - sd,
      ymax = std_case + sd,
      alpha = "Ensemble SD",
    ),
    width = 0.1,
    fill = "#AA3377",
    alpha = 0.4,
    position = position_nudge(x = 0.2)
  ) +
  geom_point(
    data = dcant_budget_ensemble_stat %>% filter(data_source == "obs"),
    aes(x = period,
        y = std_case,
        fill = "Standard case",
        alpha = "Standard case"),
    size = 2,
    shape = 21,
    position = position_nudge(x = 0.2)
  ) +
  scale_fill_manual(name = "group", values = c("#BB5566", "white", "#DDAA33")) +
  scale_color_manual(values = c("grey50"), label = expression(Scaled~C[ant]~1994)) +
  scale_linetype(name = "X") +
  scale_alpha_manual(name = "group", values = c(0.7,1,0.7)) +
  scale_shape_manual(values = 95) +
  scale_y_continuous(name = dcant_pgc_label) +
  guides(
    fill = guide_legend(order = 1),
    linetype = guide_legend(order = 2),
    alpha = guide_legend(order = 1)
  ) +
  facet_wrap(~ basin, ncol = 3, dir = "v", scales = "free_y") +
  theme(legend.title = element_blank(),
        axis.title.x = element_blank())

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
ggsave(path = here::here("output/publication"),
       filename = "Fig_dcant_inventory_ensemble_uncertainty.png",
       height = 6,
       width = 8)

dcant_budget_basin_MLR_all_ensemble %>%
  mutate(ensemble_role = if_else(Version_ID %in% Version_IDs,
                                 "Standard case",
                                 "others")) %>%
  filter(data_source == "obs",
         period != "1994 - 2014") %>%
  ggplot(aes(period, dcant)) +
  scale_fill_brewer(palette = "Dark2", name = "ensemble group") +
  scale_color_manual(values = c("grey", "black", "red"),
                     name = "Ensemble member") +
  geom_boxplot(
    width = .1,
    outlier.shape = NA,
    fill = "grey",
    alpha = 0.7,
    position = position_nudge(x = 0.3)
  ) +
  geom_point(
    data = dcant_budget_basin_MLR_all_no_adj %>%
      mutate(ensemble_role = "no adjustment") %>%
      filter(data_source == "obs",
         period != "1994 - 2014"),
    aes(fill = Version_ID_group,
        col = ensemble_role),
    size = 1.3,
    alpha = .7,
    shape = 21,
    position = position_dodge2(width = 0.3)
  ) +
  geom_point(
    aes(fill = Version_ID_group,
        col = ensemble_role),
    size = 1.3,
    alpha = .7,
    shape = 21,
    position = position_dodge2(width = 0.3)
  ) +
  scale_y_continuous(name = dcant_pgc_label) +
  facet_wrap(~ basin, ncol = 3, scales = "free_y")

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
# dcant_budget_basin_MLR_all_ensemble_summary <- dcant_budget_basin_MLR_all_ensemble %>% 
#   group_by(data_source, basin, period) %>% 
#   summarise(dcant_mean = mean(dcant),
#             dcant_sd = sd(dcant)*sd_factor) %>% 
#   ungroup()
# 
# dcant_budget_global_all_ensemble_summary <-
#   dcant_budget_basin_MLR_all_ensemble %>%
#   filter(period != "1994 - 2014") %>%
#   group_by(data_source, Version_ID, tref1, tref2, period) %>%
#   summarise(dcant = sum(dcant)) %>%
#   ungroup() %>%
#   group_by(data_source, tref1, tref2, period) %>%
#   summarise(dcant_mean = mean(dcant),
#             dcant_sd = sd(dcant)*sd_factor) %>%
#   ungroup() %>%
#   filter(data_source == "obs")

14.1.2 Additive uncertainty

dcant_budget_basin_MLR_all_ensemble %>%
  filter(data_source == "obs",
         period != "1994 - 2014",
         !(Version_ID %in% Version_IDs),
         MLR_basins == unique(params_local_all$MLR_basins)) %>%
  ggplot(aes(period, dcant)) +
  geom_errorbar(
    data = tcant_budget_basin_MLR,
    aes(x = period,
        ymax = dcant, ymin = dcant,
        col = "Scaled 1994\nestimate"),
    width = 0.8,
    size = 1,
    linetype = 1,
    position = position_nudge(x = 0.05)
  ) +
  geom_jitter(
    data = dcant_budget_basin_MLR_all_ensemble %>%
      filter(data_source == "obs",
             period != "1994 - 2014",
             Version_ID_group == "Bulk adjustment"),
    aes(fill = "Regional clustering",
        alpha = "Regional clustering"),
    shape = 21,
    position = position_jitter(width = 0.1, height = 0)
  ) +
  geom_point(
    aes(fill = "Configuration changes",
        alpha = "Configuration changes"),
    shape = 21,
    position = position_jitter(width = 0.1, height = 0)
  ) +
  geom_crossbar(
    data = dcant_budget_ensemble_stat_factorial %>% filter(data_source == "obs"),
    aes(
      x = period,
      y = std_case,
      ymin = std_case - 2*sd,
      ymax = std_case + 2*sd,
      linetype = "Combined uncertainty"
    ),
    width = 0.1,
    fill = "#BBBBBB",
    alpha = 0.2,
    position = position_nudge(x = 0.2)
  ) +
  geom_crossbar(
    data = dcant_budget_ensemble_stat_factorial %>% filter(data_source == "obs"),
    aes(
      x = period,
      y = std_case,
      ymin = std_case - sd,
      ymax = std_case + sd,
      alpha = "Combined uncertainty",
    ),
    width = 0.1,
    fill = "#BBBBBB",
    alpha = 0.4,
    position = position_nudge(x = 0.2)
  ) +
  geom_point(
    data = dcant_budget_ensemble_stat %>% filter(data_source == "obs"),
    aes(x = period,
        y = std_case,
        fill = "Standard case",
        alpha = "Standard case"),
    size = 2,
    shape = 21,
    position = position_nudge(x = 0.2)
  ) +
  scale_fill_manual(name = "group", values = c("#BB5566", "#004488", "white")) +
  scale_color_manual(values = c("grey50"), label = expression(Scaled~C[ant]~1994)) +
  scale_linetype(name = "X") +
  scale_alpha_manual(name = "group", values = c(0.7,0.7,1)) +
  scale_shape_manual(values = 95) +
  scale_y_continuous(name = dcant_pgc_label) +
  guides(
    fill = guide_legend(order = 1),
    linetype = guide_legend(order = 2),
    alpha = guide_legend(order = 1)
  ) +
  facet_wrap(~ basin, ncol = 3, dir = "v", scales = "free_y") +
  theme(legend.title = element_blank(),
        axis.title.x = element_blank())

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
ggsave(path = here::here("output/publication"),
       filename = "Fig_dcant_inventory_additive_uncertainty.png",
       height = 6,
       width = 8)

14.1.3 Beta

# determine scaling factor from dcant -> beta inventories
# including scaling for: delta pCO2 atm, basin area, PgC -> molC

beta_scaling <-
  bind_rows(
    area_scaling,
    area_scaling %>%
      summarise(M22 = sum(M22) * dcant_scaling) %>%
      mutate(basin = "Global")
  ) %>% 
  select(basin, area = M22)


beta_scaling <- 
  full_join(delta_pCO2_atm,
            beta_scaling,
            by = character())

beta_scaling <- beta_scaling %>% 
  mutate(scaling_factor = 1e15 / 12 / delta_pCO2 / area) %>% 
  select(period, basin, scaling_factor, area)

beta_budget_basin_MLR_all_no_adj <-
  left_join(dcant_budget_basin_MLR_all_no_adj,
            beta_scaling) %>%
  mutate(beta = dcant * scaling_factor) %>% 
  select(-scaling_factor)

beta_budget_basin_MLR_all_ensemble <-
  left_join(dcant_budget_basin_MLR_all_ensemble,
            beta_scaling) %>%
  mutate(beta = dcant * scaling_factor) %>% 
  select(-scaling_factor)


tcant_budget_basin_MLR <-
  left_join(tcant_budget_basin_MLR,
            beta_scaling) %>%
  mutate(beta_1994 = beta_1994 * 1e15 / 12 / area) %>% 
  select(-c(area,scaling_factor))

beta_budget_ensemble_stat <- 
  left_join(dcant_budget_ensemble_stat,
            beta_scaling) %>% 
  mutate(
    median = median * scaling_factor,
    sd = sd * scaling_factor,
    std_case = std_case * scaling_factor
    ) %>% 
  select(-scaling_factor)

beta_budget_ensemble_stat_factorial <- 
  left_join(dcant_budget_ensemble_stat_factorial,
            beta_scaling) %>% 
  mutate(
    sd = sd * scaling_factor,
    std_case = std_case * scaling_factor
    ) %>% 
  select(-scaling_factor)
# beta_budget_ensemble_stat <-
#   beta_budget_basin_MLR_all_ensemble %>% 
#   filter(period != "1994 - 2014",
#          data_source != "mod_truth") %>%
#   select(basin, period, dcant, beta, data_source) %>% 
#   pivot_longer(c(dcant, beta),
#                values_to = "value",
#                names_to = "estimate") %>% 
#   group_by(period, basin, estimate, data_source) %>%
#   summarise(
#     median = median(value),
#     sd = sd(value),
#     n = n()
#   ) %>%
#   ungroup() 
# 
# 
# beta_budget_ensemble_stat <-
#   full_join(
#     beta_budget_ensemble_stat,
#     beta_budget_basin_MLR_all_ensemble %>%
#       filter(
#         Version_ID %in% Version_IDs,
#         period != "1994 - 2014"
#       ) %>%
#       select(period,
#              basin,
#              data_source,
#              dcant,
#              beta) %>% 
#         pivot_longer(c(dcant, beta),
#                values_to = "std_case",
#                names_to = "estimate")
#   )


dcant_beta_budget_ensemble_stat <-
  bind_rows(
    dcant_budget_ensemble_stat %>% mutate(estimate = "dcant",
                                          uncertainty = "ensemble"),
    beta_budget_ensemble_stat %>% mutate(estimate = "beta",
                                         uncertainty = "ensemble"),
    dcant_budget_ensemble_stat_factorial %>% mutate(estimate = "dcant",
                                                    uncertainty = "additive"),
    beta_budget_ensemble_stat_factorial %>% mutate(estimate = "beta",
                                                   uncertainty = "additive")
  ) %>%
  filter(data_source != "mod_truth") %>%
  select(-c(median))
  

dcant_beta_budget_ensemble_significance <- 
  dcant_beta_budget_ensemble_stat %>% 
  arrange(period) %>% 
  group_by(estimate, uncertainty, basin, data_source) %>%
  mutate(
    delta = std_case - lag(std_case),
    RSS = sqrt(sd_factor * sd ^ 2 + lag(sd_factor * sd ^ 2)),
    RSS_delta_ratio = abs(delta) / RSS,
    ttest_p = tsum.test(
      mean.x = std_case,
      s.x = sd,
      n.x = n,
      mean.y = lag(std_case),
      s.y = lag(sd),
      n.y = lag(n)
    )$p.value
  ) %>%
  ungroup() %>% 
  filter(!is.na(delta))
  

dcant_beta_budget_ensemble_stat_significance <-
  full_join(
    dcant_beta_budget_ensemble_stat %>%
      select(-c(n)) %>%
      pivot_wider(
        names_from = period,
        values_from = c(sd, std_case),
        names_sep = " "
      ),
    dcant_beta_budget_ensemble_significance %>% 
      select(-c(sd, n, std_case))
  )

dcant_beta_budget_ensemble_stat_significance <-
  dcant_beta_budget_ensemble_stat_significance %>% 
  mutate(across(where(is.numeric), signif, 2))

dcant_beta_budget_ensemble_stat_significance %>% 
  kable() %>%
  kable_styling() %>%
  scroll_box(height = "300px")
basin data_source estimate uncertainty area sd 1994 - 2004 sd 2004 - 2014 std_case 1994 - 2004 std_case 2004 - 2014 period delta RSS RSS_delta_ratio ttest_p
Global mod dcant ensemble NA 1.500 1.600 20.00 25.00 2004 - 2014 4.8000 3.000 1.600 0.0e+00
Global obs dcant ensemble NA 1.800 1.800 29.00 27.00 2004 - 2014 -1.9000 3.500 0.540 3.4e-06
Indian mod dcant ensemble NA 0.860 0.640 5.10 6.60 2004 - 2014 1.5000 1.500 0.960 0.0e+00
Indian obs dcant ensemble NA 0.850 0.810 7.20 5.70 2004 - 2014 -1.4000 1.700 0.860 0.0e+00
N. Pacific mod dcant ensemble NA 0.330 0.390 3.10 3.40 2004 - 2014 0.2300 0.720 0.330 3.8e-03
N. Pacific obs dcant ensemble NA 0.950 0.780 2.90 3.20 2004 - 2014 0.3200 1.700 0.180 9.6e-02
S. Pacific mod dcant ensemble NA 0.720 0.630 5.50 7.40 2004 - 2014 1.9000 1.400 1.400 0.0e+00
S. Pacific obs dcant ensemble NA 1.000 0.930 8.60 7.40 2004 - 2014 -1.2000 1.900 0.650 1.0e-07
N. Atlantic mod dcant ensemble NA 0.210 0.190 2.20 2.40 2004 - 2014 0.2200 0.410 0.550 3.3e-06
N. Atlantic obs dcant ensemble NA 0.180 0.390 4.80 3.90 2004 - 2014 -0.9000 0.600 1.500 0.0e+00
S. Atlantic mod dcant ensemble NA 0.300 0.330 2.70 3.40 2004 - 2014 0.7100 0.630 1.100 0.0e+00
S. Atlantic obs dcant ensemble NA 0.570 0.630 3.90 5.40 2004 - 2014 1.5000 1.200 1.200 0.0e+00
Global mod beta ensemble 3.6e+14 0.018 0.018 0.25 0.28 2004 - 2014 0.0340 0.036 0.930 0.0e+00
Global obs beta ensemble 3.6e+14 0.023 0.020 0.37 0.31 2004 - 2014 -0.0540 0.043 1.300 0.0e+00
Indian mod beta ensemble 7.3e+13 0.053 0.036 0.31 0.37 2004 - 2014 0.0540 0.090 0.610 5.0e-07
Indian obs beta ensemble 7.3e+13 0.052 0.046 0.44 0.32 2004 - 2014 -0.1200 0.098 1.200 0.0e+00
N. Pacific mod beta ensemble 7.8e+13 0.019 0.020 0.18 0.18 2004 - 2014 -0.0033 0.039 0.085 4.4e-01
N. Pacific obs beta ensemble 7.8e+13 0.054 0.041 0.17 0.17 2004 - 2014 0.0023 0.096 0.024 8.3e-01
S. Pacific mod beta ensemble 9.6e+13 0.034 0.027 0.26 0.32 2004 - 2014 0.0580 0.061 0.960 0.0e+00
S. Pacific obs beta ensemble 9.6e+13 0.046 0.039 0.40 0.31 2004 - 2014 -0.0880 0.086 1.000 0.0e+00
N. Atlantic mod beta ensemble 4.1e+13 0.024 0.019 0.24 0.25 2004 - 2014 0.0010 0.043 0.024 8.3e-01
N. Atlantic obs beta ensemble 4.1e+13 0.020 0.039 0.53 0.39 2004 - 2014 -0.1400 0.062 2.200 0.0e+00
S. Atlantic mod beta ensemble 4.5e+13 0.030 0.030 0.27 0.31 2004 - 2014 0.0410 0.060 0.680 0.0e+00
S. Atlantic obs beta ensemble 4.5e+13 0.057 0.058 0.39 0.49 2004 - 2014 0.0990 0.110 0.870 0.0e+00
Global mod dcant additive NA 2.300 2.800 20.00 25.00 2004 - 2014 4.8000 5.100 0.940 NA
Global obs dcant additive NA 2.300 3.200 29.00 27.00 2004 - 2014 -1.9000 5.500 0.350 NA
Indian mod dcant additive NA 0.830 1.100 5.10 6.60 2004 - 2014 1.5000 2.000 0.750 NA
Indian obs dcant additive NA 0.980 1.500 7.20 5.70 2004 - 2014 -1.4000 2.600 0.550 NA
N. Pacific mod dcant additive NA 0.330 0.850 3.10 3.40 2004 - 2014 0.2300 1.300 0.180 NA
N. Pacific obs dcant additive NA 1.100 2.100 2.90 3.20 2004 - 2014 0.3200 3.300 0.097 NA
S. Pacific mod dcant additive NA 1.300 0.930 5.50 7.40 2004 - 2014 1.9000 2.300 0.820 NA
S. Pacific obs dcant additive NA 1.300 0.960 8.60 7.40 2004 - 2014 -1.2000 2.300 0.540 NA
N. Atlantic mod dcant additive NA 0.180 0.380 2.20 2.40 2004 - 2014 0.2200 0.600 0.370 NA
N. Atlantic obs dcant additive NA 0.170 0.330 4.80 3.90 2004 - 2014 -0.9000 0.530 1.700 NA
S. Atlantic mod dcant additive NA 0.620 0.490 2.70 3.40 2004 - 2014 0.7100 1.100 0.630 NA
S. Atlantic obs dcant additive NA 0.770 0.790 3.90 5.40 2004 - 2014 1.5000 1.600 0.930 NA
Global mod beta additive 3.6e+14 0.029 0.032 0.25 0.28 2004 - 2014 0.0340 0.061 0.550 NA
Global obs beta additive 3.6e+14 0.029 0.036 0.37 0.31 2004 - 2014 -0.0540 0.066 0.830 NA
Indian mod beta additive 7.3e+13 0.051 0.062 0.31 0.37 2004 - 2014 0.0540 0.110 0.480 NA
Indian obs beta additive 7.3e+13 0.060 0.086 0.44 0.32 2004 - 2014 -0.1200 0.150 0.800 NA
N. Pacific mod beta additive 7.8e+13 0.019 0.044 0.18 0.18 2004 - 2014 -0.0033 0.068 0.049 NA
N. Pacific obs beta additive 7.8e+13 0.062 0.110 0.17 0.17 2004 - 2014 0.0023 0.180 0.013 NA
S. Pacific mod beta additive 9.6e+13 0.063 0.040 0.26 0.32 2004 - 2014 0.0580 0.100 0.550 NA
S. Pacific obs beta additive 9.6e+13 0.061 0.041 0.40 0.31 2004 - 2014 -0.0880 0.100 0.850 NA
N. Atlantic mod beta additive 4.1e+13 0.020 0.039 0.24 0.25 2004 - 2014 0.0010 0.061 0.017 NA
N. Atlantic obs beta additive 4.1e+13 0.018 0.033 0.53 0.39 2004 - 2014 -0.1400 0.054 2.500 NA
S. Atlantic mod beta additive 4.5e+13 0.062 0.045 0.27 0.31 2004 - 2014 0.0410 0.110 0.380 NA
S. Atlantic obs beta additive 4.5e+13 0.077 0.072 0.39 0.49 2004 - 2014 0.0990 0.150 0.660 NA
dcant_beta_budget_ensemble_stat_significance %>% 
  ggplot(aes(abs(delta) / RSS, ttest_p, 
             col = basin, shape = uncertainty)) +
  geom_vline(xintercept = 1) +
  geom_hline(yintercept = 0.05) +
  geom_point() +
  scale_y_log10() +
  scale_color_brewer(palette = "Dark2") +
  facet_grid(data_source ~ estimate)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
a80b59b jens-daniel-mueller 2022-07-20
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
efa414b jens-daniel-mueller 2022-07-16
dcant_beta_budget_ensemble_stat_significance_table <-
dcant_beta_budget_ensemble_stat_significance %>%
  filter(data_source == "obs") %>% 
  select(-data_source) %>% 
  mutate(
    `1994 - 2004` = paste(`std_case 1994 - 2004`, `sd 1994 - 2004`, sep = " ± "),
    `2004 - 2014` = paste(`std_case 2004 - 2014`, `sd 2004 - 2014`, sep = " ± "),
    `Deacadal change` = paste0(delta, " ± ", RSS, if_else(abs(delta) > RSS, " *",""))
  ) %>%
  select(Region = basin,
         Estimate = estimate,
         Uncertainty = uncertainty,
         `1994 - 2004`,
         `2004 - 2014`,
         `Deacadal change`) %>%
  arrange(Region, desc(Estimate), Uncertainty) 

dcant_beta_budget_ensemble_stat_significance_table %>% 
  write_csv(here::here("output/publication/Table_budget_stats.csv"))
beta_budget_basin_MLR_all_ensemble %>%
  filter(data_source == "obs",
         period != "1994 - 2014",
         !(Version_ID %in% Version_IDs)) %>%
  ggplot(aes(period, beta)) +
  geom_errorbar(
    data = tcant_budget_basin_MLR %>% 
      rename(beta = beta_1994),
    aes(x = period,
        ymax = beta, ymin = beta,
        col = "Scaled 1994\nestimate"),
    width = 0.8,
    size = 1,
    linetype = 1,
    position = position_nudge(x = 0.05)
  ) +
  geom_jitter(
    data = beta_budget_basin_MLR_all_no_adj %>%
      filter(data_source == "obs",
             period != "1994 - 2014"),
    aes(fill = "Unadjusted data",
        alpha = "Unadjusted data"),
    shape = 21,
    position = position_jitter(width = 0.1, height = 0)
  ) +
  geom_point(
    aes(fill = "Ensemble member",
        alpha = "Ensemble member"),
    shape = 21,
    position = position_jitter(width = 0.1, height = 0)
  ) +
  geom_crossbar(
    data = beta_budget_ensemble_stat %>% 
      filter(data_source == "obs"),
    aes(
      x = period,
      y = std_case,
      ymin = std_case - 2*sd,
      ymax = std_case + 2*sd,
      linetype = "Ensemble SD"
    ),
    width = 0.1,
    fill = "#AA3377",
    alpha = 0.2,
    position = position_nudge(x = 0.2)
  ) +
  geom_crossbar(
    data = beta_budget_ensemble_stat %>% 
      filter(data_source == "obs"),
    aes(
      x = period,
      y = std_case,
      ymin = std_case - sd,
      ymax = std_case + sd,
      alpha = "Ensemble SD",
    ),
    width = 0.1,
    fill = "#AA3377",
    alpha = 0.4,
    position = position_nudge(x = 0.2)
  ) +
  geom_point(
    data = beta_budget_ensemble_stat %>% 
      filter(data_source == "obs"),
    aes(x = period,
        y = std_case,
        fill = "Standard case",
        alpha = "Standard case"),
    size = 2,
    shape = 21,
    position = position_nudge(x = 0.2)
  ) +
  scale_fill_manual(name = "group", values = c("#BB5566", "white", "#BBBBBB")) +
  scale_color_manual(values = c("grey50"), label = expression(Scaled~C[ant]~1994)) +
  scale_linetype(name = "X") +
  scale_alpha_manual(name = "group", values = c(0.5,1,0.5)) +
  scale_shape_manual(values = 95) +
  scale_y_continuous(name = dcant_pgc_scaled_label) +
  guides(
    fill = guide_legend(order = 1),
    linetype = guide_legend(order = 2),
    alpha = guide_legend(order = 1)
  ) +
  facet_wrap(~ basin, ncol = 3, dir = "v") +
  theme(legend.title = element_blank(),
        axis.title.x = element_blank())

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
ggsave(path = here::here("output/publication"),
       filename = "FigS_beta_budgets_ensemble_member.png",
       height = 6,
       width = 8)
beta_budget_basin_MLR_all_ensemble %>%
  filter(data_source == "obs",
         period != "1994 - 2014",
         !(Version_ID %in% Version_IDs),
         MLR_basins == unique(params_local_all$MLR_basins)) %>%
  ggplot(aes(period, beta)) +
  geom_errorbar(
    data = tcant_budget_basin_MLR %>% 
      rename(beta = beta_1994),
    aes(x = period,
        ymax = beta, ymin = beta,
        col = "Scaled 1994\nestimate"),
    width = 0.8,
    size = 1,
    linetype = 1,
    position = position_nudge(x = 0.05)
  ) +
  geom_jitter(
    data = beta_budget_basin_MLR_all_ensemble %>%
      filter(data_source == "obs",
             period != "1994 - 2014",
             Version_ID_group == "Bulk adjustment"),
    aes(fill = "Regional clustering",
        alpha = "Regional clustering"),
    shape = 21,
    position = position_jitter(width = 0.1, height = 0)
  ) +
  geom_point(
    aes(fill = "Configuration changes",
        alpha = "Configuration changes"),
    shape = 21,
    position = position_jitter(width = 0.1, height = 0)
  ) +
  geom_crossbar(
    data = beta_budget_ensemble_stat_factorial %>% filter(data_source == "obs"),
    aes(
      x = period,
      y = std_case,
      ymin = std_case - 2*sd,
      ymax = std_case + 2*sd,
      linetype = "Combined uncertainty"
    ),
    width = 0.1,
    fill = "#BBBBBB",
    alpha = 0.2,
    position = position_nudge(x = 0.2)
  ) +
  geom_crossbar(
    data = beta_budget_ensemble_stat_factorial %>% filter(data_source == "obs"),
    aes(
      x = period,
      y = std_case,
      ymin = std_case - sd,
      ymax = std_case + sd,
      alpha = "Combined uncertainty",
    ),
    width = 0.1,
    fill = "#BBBBBB",
    alpha = 0.4,
    position = position_nudge(x = 0.2)
  ) +
  geom_point(
    data = beta_budget_ensemble_stat %>% filter(data_source == "obs"),
    aes(x = period,
        y = std_case,
        fill = "Standard case",
        alpha = "Standard case"),
    size = 2,
    shape = 21,
    position = position_nudge(x = 0.2)
  ) +
  scale_fill_manual(name = "group", values = c("#BB5566", "#004488", "white")) +
  scale_color_manual(values = c("grey50"), label = expression(Scaled~C[ant]~1994)) +
  scale_linetype(name = "X") +
  scale_alpha_manual(name = "group", values = c(0.7,0.7,1)) +
  scale_shape_manual(values = 95) +
  scale_y_continuous(name = dcant_pgc_label) +
  guides(
    fill = guide_legend(order = 1),
    linetype = guide_legend(order = 2),
    alpha = guide_legend(order = 1)
  ) +
  facet_wrap(~ basin, ncol = 3, dir = "v", scales = "free_y") +
  theme(legend.title = element_blank(),
        axis.title.x = element_blank())

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
ggsave(path = here::here("output/publication"),
       filename = "Fig_beta_inventory_additive_uncertainty.png",
       height = 6,
       width = 8)

14.1.4 Biases

dcant_budget_basin_MLR_all_ensemble_bias <- 
dcant_budget_basin_MLR_all_ensemble %>%
  filter(data_source %in% c("mod", "mod_truth")) %>% 
  pivot_wider(names_from = data_source,
              values_from = dcant) %>% 
  mutate(dcant_bias = mod - mod_truth,
         dcant_bias_rel = 100 * dcant_bias / mod_truth)

dcant_budget_basin_MLR_all_ensemble_bias <- 
dcant_budget_basin_MLR_all_ensemble_bias %>%
  mutate(ensemble_role = if_else(Version_ID %in% Version_IDs,
                                 "Standard case",
                                 "others"))

dcant_budget_basin_MLR_all_ensemble_bias %>%
  ggplot(aes(period, dcant_bias)) +
  geom_hline(yintercept = 0) +
  geom_point(
    aes(fill = Version_ID_group,
        col = ensemble_role),
    size = 1.3,
    alpha = .7,
    shape = 21,
    position = position_dodge2(width = 0.3)
  ) +
  stat_summary(
    fun.data = "mean_sdl",
    fun.args = list(mult = 2),
    position = position_nudge(x = -0.3),
    col = "grey"
  ) +
  stat_summary(
    fun.data = "mean_sdl",
    fun.args = list(mult = 1),
    position = position_nudge(x = -0.3),
    size = 0.1
  ) +
  scale_fill_brewer(palette = "Dark2") +
    scale_color_manual(values = c("transparent", "black"),
                     name = "Ensemble member") +
  facet_grid(basin ~ .)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
9c3be27 jens-daniel-mueller 2022-08-09
a691b29 jens-daniel-mueller 2022-08-09
dcant_budget_bias_ensemble_stat <-
  dcant_budget_basin_MLR_all_ensemble_bias %>%
  filter(period != "1994 - 2014") %>%
  group_by(period, basin) %>%
  summarise(
    median = median(dcant_bias),
    sd = sd(dcant_bias),
    n = n()
  ) %>%
  ungroup() 


dcant_budget_bias_ensemble_stat <-
  full_join(
    dcant_budget_bias_ensemble_stat,
    dcant_budget_basin_MLR_all_ensemble_bias %>%
        filter(Version_ID %in% Version_IDs,
               period != "1994 - 2014") %>%
        select(period,
               basin,
               std_case = dcant_bias)
  )




dcant_budget_basin_MLR_all_ensemble_bias %>%
  filter(period != "1994 - 2014") %>%
  ggplot(aes(period, dcant_bias)) +
  geom_hline(yintercept = 0) +
  geom_point(
    aes(fill = "Ensemble member",
        alpha = "Ensemble member"),
    shape = 21,
    position = position_jitter(width = 0.1, height = 0)
  ) +
  geom_crossbar(
    data = dcant_budget_bias_ensemble_stat,
    aes(
      x = period,
      y = std_case,
      ymin = std_case - 2 * sd,
      ymax = std_case + 2 * sd,
      linetype = "Ensemble SD"
    ),
    width = 0.1,
    fill = "#AA3377",
    alpha = 0.2,
    position = position_nudge(x = 0.2)
  ) +
  geom_crossbar(
    data = dcant_budget_bias_ensemble_stat,
    aes(
      x = period,
      y = std_case,
      ymin = std_case - sd,
      ymax = std_case + sd,
      alpha = "Ensemble SD",
    ),
    width = 0.1,
    fill = "#AA3377",
    alpha = 0.4,
    position = position_nudge(x = 0.2)
  ) +
  geom_point(
    data = dcant_budget_bias_ensemble_stat,
    aes(
      x = period,
      y = std_case,
      fill = "Standard case",
      alpha = "Standard case"
    ),
    size = 2,
    shape = 21,
    position = position_nudge(x = 0.2)
  )+
  scale_fill_manual(name = "group", values = c("#BB5566", "white", "#BBBBBB")) +
  scale_linetype(name = "X") +
  scale_alpha_manual(name = "group", values = c(0.5,1,0.5)) +
  scale_shape_manual(values = 95) +
  scale_y_continuous(name = dcant_bias_pgc_label) +
  guides(
    fill = guide_legend(order = 1),
    linetype = guide_legend(order = 2),
    alpha = guide_legend(order = 1)
  ) +
  facet_wrap(~ basin, ncol = 3, dir = "v", scales = "free_y") +
  theme(legend.title = element_blank(),
        axis.title.x = element_blank())

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
0b40366 jens-daniel-mueller 2022-10-26
91052ae jens-daniel-mueller 2022-10-20
46c163a jens-daniel-mueller 2022-10-10
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
9c3be27 jens-daniel-mueller 2022-08-09
a691b29 jens-daniel-mueller 2022-08-09
ggsave(path = here::here("output/publication"),
       filename = "FigS_dcant_bias_budgets_ensemble_member.png",
       height = 6,
       width = 8)



dcant_budget_basin_MLR_all_ensemble_bias %>% 
  ggplot(aes(period, dcant_bias_rel, col = Version_ID_group)) +
  geom_hline(yintercept = 0) +
  geom_jitter(alpha = 0.5) +
  scale_color_brewer(palette = "Dark2") +
  facet_grid(basin ~ MLR_basins)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
0b40366 jens-daniel-mueller 2022-10-26
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
5b77c4f jens-daniel-mueller 2022-08-10
9c3be27 jens-daniel-mueller 2022-08-09
a691b29 jens-daniel-mueller 2022-08-09
delta_dcant_budget_basin_MLR_all_ensemble <-
dcant_budget_basin_MLR_all_ensemble_bias %>%
  filter(period %in% two_decades) %>%
  select(basin, period, MLR_basins, Version_ID_group, mod, mod_truth, Version_ID) %>%
  pivot_longer(cols = mod:mod_truth,
               names_to = "data_source",
               values_to = "dcant") %>%
  group_by(basin, MLR_basins, Version_ID_group, data_source) %>%
  arrange(period) %>%
  mutate(delta_dcant = dcant - lag(dcant)) %>%
  ungroup() %>%
  drop_na() %>%
  select(-dcant) 

delta_dcant_budget_basin_MLR_all_ensemble_bias <- 
  delta_dcant_budget_basin_MLR_all_ensemble %>%
  pivot_wider(names_from = data_source,
              values_from = delta_dcant) %>%
  mutate(delta_dcant_bias = mod - mod_truth,
         delta_dcant_bias_rel = 100 * delta_dcant_bias / mod_truth)

delta_dcant_budget_basin_MLR_all_ensemble %>% 
  ggplot(aes(data_source, delta_dcant, col = Version_ID_group)) +
  geom_hline(yintercept = 0) +
  geom_jitter(alpha = 0.5) +
  scale_color_brewer(palette = "Dark2") +
  facet_grid(basin ~ MLR_basins)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
0b40366 jens-daniel-mueller 2022-10-26
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
5b77c4f jens-daniel-mueller 2022-08-10
9c3be27 jens-daniel-mueller 2022-08-09
a691b29 jens-daniel-mueller 2022-08-09
delta_dcant_budget_basin_MLR_all_ensemble_bias %>% 
  ggplot(aes(period, delta_dcant_bias, col = Version_ID_group)) +
  geom_hline(yintercept = 0) +
  geom_jitter(alpha = 0.5) +
  scale_color_brewer(palette = "Dark2") +
  facet_grid(basin ~ MLR_basins)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
0b40366 jens-daniel-mueller 2022-10-26
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
5b77c4f jens-daniel-mueller 2022-08-10
9c3be27 jens-daniel-mueller 2022-08-09
delta_dcant_budget_bias_ensemble_stat <-
  delta_dcant_budget_basin_MLR_all_ensemble_bias %>%
  group_by(basin) %>%
  summarise(
    median = median(delta_dcant_bias),
    sd = sd(delta_dcant_bias),
    n = n()
  ) %>%
  ungroup() 


delta_dcant_budget_bias_ensemble_stat <-
  full_join(
    delta_dcant_budget_bias_ensemble_stat,
    delta_dcant_budget_basin_MLR_all_ensemble_bias %>%
        filter(Version_ID %in% Version_IDs,
               period != "1994 - 2014") %>%
        select(period,
               basin,
               std_case = delta_dcant_bias)
  )



delta_dcant_budget_bias_ensemble_stat_RSS <-
  dcant_budget_bias_ensemble_stat %>% 
  arrange(period) %>% 
  group_by(basin) %>% 
  mutate(delta_std_case = std_case - lag(std_case),
         RSS = sqrt(sd^2 + lag(sd)^2)) %>% 
  ungroup() %>% 
  drop_na()
  



delta_dcant_budget_basin_MLR_all_ensemble_bias %>%
  ggplot(aes(period, delta_dcant_bias)) +
  geom_hline(yintercept = 0) +
  geom_point(
    aes(fill = "Ensemble member",
        alpha = "Ensemble member"),
    shape = 21,
    position = position_jitter(width = 0.1, height = 0)
  ) +
  # geom_crossbar(
  #   data = delta_dcant_budget_bias_ensemble_stat,
  #   aes(
  #     x = period,
  #     y = std_case,
  #     ymin = std_case - 2 * sd,
  #     ymax = std_case + 2 * sd,
  #     linetype = "Ensemble SD"
  #   ),
  #   width = 0.1,
  #   fill = "#AA3377",
  #   alpha = 0.2,
  #   position = position_nudge(x = 0.2)
  # ) +
  # geom_crossbar(
  #   data = delta_dcant_budget_bias_ensemble_stat,
  #   aes(
  #     x = period,
  #     y = std_case,
  #     ymin = std_case - sd,
  #     ymax = std_case + sd,
  #     alpha = "Ensemble SD",
  #   ),
  #   width = 0.1,
  #   fill = "#AA3377",
  #   alpha = 0.4,
  #   position = position_nudge(x = 0.2)
  # ) +
  geom_crossbar(
    data = delta_dcant_budget_bias_ensemble_stat_RSS,
    aes(
      x = period,
      y = delta_std_case,
      ymin = delta_std_case - 2 * RSS,
      ymax = delta_std_case + 2 * RSS,
      linetype = "RSS"
    ),
    width = 0.1,
    fill = "#AA3377",
    alpha = 0.2,
    position = position_nudge(x = 0.2)
  ) +
  geom_crossbar(
    data = delta_dcant_budget_bias_ensemble_stat_RSS,
    aes(
      x = period,
      y = delta_std_case,
      ymin = delta_std_case - RSS,
      ymax = delta_std_case + RSS,
      alpha = "RSS",
    ),
    width = 0.1,
    fill = "#AA3377",
    alpha = 0.4,
    position = position_nudge(x = 0.2)
  ) +
  geom_point(
    data = delta_dcant_budget_bias_ensemble_stat,
    aes(
      x = period,
      y = std_case,
      fill = "Standard case",
      alpha = "Standard case"
    ),
    size = 2,
    shape = 21,
    position = position_nudge(x = 0.2)
  )+
  scale_fill_manual(name = "group", values = c("#BB5566", "white", "#BBBBBB")) +
  scale_linetype(name = "X") +
  scale_alpha_manual(name = "group", values = c(0.5,1,0.5)) +
  scale_shape_manual(values = 95) +
  scale_y_continuous(name = delta_dcant_bias_pgc_label) +
  guides(
    fill = guide_legend(order = 1),
    linetype = guide_legend(order = 2),
    alpha = guide_legend(order = 1)
  ) +
  facet_wrap(~ basin, ncol = 3, dir = "v", scales = "free_y") +
  theme(legend.title = element_blank(),
        axis.title.x = element_blank(),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank(), 
        panel.grid.major.x = element_blank())

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
0b40366 jens-daniel-mueller 2022-10-26
91052ae jens-daniel-mueller 2022-10-20
46c163a jens-daniel-mueller 2022-10-10
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
318fefe jens-daniel-mueller 2022-08-11
5b77c4f jens-daniel-mueller 2022-08-10
9c3be27 jens-daniel-mueller 2022-08-09
ggsave(path = here::here("output/publication"),
       filename = "FigS_delta_dcant_bias_budgets_ensemble_member.png",
       height = 6,
       width = 6)

14.2 Flow chart

dcant_budget_basin_MLR_all <- 
  dcant_budget_basin_MLR_all %>% 
  filter(basin != "Global")

dcant_budget_basin_MLR_all <- left_join(dcant_budget_basin_MLR_all,
                           co2_atm %>% rename(tref1 = year,
                                              pCO21 = pCO2))

dcant_budget_basin_MLR_all <- left_join(dcant_budget_basin_MLR_all,
                           co2_atm %>% rename(tref2 = year,
                                              pCO22 = pCO2))


dcant_budget_basin_MLR_all_plot <- dcant_budget_basin_MLR_all %>%
  filter(period != "1994 - 2014",
         data_source == "obs")
tcant_budget_basin_MLR <-
  tcant_inv %>%
  mutate(method = "layer",
         data_source = "obs") %>% 
  group_by(basin) %>%
  nest() %>% 
  mutate(budget = map(.x = data, ~m_dcant_budget(.x))) %>% 
  select(-data) %>%
  unnest(budget)

tcant_budget_basin_MLR <-
  full_join(tcant_budget_basin_MLR,
            area_scaling %>% select(basin, scaling_factor)) %>%
  mutate(value = value * scaling_factor) %>%
  select(-scaling_factor)


tcant_budget_basin_MLR <- tcant_budget_basin_MLR %>% 
  mutate(pCO21 = 281,
         tref1 = 1800,
         tref2 = 1994)

tcant_budget_basin_MLR <- left_join(tcant_budget_basin_MLR,
                                    co2_atm %>% rename(tref2 = year,
                                                       pCO22 = pCO2))

tcant_budget_basin_MLR <- tcant_budget_basin_MLR %>% 
  mutate(period = paste(tref1, tref2, sep = " - ")) %>% 
  filter(estimate == "dcant") %>% 
  select(-estimate) %>% 
  rename(dcant = value)

dcant_budget_basin_MLR_all_plot <- bind_rows(
  dcant_budget_basin_MLR_all_plot,
  tcant_budget_basin_MLR)

dcant_budget_basin_MLR_all_plot <-
  left_join(dcant_budget_basin_MLR_all_plot,
            dcant_budget_basin_MLR_all_ensemble_summary)

14.2.1 Absolute

g1 <- dcant_budget_basin_MLR_all_plot %>%
  filter(period != "1800 - 1994") %>% 
  ggplot(aes(
    y = dcant,
    x = period,
    alluvium = basin,
    fill  = basin,
    stratum = basin
  )) +
  stat_alluvium(decreasing = FALSE) +
  stat_stratum(decreasing = FALSE) +
  stat_stratum(geom = "text",
               decreasing = FALSE,
               aes(label = paste(
                 round(after_stat(max-min),1)
                 # 100*round(after_stat(prop), 2), "%"
                 ))) +
  ggrepel::geom_label_repel(
    data = dcant_budget_basin_MLR_all_plot %>% filter(period == "2004 - 2014"),
    stat = "stratum",
    size = 4,
    nudge_x = .5,
    point.padding = 3,
    aes(fill = basin, label = basin),
    decreasing = FALSE
  )+
  scale_fill_brewer(palette = "Paired", guide = "none") +
  scale_y_continuous(limits = c(0, 32), expand = c(0, 0)) +
  labs(y = dcant_pgc_label) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1),
        axis.title.x = element_blank()) +
  theme_classic()


newdat <- tibble(layer_data(g1))

change <- 
  newdat %>% 
  select(x, alluvium, count) %>% 
  pivot_wider(names_from = x,
              values_from = count) %>% 
  mutate(dcant_change = round(100*(`2` - `1`) / `1`)) %>% 
  select(alluvium, dcant_change)

coord <- newdat %>%
  filter(x == 2) %>% 
  select(x, y, alluvium)

new_layer <- full_join(
  change,
  coord
)

new_layer <- new_layer %>% 
  mutate(dcant_change = as.character(dcant_change),
         dcant_change = if_else(str_detect(dcant_change, "-"),
                                dcant_change,
                                paste0("+", dcant_change)),
         dcant_change = paste(dcant_change, "%"))

g1 +
  geom_text(data = new_layer,
            aes(
              x = x - 0.3,
              y = y,
              label = dcant_change
            ),
            inherit.aes = FALSE)
g2 <- dcant_budget_basin_MLR_all_plot %>%
    filter(period != "1800 - 1994") %>%
  ggplot(aes(
    y = dcant,
    x = period,
    alluvium = basin,
    fill  = basin,
    stratum = basin,
    label = basin
  )) +
  geom_alluvium() +
  geom_stratum() +
  stat_stratum(geom = "text",
               aes(label = paste(
                 round(after_stat(count),1)
                 # 100*round(after_stat(prop), 2), "%"
                 ))) +
  ggrepel::geom_label_repel(
    data = dcant_budget_basin_MLR_all_plot %>% filter(period == "2004 - 2014"),
    stat = "stratum",
    size = 4,
    nudge_x = .5,
    point.padding = 3,
    aes(fill = basin)
  )+
  scale_fill_brewer(palette = "Paired", guide = "none") +
  scale_color_brewer(palette = "Paired", guide = "none") +
  scale_y_continuous(limits = c(0, 33), expand = c(0, 0)) +
  guides(y = "none") +
  labs(title = dcant_pgc_label) +
  theme_classic() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1),
        axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        plot.title = element_text(hjust = 0.5))


newdat <- tibble(layer_data(g2))

change_basin <- 
  newdat %>% 
  select(x, alluvium, count) %>% 
  pivot_wider(names_from = x,
              values_from = count) %>% 
  mutate(dcant_change = round(100*(`2` - `1`) / `1`)) %>% 
  select(alluvium, dcant_change)

coord_basin <- newdat %>%
  filter(x == 2) %>% 
  select(x, y, alluvium)

new_layer_basin <- full_join(
  change_basin,
  coord_basin
)

new_layer_basin <- new_layer_basin %>% 
  mutate(dcant_change = as.character(dcant_change),
         dcant_change = if_else(str_detect(dcant_change, "-"),
                                dcant_change,
                                paste0("+", dcant_change)),
         dcant_change = paste(dcant_change, "%"))

new_layer_total <- 
  newdat %>% 
  select(x, alluvium, count) %>% 
  group_by(x) %>% 
  summarise(dcant_change = sum(count)) %>% 
  ungroup()

new_layer_total <- new_layer_total %>% 
  mutate(y = dcant_change,
         dcant_change = as.character(round(dcant_change,1)),
         dcant_change = paste("global:",dcant_change))

g2 +
  geom_text(data = new_layer_basin,
            aes(
              x = x - 0.3,
              y = y,
              label = dcant_change
            ),
            inherit.aes = FALSE) +
  geom_label(data = new_layer_total,
            aes(
              x = x,
              y = y + 1,
              label = dcant_change
            ),
            inherit.aes = FALSE)

14.2.2 Scaled

dcant_budget_basin_MLR_all_plot <- left_join(dcant_budget_basin_MLR_all_plot,
                           co2_atm %>% rename(tref1 = year,
                                              pCO21 = pCO2))

dcant_budget_basin_MLR_all_plot <- left_join(dcant_budget_basin_MLR_all_plot,
                           co2_atm %>% rename(tref2 = year,
                                              pCO22 = pCO2))

dcant_budget_basin_MLR_all_plot <- dcant_budget_basin_MLR_all_plot %>% 
  mutate(delta_pCO2 = pCO22 - pCO21,
         beta = dcant / delta_pCO2,
         dcant_sd_scaled = dcant_sd / delta_pCO2) %>% 
  select(-starts_with("pCO2"))


dcant_budget_global_all_ensemble_summary <- left_join(dcant_budget_global_all_ensemble_summary,
                           co2_atm %>% rename(tref1 = year,
                                              pCO21 = pCO2))

dcant_budget_global_all_ensemble_summary <- left_join(dcant_budget_global_all_ensemble_summary,
                           co2_atm %>% rename(tref2 = year,
                                              pCO22 = pCO2))

dcant_budget_global_all_ensemble_summary <- dcant_budget_global_all_ensemble_summary %>% 
  mutate(delta_pCO2 = pCO22 - pCO21,
         beta = dcant_mean / delta_pCO2,
         dcant_sd_scaled = dcant_sd / delta_pCO2) %>% 
  select(-starts_with("pCO2"))
g2 <- dcant_budget_basin_MLR_all_plot %>%
  filter(period != "1800 - 1994") %>% 
  ggplot(aes(
    y = beta,
    x = period,
    alluvium = basin,
    fill  = basin,
    stratum = basin,
    label = basin
  )) +
  geom_alluvium() +
  geom_stratum() +
  stat_stratum(geom = "text",
               aes(label = paste(
                 round(after_stat(count),2)
                 # 100*round(after_stat(prop), 2), "%"
                 ))) +
  ggrepel::geom_label_repel(
    data = dcant_budget_basin_MLR_all_plot %>% filter(period == "2004 - 2014"),
    stat = "stratum",
    size = 4,
    nudge_x = .5,
    point.padding = 3,
    aes(fill = basin)
  )+
  scale_fill_brewer(palette = "Paired", guide = "none") +
  scale_color_brewer(palette = "Paired", guide = "none") +
  # scale_y_continuous(limits = c(0, 33), expand = c(0, 0)) +
  guides(y = "none") +
  labs(title = dcant_pgc_scaled_label) +
  theme_classic() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1),
        axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        plot.title = element_text(hjust = 0.5))


newdat <- tibble(layer_data(g2))

change_basin <- 
  newdat %>% 
  select(x, alluvium, count) %>% 
  pivot_wider(names_from = x,
              values_from = count) %>% 
  mutate(dcant_change = round(100*(`2` - `1`) / `1`)) %>% 
  select(alluvium, dcant_change)

coord_basin <- newdat %>%
  filter(x == 2) %>% 
  select(x, y, alluvium)

new_layer_basin <- full_join(
  change_basin,
  coord_basin
)

new_layer_basin <- new_layer_basin %>% 
  mutate(dcant_change = as.character(dcant_change),
         dcant_change = if_else(str_detect(dcant_change, "-"),
                                dcant_change,
                                paste0("+", dcant_change)),
         dcant_change = paste(dcant_change, "%"))

new_layer_total <- 
  newdat %>% 
  select(x, alluvium, count) %>% 
  group_by(x) %>% 
  summarise(dcant_change = sum(count)) %>% 
  ungroup()

new_layer_total <- new_layer_total %>% 
  mutate(y = dcant_change,
         dcant_change = as.character(round(dcant_change,2)),
         dcant_change = paste("global:",dcant_change))

g2 +
  geom_text(data = new_layer_basin,
            aes(
              x = x - 0.3,
              y = y,
              label = dcant_change
            ),
            inherit.aes = FALSE) +
  geom_label(data = new_layer_total,
            aes(
              x = x,
              y = y + 0.05,
              label = dcant_change
            ),
            inherit.aes = FALSE)
g2 <- dcant_budget_basin_MLR_all_plot %>%
  ggplot(aes(
    y = beta,
    x = period,
    alluvium = basin,
    fill  = basin,
    stratum = basin,
    label = basin
  )) +
  geom_alluvium() +
  geom_stratum() +
  stat_stratum(geom = "text",
               aes(label = paste(
                 round(after_stat(count),2)
                 # 100*round(after_stat(prop), 2), "%"
                 ))) +
  ggrepel::geom_label_repel(
    data = dcant_budget_basin_MLR_all_plot %>% filter(period == "2004 - 2014"),
    stat = "stratum",
    size = 4,
    nudge_x = .5,
    point.padding = 3,
    aes(fill = basin)
  )+
  scale_fill_brewer(palette = "Paired", guide = "none") +
  scale_color_brewer(palette = "Paired", guide = "none") +
  scale_y_continuous(limits = c(0, 1.7), expand = c(0, 0)) +
  guides(y = "none") +
  labs(title = dcant_pgc_scaled_label) +
  theme_classic() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1),
        axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        plot.title = element_text(hjust = 0.5))


newdat <- tibble(layer_data(g2))

change_basin <- 
  newdat %>% 
  select(x, alluvium, count) %>% 
  group_by(alluvium) %>% 
  arrange(x) %>% 
  mutate(dcant_change = round(100*(count - lag(count)) / lag(count))) %>% 
  ungroup()

coord_basin <- newdat %>%
  select(x, y, alluvium)

new_layer_basin <- left_join(
  change_basin %>% drop_na(),
  coord_basin
)

new_layer_basin <- new_layer_basin %>% 
  mutate(dcant_change = as.character(dcant_change),
         dcant_change = if_else(str_detect(dcant_change, "-"),
                                dcant_change,
                                paste0("+", dcant_change)),
         dcant_change = paste(dcant_change, "%"))

new_layer_total <- 
  newdat %>% 
  select(x, alluvium, count) %>% 
  group_by(x) %>% 
  summarise(dcant_change = sum(count)) %>% 
  ungroup()

new_layer_total <- new_layer_total %>% 
  mutate(y = dcant_change,
         dcant_change = as.character(round(dcant_change,2)),
         dcant_change = paste("global:",dcant_change))

g2 +
  geom_text(data = new_layer_basin,
            aes(
              x = x - 0.3,
              y = y,
              label = dcant_change
            ),
            inherit.aes = FALSE) +
  geom_label(data = new_layer_total,
            aes(
              x = x,
              y = y + 0.1,
              label = dcant_change
            ),
            inherit.aes = FALSE)
g2 <- dcant_budget_basin_MLR_all_plot %>%
  ggplot(aes(
    y = beta,
    x = period,
    alluvium = basin,
    fill  = basin,
    stratum = basin,
    label = basin
  )) +
  geom_alluvium() +
  geom_stratum() +
  ggrepel::geom_label_repel(
    data = dcant_budget_basin_MLR_all_plot %>% filter(period == "2004 - 2014"),
    stat = "stratum",
    size = 4,
    nudge_x = .5,
    point.padding = 3,
    aes(fill = basin)
  )+
  scale_fill_brewer(palette = "Paired", guide = "none") +
  scale_color_brewer(palette = "Paired", guide = "none") +
  scale_y_continuous(limits = c(0, 1.6), expand = c(0, 0)) +
  guides(y = "none") +
  labs(title = dcant_pgc_scaled_label) +
  theme_classic() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1),
        axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        plot.title = element_text(hjust = 0.5))


newdat <- tibble(layer_data(g2))

# construct budget labels

budget_basin <- 
  newdat %>% 
  select(x, y, alluvium, count)

budget_layer_basin <- budget_basin %>% 
  mutate(dcant = as.character(round(count,2)))

# construct uncertainty labels

uncertainty_basin <- 
  dcant_budget_basin_MLR_all_plot %>% 
  mutate(x = fct_recode(period,
                        "2" = "1994 - 2004",
                        "3" = "2004 - 2014")) %>% 
  select(x, alluvium = basin, dcant_sd_scaled) %>% 
  drop_na() %>% 
  arrange(x, alluvium)
  

coord_basin <- newdat %>%
  select(x, y, alluvium) %>% 
  filter(x != 1)

uncertainty_layer_basin <- bind_cols(
  coord_basin,
  uncertainty_basin %>% select(dcant_sd_scaled),
)

# construct change labels

change_basin <- 
  newdat %>% 
  select(x, alluvium, count) %>% 
  group_by(alluvium) %>% 
  arrange(x) %>% 
  mutate(dcant_change_abs = count - lag(count),
         dcant_change = round(100*(dcant_change_abs) / lag(count))) %>% 
  ungroup()

coord_basin <- newdat %>%
  select(x, y, alluvium)

new_layer_basin <- left_join(
  change_basin %>% drop_na(),
  coord_basin
)

new_layer_basin <- new_layer_basin %>% 
  mutate(dcant_change = as.character(dcant_change),
         dcant_change = if_else(str_detect(dcant_change, "-"),
                                dcant_change,
                                paste0("+", dcant_change)),
         dcant_change = paste0(dcant_change, "%"))

# construct global budget labels

new_layer_total <- 
  newdat %>% 
  select(x, alluvium, count) %>% 
  group_by(x) %>% 
  summarise(dcant_change = sum(count)) %>% 
  ungroup()

dcant_sd_scaled <- round(c(
  0.24,
  dcant_budget_global_all_ensemble_summary %>%
    pull(dcant_sd_scaled)
), 2)

new_layer_total <- bind_cols(new_layer_total, dcant_sd_scaled = dcant_sd_scaled)

new_layer_total <- new_layer_total %>% 
  mutate(y = dcant_change,
         dcant_sd_scaled_rel = round(100 * dcant_sd_scaled/dcant_change),
         dcant_change = as.character(round(dcant_change,2)),
         dcant_sd_scaled = round(dcant_sd_scaled,1),
         dcant_change = paste0(dcant_change, "\n(±", dcant_sd_scaled, ")"))

# basin change + uncertainty

budget_layer_basin <- full_join(budget_layer_basin,
                                uncertainty_layer_basin)

budget_layer_basin <- 
  budget_layer_basin %>% 
  mutate(dcant_sd_scaled_rel = 100*dcant_sd_scaled/count,
         dcant_sd_scaled_rel = as.character(round(dcant_sd_scaled_rel)),
         dcant_sd_scaled_numeric = dcant_sd_scaled,
         dcant_sd_scaled = round(dcant_sd_scaled, 2),
         dcant_sd_scaled = paste0("(±", dcant_sd_scaled, ")"),
         dcant_label = if_else(dcant_sd_scaled != "(±NA)",
                               paste0(dcant, "\n", dcant_sd_scaled),
                               dcant))


# uncertainty changes

uncertainty_changes <- budget_layer_basin %>% 
  select(x, alluvium, dcant_sd_scaled = dcant_sd_scaled_numeric) %>% 
  group_by(alluvium) %>% 
  mutate(dcant_change_uncert = sqrt(dcant_sd_scaled^2 + lag(dcant_sd_scaled)^2)) %>% 
  ungroup()


new_layer_basin <- left_join(new_layer_basin, uncertainty_changes) %>% 
  mutate(dcant_change_uncert_rel = 100*dcant_change_uncert/abs((count + lag(count))/2),
         dcant_change_label = if_else(!is.na(dcant_change_uncert),
                                      paste0(dcant_change, "\n(±", round(dcant_change_uncert_rel), "%)"),
                                      dcant_change))


g2 +
  geom_text(data = budget_layer_basin,
            aes(
              x = x,
              y = y,
              label = dcant_label
            ),
            size = 3,
            inherit.aes = FALSE) +
  geom_text(data = new_layer_basin,
            aes(
              x = x - 0.3,
              y = y,
              label = dcant_change_label
            ),
            size = 4,
            inherit.aes = FALSE)
  # geom_label(data = new_layer_total,
  #           aes(
  #             x = x,
  #             y = y + 0.13,
  #             label = dcant_change
  #           ),
  #           size = 4,
  #           inherit.aes = FALSE)



# ggsave(path = here::here("output/publication"),
#        filename = "Fig_budget_beta_basin_hemisphere.png",
#        height = 6,
#        width = 8)

14.3 Depth layer

dcant_budget_change <- dcant_budget_basin_MLR_layer_all %>%
  filter(estimate == "dcant",
         period != "1994 - 2014",
         inv_depth <= 3000,
         data_source == "obs") %>%
  rename(dcant = value) %>%
  select(-c(tref1, tref2, Version_ID)) %>%
  pivot_wider(names_from = period,
              values_from = dcant) %>%
  mutate(sign = if_else(`2004 - 2014` - `1994 - 2004` > 0,
                        "increase",
                        "decrease"))

dcant_budget_layer <- dcant_budget_basin_MLR_layer_all %>%
  filter(estimate == "dcant",
         period != "1994 - 2014",
         inv_depth <= 3400,
         data_source == "obs") %>%
  rename(dcant = value) %>%
  group_by(basin, period, data_source) %>% 
  mutate(dcant = if_else(is.na(lead(dcant)), 888, dcant),
         dcant = na_if(dcant, 888)) %>%
  fill(dcant) %>% 
  ungroup()

dcant_budget_layer %>%
  ggplot() +
  geom_hline(yintercept = 0) +
  geom_rect(
    data = dcant_budget_change,
    aes(
      xmin = inv_depth - 250,
      xmax = inv_depth + 250,
      ymin = `1994 - 2004`,
      ymax = `2004 - 2014`,
      fill = sign
    ),
    alpha = 0.4
  ) +
  geom_step(aes(inv_depth - 250, dcant, col = period), direction = "vh",
            size = 1) +
  coord_flip() +
  scale_x_reverse(breaks = seq(0, 3000, 500)) +
  scale_color_brewer(palette = "Set1", direction = -1, name = "period") +
  scale_fill_brewer(palette = "Set1", direction = -1, name = "") +
  facet_wrap(~ basin, ncol = 3, dir = "v") +
  labs(y = dcant_layer_budget_label,
       x = "Depth (m)") +
      theme(legend.position = c(0.8,0.2))

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
26e9496 jens-daniel-mueller 2022-07-12
dcant_budget_range <- dcant_budget_basin_MLR_layer_all_ensemble %>%
  filter(estimate == "dcant",
         period != "1994 - 2014",
         inv_depth <= 3000,
         data_source == "obs") %>%
  rename(dcant = value) %>%
  select(-c(tref1, tref2, Version_ID)) %>%
  group_by(basin, inv_depth, period) %>% 
  summarise(dcant_sd = sd(dcant)*2) %>%
  ungroup()

dcant_budget_layer <-
  full_join(dcant_budget_range,
            dcant_budget_layer)

p_dcant_budget_depth_layer <- 
dcant_budget_layer %>%
  ggplot() +
  geom_hline(yintercept = 0, size = 0.1) +
  geom_vline(xintercept = 1000, size = 0.1) +
  geom_rect(
    aes(
      xmin = inv_depth - 250,
      xmax = inv_depth + 250,
      ymin = dcant - dcant_sd,
      ymax = dcant + dcant_sd,
      fill = period
    ),
    alpha = 0.4
  ) +
  geom_step(aes(inv_depth - 250, dcant, col = period), direction = "vh",
            size = 1) +
  coord_flip() +
  scale_x_reverse(breaks = seq(0, 3000, 500), limits = c(3000, 0)) +
  scale_color_manual(values = c("#EE7733", "#009988"), name = "Mean \u00B1 2 SD") +
  scale_fill_manual(values = c("#EE7733", "#009988"), name = "Mean \u00B1 2 SD") +
  labs(y = dcant_layer_budget_label,
       x = "Depth (m)") +
  facet_wrap(~ basin, ncol = 3, dir = "v", scales = "free_x") +
  theme(legend.position = c(0.9, 0.1))

p_dcant_budget_depth_layer

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
fea41c1 jens-daniel-mueller 2022-07-20
d803308 jens-daniel-mueller 2022-07-19
b1f7ab3 jens-daniel-mueller 2022-07-18
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
26e9496 jens-daniel-mueller 2022-07-12
p_dcant_profiles + p_dcant_budget_depth_layer +
  plot_layout(ncol = 1) +
  plot_annotation(tag_levels = 'A')

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
fea41c1 jens-daniel-mueller 2022-07-20
d803308 jens-daniel-mueller 2022-07-19
ggsave(path = here::here("output/publication"),
       filename = "Fig_dcant_profiles_and_depth_layer_budget.png",
       height = 12,
       width = 8)
dcant_budget_layer <- dcant_budget_basin_MLR_layer_all %>%
  filter(estimate == "dcant",
         period != "1994 - 2014",
         inv_depth <= 3400,
         data_source != "obs") %>%
  rename(dcant = value) %>%
  group_by(basin, period, data_source) %>% 
  mutate(dcant = if_else(is.na(lead(dcant)), 888, dcant),
         dcant = na_if(dcant, 888)) %>%
  fill(dcant) %>% 
  ungroup()

dcant_budget_range <- dcant_budget_basin_MLR_layer_all_ensemble %>%
  filter(estimate == "dcant",
         period != "1994 - 2014",
         inv_depth <= 3000,
         data_source != "obs") %>%
  rename(dcant = value) %>%
  select(-c(tref1, tref2, Version_ID)) %>%
  group_by(basin, inv_depth, period, data_source) %>% 
  summarise(dcant_sd = sd(dcant)*2) %>%
  ungroup()

dcant_budget_layer <-
  full_join(dcant_budget_range,
            dcant_budget_layer)

p_dcant_budget_depth_layer_mod <- 
dcant_budget_layer %>%
      mutate(data_source = case_when(
    data_source == "mod" ~ "Reconstruction",
    data_source == "mod_truth" ~ "Model truth"
  )) %>%  
  ggplot() +
  geom_hline(yintercept = 0, size = 0.1) +
  geom_vline(xintercept = 1000, size = 0.1) +
  geom_rect(
    aes(
      xmin = inv_depth - 250,
      xmax = inv_depth + 250,
      ymin = dcant - dcant_sd,
      ymax = dcant + dcant_sd,
      fill = data_source
    ),
    alpha = 0.4
  ) +
  geom_step(aes(inv_depth - 250, dcant, col = data_source), direction = "vh",
            size = 1) +
  coord_flip() +
  scale_x_reverse(breaks = seq(0, 3000, 500), limits = c(3000, 0)) +
  scale_color_manual(values = c("#009988", "#EE7733"), name = "Mean \u00B1 2 SD") +
  scale_fill_manual(values = c("#009988", "#EE7733"), name = "Mean \u00B1 2 SD") +
  labs(y = dcant_layer_budget_label,
       x = "Depth (m)") +
  facet_grid(period ~ basin, scales = "free_x") +
  theme(legend.position = "none")

p_dcant_budget_depth_layer_mod

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
318fefe jens-daniel-mueller 2022-08-11
p_dcant_profiles_mod + p_dcant_budget_depth_layer_mod +
  plot_layout(ncol = 1) +
  plot_annotation(tag_levels = 'A')

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
318fefe jens-daniel-mueller 2022-08-11
ggsave(path = here::here("output/publication"),
       filename = "FigS_dcant_profiles_and_depth_layer_budget_synthetic_data.png",
       height = 10,
       width = 7)
dcant_budget_basin_MLR_layer_all_ensemble_stat <-
dcant_budget_basin_MLR_layer_all_ensemble %>%
  filter(estimate == "dcant",
         data_source == "obs",
         inv_depth < 3000,
         period %in% two_decades) %>% 
  group_by(basin,
           period,
           inv_depth) %>%
  summarise(dcant_sd = sd(value) * 2) %>%
  ungroup()

dcant_layer_budget_stat <-
  full_join(
    dcant_budget_basin_MLR_layer_all %>%
      filter(
        estimate == "dcant",
        data_source == "obs",
        inv_depth < 3000,
        period %in% two_decades
      ) %>% 
      select(basin, period, inv_depth, dcant = value),
    dcant_budget_basin_MLR_layer_all_ensemble_stat
  )  

rm(dcant_budget_basin_MLR_layer_all_ensemble_stat)  

dcant_layer_budget_stat %>%
  filter(period %in% two_decades) %>%
  arrange(period) %>% 
  group_by(basin, inv_depth) %>%
  mutate(delta_dcant = dcant - lag(dcant),
         RSS = sqrt(dcant_sd ^ 2 + lag(dcant_sd ^ 2))) %>%
  ungroup() %>%
  drop_na() %>% 
  filter(abs(delta_dcant) >= RSS) %>% 
  select(basin, inv_depth, delta_dcant, RSS) %>% 
  kable() %>%
  kable_styling() %>%
  scroll_box(height = "300px")
basin inv_depth delta_dcant RSS
Global 2750 -1.095 0.9980740
Indian 1750 -0.396 0.3688201
N. Atlantic 750 0.336 0.2694706
N. Atlantic 1750 -0.469 0.2032479
N. Atlantic 2250 -0.245 0.1563450
N. Atlantic 2750 -0.346 0.1863157
S. Atlantic 750 0.912 0.4358090
S. Atlantic 1250 0.495 0.3151858
dcant_budget_change <- dcant_budget_basin_MLR_layer_all %>%
  filter(estimate == "dcant",
         period != "1994 - 2014",
         inv_depth <= 3000,
         data_source == "obs") %>%
  rename(dcant = value) %>%
  arrange(inv_depth) %>% 
  group_by(data_source, basin, period) %>% 
  mutate(dcant_cum = cumsum(dcant)) %>% 
  ungroup() %>%
  select(-c(tref2, Version_ID, dcant)) %>%
  pivot_wider(names_from = period,
              values_from = dcant_cum) %>%
  mutate(sign = if_else(`2004 - 2014` - `1994 - 2004` > 0,
                        "increase",
                        "decrease"))

dcant_budget_layer <- dcant_budget_basin_MLR_layer_all %>%
  filter(estimate == "dcant",
         period != "1994 - 2014",
         inv_depth <= 3400,
         data_source == "obs") %>%
  rename(dcant = value) %>%
  arrange(inv_depth) %>% 
  group_by(data_source, basin, period) %>% 
  mutate(dcant_cum = cumsum(dcant)) %>% 
  ungroup() %>%
  group_by(basin, period, data_source) %>% 
  mutate(dcant_cum = if_else(is.na(lead(dcant_cum)), 888, dcant_cum),
         dcant_cum = na_if(dcant_cum, 888)) %>%
  fill(dcant_cum) %>% 
  ungroup()



dcant_budget_layer %>%
  ggplot() +
  geom_hline(yintercept = 0) +
  geom_rect(
    data = dcant_budget_change,
    aes(
      xmin = inv_depth - 250,
      xmax = inv_depth + 250,
      ymin = `1994 - 2004`,
      ymax = `2004 - 2014`,
      fill = sign
    ),
    alpha = 0.3
  ) +
  geom_step(aes(inv_depth - 250, dcant_cum, col = period), direction = "vh",
            size = 1) +
  coord_flip() +
  scale_x_reverse(breaks = seq(0, 3000, 500)) +
  scale_color_brewer(palette = "Set1",
                     direction = -1,
                     name = "Decade") +
  scale_fill_brewer(palette = "Set1",
                    direction = -1,
                    name = "Decadal change") +
  
  facet_wrap( ~ basin, ncol = 3, dir = "v") +
  labs(y = dcant_layer_budget_label,
       x = "Depth (m)",
       title = "Cumulative layer inventory change") +
      theme(legend.position = c(0.8,0.2))

Version Author Date
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
26e9496 jens-daniel-mueller 2022-07-12
37f56b3 jens-daniel-mueller 2022-07-01
df21d31 jens-daniel-mueller 2022-07-01
87e9eb8 jens-daniel-mueller 2022-06-27
b52b159 jens-daniel-mueller 2022-06-27
1d73ec9 jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
d2191ad jens-daniel-mueller 2022-02-04
32e9682 jens-daniel-mueller 2022-02-02
913e42f jens-daniel-mueller 2022-02-01
189de95 jens-daniel-mueller 2022-02-01
ab001eb jens-daniel-mueller 2022-01-31
b62308d jens-daniel-mueller 2022-01-31
5f2aed0 jens-daniel-mueller 2022-01-27

15 Time series

15.1 eMLR only

dcant_budget_global_all_ensemble %>% 
  filter(data_source == "obs",
         period != "1994 - 2014") %>% 
  ggplot(aes(tref2, dcant, group = interaction(MLR_basins, Version_ID_group),
             col=Version_ID_group)) +
  geom_path() +
  geom_point()

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
fea41c1 jens-daniel-mueller 2022-07-20
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
d20faeb jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
232909e jens-daniel-mueller 2022-07-01
dcant_budget_global_all_ensemble %>% 
  filter(data_source == "obs") %>% 
  select(MLR_basins, Version_ID_group, period, dcant) %>% 
  pivot_wider(names_from = period,
              values_from = dcant) %>% 
  ggplot(aes(`1994 - 2004`, `2004 - 2014`,
             col=MLR_basins)) +
  coord_equal() +
  geom_point() +
  facet_wrap(~ Version_ID_group)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
fea41c1 jens-daniel-mueller 2022-07-20
b1f7ab3 jens-daniel-mueller 2022-07-18
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
d20faeb jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
232909e jens-daniel-mueller 2022-07-01
dcant_budget_global_all_ensemble %>% 
  filter(data_source == "obs") %>% 
  select(MLR_basins, Version_ID_group, period, dcant) %>% 
  pivot_wider(names_from = period,
              values_from = dcant) %>% 
  ggplot(aes(`1994 - 2004`, `2004 - 2014`,
             col=Version_ID_group)) +
  coord_equal() +
  geom_point() +
  facet_wrap(~ MLR_basins)

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
fea41c1 jens-daniel-mueller 2022-07-20
b1f7ab3 jens-daniel-mueller 2022-07-18
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
d20faeb jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
232909e jens-daniel-mueller 2022-07-01
dcant_budget_global_all_ensemble %>% 
  filter(data_source == "obs") %>% 
  select(MLR_basins, Version_ID_group, period, dcant) %>% 
  pivot_wider(names_from = period,
              values_from = dcant) %>% 
  ggplot(aes(`1994 - 2004`, `1994 - 2014`,
             col=Version_ID_group)) +
  coord_equal() +
  geom_point()

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
fea41c1 jens-daniel-mueller 2022-07-20
b1f7ab3 jens-daniel-mueller 2022-07-18
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
d20faeb jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
232909e jens-daniel-mueller 2022-07-01
dcant_budget_global_all_ensemble %>% 
  filter(data_source == "obs") %>% 
  select(MLR_basins, Version_ID_group, period, dcant) %>% 
  pivot_wider(names_from = period,
              values_from = dcant) %>% 
  ggplot(aes(`1994 - 2004` + `2004 - 2014`, `1994 - 2014`,
             col=Version_ID_group)) +
  geom_abline(intercept = 0, slope = 1) +
  coord_equal() +
  scale_x_continuous(breaks = seq(0,100,1)) +
  scale_y_continuous(breaks = seq(0,100,1)) +
  geom_point()

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
fea41c1 jens-daniel-mueller 2022-07-20
b1f7ab3 jens-daniel-mueller 2022-07-18
dcant_budget_global_ts <- dcant_budget_global_all %>% 
  filter(data_source == "obs",
         period  %in% two_decades) %>% 
  select(year = tref2, dcant_mean = dcant)


dcant_budget_global_all_ensemble_summary <-
  dcant_budget_basin_MLR_all_ensemble %>%
  filter(period %in% c("1994 - 2004", "1994 - 2014"),
         data_source == "obs",
         basin == "Global") %>%
  group_by(data_source, tref2, period) %>%
  summarise(#dcant_mean = mean(dcant),
            dcant_sd = sd(dcant)*sd_factor) %>%
  ungroup()

dcant_budget_global_ts <- left_join(dcant_budget_global_ts,
                                    dcant_budget_global_all_ensemble_summary %>% 
                                      select(year = tref2, dcant_sd))


tcant_S04 <- bind_cols(year = 1994, dcant_mean = 118, dcant_sd = 19)

tcant_ts <- full_join(dcant_budget_global_ts, tcant_S04)

tcant_ts <- left_join(tcant_ts, co2_atm)

co2_atm_pi <- bind_cols(pCO2 = 280, dcant_mean = 0, year = 1800, dcant_sd = NA)

tcant_ts <- full_join(tcant_ts, co2_atm_pi)


tcant_ts <- tcant_ts %>%
  arrange(year) %>%
  mutate(
    tcant = cumsum(dcant_mean),
    tcant_sd = sqrt(dcant_sd ^ 2 + nth(dcant_sd,2) ^ 2)
  ) %>%
  mutate(
    tcant_sd = case_when(
      year == 1800 ~ 0,
      year == 1994 ~ dcant_sd,
      TRUE ~ tcant_sd
    ),
    dcant_sd_int = dcant_sd,
    dcant_sd = case_when(
      year == 1994 ~ 0,
      TRUE ~ dcant_sd
    )
  )

beta <- 1.57
co2_atm_pi_value <- 283
atm_co2_col <- "#CC3311"
tcant_col <- "#004488"

p_tcant_year <- tcant_ts %>%
  ggplot(aes(year, tcant)) +
  geom_line(data = co2_atm_reccap2 %>% filter(year > 1790),
            aes(year, (pCO2 - co2_atm_pi_value) * beta),
            col = atm_co2_col) +
  geom_linerange(aes(
    ymin = tcant - dcant_sd_int,
    ymax = tcant + dcant_sd_int,
    col = "Estimate\n±\ninterval\nuncertainty"
  ), size = 1) +
  geom_point(fill = "white", shape = 21,
             aes(col = "Estimate\n±\ninterval\nuncertainty")) +
  scale_y_continuous(name = expression(Total ~ oceanic ~ C[ant] ~ (PgC)),
                     sec.axis = sec_axis( ~ (. / beta + co2_atm_pi_value),
                                          name = expression(Atm. ~ pCO[2] ~ (µatm)))) +
  scale_x_continuous(name = "Year", breaks = seq(1800, 2000, 50)) +
  scale_color_manual(values = tcant_col) +
  theme(
    axis.title.y.right = element_text(color = atm_co2_col),
    axis.text.y.right = element_text(color = atm_co2_col),
    axis.ticks.y.right = element_line(color = atm_co2_col), 
    axis.title.y.left = element_text(color = tcant_col),
    axis.text.y.left = element_text(color = tcant_col),
    axis.ticks.y.left = element_line(color = tcant_col), 
    legend.background = element_rect(fill = "transparent"),
    legend.position = c(0.85, 0.2),
    legend.title = element_blank()
  )

p_tcant_year

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
9bbc6a4 jens-daniel-mueller 2022-07-20
fea41c1 jens-daniel-mueller 2022-07-20
d803308 jens-daniel-mueller 2022-07-19
b1f7ab3 jens-daniel-mueller 2022-07-18
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
8ab4a87 jens-daniel-mueller 2022-06-29
7629c78 jens-daniel-mueller 2022-06-29
f6786c8 jens-daniel-mueller 2022-06-29
0825298 jens-daniel-mueller 2022-06-28
87e9eb8 jens-daniel-mueller 2022-06-27
b52b159 jens-daniel-mueller 2022-06-27
1d73ec9 jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
8dca96a jens-daniel-mueller 2022-04-12
209c9b6 jens-daniel-mueller 2022-04-10
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
5a6be34 jens-daniel-mueller 2022-03-22
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
251c7cf jens-daniel-mueller 2022-02-17
565224d jens-daniel-mueller 2022-02-17
2116dd3 jens-daniel-mueller 2022-02-09
6fe70a1 jens-daniel-mueller 2022-02-05
a6b33aa jens-daniel-mueller 2022-02-04
atm_co2_col <- "transparent"

p_tcant_year_trans <- tcant_ts %>%
  ggplot(aes(year, tcant)) +
  geom_line(data = co2_atm_reccap2 %>% filter(year > 1790),
            aes(year, (pCO2 - co2_atm_pi_value) * beta),
            col = atm_co2_col) +
  geom_linerange(aes(
    ymin = tcant - dcant_sd_int,
    ymax = tcant + dcant_sd_int,
    col = "Estimate\n±\ninterval\nuncertainty"
  ), size = 1) +
  geom_point(fill = "white", shape = 21,
             aes(col = "Estimate\n±\ninterval\nuncertainty")) +
  scale_y_continuous(name = expression(Total ~ oceanic ~ C[ant] ~ (PgC)),
                     sec.axis = sec_axis( ~ (. / beta + co2_atm_pi_value),
                                          name = expression(Atm. ~ pCO[2] ~ (µatm)))) +
  scale_x_continuous(name = "Year", breaks = seq(1800, 2000, 50)) +
  scale_color_manual(values = tcant_col) +
  theme(
    axis.title.y.right = element_text(color = atm_co2_col),
    axis.text.y.right = element_text(color = atm_co2_col),
    axis.ticks.y.right = element_line(color = atm_co2_col),
    axis.title.y.left = element_text(color = tcant_col),
    axis.text.y.left = element_text(color = tcant_col),
    axis.ticks.y.left = element_line(color = tcant_col),
    legend.background = element_rect(fill = "transparent"),
    legend.position = c(0.85, 0.2),
    legend.title = element_blank()
  )

p_tcant_year_trans

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
d803308 jens-daniel-mueller 2022-07-19
b1f7ab3 jens-daniel-mueller 2022-07-18
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
8ab4a87 jens-daniel-mueller 2022-06-29
7629c78 jens-daniel-mueller 2022-06-29
f6786c8 jens-daniel-mueller 2022-06-29
0825298 jens-daniel-mueller 2022-06-28
87e9eb8 jens-daniel-mueller 2022-06-27
b52b159 jens-daniel-mueller 2022-06-27
1d73ec9 jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
8dca96a jens-daniel-mueller 2022-04-12
209c9b6 jens-daniel-mueller 2022-04-10
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
5a6be34 jens-daniel-mueller 2022-03-22
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
251c7cf jens-daniel-mueller 2022-02-17
565224d jens-daniel-mueller 2022-02-17
2116dd3 jens-daniel-mueller 2022-02-09
atm_co2_col <- "#CC3311"

p_tcant_atm_co2 <- tcant_ts %>%
  ggplot(aes(pCO2, tcant)) +
  geom_ribbon(aes(
    ymin = tcant - tcant_sd,
    ymax = tcant + tcant_sd,
    fill = "1800 - 2014",
    alpha = "1800 - 2014"
  )) +
  geom_ribbon(aes(
    ymin = tcant - dcant_sd,
    ymax = tcant + dcant_sd,
    fill = "1994 - 2014",
    alpha = "1994 - 2014"
  )) +
  geom_line(color = tcant_col) +
  geom_point(shape = 21, fill = "white", color = tcant_col) +
  scale_x_continuous(breaks = seq(280, 400, 30)) +
  scale_fill_manual(values = c(tcant_col, tcant_col), name = "Cumulative\nuncertainty") +
  scale_alpha_manual(values = c(0.2, 0.6), name = "Cumulative\nuncertainty") +
  scale_color_manual(values = "black", name = "") +
  geom_text(aes(label = year), nudge_x = -6, nudge_y = 6) +
  labs(x = expression(Atmospheric ~ pCO[2] ~ (µatm)),
       y = expression(Total ~ oceanic ~ C[ant] ~ (PgC))) +
  theme(
    axis.title.y.left = element_text(color = tcant_col),
    axis.text.y.left = element_text(color = tcant_col),
    axis.ticks.y.left = element_line(color = tcant_col),
    legend.background = element_rect(fill = "transparent"),
    legend.position = c(0.85, 0.25),
    axis.title.x = element_text(color = atm_co2_col),
    axis.text.x = element_text(color = atm_co2_col),
    axis.ticks.x = element_line(color = atm_co2_col)
  )

p_tcant_year / p_tcant_atm_co2 + 
  plot_annotation(tag_levels = 'A')

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
9bbc6a4 jens-daniel-mueller 2022-07-20
a80b59b jens-daniel-mueller 2022-07-20
fea41c1 jens-daniel-mueller 2022-07-20
d803308 jens-daniel-mueller 2022-07-19
b1f7ab3 jens-daniel-mueller 2022-07-18
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
8ab4a87 jens-daniel-mueller 2022-06-29
7629c78 jens-daniel-mueller 2022-06-29
f6786c8 jens-daniel-mueller 2022-06-29
0825298 jens-daniel-mueller 2022-06-28
87e9eb8 jens-daniel-mueller 2022-06-27
b52b159 jens-daniel-mueller 2022-06-27
1d73ec9 jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
8dca96a jens-daniel-mueller 2022-04-12
209c9b6 jens-daniel-mueller 2022-04-10
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
5a6be34 jens-daniel-mueller 2022-03-22
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
251c7cf jens-daniel-mueller 2022-02-17
565224d jens-daniel-mueller 2022-02-17
2116dd3 jens-daniel-mueller 2022-02-09
6fe70a1 jens-daniel-mueller 2022-02-05
a6b33aa jens-daniel-mueller 2022-02-04
d2191ad jens-daniel-mueller 2022-02-04
0d0f790 jens-daniel-mueller 2022-02-02
60727e6 jens-daniel-mueller 2022-02-02
c7b4984 jens-daniel-mueller 2022-02-02
7fb28a2 jens-daniel-mueller 2022-02-02
7655085 jens-daniel-mueller 2022-02-02
ec7fe7e jens-daniel-mueller 2022-01-31
ggsave(path = here::here("output/publication"),
       filename = "Fig_dcant_budget_global_vs_atm_pCO2.png",
       height = 6,
       width = 7)


p_tcant_year / p_tcant_atm_co2

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
b1f7ab3 jens-daniel-mueller 2022-07-18
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
8ab4a87 jens-daniel-mueller 2022-06-29
7629c78 jens-daniel-mueller 2022-06-29
f6786c8 jens-daniel-mueller 2022-06-29
0825298 jens-daniel-mueller 2022-06-28
87e9eb8 jens-daniel-mueller 2022-06-27
b52b159 jens-daniel-mueller 2022-06-27
1d73ec9 jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
8dca96a jens-daniel-mueller 2022-04-12
209c9b6 jens-daniel-mueller 2022-04-10
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
5a6be34 jens-daniel-mueller 2022-03-22
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
251c7cf jens-daniel-mueller 2022-02-17
565224d jens-daniel-mueller 2022-02-17
2116dd3 jens-daniel-mueller 2022-02-09
ggsave(path = here::here("output/presentation"),
       filename = "Fig_dcant_budget_global_vs_atm_pCO2.png",
       height = 6,
       width = 7)

p_tcant_year_trans / p_tcant_atm_co2

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
ggsave(path = here::here("output/presentation"),
       filename = "Fig_dcant_budget_global_vs_atm_pCO2_trans.png",
       height = 6,
       width = 7)
tcant_ts %>% 
  mutate(beta = dcant_mean / (pCO2-lag(pCO2)))
# A tibble: 4 × 8
   year dcant_mean dcant_sd  pCO2 tcant tcant_sd dcant_sd_int  beta
  <dbl>      <dbl>    <dbl> <dbl> <dbl>    <dbl>        <dbl> <dbl>
1  1800        0      NA     280     0       0          NA    NA   
2  1994      118       0     358.  118      19          19     1.51
3  2004       27.4     3.28  377.  145.     19.3         3.28  1.47
4  2014       25.6     4.55  397.  171.     19.5         4.55  1.25

15.2 incl fluxes

Ocean_Sink <- Ocean_Sink %>%
  filter(product != "Watson")
Ocean_Sink_cum_1994 <-
  Ocean_Sink %>%
  filter(year >= 1994, year <= 2007) %>%
  mutate(fgco2_glob = if_else(year == 1994, 0, GtC_yr),
         fgco2_glob = fgco2_glob) %>% 
  arrange(year) %>%
  group_by(product, type) %>%
  mutate(fgco2_glob_cum = cumsum(fgco2_glob)) %>%
  ungroup()

Ocean_Sink_cum_1994 <-
  left_join(Ocean_Sink_cum_1994,
            co2_atm) 


Ocean_Sink_cum_1994 %>%
  group_split(type) %>%
  map(
    ~ ggplot(data = .x, aes(pCO2, fgco2_glob_cum, col = product)) +
      geom_line() +
      geom_point(shape = 21, fill = "white") +
      theme(legend.position = "bottom") +
      facet_grid(. ~ type)
  )
[[1]]

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
8105380 jens-daniel-mueller 2022-10-07
f68fcfa jens-daniel-mueller 2022-07-26
f2615fb jens-daniel-mueller 2022-07-26

[[2]]

Version Author Date
8105380 jens-daniel-mueller 2022-10-07
Ocean_Sink_cum_1994 <- Ocean_Sink_cum_1994 %>% 
  mutate(fgco2_glob_cum_total = fgco2_glob_cum + 118) %>%
  select(year, pCO2, product, fgco2_glob_cum, fgco2_glob_cum_total, type)

Ocean_Sink_cum_1994 <- Ocean_Sink_cum_1994 %>% 
  mutate(type = case_when(
    type == "data_products" ~ "Observation-based\nsurface flux\nproducts",
    TRUE ~ "Global Ocean\nBiogeochemical Models\n(GOBM)"
  ))

Ocean_Sink_cum_1994 %>% 
  filter(year == 2007) %>% 
  group_by(type) %>% 
  summarise(dcant_sd = sd(fgco2_glob_cum)*2) %>% 
  ungroup()
# A tibble: 2 × 2
  type                                          dcant_sd
  <chr>                                            <dbl>
1 "Global Ocean\nBiogeochemical Models\n(GOBM)"     6.99
2 "Observation-based\nsurface flux\nproducts"       6.66
Ocean_Sink_cum_1994 <-
  Ocean_Sink %>%
  filter(year >= 1994, year <= 2014) %>%
  mutate(fgco2_glob = if_else(year == 1994, 0, GtC_yr),
         fgco2_glob = fgco2_glob) %>% 
  arrange(year) %>%
  group_by(product, type) %>%
  mutate(fgco2_glob_cum = cumsum(fgco2_glob)) %>%
  ungroup()

Ocean_Sink_cum_1994 <-
  left_join(Ocean_Sink_cum_1994,
            co2_atm) 

Ocean_Sink_cum_1994 %>%
  group_split(type) %>%
  map(
    ~ ggplot(data = .x, aes(pCO2, fgco2_glob_cum, col = product)) +
      geom_line() +
      geom_point(shape = 21, fill = "white") +
      theme(legend.position = "bottom") +
      facet_grid(. ~ type)
  )
[[1]]

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
8105380 jens-daniel-mueller 2022-10-07
f68fcfa jens-daniel-mueller 2022-07-26
f2615fb jens-daniel-mueller 2022-07-26
bd24a0f jens-daniel-mueller 2022-07-15

[[2]]

Version Author Date
8105380 jens-daniel-mueller 2022-10-07
Ocean_Sink_cum_1994 <- Ocean_Sink_cum_1994 %>% 
  mutate(fgco2_glob_cum_total = fgco2_glob_cum + 118) %>%
  select(year, pCO2, product, fgco2_glob_cum, fgco2_glob_cum_total, type)

Ocean_Sink_cum_1994 <- Ocean_Sink_cum_1994 %>% 
  mutate(type = case_when(
    type == "data_products" ~ "Observation-based\nsurface flux\nproducts",
    TRUE ~ "Global Ocean\nBiogeochemical Models\n(GOBM)"
  ))
tcant_2004 <- tcant_ts %>% 
  filter(year == 2004) %>% 
  pull(tcant)

Ocean_Sink_cum_2004 <-
  Ocean_Sink %>%
  filter(year >= 2004, year <= 2014) %>%
  mutate(fgco2_glob = if_else(year == 2004, 0, GtC_yr)) %>% 
  arrange(year) %>%
  group_by(product, type) %>%
  mutate(fgco2_glob_cum = cumsum(fgco2_glob)) %>%
  ungroup()

Ocean_Sink_cum_2004 <-
  left_join(Ocean_Sink_cum_2004,
            co2_atm) 

Ocean_Sink_cum_2004 %>%
  group_split(type) %>%
  map(
    ~ ggplot(data = .x, aes(pCO2, fgco2_glob_cum, col = product)) +
      geom_line() +
      geom_point(shape = 21, fill = "white") +
      theme(legend.position = "bottom") +
      facet_grid(. ~ type)
  )
[[1]]

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
8105380 jens-daniel-mueller 2022-10-07
f68fcfa jens-daniel-mueller 2022-07-26
f2615fb jens-daniel-mueller 2022-07-26
bd24a0f jens-daniel-mueller 2022-07-15

[[2]]

Version Author Date
8105380 jens-daniel-mueller 2022-10-07
Ocean_Sink_cum_2004 <- Ocean_Sink_cum_2004 %>% 
  mutate(fgco2_glob_cum_total = fgco2_glob_cum + tcant_2004) %>% 
  select(year, pCO2, product, fgco2_glob_cum, fgco2_glob_cum_total, type)

Ocean_Sink_cum_2004 <- Ocean_Sink_cum_2004 %>% 
  mutate(type = case_when(
    type == "data_products" ~ "Observation-based\nsurface flux\nproducts",
    TRUE ~ "Global Ocean\nBiogeochemical Models\n(GOBM)"
  ))
tcant_ts_zoom <- tcant_ts %>%
  filter(year != 1800)

tcant_min = tcant_ts_zoom %>% pull(tcant) %>% min()
tcant_max =
  tcant_ts_zoom %>% pull(tcant) %>% max() +
  tcant_ts_zoom %>% pull(dcant_sd) %>% max() + 0.2

p_tcant_ts_zoom <-
  tcant_ts_zoom %>%
  ggplot(aes(pCO2, tcant)) +
  geom_ribbon(
    aes(ymin = tcant - dcant_sd,
        ymax = tcant + dcant_sd),
    alpha = 0.2,
    fill = tcant_col
  ) +
  geom_ribbon(
    aes(
      ymin = tcant - dcant_sd / 2,
      ymax = tcant + dcant_sd / 2
    ),
    alpha = 0.3,
    fill = tcant_col
  ) +
  geom_line(data = Ocean_Sink_cum_1994,
            aes(pCO2, fgco2_glob_cum_total, group = product, col = type)) +
  geom_point(
    data = Ocean_Sink_cum_1994,
    aes(pCO2, fgco2_glob_cum_total, group = product, col = type),
    size = 0.3
  ) +
  geom_point(
    data = Ocean_Sink_cum_1994 %>% filter(year %in% c(2004, 2014)),
    aes(
      pCO2,
      fgco2_glob_cum_total,
      col = type
    ),
    fill = "white",
    shape = 21
  ) +
  geom_line(aes(col = "eMLR(C*)")) +
  geom_point(aes(col = "eMLR(C*)"),
             shape = 21,
             fill = "white") +
  geom_text(aes(label = year), nudge_x = -2, nudge_y = 3) +
  scale_color_highcontrast(name = "Data source") +
  scale_fill_highcontrast(name = "Data source") +
  scale_y_continuous(limits = c(tcant_min, tcant_max)) +
  labs(x = expression(Atmospheric ~ pCO[2] ~ (µatm)),
       y = expression(Total ~ oceanic ~ carbon ~ storage ~ since ~ 1800 ~ (PgC))) +
  guides(colour = guide_legend(order = 1),
         fill = "none") +
  theme_classic() +
  theme(
    legend.background = element_rect(fill = "transparent"),
    legend.position = c(0.25, 0.83),
    legend.title = element_blank(),
    legend.box.just = "top",
    legend.box = "horizontal",
    legend.key.size = unit(2.5, 'lines'),
    panel.grid.major.y = element_line(colour = "black",
                                      size = 0.1)
  )

p_tcant_ts_zoom

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
8105380 jens-daniel-mueller 2022-10-07
f68fcfa jens-daniel-mueller 2022-07-26
f2615fb jens-daniel-mueller 2022-07-26
4af29f9 jens-daniel-mueller 2022-07-24
b18b250 jens-daniel-mueller 2022-07-20
a80b59b jens-daniel-mueller 2022-07-20
fea41c1 jens-daniel-mueller 2022-07-20
d803308 jens-daniel-mueller 2022-07-19
b1f7ab3 jens-daniel-mueller 2022-07-18
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
8ab4a87 jens-daniel-mueller 2022-06-29
7629c78 jens-daniel-mueller 2022-06-29
f6786c8 jens-daniel-mueller 2022-06-29
9393c07 jens-daniel-mueller 2022-06-28
0825298 jens-daniel-mueller 2022-06-28
fb59a6f jens-daniel-mueller 2022-06-27
3c1100c jens-daniel-mueller 2022-05-16
2ca0109 jens-daniel-mueller 2022-05-02
b018a9a jens-daniel-mueller 2022-04-29
e09320d jens-daniel-mueller 2022-04-12
8dca96a jens-daniel-mueller 2022-04-12
209c9b6 jens-daniel-mueller 2022-04-10
acad2e2 jens-daniel-mueller 2022-04-09
3d81135 jens-daniel-mueller 2022-04-07
a74e341 jens-daniel-mueller 2022-04-04
bd9e11d jens-daniel-mueller 2022-03-22
2501978 jens-daniel-mueller 2022-03-21
c3a6238 jens-daniel-mueller 2022-03-08
094bfa0 jens-daniel-mueller 2022-02-18
ba2d62e jens-daniel-mueller 2022-02-17
192504c jens-daniel-mueller 2022-02-17
d2191ad jens-daniel-mueller 2022-02-04
4c5b079 jens-daniel-mueller 2022-02-03
4077397 jens-daniel-mueller 2022-02-03
dcant_type_box <-
  bind_rows(
    dcant_budget_global_all_ensemble %>%
      filter(data_source == "obs") %>%
      select(period, dcant) %>%
      mutate(type = "eMLR(C*)",
             dcant = dcant + 118,
             dcant = if_else(period == "2004 - 2014",
                             dcant + tcant_2004 - 118,
                             dcant)),
    Ocean_Sink_cum_1994 %>%
      filter(year %in% c(2004, 2014)) %>%
      mutate(period = if_else(year == 2004,
                              "1994 - 2004",
                              "1994 - 2014")) %>%
      select(period, dcant = fgco2_glob_cum_total, type),
    Ocean_Sink_cum_2004 %>%
      filter(year %in% c(2014)) %>%
      mutate(period = if_else(year == 2014,
                              "2004 - 2014",
                              "other")) %>%
      select(period, dcant = fgco2_glob_cum_total, type)
  )

dcant_type_box_stat <- dcant_type_box %>% 
  group_by(period, type) %>% 
  summarise(dcant_mean = mean(dcant),
            dcant_sd = sd(dcant)) %>% 
  ungroup()

dcant_type_box_stat <-
left_join(
  dcant_type_box_stat,
  dcant_budget_global_all %>%
    filter(data_source == "obs") %>%
    mutate(
      dcant = dcant + 118,
      dcant = if_else(period == "2004 - 2014",
                      dcant + tcant_2004 - 118,
                      dcant)
    ) %>%
    select(period, dcant_st_case = dcant)
)

dcant_type_box_stat <- dcant_type_box_stat %>% 
  mutate(dcant_mean = if_else(type == "eMLR(C*)",
                              dcant_st_case,
                              dcant_mean)) %>% 
  select(-dcant_st_case)

p_tcant_box <-
dcant_type_box %>%
  filter(period == "1994 - 2014") %>%
  ggplot(aes(period, dcant)) +
 geom_crossbar(
    data = dcant_type_box_stat %>%
      filter(period == "1994 - 2014"),
    position = position_dodge(width = 1),
    aes(
      x = period,
      y = dcant_mean,
      ymin = dcant_mean - dcant_sd,
      ymax = dcant_mean + dcant_sd,
      col = type,
      fill = type
    ), width = 0.7, alpha = 0.4
  ) +
  geom_crossbar(
    data = dcant_type_box_stat %>%
      filter(period == "1994 - 2014"),
    position = position_dodge(width = 1),
    aes(
      x = period,
      y = dcant_mean,
      ymin = dcant_mean - dcant_sd*2,
      ymax = dcant_mean + dcant_sd*2,
      col = type,
      fill = type
    ), width = 0.7, alpha = 0.2
  ) +
  geom_point(aes(fill = type),
              position = position_jitterdodge(
                dodge.width = 1,
                jitter.width = 0.1),
              shape = 21,
              alpha = 0.5) +
  scale_fill_highcontrast(
    name = "Data source",
    guide = "none"
  ) +
  scale_color_highcontrast(
    name = "Data source",
    guide = "none"
  ) +
  scale_y_continuous(limits = c(tcant_min, tcant_max)) +
  labs(x = "20yr period") +
  theme_classic() +
  theme(
    axis.line.y.left = element_blank(),
    axis.text.y = element_blank(),
    axis.ticks.y = element_blank(),
    axis.title.y = element_blank(),
    panel.grid.major.y = element_line(colour = "black",
                                      size = 0.1)
  )

p_tcant_box_10 <-
  dcant_type_box %>%
  filter(period != "1994 - 2014") %>%
  ggplot(aes(period, dcant)) +
  geom_crossbar(
    data = dcant_type_box_stat %>%
      filter(period != "1994 - 2014"),
    position = position_dodge(width = 1),
    aes(
      x = period,
      y = dcant_mean,
      ymin = dcant_mean - dcant_sd,
      ymax = dcant_mean + dcant_sd,
      col = type,
      fill = type
    ),
    width = 0.7,
    alpha = 0.4
  ) +
  geom_crossbar(
    data = dcant_type_box_stat %>%
      filter(period != "1994 - 2014"),
    position = position_dodge(width = 1),
    aes(
      x = period,
      y = dcant_mean,
      ymin = dcant_mean - dcant_sd * 2,
      ymax = dcant_mean + dcant_sd * 2,
      col = type,
      fill = type
    ),
    width = 0.7,
    alpha = 0.2
  ) +
  geom_point(
    aes(fill = type),
    position = position_jitterdodge(dodge.width = 1,
                                    jitter.width = 0.1),
    shape = 21,
    alpha = 0.5
  ) +
  geom_point(
    data = dcant_type_box_stat %>%
      filter(period != "1994 - 2014"),
    position = position_dodge(width = 1),
    aes(x = period,
        y = dcant_mean,
        col = type),
    fill = "white",
    shape = 21,
    size = 2
  ) +
  scale_fill_highcontrast(name = "Data source",
                          guide = "none") +
  scale_color_highcontrast(name = "Data source",
                           guide = "none") +
  scale_y_continuous(limits = c(tcant_min, tcant_max)) +
  labs(x = "10yr periods") +
  theme_classic() +
  theme(
    axis.line.y.left = element_blank(),
    axis.text.y = element_blank(),
    axis.ticks.y = element_blank(),
    axis.title.y = element_blank(),
    panel.grid.major.y = element_line(colour = "black",
                                      size = 0.1)
  )

p_tcant_ts_zoom + p_tcant_box + p_tcant_box_10 +
  plot_layout(ncol = 3, widths = c(6,1,1.8)) + 
  plot_annotation(tag_levels = 'A')

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
0b40366 jens-daniel-mueller 2022-10-26
91052ae jens-daniel-mueller 2022-10-20
77e6a80 jens-daniel-mueller 2022-09-08
051b911 jens-daniel-mueller 2022-09-07
75bd58c jens-daniel-mueller 2022-09-07
1c6de0d jens-daniel-mueller 2022-09-07
78dbb27 jens-daniel-mueller 2022-08-11
302d289 jens-daniel-mueller 2022-08-11
318fefe jens-daniel-mueller 2022-08-11
5b77c4f jens-daniel-mueller 2022-08-10
9c3be27 jens-daniel-mueller 2022-08-09
a691b29 jens-daniel-mueller 2022-08-09
910f96e jens-daniel-mueller 2022-08-08
f68fcfa jens-daniel-mueller 2022-07-26
f2615fb jens-daniel-mueller 2022-07-26
4af29f9 jens-daniel-mueller 2022-07-24
b18b250 jens-daniel-mueller 2022-07-20
a80b59b jens-daniel-mueller 2022-07-20
fea41c1 jens-daniel-mueller 2022-07-20
d803308 jens-daniel-mueller 2022-07-19
b1f7ab3 jens-daniel-mueller 2022-07-18
d2ae54c jens-daniel-mueller 2022-07-18
2695085 jens-daniel-mueller 2022-07-17
535196a jens-daniel-mueller 2022-07-17
d20faeb jens-daniel-mueller 2022-07-17
afb27ad jens-daniel-mueller 2022-07-15
b492b46 jens-daniel-mueller 2022-07-15
bd24a0f jens-daniel-mueller 2022-07-15
17cd1d1 jens-daniel-mueller 2022-07-13
26e9496 jens-daniel-mueller 2022-07-12
8fb595c jens-daniel-mueller 2022-07-12
003b161 jens-daniel-mueller 2022-07-12
8ab4a87 jens-daniel-mueller 2022-06-29
7629c78 jens-daniel-mueller 2022-06-29
f6786c8 jens-daniel-mueller 2022-06-29
9393c07 jens-daniel-mueller 2022-06-28
0825298 jens-daniel-mueller 2022-06-28
ggsave(path = here::here("output/publication"),
       filename = "Fig_dcant_budget_global_vs_GCB_ocean_sink.png",
       height = 6,
       width = 9)

p_tcant_ts_zoom + p_tcant_box + p_tcant_box_10 +
  plot_layout(ncol = 2, widths = c(6,1.8))

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
0b40366 jens-daniel-mueller 2022-10-26
91052ae jens-daniel-mueller 2022-10-20
ggsave(path = here::here("output/presentation"),
       filename = "Fig_dcant_budget_global_vs_GCB_ocean_sink.png",
       height = 6,
       width = 9)

dcant_type_significance <- dcant_type_box_stat %>%
  mutate(dcant_mean = dcant_mean - 118,
         dcant_mean = if_else(period == "2004 - 2014",
                         dcant_mean - (tcant_2004 - 118),
                         dcant_mean),
         dcant_sd = dcant_sd * 2) %>%
  group_by(period) %>%
  mutate(
    dcant_diff = dcant_mean - first(dcant_mean),
    dcant_diff_rel = 100 * dcant_diff / first(dcant_mean),
    dcant_diff_sd = sqrt(dcant_sd ^ 2 + first(dcant_sd) ^ 2),
    dcant_diff_sd_comparison = dcant_diff_sd - abs(dcant_diff)
  ) %>%
  ungroup()

dcant_type_significance %>% 
  kable() %>%
  kable_styling() %>%
  scroll_box(height = "300px")
period type dcant_mean dcant_sd dcant_diff dcant_diff_rel dcant_diff_sd dcant_diff_sd_comparison
1994 - 2004 eMLR(C*) 27.38800 3.077153 0.000000 0.000000 4.351752 4.3517521
1994 - 2004 Global Ocean Biogeochemical Models (GOBM) 19.52578 5.403004 -7.862222 -28.706812 6.217824 -1.6443981
1994 - 2004 Observation-based surface flux products 21.41458 5.597734 -5.973418 -21.810347 6.387762 0.4143439
1994 - 2014 eMLR(C*) 53.12500 4.263935 0.000000 0.000000 6.030115 6.0301148
1994 - 2014 Global Ocean Biogeochemical Models (GOBM) 42.28477 10.974456 -10.840229 -20.405137 11.773692 0.9334632
1994 - 2014 Observation-based surface flux products 47.89526 7.743738 -5.229744 -9.844224 8.840058 3.6103140
2004 - 2014 eMLR(C*) 25.58300 3.061832 0.000000 0.000000 4.330085 4.3300846
2004 - 2014 Global Ocean Biogeochemical Models (GOBM) 22.75899 5.576053 -2.824007 -11.038608 6.361383 3.5373753
2004 - 2014 Observation-based surface flux products 26.48067 2.612751 0.897674 3.508869 4.025082 3.1274082
# Ocean_Sink %>% 
#   filter(between(year, 1994, 2007)) %>% 
#   arrange(year) %>% 
#   group_by(product) %>% 
#   mutate(GtC = cumsum(GtC_yr)) %>% 
#   ungroup() %>% 
#   # ggplot(aes(year, GtC, col=product)) +
#   # geom_line() %>% 
#   filter(year == 2007) %>% 
#   summarise(sd(GtC)*2)
Ocean_Sink_cum_1994_ensemble_mean <- Ocean_Sink_cum_1994 %>% 
  group_by(year, pCO2, type) %>% 
  summarise(fgco2_glob_cum_total_mean = mean(fgco2_glob_cum_total),
            fgco2_glob_cum_total_sd = sd(fgco2_glob_cum_total)) %>% 
  ungroup()

p_tcant_ts_zoom <-
tcant_ts_zoom %>%
  ggplot() +
  geom_ribbon(aes(pCO2, tcant,
                  ymin = tcant - dcant_sd,
                  ymax = tcant + dcant_sd,
              fill = "eMLR(C*)"),
              alpha = 0.2) +
  geom_ribbon(
    aes(pCO2, tcant,
        ymin = tcant - dcant_sd / 2,
        ymax = tcant + dcant_sd / 2,
              fill = "eMLR(C*)"),
    alpha = 0.3
  ) +
  # geom_ribbon(
  #   data = Ocean_Sink_cum_1994_ensemble_mean,
  #   aes(
  #     pCO2,
  #     ymin = fgco2_glob_cum_total_mean - fgco2_glob_cum_total_sd,
  #     ymax = fgco2_glob_cum_total_mean + fgco2_glob_cum_total_sd,
  #     fill = type
  #   ),
  #   alpha = 0.3
  # ) +
    geom_line(data = Ocean_Sink_cum_1994,
            aes(pCO2, fgco2_glob_cum_total, group = product, col = type), size = 0.3) +
  geom_line(data = Ocean_Sink_cum_1994_ensemble_mean,
            aes(pCO2, fgco2_glob_cum_total_mean, col = type), size = 2) +
  geom_point(
    data = Ocean_Sink_cum_1994_ensemble_mean,
    aes(pCO2, fgco2_glob_cum_total_mean, col = type), size = 1,
    shape = 21,
    fill = "white"
  ) +
  geom_point(
    data = Ocean_Sink_cum_1994_ensemble_mean %>% filter(year %in% c(2004, 2014)),
    aes(pCO2, fgco2_glob_cum_total_mean, col = type), size = 2,
    shape = 21,
    fill = "white"
  ) +
  # geom_point(
  #   data = Ocean_Sink_cum_1994 %>% filter(year %in% c(2004, 2014)),
  #   aes(
  #     pCO2,
  #     fgco2_glob_cum_total,
  #     col = type
  #   ),
  #   fill = "white",
  #   shape = 21
  # ) +
  geom_line(aes(pCO2, tcant, col = "eMLR(C*)"), size = 2) +
  geom_point(aes(pCO2, tcant, col = "eMLR(C*)"), size = 2,
             shape = 21,
             fill = "white") +
  geom_text(aes(pCO2, tcant, label = year), nudge_x = -2, nudge_y = 3) +
  scale_color_highcontrast(name = "Data source") +
  scale_fill_highcontrast(name = "Data source") +
  scale_y_continuous(limits = c(tcant_min, tcant_max)) +
  labs(
    x = expression(Atmospheric ~ pCO[2] ~ (µatm)),
    y = expression(Total ~ oceanic ~ carbon ~ storage ~ since ~ 1800 ~ (PgC))
  ) +
  guides(colour = guide_legend(order = 1),
         fill = "none") +
  theme_classic() +
  theme(
    legend.background = element_rect(fill = "transparent"),
    legend.position = c(0.25, 0.83),
    legend.title = element_blank(),
    legend.box.just = "top",
    legend.box = "horizontal",
    legend.key.size = unit(2.5, 'lines'),
    panel.grid.major.y = element_line(colour = "black",
                                      size = 0.1)
  )

p_tcant_ts_zoom

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
p_tcant_ts_zoom + p_tcant_box_10 +
  plot_layout(ncol = 2, widths = c(6,1.8))

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
99610ed jens-daniel-mueller 2022-11-01
7060801 jens-daniel-mueller 2022-10-31
ecb84c1 jens-daniel-mueller 2022-10-30
2345935 jens-daniel-mueller 2022-10-29
0b40366 jens-daniel-mueller 2022-10-26
91052ae jens-daniel-mueller 2022-10-20
ggsave(path = here::here("output/presentation"),
       filename = "Fig_dcant_budget_global_vs_GCB_ocean_sink_ensemble.png",
       height = 6,
       width = 9)

16 Revelle changes

delta_revelle <- co2_atm %>%
  mutate(revelle = seacarb::buffer(24,
                                   pCO2,
                                   2300 * 1e-6)$BetaD,
         DIC = seacarb::carb(24,
                                   pCO2,
                                   2300 * 1e-6)$DIC,
         delta_DIC = (1/pCO2) * DIC * (1/revelle) *1e6,
         delta_DIC_rel = delta_DIC / mean(delta_DIC),
         delta_DIC_rel_cum = delta_DIC_rel - first(delta_DIC_rel),
         delta_year = year - first(year))
  
  
delta_revelle %>% 
  ggplot(aes(delta_year, pCO2)) +
  geom_path() +
  geom_point()

Version Author Date
084a41c jens-daniel-mueller 2022-10-13
fea41c1 jens-daniel-mueller 2022-07-20
delta_revelle %>% 
  ggplot(aes(delta_year,1/revelle)) +
  geom_smooth(method = "lm", aes(col="lm"), se = FALSE) +
  geom_path() +
  geom_point()

Version Author Date
084a41c jens-daniel-mueller 2022-10-13
delta_revelle %>% 
  ggplot(aes(delta_year,delta_DIC_rel)) +
  geom_smooth(method = "lm", aes(col="lm"), se = FALSE) +
  geom_path() +
  geom_point()

Version Author Date
084a41c jens-daniel-mueller 2022-10-13
delta_revelle %>% 
  ggplot(aes(delta_year,delta_DIC_rel_cum)) +
  geom_smooth(method = "lm", aes(col="lm"), se = FALSE) +
  geom_path() +
  geom_point()

Version Author Date
084a41c jens-daniel-mueller 2022-10-13
min(delta_revelle$delta_DIC_rel_cum / max(delta_revelle$delta_year))
[1] -0.006078176

17 GCB implications

17.1 Land sink

flux_label <- expression(CO[2]~flux~(PgC~yr^{-1}))

flux_components <- Global_Carbon_Budget %>% 
  distinct(estimate) %>% 
  pull()

emission_components <- flux_components[c(1,2,6)]
sink_components <- flux_components[3:5]

estimates <- Global_Carbon_Budget %>%
  select(-GtC) %>%
  pivot_wider(names_from = estimate,
              values_from = GtC_yr) %>%
  mutate(`fossil emissions` = 
           `fossil emissions excluding carbonation` - `cement carbonation sink`) %>%
  select(-c(`fossil emissions excluding carbonation`, `cement carbonation sink`)) %>% 
  pivot_longer(-year,
               names_to = "estimate",
               values_to = "GtC_yr")

estimates <- estimates %>%
  filter(!(estimate %in% c("budget imbalance")),
         year >= 1960) %>%
  mutate(
    sign = if_else(estimate %in% sink_components,
                   "sinks",
                   "emissions"),
    GtC_yr = if_else(sign == "sinks",
                     -GtC_yr,
                     GtC_yr)
    # GtC_yr = if_else(estimate == "cement carbonation sink",
    #                  -GtC_yr,
    #                  GtC_yr)
  )

emissions_sinks <- estimates %>% 
  group_by(year, sign) %>% 
  summarise(GtC_yr = sum(GtC_yr)) %>% 
  ungroup()

estimates %>% distinct(estimate) %>% pull()
[1] "land-use change emissions" "atmospheric growth"       
[3] "ocean sink"                "land sink"                
[5] "fossil emissions"         
p_stacked_fluxes <- estimates %>%
  mutate(
    estimate = fct_relevel(
      estimate,
      "fossil emissions",
      "land-use change emissions",
      "atmospheric growth",
      "land sink",
      "ocean sink"
    )
  ) %>%
  ggplot() +
  geom_area(aes(year, GtC_yr, fill = estimate),
            col = "black",
            alpha = 0.7,
            size = 0.5) +
  # geom_line(data = emissions_sinks %>%   mutate(GtC_yr = if_else(sign == "emissions",
  #                                                                -GtC_yr,
  #                                                                GtC_yr)),
  #           aes(year, GtC_yr, linetype = sign)) +
  scale_fill_manual(values = c("#BBBBBB", "#CCBB44", "#66CCEE", "#228833", "#4477AA"),
                    name = "flux component") +
  geom_hline(yintercept = 0) +
  scale_x_continuous(expand = c(0,0)) +
  labs(y = flux_label,
       title = "Carbon emissions and sinks",
       subtitle = "Global Carbon Budget | Friedlingstein et al. (2021)") +
  theme(axis.title.x = element_blank())

p_stacked_fluxes

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
ggsave(path = here::here("output/presentation"),
       filename = "Fig_GCB_emissions_sinks.png",
       height = 4,
       width = 7)

p_individual_fluxes <- estimates %>%
  ggplot(aes(year, GtC_yr, col = estimate)) +
  geom_hline(yintercept = 0) +
  geom_path() +
  geom_point(size = 0.5) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_color_bright(name = "flux component") +
  labs(y = flux_label,
       title = "Individual flux components from GCB") +
  theme(axis.title.x = element_blank())

p_individual_fluxes

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
BIM <- emissions_sinks %>% 
  pivot_wider(names_from = sign,
              values_from = GtC_yr) %>% 
  mutate(BIM = emissions + sinks)

p_BIM <- ggplot() +
  geom_line(data = Global_Carbon_Budget %>%
              filter(estimate == "budget imbalance",
                     year >= 1990),
            aes(year, GtC_yr, col = "reported")) +
  geom_line(data = BIM, aes(year, BIM, col = "recalculated")) +
  geom_hline(yintercept = 0) +
  scale_color_brewer(palette = "Set1") +
  scale_x_continuous(expand = c(0, 0)) +
  labs(y = flux_label,
       title = "BIM from GCB") +
  theme(axis.title.x = element_blank(),
        legend.title = element_blank())

p_BIM

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
p_land_sink_gcb <- estimates %>%
  select(year, estimate, GtC_yr) %>%
  pivot_wider(names_from = estimate,
              values_from = GtC_yr) %>%
  mutate(`land sink residual` = 
           `fossil emissions` + 
           `land-use change emissions` + 
           `atmospheric growth` + 
           `ocean sink`) %>%
  ggplot() +
  geom_line(aes(year, -`land sink residual`, col = "residual")) +
  geom_line(aes(year, `land sink`, col = "reported")) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_color_brewer(palette = "Set1", name = "land sink\nestimate") +
  labs(y = flux_label,
       title = "Land sink estimates from GCB",
       subtitle = "Note: The offset between reported and residual estimate equals BIM") +
  theme(axis.title.x = element_blank(),
        legend.title = element_blank())

p_land_sink_gcb

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
Ocean_Sink_annual_mean <- Ocean_Sink %>%
  filter(year >= 1990) %>%
  group_by(year, type) %>%
  summarise(GtC_yr = -mean(GtC_yr)) %>%
  ungroup()

Ocean_Sink_annual_mean <- Ocean_Sink_annual_mean %>% 
  pivot_wider(names_from = type,
              values_from = GtC_yr,
              names_prefix = "ocean_sink_")

estimates_wide <- estimates %>%
  select(year, estimate, GtC_yr) %>%
  pivot_wider(names_from = estimate,
              values_from = GtC_yr)

estimates_wide <-
  full_join(estimates_wide, Ocean_Sink_annual_mean)

dcant_interior <- tcant_ts_zoom %>% 
  filter(year > 2000) %>%
  mutate(dcant_mean = dcant_mean/10) %>% 
  pull(dcant_mean)

cnat <-
  dcant_type_significance %>%
  filter(type == "Observation-based\nsurface flux\nproducts" ,
         period %in% two_decades) %>%
  mutate(dcant_diff = dcant_diff/10) %>% 
  pull(dcant_diff)

estimates_wide <- estimates_wide %>% 
  mutate(ocean_sink_interior_Cant = case_when(
    between(year, 1994, 2003) ~ -dcant_interior[1],
    between(year, 2004, 2013) ~ -dcant_interior[2],
    TRUE ~ NaN
  )) %>% 
  mutate(ocean_sink_interior_net = case_when(
    between(year, 1994, 2003) ~ -dcant_interior[1]-cnat[1],
    between(year, 2004, 2013) ~ -dcant_interior[2]-cnat[2],
    TRUE ~ NaN
  ))


p_ocean_sinks <- estimates_wide %>%
  select(year, starts_with("ocean")) %>% 
  rename(GCB_mean = `ocean sink`) %>% 
  pivot_longer(-year,
               names_to = "estimate",
               names_prefix = "ocean_sink_",
               values_to = "GtC_yr") %>% 
  mutate(estimate = str_replace(estimate, "_", " ")) %>% 
  ggplot(aes(year, GtC_yr, col = estimate)) +
  geom_path() +
  geom_point(size = 0.5) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_color_brewer(palette = "Set1", name = "ocean sink\nestimate") +
  labs(y = flux_label,
       title = "Ocean sink estimates",
       subtitle = "Note: Watson et al. (2020) is included in data products and GCB mean") +
  theme(axis.title.x = element_blank(),
        legend.title = element_blank())

p_ocean_sinks

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
estimates_long <- estimates_wide %>%
  select(year, starts_with("ocean")) %>% 
  rename(GCB_mean = `ocean sink`) %>% 
  pivot_longer(-year,
               names_to = "estimate",
               names_prefix = "ocean_sink_",
               values_to = "GtC_yr") %>% 
  filter(estimate %in% c("data_products", "models"),
         year >= 1990)

p_ocean_sinks_presentation <- estimates_long %>%
  # mutate(estimate = str_replace(estimate, "_", " ")) %>% 
  ggplot() +
  geom_path(data = Ocean_Sink %>% filter(year >= 1990),
            aes(year, GtC_yr, group = product, col = type), size = 0.3) +
  geom_path(aes(year, -GtC_yr, col = estimate), size = 2) +
  geom_point(aes(year, -GtC_yr, col = estimate), size = 2, fill = "white", shape = 21) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_color_manual(values = c("#BB5566", "#DDAA33"),
                     name = "ocean sink\nestimate") +
  labs(y = flux_label,
       title = "Ocean Carbon sink",
       subtitle = "Global Carbon Budget | Friedlingstein et al. (2021)") +
  theme(axis.title.x = element_blank(),
        legend.title = element_blank())

p_ocean_sinks_presentation

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
ggsave(path = here::here("output/presentation"),
       filename = "Fig_GCB_ocean_sinks.png",
       height = 4,
       width = 6)

p_ocean_sinks_presentation <-
  estimates_long %>%
  # mutate(estimate = str_replace(estimate, "_", " ")) %>%
  ggplot() +
  geom_path(
    data = Ocean_Sink %>% filter(year >= 1990),
    aes(year, GtC_yr, group = product, col = type),
    size = 0.3
  ) +
  geom_path(aes(year, -GtC_yr, col = estimate), size = 2) +
  geom_point(
    aes(year, -GtC_yr, col = estimate),
    size = 2,
    fill = "white",
    shape = 21
  ) +
  geom_path(
    data =             tibble(
      year = c(1994, 2007),
      estimate = "ocean_interior",
      GtC_yr = -2.6
    ),
    aes(year, -GtC_yr, col = estimate),
    size = 2
  )+
  geom_rect(
    data =             tibble(
      year_min = 1994,
      year_max = 2007,
      estimate = "ocean_interior",
      GtC_yr_min = -2.6 - 0.3,
      GtC_yr_max = -2.6 + 0.3,
    ),
    aes(xmax = year_max, xmin = year_min, ymin = -GtC_yr_min, ymax = -GtC_yr_max, col = estimate),
    fill = "transparent"
  )+
  scale_x_continuous(expand = c(0, 0)) +
  scale_color_manual(values = c("#BB5566", "#DDAA33","#004488"),
                     name = "ocean sink\nestimate") +
  labs(y = flux_label,
       title = "Ocean Carbon sink",
       subtitle = "Global Carbon Budget | Friedlingstein et al. (2021)") +
  theme(axis.title.x = element_blank(),
        legend.title = element_blank())

p_ocean_sinks_presentation

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
ggsave(path = here::here("output/presentation"),
       filename = "Fig_GCB_ocean_sinks_eMLR.png",
       height = 4,
       width = 6)

land_sink <-
  estimates_wide %>%
  mutate(emissions_atmosphere = `fossil emissions` +
           `land-use change emissions` +
           `atmospheric growth`) %>%
  rename(ocean_sink_gcb_mean = `ocean sink`) %>%
  select(year, emissions_atmosphere, starts_with("ocean")) %>%
  pivot_longer(
    starts_with("ocean_sink"),
    names_to = "ocean_sink_estimate",
    values_to = "ocean_sink",
    names_prefix = "ocean_sink_"
  ) %>%
  mutate(land_sink = -emissions_atmosphere - ocean_sink)


p_land_sink_residual <- land_sink %>%
  mutate(ocean_sink_estimate = 
           str_replace(ocean_sink_estimate, "_", " ")) %>% 
  ggplot() +
  geom_line(aes(year, land_sink, col = ocean_sink_estimate, linetype = "residual")) +
  geom_line(data = estimates_wide %>%
              filter(year >= 1990),
            aes(year, `land sink`, linetype = "reported")) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_linetype_manual(values = c(2, 1), name = "land sink\nestimate") +
  scale_color_brewer(palette = "Set1",
                     name = "ocean sink\nestimate\nunderlying\nresidual") +
  guides(linetype = guide_legend(order = 1),
         color = guide_legend(order = 2)) +
  labs(y = flux_label,
       title = "Land sink estimates",
       subtitle = "Note: Residuals are determined for a range of ocean sink estimates") +
  theme(axis.title.x = element_blank())

p_land_sink_residual

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
land_sink <-
  full_join(
    land_sink,
    estimates_wide %>%
      select(year, land_sink_reported = `land sink`)
  )


p_land_sink_residual_delta <- land_sink %>%
  mutate(ocean_sink_estimate =
           str_replace(ocean_sink_estimate, "_", " ")) %>%
  ggplot() +
  geom_hline(yintercept = 0) +
  geom_line(aes(year, land_sink - land_sink_reported, col = ocean_sink_estimate)) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_color_brewer(palette = "Set1",
                     name = "ocean sink\nestimate\nunderlying\nresidual") +
  labs(y = flux_label,
       title = "Land sink estimates (reported - residual)",
       subtitle = "Note: Residuals are determined for a range of ocean sink estimates") +
  theme(axis.title.x = element_blank())

p_land_sink_residual_delta

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
p_land_sink_residual_decade <- land_sink %>%
  mutate(period = cut(year, c(1993, 2003, 2013),
                      c("1994 - 2004", "2004 - 2014"))) %>%
  filter(!is.na(period)) %>%
  group_by(ocean_sink_estimate, period) %>%
  summarise(across(starts_with("land_sink"), list(mean = mean, sd = sd))) %>%
  ungroup() %>%
  mutate(ocean_sink_estimate =
           str_replace(ocean_sink_estimate, "_", " ")) %>%
  ggplot() +
  geom_pointrange(
    aes(
      period,
      land_sink_reported_mean,
      ymin = land_sink_reported_mean - land_sink_reported_sd,
      ymax = land_sink_reported_mean + land_sink_reported_sd,
      shape = "reported"
    ),
    position = position_dodge2(width = 0.6)
  ) +
  geom_pointrange(
    aes(
      period,
      land_sink_mean,
      ymin = land_sink_mean - land_sink_sd,
      ymax = land_sink_mean + land_sink_sd,
      col = ocean_sink_estimate,
      shape = "residual"
    ),
    position = position_dodge2(width = 0.5)
  ) +
  scale_color_brewer(palette = "Set1",
                     name = "ocean sink\nestimate\nunderlying\nresidual") +
  scale_shape_manual(values = c(17, 16), name = "land sink\nestimate") +
  guides(shape = guide_legend(order = 1),
         color = guide_legend(order = 2)) +
  theme(axis.title.x = element_blank()) +
  labs(y = flux_label,
       title = "Decadal mean land sink estimates",
       subtitle = "Note: Errorbars indicate the StDev of the IAV") +
  theme(axis.title.x = element_blank())

p_land_sink_residual_decade

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
pdf(
  file = here::here("output/publication/GCB_land_sink_residual.pdf"),
  height = 6,
  width = 9
)

p_stacked_fluxes
p_individual_fluxes
p_BIM
p_land_sink_gcb
p_ocean_sinks
p_land_sink_residual
p_land_sink_residual_delta
p_land_sink_residual_decade

dev.off()
png 
  2 
rm(
  p_stacked_fluxes,
  p_individual_fluxes,
  p_BIM,
  p_land_sink_gcb,
  p_ocean_sinks,
  p_land_sink_residual,
  p_land_sink_residual_delta,
  p_land_sink_residual_decade,
  estimates,
  estimates_wide,
  land_sink,
  Ocean_Sink_annual_mean,
  flux_components,
  flux_label,
  emission_components,
  sink_components
)

17.2 Net land sink

flux_label <- expression(flux~(PgC~yr^{-1}))

Global_Carbon_Budget_net_land_sink <- Global_Carbon_Budget %>%
  select(year, estimate, GtC_yr) %>%
  pivot_wider(names_from = estimate,
              values_from = GtC_yr) %>%
  mutate(`net land sink` = `land sink` - `land-use change emissions`) %>%
  select(-c(`land sink`, `land-use change emissions`)) %>%
  pivot_longer(-year,
               names_to = "estimate",
               values_to = "GtC_yr")

flux_components <- Global_Carbon_Budget_net_land_sink %>% 
  distinct(estimate) %>% 
  pull()

emission_components <- flux_components[c(1,4)]
sink_components <- flux_components[c(2,3,6)]

estimates <- Global_Carbon_Budget_net_land_sink %>%
  filter(!(estimate %in% c("budget imbalance")),
         year >= 1990) %>%
  mutate(
    sign = if_else(estimate %in% sink_components,
                   "sinks",
                   "emissions"),
    GtC_yr = if_else(sign == "sinks",
                     -GtC_yr,
                     GtC_yr),
    GtC_yr = if_else(estimate == "cement carbonation sink",
                     -GtC_yr,
                     GtC_yr)
  )

emissions_sinks <- estimates %>% 
  group_by(year, sign) %>% 
  summarise(GtC_yr = sum(GtC_yr)) %>% 
  ungroup()


p_stacked_fluxes <- estimates %>%
  ggplot() +
  geom_area(aes(year, GtC_yr, fill = estimate),
            col = "white",
            alpha = 0.7,
            size = 0.5) +
  geom_line(data = emissions_sinks %>%   mutate(GtC_yr = if_else(sign == "emissions",
                                                                 -GtC_yr,
                                                                 GtC_yr)),
            aes(year, GtC_yr, linetype = sign)) +
  scale_fill_bright(name = "flux component") +
  geom_hline(yintercept = 0) +
  scale_x_continuous(expand = c(0,0)) +
  labs(y = flux_label,
       title = "Stacked emission and sink components from GCB",
       subtitle = "Note: The cement carbonation sink is accounted for in emissions") +
  theme(axis.title.x = element_blank())

p_stacked_fluxes

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
p_individual_fluxes <- estimates %>%
  ggplot(aes(year, GtC_yr, col = estimate)) +
  geom_hline(yintercept = 0) +
  geom_path() +
  geom_point(size = 0.5) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_color_bright(name = "flux component") +
  labs(y = flux_label,
       title = "Individual flux components from GCB") +
  theme(axis.title.x = element_blank())

p_individual_fluxes

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
BIM <- emissions_sinks %>% 
  pivot_wider(names_from = sign,
              values_from = GtC_yr) %>% 
  mutate(BIM = emissions + sinks)

p_BIM <- ggplot() +
  geom_line(data = Global_Carbon_Budget %>%
              filter(estimate == "budget imbalance",
                     year >= 1990),
            aes(year, GtC_yr, col = "reported")) +
  geom_line(data = BIM, aes(year, BIM, col = "recalculated")) +
  geom_hline(yintercept = 0) +
  scale_color_brewer(palette = "Set1") +
  scale_x_continuous(expand = c(0, 0)) +
  labs(y = flux_label,
       title = "BIM from GCB") +
  theme(axis.title.x = element_blank(),
        legend.title = element_blank())

p_BIM

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
p_land_sink_gcb <- estimates %>%
  select(year, estimate, GtC_yr) %>%
  pivot_wider(names_from = estimate,
              values_from = GtC_yr) %>%
  mutate(`net land sink residual` = 
           `fossil emissions excluding carbonation` + 
           `cement carbonation sink` + 
           `atmospheric growth` + 
           `ocean sink`) %>%
  ggplot() +
  geom_line(aes(year, -`net land sink residual`, col = "residual")) +
  geom_line(aes(year, `net land sink`, col = "reported")) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_color_brewer(palette = "Set1", name = "land sink\nestimate") +
  labs(y = flux_label,
       title = "Land sink estimates from GCB",
       subtitle = "Note: The offset between reported and residual estimate equals BIM") +
  theme(axis.title.x = element_blank(),
        legend.title = element_blank())

p_land_sink_gcb

Version Author Date
91052ae jens-daniel-mueller 2022-10-20
Ocean_Sink_annual_mean <- Ocean_Sink %>%
  filter(year >= 1990) %>%
  group_by(year, type) %>%
  summarise(GtC_yr = -mean(GtC_yr)) %>%
  ungroup()

Ocean_Sink_annual_mean <- Ocean_Sink_annual_mean %>% 
  pivot_wider(names_from = type,
              values_from = GtC_yr,
              names_prefix = "ocean_sink_")

estimates_wide <- estimates %>%
  select(year, estimate, GtC_yr) %>%
  pivot_wider(names_from = estimate,
              values_from = GtC_yr)

estimates_wide <-
  full_join(estimates_wide, Ocean_Sink_annual_mean)

dcant_interior <- tcant_ts_zoom %>% 
  filter(year > 2000) %>%
  mutate(dcant_mean = dcant_mean/10) %>% 
  pull(dcant_mean)

cnat <-
  dcant_type_significance %>%
  filter(type == "Observation-based\nsurface flux\nproducts" ,
         period %in% two_decades) %>%
  mutate(dcant_diff = dcant_diff/10) %>% 
  pull(dcant_diff)

estimates_wide <- estimates_wide %>% 
  mutate(ocean_sink_interior_Cant = case_when(
    between(year, 1994, 2003) ~ -dcant_interior[1],
    between(year, 2004, 2013) ~ -dcant_interior[2],
    TRUE ~ NaN
  )) %>% 
  mutate(ocean_sink_interior_net = case_when(
    between(year, 1994, 2003) ~ -dcant_interior[1]-cnat[1],
    between(year, 2004, 2013) ~ -dcant_interior[2]-cnat[2],
    TRUE ~ NaN
  ))


p_ocean_sinks <- estimates_wide %>%
  select(year, starts_with("ocean")) %>% 
  rename(GCB_mean = `ocean sink`) %>% 
  pivot_longer(-year,
               names_to = "estimate",
               names_prefix = "ocean_sink_",
               values_to = "GtC_yr") %>% 
  mutate(estimate = str_replace(estimate, "_", " ")) %>% 
  ggplot(aes(year, GtC_yr, col = estimate)) +
  geom_path() +
  geom_point(size = 0.5) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_color_brewer(palette = "Set1", name = "ocean sink\nestimate") +
  labs(y = flux_label,
       title = "Ocean sink estimates",
       subtitle = "Note: Watson et al. (2020) is included in data products and GCB mean") +
  theme(axis.title.x = element_blank(),
        legend.title = element_blank())

p_ocean_sinks

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
land_sink <-
  estimates_wide %>%
  mutate(emissions_atmosphere = `fossil emissions excluding carbonation` +
           `atmospheric growth`) %>%
  rename(ocean_sink_gcb_mean = `ocean sink`) %>%
  select(year, emissions_atmosphere, starts_with("ocean")) %>%
  pivot_longer(
    starts_with("ocean_sink"),
    names_to = "ocean_sink_estimate",
    values_to = "ocean_sink",
    names_prefix = "ocean_sink_"
  ) %>%
  mutate(net_land_sink = -emissions_atmosphere - ocean_sink)


p_land_sink_residual <- land_sink %>%
  mutate(ocean_sink_estimate = 
           str_replace(ocean_sink_estimate, "_", " ")) %>% 
  ggplot() +
  geom_line(aes(year, net_land_sink, col = ocean_sink_estimate, linetype = "residual")) +
  geom_line(data = estimates_wide %>%
              filter(year >= 1990),
            aes(year, `net land sink`, linetype = "reported")) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_linetype_manual(values = c(2, 1), name = "net land sink\nestimate") +
  scale_color_brewer(palette = "Set1",
                     name = "ocean sink\nestimate\nunderlying\nresidual") +
  guides(linetype = guide_legend(order = 1),
         color = guide_legend(order = 2)) +
  labs(y = flux_label,
       title = "Net land sink estimates",
       subtitle = "Note: Residuals are determined for a range of ocean sink estimates") +
  theme(axis.title.x = element_blank())

p_land_sink_residual

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
land_sink <-
  full_join(
    land_sink,
    estimates_wide %>%
      select(year, net_land_sink_reported = `net land sink`)
  )


p_land_sink_residual_delta <- land_sink %>%
  mutate(ocean_sink_estimate =
           str_replace(ocean_sink_estimate, "_", " ")) %>%
  ggplot() +
  geom_hline(yintercept = 0) +
  geom_line(aes(year, net_land_sink - net_land_sink_reported, col = ocean_sink_estimate)) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_color_brewer(palette = "Set1",
                     name = "ocean sink\nestimate\nunderlying\nresidual") +
  labs(y = flux_label,
       title = "Let land sink estimates (reported - residual)",
       subtitle = "Note: Residuals are determined for a range of ocean sink estimates") +
  theme(axis.title.x = element_blank())

p_land_sink_residual_delta

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
p_land_sink_residual_decade <- land_sink %>%
  mutate(period = cut(year, c(1993, 2003, 2013),
                      c("1994 - 2004", "2004 - 2014"))) %>%
  filter(!is.na(period)) %>%
  group_by(ocean_sink_estimate, period) %>%
  summarise(across(starts_with("net_land_sink"), list(mean = mean, sd = sd))) %>%
  ungroup() %>%
  mutate(ocean_sink_estimate =
           str_replace(ocean_sink_estimate, "_", " ")) %>%
  ggplot() +
  geom_pointrange(
    aes(
      period,
      net_land_sink_reported_mean,
      ymin = net_land_sink_reported_mean - net_land_sink_reported_sd,
      ymax = net_land_sink_reported_mean + net_land_sink_reported_sd,
      shape = "reported"
    ),
    position = position_dodge2(width = 0.6)
  ) +
  geom_pointrange(
    aes(
      period,
      net_land_sink_mean,
      ymin = net_land_sink_mean - net_land_sink_sd,
      ymax = net_land_sink_mean + net_land_sink_sd,
      col = ocean_sink_estimate,
      shape = "residual"
    ),
    position = position_dodge2(width = 0.5)
  ) +
  scale_color_brewer(palette = "Set1",
                     name = "ocean sink\nestimate\nunderlying\nresidual") +
  scale_shape_manual(values = c(17, 16), name = "land sink\nestimate") +
  guides(shape = guide_legend(order = 1),
         color = guide_legend(order = 2)) +
  theme(axis.title.x = element_blank()) +
  labs(y = flux_label,
       title = "Decadal mean land sink estimates",
       subtitle = "Note: Errorbars indicate the StDev of the IAV") +
  theme(axis.title.x = element_blank())

p_land_sink_residual_decade

Version Author Date
7275091 jens-daniel-mueller 2022-11-05
2345935 jens-daniel-mueller 2022-10-29
91052ae jens-daniel-mueller 2022-10-20
pdf(
  file = here::here("output/publication/GCB_net_land_sink_residual.pdf"),
  height = 6,
  width = 9
)

p_stacked_fluxes
p_individual_fluxes
p_BIM
p_land_sink_gcb
p_ocean_sinks
p_land_sink_residual
p_land_sink_residual_delta
p_land_sink_residual_decade

dev.off()
png 
  2 
rm(
  p_stacked_fluxes,
  p_individual_fluxes,
  p_BIM,
  p_land_sink_gcb,
  p_ocean_sinks,
  p_land_sink_residual,
  p_land_sink_residual_delta,
  p_land_sink_residual_decade,
  estimates,
  estimates_wide,
  land_sink,
  Ocean_Sink_annual_mean,
  flux_components,
  flux_label,
  emission_components,
  sink_components
)

18 Emission removal

GCB_Cant_emissions <- Global_Carbon_Budget %>%
  mutate(year = cut(year, c(1994, 2004, 2014), c("2004", "2014")),
         year = as.numeric(as.character(year))) %>%
  drop_na() %>%
  filter(estimate %in% c(
    "fossil emissions excluding carbonation",
    "land-use change emissions"
  )) %>%
  group_by(year) %>%
  summarise(cant_emissions = sum(GtC_yr)) %>%
  ungroup()

left_join(GCB_Cant_emissions,
          tcant_ts_zoom) %>%
  mutate(
    dcant_per_emission = 100 * dcant_mean / cant_emissions,
    dcant_per_emission_sd = 100 * dcant_sd / cant_emissions
  ) %>%
  kable() %>%
  kable_styling() %>%
  scroll_box(height = "300px")
year cant_emissions dcant_mean dcant_sd pCO2 tcant tcant_sd dcant_sd_int dcant_per_emission dcant_per_emission_sd
2004 82.66365 27.388 3.281987 376.95 145.388 19.28138 3.281987 33.13185 3.970291
2014 101.81399 25.583 4.547768 397.34 170.971 19.53669 4.547768 25.12719 4.466742

18.0.0.1 Map test color palettes

breaks <- c(-Inf, seq(0, 16, 2), Inf)

legend_title <- expression(atop(Delta * C["ant"],
                                (mol ~ m ^ {
                                  -2
                                })))

breaks_n <- length(breaks) - 1

dcant_inv_all_color_test <- dcant_inv_all %>%
  filter(data_source %in% c("obs"),
         period == "2004 - 2014") %>%
  mutate(dcant_int = cut(dcant,
                         breaks,
                         right = FALSE))

scico_continous_palettes <- c(
  "acton",
  "bamako",
  "batlow",
  "bilbao",
  "buda",
  "davos",
  "devon",
  "grayC",
  "hawaii",
  "imola",
  "lajolla",
  "lapaz",
  "nuuk",
  "oslo",
  "tokyo",
  "turku"
)

p_test_scico <- function(df, i_palette) {
  p_reg <- map +
    geom_raster(data = df,
                aes(lon, lat, fill = dcant_int)) +
    scale_fill_scico_d(
      palette = i_palette,
      drop = FALSE,
      name = legend_title,
      guide = "none"
    ) +
    labs(title = i_palette) +
    theme(axis.text = element_blank(),
          axis.ticks = element_blank())
  
  p_rev <- map +
    geom_raster(data = df,
              aes(lon, lat, fill = dcant_int)) +
    scale_fill_scico_d(
      palette = i_palette,
      drop = FALSE,
      name = legend_title,
      direction = -1,
      guide = "none"
    ) +
    labs(title = paste(i_palette, "rev")) +
    theme(axis.text = element_blank(),
          axis.ticks = element_blank())
  
  p_comb <- p_reg / p_rev
  
  return(p_comb)
}


all_plots_scico <- scico_continous_palettes %>% 
  # head(1) %>% 
  map(~p_test_scico(df = dcant_inv_all_color_test,
                      i_palette = .x))

viridis_continous_palettes <- c(
  "viridis",
  "magma",
  "inferno",
  "plasma"
)

p_test_viridis <- function(df, i_palette) {
  p_reg <- map +
    geom_raster(data = df,
                aes(lon, lat, fill = dcant_int)) +
    scale_fill_viridis_d(
      option = i_palette,
      drop = FALSE,
      name = legend_title,
      guide = "none"
    ) +
    labs(title = i_palette) +
    theme(axis.text = element_blank(),
          axis.ticks = element_blank())
  
  p_rev <- map +
    geom_raster(data = df,
              aes(lon, lat, fill = dcant_int)) +
    scale_fill_viridis_d(
      option = i_palette,
      drop = FALSE,
      name = legend_title,
      direction = -1,
      guide = "none"
    ) +
    labs(title = paste(i_palette, "rev")) +
    theme(axis.text = element_blank(),
          axis.ticks = element_blank())
  
  p_comb <- p_reg / p_rev
  
  return(p_comb)
}

all_plots_viridis <- viridis_continous_palettes %>% 
  # head(1) %>% 
  map(~p_test_viridis(df = dcant_inv_all_color_test,
                      i_palette = .x))



library(colorspace)

colorspace_continous_palettes <- c(
  # "Purple - Blue",
  # "Red - Purple",
  # "Blue - Yellow",
  # "Heat",
  # "Heat 2",
  "Rocket"
  # "Mako",
  # "Dark",
  # "Mint",
  # "Mint",
  # "BluGrn",
  # "Teal",
  # "Sunset",
  # "SunsetDark",
  # "ag_Sunset",
  # "YlOrRd",
  # "YlGnBu",
  # "RdPu"
)

p_test_colorspace <- function(df, i_palette) {
  
  i_palette <<- i_palette
  
  p_reg <- map +
    geom_raster(data = df,
                aes(lon, lat, fill = dcant_int)) +
    scale_fill_discrete_sequential(
      palette = i_palette,
      drop = FALSE,
      name = legend_title,
      guide = "none"
    ) +
    labs(title = i_palette) +
    theme(axis.text = element_blank(),
          axis.ticks = element_blank())
  
  p_rev <- map +
    geom_raster(data = df,
                aes(lon, lat, fill = dcant_int)) +
    scale_fill_discrete_sequential(
      palette = i_palette,
      drop = FALSE,
      name = legend_title,
      rev = FALSE,
      guide = "none"
    ) +
    labs(title = paste(i_palette, "rev")) +
    theme(axis.text = element_blank(),
          axis.ticks = element_blank())

  p_comb <- p_reg / p_rev
  
  return(p_comb)
  rm(i_palette)
  
}

all_plots_colorspace <- colorspace_continous_palettes %>%
  # head(2) %>%
  map(~p_test_colorspace(df = dcant_inv_all_color_test,
                           i_palette = .x))

all_plots_colorspace

all_plots <- c(all_plots_colorspace, all_plots_viridis, all_plots_scico)

pdf(here::here("output/publication/test_color_scales.pdf"),
    width = 4, height = 4)
all_plots
dev.off()

sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: openSUSE Leap 15.3

Matrix products: default
BLAS:   /usr/local/R-4.1.2/lib64/R/lib/libRblas.so
LAPACK: /usr/local/R-4.1.2/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] ggpattern_1.0.0    ggh4x_0.2.1        khroma_1.9.0       BSDA_1.2.1        
 [5] lattice_0.20-45    kableExtra_1.3.4   ggdist_3.1.1       ggalluvial_0.12.3 
 [9] geomtextpath_0.1.0 colorspace_2.0-2   marelac_2.1.10     shape_1.4.6       
[13] ggforce_0.3.3      metR_0.11.0        scico_1.3.0        patchwork_1.1.1   
[17] collapse_1.7.0     forcats_0.5.1      stringr_1.4.0      dplyr_1.0.7       
[21] purrr_0.3.4        readr_2.1.1        tidyr_1.1.4        tibble_3.1.6      
[25] ggplot2_3.3.5      tidyverse_1.3.1    workflowr_1.7.0   

loaded via a namespace (and not attached):
  [1] readxl_1.3.1         backports_1.4.1      Hmisc_4.6-0         
  [4] systemfonts_1.0.3    plyr_1.8.6           splines_4.1.2       
  [7] digest_0.6.29        htmltools_0.5.2      fansi_1.0.2         
 [10] magrittr_2.0.1       checkmate_2.0.0      memoise_2.0.1       
 [13] cluster_2.1.2        tzdb_0.2.0           modelr_0.1.8        
 [16] vroom_1.5.7          svglite_2.0.0        jpeg_0.1-9          
 [19] rvest_1.0.2          textshaping_0.3.6    haven_2.4.3         
 [22] xfun_0.29            callr_3.7.0          crayon_1.4.2        
 [25] jsonlite_1.7.3       survival_3.2-13      zoo_1.8-9           
 [28] glue_1.6.0           polyclip_1.10-0      gtable_0.3.0        
 [31] webshot_0.5.2        distributional_0.3.0 scales_1.1.1        
 [34] DBI_1.1.2            Rcpp_1.0.8           isoband_0.2.5       
 [37] htmlTable_2.4.0      viridisLite_0.4.0    units_0.7-2         
 [40] foreign_0.8-82       bit_4.0.4            proxy_0.4-26        
 [43] Formula_1.2-4        htmlwidgets_1.5.4    httr_1.4.2          
 [46] seacarb_3.3.0        RColorBrewer_1.1-2   ellipsis_0.3.2      
 [49] pkgconfig_2.0.3      farver_2.1.0         nnet_7.3-17         
 [52] sass_0.4.0           dbplyr_2.1.1         utf8_1.2.2          
 [55] here_1.0.1           tidyselect_1.1.1     labeling_0.4.2      
 [58] rlang_1.0.2          later_1.3.0          munsell_0.5.0       
 [61] cellranger_1.1.0     tools_4.1.2          cachem_1.0.6        
 [64] cli_3.1.1            generics_0.1.1       broom_0.7.11        
 [67] evaluate_0.14        fastmap_1.1.0        yaml_2.2.1          
 [70] oce_1.5-0            processx_3.5.2       knitr_1.37          
 [73] bit64_4.0.5          fs_1.5.2             nlme_3.1-155        
 [76] whisker_0.4          xml2_1.3.3           gridpattern_1.0.1   
 [79] compiler_4.1.2       rstudioapi_0.13      png_0.1-7           
 [82] e1071_1.7-9          reprex_2.0.1         tweenr_1.0.2        
 [85] bslib_0.3.1          stringi_1.7.6        highr_0.9           
 [88] ps_1.6.0             Matrix_1.4-0         classInt_0.4-3      
 [91] vctrs_0.3.8          pillar_1.6.4         lifecycle_1.0.1     
 [94] jquerylib_0.1.4      gsw_1.0-6            data.table_1.14.2   
 [97] httpuv_1.6.5         R6_2.5.1             latticeExtra_0.6-29 
[100] promises_1.2.0.1     gridExtra_2.3        KernSmooth_2.23-20  
[103] MASS_7.3-55          assertthat_0.2.1     rprojroot_2.0.2     
[106] withr_2.4.3          SolveSAPHE_2.1.0     mgcv_1.8-38         
[109] parallel_4.1.2       hms_1.1.1            rpart_4.1-15        
[112] grid_4.1.2           class_7.3-20         rmarkdown_2.11      
[115] git2r_0.29.0         sf_1.0-5             getPass_0.2-2       
[118] lubridate_1.8.0      base64enc_0.1-3