Last updated: 2021-08-03

Checks: 7 0

Knit directory: emlr_obs_v_XXX/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20200707) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 4d7bb5a. 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/

Unstaged changes:
    Modified:   code/Workflowr_project_managment.R
    Modified:   data/auxillary/params_local.rds

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/mapping_dcant_eMLR.Rmd) and HTML (docs/mapping_dcant_eMLR.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 a53656d jens-daniel-mueller 2021-08-03 Build site.
html 88f7356 jens-daniel-mueller 2021-08-02 Build site.
html d759279 jens-daniel-mueller 2021-08-02 Build site.
html 127b801 jens-daniel-mueller 2021-07-24 Build site.
html 1f65ef1 jens-daniel-mueller 2021-07-23 Build site.
html 912d90e jens-daniel-mueller 2021-07-23 Build site.
html 2477316 jens-daniel-mueller 2021-07-23 rebuild: surface dcant mapping seperate
html c9ccc00 jens-daniel-mueller 2021-07-22 Build site.
Rmd 6a7f226 jens-daniel-mueller 2021-07-22 surface dcant mapping seperate
html f3c0d7a jens-daniel-mueller 2021-07-22 Build site.
Rmd 203223f jens-daniel-mueller 2021-07-22 surface dcant mapping seperate
html c75b2a0 jens-daniel-mueller 2021-07-22 Build site.
Rmd 7d6951d jens-daniel-mueller 2021-07-22 surface dcant mapping seperate
html 768ae83 jens-daniel-mueller 2021-07-22 Build site.
Rmd 17db872 jens-daniel-mueller 2021-07-22 surface dcant mapping with surface data only
html 426b2df jens-daniel-mueller 2021-07-21 Build site.
html 78fe930 jens-daniel-mueller 2021-07-21 Build site.
Rmd ee0e941 jens-daniel-mueller 2021-07-21 surface dcant mapping with preformed DIC
html 971ce87 jens-daniel-mueller 2021-07-13 Build site.
Rmd 89d9fcb jens-daniel-mueller 2021-07-13 complete revision
html bef1b71 jens-daniel-mueller 2021-07-09 Build site.
Rmd f682536 jens-daniel-mueller 2021-07-09 complete revision

1 Version ID

The results displayed on this site correspond to the Version_ID: v_XXX

2 Required data

2.1 Predictor fields

Currently, we use following combined predictor fields:

  • WOA18: S, T, and derived variables
  • GLODAP16: Oxygen, PO4, NO3, Silicate, and derived variables
predictors <-
  read_csv(paste(path_version_data,
                 "W18_st_G16_opsn.csv",
                 sep = ""))

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

2.2 Atm. pCO2

Required only to estimate the change of dcant in surface water and assuming that the ocean pCO2 trend follows the atmospheric forcing.

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

2.3 MLR models

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

3 Join MLRs + climatologies

# remove predictor variable from model
lm_best_dcant <- lm_best_dcant %>% 
  mutate(model = str_remove(model, paste(params_local$MLR_target, "~ ")))

# join predictors and MLR
dcant <- left_join(lm_best_dcant, predictors)

rm(predictors, lm_best_dcant)

4 Map dcant

4.1 Deep water

4.1.1 Apply MLRs to predictor

dcant <- b_dcant(dcant)

4.1.2 Sections by model

Zonal section plots are produced for every 20° longitude, each era and for all models individually. Plots can be accessed here:

  • /nfs/kryo/work/jenmueller/emlr_cant/observations/v_XXX/figures/Cant_model_sections/
if (params_local$plot_all_figures == "y") {
  for (i_eras in unique(cant$eras)) {
    # i_eras <- unique(cant$eras)[2]
    cant_eras <- cant %>%
      filter(eras == i_eras)
    
    for (i_lon in params_global$longitude_sections_regular) {
      # i_lon <- params_global$longitude_sections_regular[7]
      cant_eras_lon <- cant_eras %>%
        filter(lon == i_lon)
      
      limits = max(abs(cant_eras_lon$cant)) * c(-1, 1)
      
      cant_eras_lon %>%
        ggplot(aes(lat, depth, z = cant)) +
        stat_summary_2d(
          fun = "mean",
          na.rm = TRUE,
          bins = 20,
          col = "grey"
        ) +
        scale_fill_scico(name = "Cant",
                         palette = "vik",
                         limit = limits) +
        scale_y_reverse(limits = c(params_global$plotting_depth, NA)) +
        scale_x_continuous(limits = c(-85, 85)) +
        labs(title = paste(
          "eras:",
          i_eras,
          "| lon:",
          i_lon,
          "|",
          params_local$Version_ID
        )) +
        facet_wrap(~ model, ncol = 5)
      
      ggsave(
        paste(
          path_version_figures,
          "Cant_model_sections/",
          paste("Cant_model",
                i_eras,
                "lon",
                i_lon,
                "section.png",
                sep = "_"),
          sep = ""
        ),
        width = 17,
        height = 9
      )
      
    }
  }
}

4.2 Surface water

As outlined in Gruber et al. (2019), a transient equilibrium approach was applied to estimate dcant in surface waters, assuming that the CO2 system in these waters has followed the increase in atmospheric CO2 closely.

Using eq 10.2.16 from OBD, the change in anthropogenic CO2 in the upper ocean was computed as:

\(\Delta\)tCant,eq(t2 − t1) = 1∕\(\gamma\) ⋅ DIC/pCO2 ⋅ (pCO2,atm (t2)− pCO2,atm(t1))

, where DIC and pCO2 are the in situ values, where \(\gamma\) is the buffer (Revelle) factor and where we evaluated the right-hand side using seacarb employing the Luecker constants using the climatological values for temperature, salinity, DIC and Alk.

4.2.1 Layer depth

surface_layer <- predictors_surface %>% 
  group_by(lat, lon, data_source) %>% 
  summarise(depth_max = max(depth),
            n_layer = n()) %>% 
  ungroup()


map +
  geom_raster(data = surface_layer,
              aes(lon, lat, fill=depth_max)) +
  scale_fill_scico(palette = "nuuk", direction = -1) +
  facet_grid(data_source ~ .)

Version Author Date
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22
map +
  geom_raster(data = surface_layer,
              aes(lon, lat, fill=n_layer)) +
  scale_fill_scico(palette = "tokyo") +
  facet_grid(data_source ~ .)

Version Author Date
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22

4.2.2 Surface pCO2

predictors_surface_all_depth <- predictors_surface

predictors_surface <- predictors_surface %>%
  filter(depth %in% c(0, 5)) %>%
  mutate(
    pCO2 = carb(
      flag = 15,
      var1 = TAlk * 1e-6,
      var2 = TCO2 * 1e-6,
      S = sal,
      T = temp,
      P = depth / 10,
      Pt = phosphate * 1e-6,
      Sit = silicate * 1e-6,
      k1k2 = "l"
    )$pCO2
  )
predictors_surface %>%
  mutate(depth = 0) %>% 
  group_split(data_source) %>%
  # head(1) %>%
  map( ~
         p_map_climatology(
           df = .x,
           var = "pCO2",
           subtitle_text = paste("Data source: ", unique(.x$data_source))
         ))
[[1]]

Version Author Date
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
768ae83 jens-daniel-mueller 2021-07-22
78fe930 jens-daniel-mueller 2021-07-21
bef1b71 jens-daniel-mueller 2021-07-09

[[2]]

Version Author Date
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
768ae83 jens-daniel-mueller 2021-07-22
78fe930 jens-daniel-mueller 2021-07-21
bef1b71 jens-daniel-mueller 2021-07-09

4.2.3 Revelle factor

Plots below show the calculated climatological Revelle factor values.

predictors_surface <- predictors_surface %>%
  mutate(
    rev_fac = buffer(
      flag = 15,
      var1 = TAlk * 1e-6,
      var2 = TCO2 * 1e-6,
      S = sal,
      T = temp,
      P = depth / 10,
      Pt = phosphate * 1e-6,
      Sit = silicate * 1e-6,
      k1k2 = "l"
    )$BetaD
  )
predictors_surface %>%
  group_split(data_source) %>%
  # head(1) %>%
  map( ~
         p_map_climatology(
           df = .x,
           var = "rev_fac",
           subtitle_text = paste("Data source: ", unique(.x$data_source))
         ))
[[1]]

Version Author Date
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
768ae83 jens-daniel-mueller 2021-07-22
78fe930 jens-daniel-mueller 2021-07-21
bef1b71 jens-daniel-mueller 2021-07-09

[[2]]

Version Author Date
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
768ae83 jens-daniel-mueller 2021-07-22
78fe930 jens-daniel-mueller 2021-07-21
bef1b71 jens-daniel-mueller 2021-07-09
predictors_surface %>%
  group_split(data_source) %>%
  # head(1) %>%
  map( ~
         p_section_climatology_regular(
           df = .x,
           var = "rev_fac",
           surface = "y",
           subtitle_text = paste("Data source: ", unique(.x$data_source))
         ))

4.2.4 dcant calculation

# calculate increase in atm pCO2 between eras
co2_atm_tref <- co2_atm_tref %>%
  arrange(pCO2_tref) %>%
  mutate(d_pCO2_tref = pCO2_tref - lag(pCO2_tref)) %>%
  drop_na() %>%
  select(d_pCO2_tref)

dcant_surface <- full_join(predictors_surface, co2_atm_tref,
                           by = character())

# calculate cant
dcant_surface <- dcant_surface %>%
  mutate(dcant = (1 / rev_fac) *
           (TCO2 / pCO2) * d_pCO2_tref)

# calculate positive cant
dcant_surface <- dcant_surface %>%
  mutate(dcant_pos = if_else(dcant < 0, 0, dcant)) %>% 
  select(lon, lat, data_source, dcant, dcant_pos)


dcant_surface <- full_join(
  dcant_surface,
  predictors_surface_all_depth
)

4.2.5 Control plots

dcant_surface %>%
  group_split(data_source) %>%
  # head(1) %>%
  map( ~
         p_map_climatology(
           df = .x,
           var = "dcant",
           subtitle_text = paste("Data source: ", unique(.x$data_source))
         ))
[[1]]

Version Author Date
88f7356 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
bef1b71 jens-daniel-mueller 2021-07-09

[[2]]

Version Author Date
88f7356 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
bef1b71 jens-daniel-mueller 2021-07-09
dcant_surface %>%
  group_split(data_source) %>%
  # head(1) %>%
  map( ~
         p_section_climatology_regular(
           df = .x,
           var = "dcant",
           surface = "y",
           subtitle_text = paste("Data source: ", unique(.x$data_source))
         ))
[[1]]

Version Author Date
88f7356 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22
768ae83 jens-daniel-mueller 2021-07-22
78fe930 jens-daniel-mueller 2021-07-21
bef1b71 jens-daniel-mueller 2021-07-09

[[2]]

Version Author Date
88f7356 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22
768ae83 jens-daniel-mueller 2021-07-22
78fe930 jens-daniel-mueller 2021-07-21
bef1b71 jens-daniel-mueller 2021-07-09

4.3 Average model dcant

Mean and sd are calculated across 10 models for Cant in each grid cell (XYZ), basin and era combination. Calculations are performed for all cant values vs positive values only.

4.3.1 Deep water averaging

dcant_average <- m_dcant_3d_average(dcant)
dcant_average <- m_cut_gamma(dcant_average, "gamma")

# split data set for individual predictor contributions and total cant
dcant_predictor_3d <- dcant_average %>% 
  select(-c("dcant", "dcant_pos", ends_with("_sd")))

dcant_average <- dcant_average %>%
  select(
    lon,
    lat,
    depth,
    basin_AIP,
    data_source,
    dcant,
    dcant_pos,
    dcant_sd,
    dcant_pos_sd,
    gamma,
    gamma_sd,
    gamma_slab
  )
dcant_average %>%
  group_split(data_source) %>%
  # head(1) %>% 
  map(~ p_map_climatology(
    df = .x,
    var = "dcant_pos",
    subtitle_text = paste("data_source:", unique(.x$data_source))
  ))
[[1]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
bef1b71 jens-daniel-mueller 2021-07-09

[[2]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
bef1b71 jens-daniel-mueller 2021-07-09
dcant_average %>%
  group_split(data_source) %>%
  # head(1) %>% 
  map(~ p_section_climatology_regular(
    df = .x,
    surface = "n",
    var = "dcant_pos",
    subtitle_text = paste("data_source:", unique(.x$data_source))
  ))
[[1]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
bef1b71 jens-daniel-mueller 2021-07-09

[[2]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
bef1b71 jens-daniel-mueller 2021-07-09

4.3.2 Surface water averaging

The averaging function is also applied to the surface data, although only one value per grid cell was mapped, to ensure consistency with the deep water values.

dcant_surface_average <-
  m_dcant_3d_average(dcant_surface)

dcant_surface_average <- m_cut_gamma(dcant_surface_average, "gamma")
rm(dcant_surface)

4.4 Join surface and deep water

dcant_3d <-
  full_join(
    dcant_average %>% mutate(method = "eMLR"),
    dcant_surface_average %>%  mutate(method = "surface")
  )

rm(dcant_surface_average, dcant_average)

4.5 Zonal sections

For each basin and era combination, the zonal mean dcant is calculated, again for all vs positive only values. Likewise, sd is calculated for the averaging of the mean basin fields.

dcant_zonal <- dcant_3d %>%
  group_by(data_source) %>%
  nest() %>%
  mutate(zonal = map(.x = data, ~m_zonal_mean_sd(.x))) %>%
  select(-data) %>%
  unnest(zonal)

dcant_zonal <- m_cut_gamma(dcant_zonal,
                           "gamma_mean")

dcant_zonal_method <- dcant_3d %>%
  group_by(data_source, method) %>%
  nest() %>%
  mutate(zonal = map(.x = data, ~m_zonal_mean_sd(.x))) %>%
  select(-data) %>%
  unnest(zonal)

dcant_zonal_method <- m_cut_gamma(dcant_zonal_method,
                                   "gamma_mean")

4.6 Mean dcant sections by coefficient

For each basin and era combination, the zonal mean is calculated for the term of each predictor.

dcant_predictor_zonal <- dcant_predictor_3d %>%
  group_by(data_source) %>%
  nest() %>%
  mutate(zonal = map(.x = data, ~m_zonal_mean_sd(.x))) %>%
  select(-data) %>%
  unnest(zonal)

dcant_predictor_zonal <-
  m_cut_gamma(dcant_predictor_zonal, "gamma_mean")

4.7 Inventory calculation

To calculate dcant column inventories, we:

  1. Convert dcant concentrations to volumetric units
  2. Multiply layer thickness with volumetric dcant concentration to get a layer inventory
  3. For each horizontal grid cell and era, sum dcant layer inventories for different inventory depths (100, 500, 1000, 3000, 10^{4} m)

Step 2 is performed separately for all dcant and positive dcant values only.

4.7.1 Full water column

dcant_inv <- dcant_3d %>%
  group_by(data_source) %>%
  nest() %>%
  mutate(inv = map(.x = data, ~m_dcant_inv(.x))) %>%
  select(-data) %>%
  unnest(inv)

p_map_cant_inv(df = dcant_inv,
               var = "dcant_pos",
               subtitle_text = "for predefined integration depths") +
  facet_grid(inv_depth ~ data_source)

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
768ae83 jens-daniel-mueller 2021-07-22
78fe930 jens-daniel-mueller 2021-07-21
971ce87 jens-daniel-mueller 2021-07-13
bef1b71 jens-daniel-mueller 2021-07-09

4.7.2 Surface layer

dcant_inv_surface <- dcant_3d %>%
  filter(method == "surface") %>% 
  group_by(data_source) %>%
  nest() %>%
  mutate(inv = map(.x = data, ~m_dcant_inv(.x))) %>%
  select(-data) %>%
  unnest(inv)

p_map_cant_inv(df = dcant_inv_surface %>% 
                 filter(inv_depth < 1000),
               var = "dcant_pos",
               subtitle_text = "for predefined integration depths",
               breaks = c(-Inf,seq(0,4,0.5), Inf)) +
  facet_grid(inv_depth ~ data_source)

Version Author Date
88f7356 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22

4.7.3 eMLR only

dcant_inv <- full_join(
  dcant_inv %>% rename(dcant_total = dcant,
                       dcant_pos_total = dcant_pos),
  dcant_inv_surface %>% rename(dcant_surface = dcant,
                               dcant_pos_surface = dcant_pos)
)

dcant_inv <- dcant_inv %>%
  mutate(dcant_eMLR = dcant_total -
           replace(dcant_surface, is.na(dcant_surface), 0),
         dcant_pos_eMLR = dcant_pos_total -
           replace(dcant_pos_surface, is.na(dcant_pos_surface), 0))

dcant_inv_all <- dcant_inv %>% 
  select(-starts_with("dcant_pos")) %>% 
  pivot_longer(starts_with("dcant_"),
               names_to = "method",
               names_prefix = "dcant_",
               values_to = "dcant")

dcant_inv_pos <- dcant_inv %>% 
  select(data_source, lon, lat, basin_AIP, inv_depth,
         starts_with("dcant_pos_")) %>% 
  pivot_longer(starts_with("dcant_pos_"),
               names_to = "method",
               names_prefix = "dcant_pos_",
               values_to = "dcant_pos")

dcant_inv <- full_join(
  dcant_inv_all,
  dcant_inv_pos
)

rm(dcant_inv_all, dcant_inv_pos, dcant_inv_surface)

dcant_inv %>%
  group_by(inv_depth) %>%
  group_split() %>% 
  # tail(1) %>%
  map(
    ~ p_map_cant_inv(df = .x,
                     var = "dcant",
                     subtitle_text = paste("Integration depth",
                                           unique(.x$inv_depth))) +
      facet_grid(method ~ data_source)
  )
[[1]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22

[[2]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22

[[3]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22

[[4]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22

[[5]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22

4.8 Budgets

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

molC_to_PgC <- 12*1e-15

dcant_budget <- dcant_inv %>% 
  mutate(surface_area = earth_surf(lat, lon),
         dcant_grid = dcant*surface_area*molC_to_PgC,
         dcant_pos_grid = dcant_pos*surface_area*molC_to_PgC)
dcant_budget_global <- dcant_budget %>%
  group_by(data_source, inv_depth, method) %>% 
  summarise(dcant = sum(dcant_grid, na.rm = TRUE),
            dcant = round(dcant,3),
            dcant_pos = sum(dcant_pos_grid, na.rm = TRUE),
            dcant_pos = round(dcant_pos,3)) %>% 
  ungroup() %>% 
  pivot_longer(cols = dcant:dcant_pos,
               names_to = "estimate",
               values_to = "value")

dcant_budget_global %>%
  filter(inv_depth == params_global$inventory_depth_standard,
         method == "total") %>%
  ggplot(aes(estimate, value)) +
  scale_fill_brewer(palette = "Dark2") +
  geom_col() +
  facet_grid(~data_source)

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22
768ae83 jens-daniel-mueller 2021-07-22
78fe930 jens-daniel-mueller 2021-07-21
bef1b71 jens-daniel-mueller 2021-07-09
dcant_budget_global %>%
  filter(inv_depth == params_global$inventory_depth_standard,
         method %in% c("surface", "eMLR")) %>%
  ggplot(aes(estimate, value, fill=method)) +
  scale_fill_brewer(palette = "Dark2") +
  geom_col() +
  facet_grid(.~data_source)

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22
dcant_budget_basin_AIP <- dcant_budget %>% 
  group_by(basin_AIP, data_source, method, inv_depth) %>% 
  summarise(dcant = sum(dcant_grid, na.rm = TRUE),
            dcant = round(dcant,3),
            dcant_pos = sum(dcant_pos_grid, na.rm = TRUE),
            dcant_pos = round(dcant_pos,3)) %>% 
  ungroup() %>% 
  pivot_longer(cols = dcant:dcant_pos,
               names_to = "estimate",
               values_to = "value")

dcant_budget_basin_AIP %>%
  filter(inv_depth == params_global$inventory_depth_standard,
         method %in% c("surface", "eMLR")) %>%
  ggplot(aes(basin_AIP, value, fill=method)) +
  scale_fill_brewer(palette = "Dark2") +
  geom_col() +
  facet_grid(estimate~data_source)

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22
768ae83 jens-daniel-mueller 2021-07-22
78fe930 jens-daniel-mueller 2021-07-21
bef1b71 jens-daniel-mueller 2021-07-09
dcant_budget_basin_MLR <-
  full_join(dcant_budget, basinmask) %>% 
  group_by(basin, MLR_basins, data_source, method, inv_depth) %>% 
  summarise(dcant = sum(dcant_grid, na.rm = TRUE),
            dcant = round(dcant,3),
            dcant_pos = sum(dcant_pos_grid, na.rm = TRUE),
            dcant_pos = round(dcant_pos,3)) %>% 
  ungroup() %>% 
  pivot_longer(cols = dcant:dcant_pos,
               names_to = "estimate",
               values_to = "value")

dcant_budget_basin_MLR %>%
  filter(inv_depth == params_global$inventory_depth_standard,
         method %in% c("surface", "eMLR")) %>%
  group_by(MLR_basins) %>%
  group_split() %>%
  # head(1) %>%
  map(
    ~ ggplot(data = .x,
             aes(basin, value, fill = method)) +
      scale_fill_brewer(palette = "Dark2") +
      geom_col() +
      facet_grid(estimate ~ data_source) +
      labs(title = paste("MLR_basins:", unique(.x$MLR_basins)))
  )
[[1]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22
768ae83 jens-daniel-mueller 2021-07-22
78fe930 jens-daniel-mueller 2021-07-21
bef1b71 jens-daniel-mueller 2021-07-09

[[2]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22

[[3]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22

[[4]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22

[[5]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22

[[6]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22
dcant_budget_lat_grid <- 
  dcant_budget %>% 
  m_grid_horizontal_coarse() %>%
  group_by(lat_grid, basin_AIP, data_source, method, inv_depth) %>% 
  summarise(dcant = sum(dcant_grid, na.rm = TRUE),
            dcant = round(dcant,3),
            dcant_pos = sum(dcant_pos_grid, na.rm = TRUE),
            dcant_pos = round(dcant_pos,3)) %>% 
  ungroup() %>% 
  pivot_longer(cols = dcant:dcant_pos,
               names_to = "estimate",
               values_to = "value")

dcant_budget_lat_grid %>%
  filter(inv_depth == params_global$inventory_depth_standard,
         method %in% c("surface", "eMLR")) %>%
  group_by(basin_AIP) %>%
  group_split() %>%
  # head(1) %>%
  map(
    ~ ggplot(data = .x,
             aes(lat_grid, value, fill = method)) +
      scale_fill_brewer(palette = "Dark2") +
      geom_col() +
      coord_flip() +
      facet_grid(estimate ~ data_source) +
      labs(title = paste("MLR_basins:", unique(.x$basin_AIP)))
  )
[[1]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
c75b2a0 jens-daniel-mueller 2021-07-22
768ae83 jens-daniel-mueller 2021-07-22
78fe930 jens-daniel-mueller 2021-07-21
bef1b71 jens-daniel-mueller 2021-07-09

[[2]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
f3c0d7a jens-daniel-mueller 2021-07-22

[[3]]

Version Author Date
a53656d jens-daniel-mueller 2021-08-03
88f7356 jens-daniel-mueller 2021-08-02
d759279 jens-daniel-mueller 2021-08-02
127b801 jens-daniel-mueller 2021-07-24
912d90e jens-daniel-mueller 2021-07-23
2477316 jens-daniel-mueller 2021-07-23
c9ccc00 jens-daniel-mueller 2021-07-22
f3c0d7a jens-daniel-mueller 2021-07-22

5 Write csv

dcant_3d %>%
  write_csv(paste(path_version_data,
                  "dcant_3d.csv", sep = ""))

dcant_predictor_3d %>%
  write_csv(paste(path_version_data,
                  "dcant_predictor_3d.csv", sep = ""))

dcant_zonal %>%
  write_csv(paste(path_version_data,
                  "dcant_zonal.csv", sep = ""))

dcant_zonal_method %>%
  write_csv(paste(path_version_data,
                  "dcant_zonal_method.csv", sep = ""))

dcant_predictor_zonal %>%
  write_csv(paste(path_version_data,
                  "dcant_predictor_zonal.csv", sep = ""))

dcant_inv %>%
  filter(method == "total") %>% 
  select(-method) %>% 
  write_csv(paste(path_version_data,
                  "dcant_inv.csv", sep = ""))

dcant_inv %>%
  filter(method != "total") %>% 
  write_csv(paste(path_version_data,
                  "dcant_inv_method.csv", sep = ""))

dcant_budget_global %>%
  write_csv(paste(path_version_data,
                  "dcant_budget_global.csv", sep = ""))

dcant_budget_basin_AIP %>%
  write_csv(paste(path_version_data,
                  "dcant_budget_basin_AIP.csv", sep = ""))

dcant_budget_basin_MLR %>%
  write_csv(paste(path_version_data,
                  "dcant_budget_basin_MLR.csv", sep = ""))

dcant_budget_lat_grid %>%
  write_csv(paste(path_version_data,
                  "dcant_budget_lat_grid.csv", sep = ""))

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

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

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

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

other attached packages:
 [1] marelac_2.1.10  shape_1.4.5     seacarb_3.2.14  oce_1.2-0      
 [5] gsw_1.0-5       testthat_2.3.2  ggforce_0.3.3   metR_0.9.0     
 [9] scico_1.2.0     patchwork_1.1.1 collapse_1.5.0  forcats_0.5.0  
[13] stringr_1.4.0   dplyr_1.0.5     purrr_0.3.4     readr_1.4.0    
[17] tidyr_1.1.2     tibble_3.0.4    ggplot2_3.3.3   tidyverse_1.3.0
[21] workflowr_1.6.2

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