Last updated: 2021-07-05

Checks: 7 0

Knit directory: emlr_obs_analysis/

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(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 c330a09. 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/Gruber_2019_comparison/
    Ignored:    output/publication/

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/anomalous_changes.Rmd) and HTML (docs/anomalous_changes.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 bf6bd95 jens-daniel-mueller 2021-07-05 Build site.
Rmd e189a01 jens-daniel-mueller 2021-07-05 test gap filled output
html f07d4a3 jens-daniel-mueller 2021-07-05 Build site.
Rmd 1d4194a jens-daniel-mueller 2021-07-05 test gap filled output
html 8f3f68d jens-daniel-mueller 2021-07-01 Build site.
Rmd 15d6c34 jens-daniel-mueller 2021-07-01 pre- vs all post-2000 data cases added
html 6953a59 jens-daniel-mueller 2021-06-30 Build site.
Rmd 946faca jens-daniel-mueller 2021-06-30 added zero rarefication results
html f5fc274 jens-daniel-mueller 2021-06-30 Build site.
Rmd 13e5163 jens-daniel-mueller 2021-06-30 plotted vif max and rarefication results
html d03fc2d jens-daniel-mueller 2021-06-30 Build site.
Rmd df977d3 jens-daniel-mueller 2021-06-30 plotted vif max and rarefication results
html 8198590 jens-daniel-mueller 2021-06-30 Build site.
Rmd 2c23169 jens-daniel-mueller 2021-06-30 plotted vif max and rarefication results
Rmd 4872385 jens-daniel-mueller 2021-06-30 manual commit
html ea89b3a jens-daniel-mueller 2021-06-30 Build site.
Rmd 1b7246d jens-daniel-mueller 2021-06-30 additive era budgets
html 00f2062 jens-daniel-mueller 2021-06-30 Build site.
Rmd f20bc36 jens-daniel-mueller 2021-06-30 revised basin era analysis
html 44ebe55 jens-daniel-mueller 2021-06-30 Build site.
Rmd 58f1510 jens-daniel-mueller 2021-06-30 rebuild with new emlr runs
html bd59fee jens-daniel-mueller 2021-06-24 Build site.
Rmd 3f83481 jens-daniel-mueller 2021-06-24 correct section plots
html 9e654c6 jens-daniel-mueller 2021-06-24 Build site.
Rmd 25bb31b jens-daniel-mueller 2021-06-24 correct section plots
html 7c82c58 jens-daniel-mueller 2021-06-24 Build site.
Rmd c551d55 jens-daniel-mueller 2021-06-24 bias correlation for column inventory
html ea6d3bb jens-daniel-mueller 2021-06-24 Build site.
Rmd e09bf25 jens-daniel-mueller 2021-06-24 new bias labels
html 3a63509 jens-daniel-mueller 2021-06-24 Build site.
Rmd 5d72d3c jens-daniel-mueller 2021-06-24 new bias labels
html e12c681 jens-daniel-mueller 2021-06-23 Build site.
Rmd 7884e68 jens-daniel-mueller 2021-06-23 new bias labels
html 7a50288 jens-daniel-mueller 2021-06-23 Build site.
Rmd 26c6754 jens-daniel-mueller 2021-06-23 new bias labels
html 4d6ce3e jens-daniel-mueller 2021-06-23 Build site.
Rmd 47093ed jens-daniel-mueller 2021-06-23 added budget plots
html 1916d70 jens-daniel-mueller 2021-06-23 Build site.
Rmd 03f3ec3 jens-daniel-mueller 2021-06-23 revised zonal section plots
html d285c6f jens-daniel-mueller 2021-06-23 Build site.
Rmd 8b4c6ee jens-daniel-mueller 2021-06-23 revised zonal section plots
html 47a9f1f jens-daniel-mueller 2021-06-23 Build site.
Rmd e2523c0 jens-daniel-mueller 2021-06-23 revised zonal section plots
html f415eba jens-daniel-mueller 2021-06-23 Build site.
Rmd 01d036b jens-daniel-mueller 2021-06-23 revised zonal section plots
html 909da16 jens-daniel-mueller 2021-06-23 Build site.
Rmd 092f3af jens-daniel-mueller 2021-06-23 include zonal section plots
html ba685e0 jens-daniel-mueller 2021-06-23 Build site.
Rmd b66210a jens-daniel-mueller 2021-06-23 include zonal section plots
html 45279c2 jens-daniel-mueller 2021-06-23 Build site.
Rmd e097035 jens-daniel-mueller 2021-06-23 plot anomalous changes for all cases
html 8b2e4d3 jens-daniel-mueller 2021-06-22 Build site.
html 2d9fe37 jens-daniel-mueller 2021-06-22 Build site.
Rmd 8117a69 jens-daniel-mueller 2021-06-22 test build

1 Data preparation

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

# Version_IDs <- Version_IDs[1:4]

1.1 Read files

Following sensitivity cases were considered:

for (i_Version_IDs in Version_IDs) {
  # i_Version_IDs <- Version_IDs[1]
  
  print(i_Version_IDs)
  
  path_version_data     <-
  paste(path_observations,
        i_Version_IDs,
        "/data/",
        sep = "")
  
  # read inventory file
  cant_inv <-
    read_csv(paste(path_version_data,
                   "anom_cant_mod_inv_bias.csv",
                   sep = ""))
  
  cant_inv <- cant_inv %>% 
    mutate(Version_ID = i_Version_IDs)
  
  # read section file
  cant_section <-
    read_csv(paste(path_version_data,
                   "anom_cant_mod_section_bias.csv",
                   sep = ""))
  
  cant_section <- cant_section %>% 
    mutate(Version_ID = i_Version_IDs)
  
  # read budget file
  cant_budget <-
    read_csv(paste(path_version_data,
                   "anom_cant_mod_inv_budget.csv",
                   sep = ""))
  
  cant_budget <- cant_budget %>% 
    mutate(Version_ID = i_Version_IDs)
  
  # read local parametrization files
  params_local <-
    read_rds(paste(path_version_data,
                   "params_local.rds",
                   sep = ""))
  
  params_local <- bind_cols(
    Version_ID = i_Version_IDs,
    MLR_basins = params_local$MLR_basins,
    rarefication = params_local$rarefication,
    rarefication_threshold = params_local$rarefication_threshold,
    vif_max = params_local$vif_max
  )
  
  cant_inv <- full_join(cant_inv, params_local)
  cant_section <- full_join(cant_section, params_local)
  cant_budget <- full_join(cant_budget, params_local)

  # read tref file
  tref <- read_csv(paste(path_version_data,
                         "tref.csv",
                         sep = ""))
  
  duration <- sort(tref$median_year)[2] - sort(tref$median_year)[1]
  eras <- paste0(sort(tref$median_year)[1],"-", sort(tref$median_year)[2])
  
  cant_inv <- cant_inv %>% 
    mutate(duration = duration,
           eras = eras)
  
  cant_section <- cant_section %>%
    mutate(duration = duration,
           eras = eras)
  
  cant_budget <- cant_budget %>%
    mutate(duration = duration,
           eras = eras)
  
  # bind inv files
  if (exists("cant_inv_all")) {
    cant_inv_all <- bind_rows(cant_inv_all, cant_inv)
  }
  
  if (!exists("cant_inv_all")) {
    cant_inv_all <- cant_inv
  }

  # bind section files
  if (exists("cant_section_all")) {
    cant_section_all <- bind_rows(cant_section_all, cant_section)
  }
  
  if (!exists("cant_section_all")) {
    cant_section_all <- cant_section
  }
  
  # bind budget files
  if (exists("cant_budget_all")) {
    cant_budget_all <- bind_rows(cant_budget_all, cant_budget)
  }
  
  if (!exists("cant_budget_all")) {
    cant_budget_all <- cant_budget
  }
  
  
}
[1] "v_301"
[1] "v_302"
[1] "v_303"
[1] "v_304"
[1] "v_305"
[1] "v_306"
[1] "v_307"
[1] "v_308"
[1] "v_309"
[1] "v_310"
[1] "v_311"
[1] "v_312"
[1] "v_313"
[1] "v_314"
[1] "v_315"
[1] "v_316"
[1] "v_317"
[1] "v_318"
[1] "v_319"
[1] "v_320"
[1] "v_321"
[1] "v_322"
[1] "v_323"
rm(cant_inv, cant_section, cant_budget)

1.1.1 Format

cant_inv_all_long <- cant_inv_all %>%
  pivot_longer(emlr_anom:nss_projection,
               names_to = "estimate",
               values_to = "delta_cant_offset")


cant_section_all_long <- cant_section_all %>%
  pivot_longer(emlr_anom:nss_projection,
               names_to = "estimate",
               values_to = "delta_cant_offset")

# unique(cant_inv_all$Version_ID)

2 Eras vs basin split

Here we compare the impact of the basin separation approach on the anomaly detection, separately for each compared eras.

cant_inv_all_sub <- cant_inv_all %>% 
    filter(rarefication == "none")

cant_inv_all_long_sub <- cant_inv_all_long %>% 
    filter(rarefication == "none")

cant_section_all_sub <- cant_section_all %>% 
    filter(rarefication == "none")

cant_section_all_long_sub <- cant_section_all_long %>% 
    filter(rarefication == "none")

cant_budget_all_sub <- cant_budget_all %>% 
    filter(rarefication == "none")

2.1 Column inventories

2.1.1 Maps

cant_inv_all_long_sub %>%
  group_split(eras) %>%
  # head(1) %>%
  map(
    ~ p_map_cant_inv_offset(
      df = .x,
      var = "delta_cant_offset",
      subtitle_text = paste("Eras:", unique(.x$eras)),
      breaks = seq(-8,8,1)
    ) +
      facet_grid(MLR_basins ~ estimate) +
      theme(axis.text = element_blank(),
            axis.ticks = element_blank())
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8198590 jens-daniel-mueller 2021-06-30

[[2]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[3]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[4]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01

2.1.2 Bias correlation

axis_limit <- 10

cant_inv_all_sub %>%
  group_split(eras) %>%
  # head(1) %>%
  map(
    ~ ggplot(data = .x, aes(emlr_bias, emlr_anom)) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0) +
      geom_bin2d(binwidth = 1) +
      scale_fill_viridis_c(trans = "log10") +
      coord_equal(
        xlim = c(-axis_limit, axis_limit),
        ylim = c(-axis_limit, axis_limit)
      ) +
      labs(title = paste("Eras:", unique(.x$eras))) +
      facet_grid(MLR_basins ~ basin_AIP)
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8198590 jens-daniel-mueller 2021-06-30

[[2]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[3]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[4]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30
cant_inv_all_sub %>%
  group_split(eras) %>%
  # head(1) %>% 
  map(
    ~ ggplot(data = .x, aes(emlr_anom, nss_mod_truth)) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0) +
      geom_bin2d(binwidth = 1) +
      scale_fill_viridis_c(trans = "log10") +
      coord_equal(
        xlim = c(-axis_limit, axis_limit),
        ylim = c(-axis_limit, axis_limit)
      ) +
      labs(title = paste("Eras:", unique(.x$eras))) +
      facet_grid(MLR_basins ~ basin_AIP)
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[2]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[3]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[4]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30
cant_inv_all_sub %>%
  group_split(eras) %>%
  # head(1) %>% 
  map(
    ~ ggplot(data = .x, aes(nss_mod_truth, nss_projection)) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0) +
      geom_bin2d(binwidth = 1) +
      scale_fill_viridis_c(trans = "log10") +
      coord_equal(
        xlim = c(-axis_limit, axis_limit),
        ylim = c(-axis_limit, axis_limit)
      ) +
      labs(title = paste("Eras:", unique(.x$eras))) +
      facet_grid(MLR_basins ~ basin_AIP)
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[2]]

Version Author Date
8f3f68d jens-daniel-mueller 2021-07-01

[[3]]

Version Author Date
8f3f68d jens-daniel-mueller 2021-07-01

[[4]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01

2.2 Zonal sections

2.2.1 Sections

cant_section_all_long_sub %>%
  group_split(eras, MLR_basins, estimate) %>%
  # head(1) %>%
  map(
    ~ p_section_zonal(
      df = .x,
      var = "delta_cant_offset",
      plot_slabs = "n",
      col = "divergent",
      subtitle_text = paste("Eras:", unique(.x$eras),
                            "| MLR Basins:", unique(.x$MLR_basins),
                            "| Estimate:", unique(.x$estimate)),
      breaks = c(-Inf,seq(-8,8,1), Inf)
    )
  )
legend_title <- expression(atop(Delta * C[ant, pos],
                               (mu * mol ~ kg ^ {
                                 -1
                               })))

cant_section_all_long_sub %>%
  group_split(eras, basin_AIP) %>% 
  # head(1) %>%
  map(
    ~ ggplot(data = .x) +
      geom_contour_filled(aes(lat, depth, z = delta_cant_offset),
                          breaks =c(-Inf,seq(-8,8,1), Inf)) +
      scale_fill_scico_d(
        palette = "vik",
        drop = FALSE,
        name = legend_title
      ) +
      guides(fill = guide_colorsteps(barheight = unit(8, "cm"),
                                     show.limits = TRUE)) +
      # scale_y_sqrt() +
      scale_y_continuous(trans = trans_reverser("sqrt"),
                         breaks = c(100,500,seq(1000,5000,1000))) +
      #scale_y_reverse() +
      scale_x_continuous(breaks = seq(-100, 100, 40),
                         limits = c(-85, 85)) +
      facet_grid(MLR_basins ~ estimate) +
      coord_cartesian(expand = 0) +
      labs(title = paste("Eras", unique(.x$eras),
                         "| Basin:", unique(.x$basin_AIP)))
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8198590 jens-daniel-mueller 2021-06-30

[[2]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8198590 jens-daniel-mueller 2021-06-30

[[3]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8198590 jens-daniel-mueller 2021-06-30

[[4]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[5]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[6]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[7]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[8]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[9]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[10]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01

[[11]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01

[[12]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01

2.2.2 Bias correlation

axis_limit <- 20

cant_section_all_sub %>%
  group_split(eras) %>%
  # head(1) %>%
  map(
    ~ ggplot(data = .x, aes(emlr_bias, emlr_anom)) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0) +
      geom_bin2d(binwidth = 1) +
      scale_fill_viridis_c(trans = "log10") +
      coord_equal(
        xlim = c(-axis_limit, axis_limit),
        ylim = c(-axis_limit, axis_limit)
      ) +
      labs(title = paste("Eras:", unique(.x$eras))) +
      facet_grid(MLR_basins ~ basin_AIP)
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8198590 jens-daniel-mueller 2021-06-30

[[2]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[3]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[4]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30
cant_section_all_sub %>%
  group_split(eras) %>%
  # head(1) %>% 
  map(
    ~ ggplot(data = .x, aes(emlr_anom, nss_mod_truth)) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0) +
      geom_bin2d(binwidth = 1) +
      scale_fill_viridis_c(trans = "log10") +
      coord_equal(
        xlim = c(-axis_limit, axis_limit),
        ylim = c(-axis_limit, axis_limit)
      ) +
      labs(title = paste("Eras:", unique(.x$eras))) +
      facet_grid(MLR_basins ~ basin_AIP)
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[2]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[3]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[4]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30
cant_section_all_sub %>%
  group_split(eras) %>%
  # head(1) %>% 
  map(
    ~ ggplot(data = .x, aes(nss_mod_truth, nss_projection)) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0) +
      geom_bin2d(binwidth = 1) +
      scale_fill_viridis_c(trans = "log10") +
      coord_equal(
        xlim = c(-axis_limit, axis_limit),
        ylim = c(-axis_limit, axis_limit)
      ) +
      labs(title = paste("Eras:", unique(.x$eras))) +
      facet_grid(MLR_basins ~ basin_AIP)
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

[[2]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01

[[3]]

Version Author Date
8f3f68d jens-daniel-mueller 2021-07-01

[[4]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01

2.3 Budgets

2.3.1 Regional

cant_budget_all_sub %>%
  filter(inv_depth == params_global$inventory_depth_standard) %>% 
  ggplot(aes(estimate, cant_pos_total, fill = basin_AIP)) +
  scale_fill_brewer(palette = "PuBuGn") +
  geom_col(col = "black") +
  facet_grid(MLR_basins ~ eras) +
  theme(axis.text.x = element_text(angle = 90))

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8f3f68d jens-daniel-mueller 2021-07-01
8198590 jens-daniel-mueller 2021-06-30

2.3.2 Era additive

cant_budget_all_sub_wide <- cant_budget_all_sub %>%
  filter(inv_depth == params_global$inventory_depth_standard) %>% 
  select(-c(duration, Version_ID)) %>% 
  pivot_wider(names_from = eras,
              values_from = cant_pos_total)

cant_budget_all_sub_wide <- cant_budget_all_sub_wide %>%
  mutate(`1994-2014 (sum)` = `1994-2005` + `2005-2014`)

cant_budget_all_sub_long <- cant_budget_all_sub_wide %>%
  select(-c(`1994-2005`, `2005-2014`)) %>% 
  pivot_longer(c(`1994-2014`, `1994-2014 (sum)`),
               names_to = "eras",
               values_to = "cant_pos_total")

cant_budget_all_sub_long %>% 
  ggplot(aes(eras, cant_pos_total, fill = basin_AIP)) +
  scale_fill_brewer(palette = "PuBuGn") +
  geom_col(col = "black") +
  facet_grid(MLR_basins ~ estimate) +
  theme(axis.text.x = element_text(angle = 90))

Version Author Date
bf6bd95 jens-daniel-mueller 2021-07-05
f07d4a3 jens-daniel-mueller 2021-07-05
8198590 jens-daniel-mueller 2021-06-30

3 Rarefication and VIF

cant_inv_all_sub <- cant_inv_all %>%
  filter(rarefication == "coarse_grid" |
           Version_ID == "v_202") %>%
  mutate(
    rarefication_threshold = as.character(rarefication_threshold),
    rarefication_threshold = if_else(rarefication == "none",
                                     "none",
                                     rarefication_threshold),
    rarefication_threshold = if_else(rarefication_threshold == "5",
                                     "05",
                                     rarefication_threshold)
  )

cant_inv_all_long_sub <- cant_inv_all_long  %>%
  filter(rarefication == "coarse_grid" |
           Version_ID == "v_202") %>%
  mutate(
    rarefication_threshold = as.character(rarefication_threshold),
    rarefication_threshold = if_else(rarefication == "none",
                                     "none",
                                     rarefication_threshold),
    rarefication_threshold = if_else(rarefication_threshold == "5",
                                     "05",
                                     rarefication_threshold)
  )

cant_section_all_sub <- cant_section_all %>% 
  filter(rarefication == "coarse_grid" |
           Version_ID == "v_202") %>%
  mutate(
    rarefication_threshold = as.character(rarefication_threshold),
    rarefication_threshold = if_else(rarefication == "none",
                                     "none",
                                     rarefication_threshold),
    rarefication_threshold = if_else(rarefication_threshold == "5",
                                     "05",
                                     rarefication_threshold)
  )

cant_section_all_long_sub <- cant_section_all_long %>% 
  filter(rarefication == "coarse_grid" |
           Version_ID == "v_202") %>%
  mutate(
    rarefication_threshold = as.character(rarefication_threshold),
    rarefication_threshold = if_else(rarefication == "none",
                                     "none",
                                     rarefication_threshold),
    rarefication_threshold = if_else(rarefication_threshold == "5",
                                     "05",
                                     rarefication_threshold)
  )

cant_budget_all_sub <- cant_budget_all %>% 
  filter(rarefication == "coarse_grid" |
           Version_ID == "v_202") %>%
  mutate(
    rarefication_threshold = as.character(rarefication_threshold),
    rarefication_threshold = if_else(rarefication == "none",
                                     "none",
                                     rarefication_threshold),
    rarefication_threshold = if_else(rarefication_threshold == "5",
                                     "05",
                                     rarefication_threshold)
  )

3.1 Column inventories

3.1.1 Maps rarefication

cant_inv_all_long_sub %>%
  filter(vif_max == 1000) %>% 
  group_split(eras) %>%
  # head(1) %>%
  map(
    ~ p_map_cant_inv_offset(
      df = .x,
      var = "delta_cant_offset",
      # col = "divergent",
      subtitle_text = paste("Rarefication test | Eras:", unique(.x$eras)),
      breaks = seq(-8,8,1)
    ) +
      facet_grid(rarefication_threshold ~ estimate) +
      theme(axis.text = element_blank(),
            axis.ticks = element_blank())
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
6953a59 jens-daniel-mueller 2021-06-30
8198590 jens-daniel-mueller 2021-06-30

3.1.2 Maps VIF

cant_inv_all_long_sub %>%
  filter(rarefication_threshold == 10) %>% 
  group_split(eras) %>%
  # head(1) %>%
  map(
    ~ p_map_cant_inv_offset(
      df = .x,
      var = "delta_cant_offset",
      # col = "divergent",
      subtitle_text = paste("VIF test | Eras:", unique(.x$eras)),
      breaks = seq(-8,8,1)
    ) +
      facet_grid(vif_max ~ estimate) +
      theme(axis.text = element_blank(),
            axis.ticks = element_blank())
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
d03fc2d jens-daniel-mueller 2021-06-30
8198590 jens-daniel-mueller 2021-06-30

3.1.3 Bias correlation

axis_limit <- 10

cant_inv_all_sub %>%
  filter(vif_max == 1000) %>% 
  group_split(eras) %>%
  # head(1) %>%
  map(
    ~ ggplot(data = .x, aes(emlr_bias, emlr_anom)) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0) +
      geom_bin2d(binwidth = 1) +
      scale_fill_viridis_c(trans = "log10") +
      coord_equal(
        xlim = c(-axis_limit, axis_limit),
        ylim = c(-axis_limit, axis_limit)
      ) +
      labs(title = paste("Eras:", unique(.x$eras))) +
      facet_grid(rarefication_threshold ~ basin_AIP)
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
6953a59 jens-daniel-mueller 2021-06-30
8198590 jens-daniel-mueller 2021-06-30
cant_inv_all_sub %>%
  filter(vif_max == 1000) %>% 
  group_split(eras) %>%
  # head(1) %>% 
  map(
    ~ ggplot(data = .x, aes(emlr_anom, nss_mod_truth)) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0) +
      geom_bin2d(binwidth = 1) +
      scale_fill_viridis_c(trans = "log10") +
      coord_equal(
        xlim = c(-axis_limit, axis_limit),
        ylim = c(-axis_limit, axis_limit)
      ) +
      labs(title = paste("Eras:", unique(.x$eras))) +
      facet_grid(rarefication_threshold ~ basin_AIP)
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
6953a59 jens-daniel-mueller 2021-06-30
8198590 jens-daniel-mueller 2021-06-30
cant_inv_all_sub %>%
  filter(vif_max == 1000) %>% 
  group_split(eras) %>%
  # head(1) %>% 
  map(
    ~ ggplot(data = .x, aes(nss_mod_truth, nss_projection)) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0) +
      geom_bin2d(binwidth = 1) +
      scale_fill_viridis_c(trans = "log10") +
      coord_equal(
        xlim = c(-axis_limit, axis_limit),
        ylim = c(-axis_limit, axis_limit)
      ) +
      labs(title = paste("Eras:", unique(.x$eras))) +
      facet_grid(rarefication_threshold ~ basin_AIP)
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
6953a59 jens-daniel-mueller 2021-06-30
8198590 jens-daniel-mueller 2021-06-30

3.2 Zonal sections

3.2.1 Sections

cant_section_all_long_sub %>%
  filter(vif_max == 1000) %>% 
  group_split(eras, rarefication_threshold, estimate) %>%
  head(1) %>%
  map(
    ~ p_section_zonal(
      df = .x,
      var = "delta_cant_offset",
      plot_slabs = "n",
      col = "divergent",
      subtitle_text = paste("Eras:", unique(.x$eras),
                            "| MLR Basins:", unique(.x$MLR_basins),
                            "| Estimate:", unique(.x$estimate)),
      breaks = c(-Inf,seq(-8,8,1), Inf)
    )
  )
legend_title <- expression(atop(Delta * C[ant, pos],
                               (mu * mol ~ kg ^ {
                                 -1
                               })))

cant_section_all_long_sub %>%
  filter(vif_max == 1000) %>% 
  group_split(eras, basin_AIP) %>% 
  # head(1) %>%
  map(
    ~ ggplot(data = .x) +
      geom_contour_filled(aes(lat, depth, z = delta_cant_offset),
                          breaks =c(-Inf,seq(-8,8,1), Inf)) +
      scale_fill_scico_d(
        palette = "vik",
        drop = FALSE,
        name = legend_title
      ) +
      guides(fill = guide_colorsteps(barheight = unit(8, "cm"),
                                     show.limits = TRUE)) +
      # scale_y_sqrt() +
      scale_y_continuous(trans = trans_reverser("sqrt"),
                         breaks = c(100,500,seq(1000,5000,1000))) +
      #scale_y_reverse() +
      scale_x_continuous(breaks = seq(-100, 100, 40),
                         limits = c(-85, 85)) +
      facet_grid(rarefication_threshold ~ estimate) +
      coord_cartesian(expand = 0) +
      labs(title = paste("Rarefication test | Eras", unique(.x$eras),
                         "| Basin:", unique(.x$basin_AIP)))
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
6953a59 jens-daniel-mueller 2021-06-30
8198590 jens-daniel-mueller 2021-06-30

[[2]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
6953a59 jens-daniel-mueller 2021-06-30
8198590 jens-daniel-mueller 2021-06-30

[[3]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
6953a59 jens-daniel-mueller 2021-06-30
8198590 jens-daniel-mueller 2021-06-30
cant_section_all_long_sub %>%
  filter(rarefication_threshold == 10) %>% 
  group_split(eras, basin_AIP) %>% 
  # head(1) %>%
  map(
    ~ ggplot(data = .x) +
      geom_contour_filled(aes(lat, depth, z = delta_cant_offset),
                          breaks =c(-Inf,seq(-8,8,1), Inf)) +
      scale_fill_scico_d(
        palette = "vik",
        drop = FALSE,
        name = legend_title
      ) +
      guides(fill = guide_colorsteps(barheight = unit(8, "cm"),
                                     show.limits = TRUE)) +
      # scale_y_sqrt() +
      scale_y_continuous(trans = trans_reverser("sqrt"),
                         breaks = c(100,500,seq(1000,5000,1000))) +
      #scale_y_reverse() +
      scale_x_continuous(breaks = seq(-100, 100, 40),
                         limits = c(-85, 85)) +
      facet_grid(vif_max ~ estimate) +
      coord_cartesian(expand = 0) +
      labs(title = paste("VIF test | Eras", unique(.x$eras),
                         "| Basin:", unique(.x$basin_AIP)))
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8198590 jens-daniel-mueller 2021-06-30

[[2]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8198590 jens-daniel-mueller 2021-06-30

[[3]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8198590 jens-daniel-mueller 2021-06-30

3.2.2 Bias correlation

axis_limit <- 20

cant_section_all_sub %>%
  filter(vif_max == 1000) %>% 
  group_split(eras) %>%
  # head(1) %>%
  map(
    ~ ggplot(data = .x, aes(emlr_bias, emlr_anom)) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0) +
      geom_bin2d(binwidth = 1) +
      scale_fill_viridis_c(trans = "log10") +
      coord_equal(
        xlim = c(-axis_limit, axis_limit),
        ylim = c(-axis_limit, axis_limit)
      ) +
      labs(title = paste("Eras:", unique(.x$eras))) +
      facet_grid(rarefication_threshold ~ basin_AIP)
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
6953a59 jens-daniel-mueller 2021-06-30
8198590 jens-daniel-mueller 2021-06-30
cant_section_all_sub %>%
  filter(vif_max == 1000) %>% 
  group_split(eras) %>%
  # head(1) %>% 
  map(
    ~ ggplot(data = .x, aes(emlr_anom, nss_mod_truth)) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0) +
      geom_bin2d(binwidth = 1) +
      scale_fill_viridis_c(trans = "log10") +
      coord_equal(
        xlim = c(-axis_limit, axis_limit),
        ylim = c(-axis_limit, axis_limit)
      ) +
      labs(title = paste("Eras:", unique(.x$eras))) +
      facet_grid(rarefication_threshold ~ basin_AIP)
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
6953a59 jens-daniel-mueller 2021-06-30
8198590 jens-daniel-mueller 2021-06-30
cant_section_all_sub %>%
  filter(vif_max == 1000) %>% 
  group_split(eras) %>%
  # head(1) %>% 
  map(
    ~ ggplot(data = .x, aes(nss_mod_truth, nss_projection)) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0) +
      geom_bin2d(binwidth = 1) +
      scale_fill_viridis_c(trans = "log10") +
      coord_equal(
        xlim = c(-axis_limit, axis_limit),
        ylim = c(-axis_limit, axis_limit)
      ) +
      labs(title = paste("Eras:", unique(.x$eras))) +
      facet_grid(rarefication_threshold ~ basin_AIP)
  )
[[1]]

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
6953a59 jens-daniel-mueller 2021-06-30
8198590 jens-daniel-mueller 2021-06-30

3.3 Budgets

3.3.1 Regional

cant_budget_all_sub %>%
  filter(vif_max == 1000,
         inv_depth == params_global$inventory_depth_standard) %>% 
  ggplot(aes(as.factor(rarefication_threshold), cant_pos_total, fill = basin_AIP)) +
  scale_fill_brewer(palette = "PuBuGn") +
  geom_col(col = "black") +
  facet_grid(estimate ~ eras) +
  theme(axis.text.x = element_text(angle = 90))

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
6953a59 jens-daniel-mueller 2021-06-30
8198590 jens-daniel-mueller 2021-06-30
cant_budget_all_sub %>%
  filter(rarefication_threshold == 10,
         inv_depth == params_global$inventory_depth_standard) %>% 
  ggplot(aes(as.factor(vif_max), cant_pos_total, fill = basin_AIP)) +
  scale_fill_brewer(palette = "PuBuGn") +
  geom_col(col = "black") +
  facet_grid(estimate ~ eras) +
  theme(axis.text.x = element_text(angle = 90))

Version Author Date
f07d4a3 jens-daniel-mueller 2021-07-05
8198590 jens-daniel-mueller 2021-06-30

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] ggforce_0.3.3   marelac_2.1.10  shape_1.4.5     metR_0.9.0     
 [5] scico_1.2.0     patchwork_1.1.1 collapse_1.5.0  forcats_0.5.0  
 [9] stringr_1.4.0   dplyr_1.0.5     purrr_0.3.4     readr_1.4.0    
[13] tidyr_1.1.2     tibble_3.0.4    ggplot2_3.3.3   tidyverse_1.3.0
[17] workflowr_1.6.2

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