Last updated: 2022-07-15

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 afb27ad. 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/publication/

Untracked files:
    Untracked:  figure/

Unstaged changes:
    Modified:   analysis/child/budget_analysis_plot_data.Rmd
    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/basics.Rmd) and HTML (docs/basics.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 b44c72a jens-daniel-mueller 2022-07-03 Build site.
html 6e173bf jens-daniel-mueller 2022-06-30 updated regional budget plots
html f09080e jens-daniel-mueller 2022-06-28 Build site.
Rmd d457610 jens-daniel-mueller 2022-06-28 save figures for publication
html a13a7cf jens-daniel-mueller 2022-06-28 Build site.
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.
Rmd aba19e4 jens-daniel-mueller 2022-05-24 rebuild with multi model assesment
html e09320d jens-daniel-mueller 2022-04-12 Build site.
html 8dca96a jens-daniel-mueller 2022-04-12 Build site.
html acad2e2 jens-daniel-mueller 2022-04-09 Build site.
html c3a6238 jens-daniel-mueller 2022-03-08 Build site.
html 565224d jens-daniel-mueller 2022-02-17 Build site.
Rmd 33422e3 jens-daniel-mueller 2022-02-17 scaled budgets to global coverage
html a246221 jens-daniel-mueller 2022-02-04 Build site.
Rmd 4874b3b jens-daniel-mueller 2022-02-04 new coaverage map
html d2191ad jens-daniel-mueller 2022-02-04 Build site.
Rmd 79a54fe jens-daniel-mueller 2022-02-04 new coaverage map
html accfd87 jens-daniel-mueller 2022-02-01 Build site.
Rmd afc3d83 jens-daniel-mueller 2022-02-01 plot 5 basin map
html de557de jens-daniel-mueller 2022-01-28 Build site.
html 9753eb8 jens-daniel-mueller 2022-01-26 Build site.
html f347cd7 jens-daniel-mueller 2022-01-18 Build site.
Rmd 86b711c jens-daniel-mueller 2022-01-18 plot hemisphere budgets and publication results
html 513630f jens-daniel-mueller 2022-01-18 Build site.
html d7dfc7c jens-daniel-mueller 2022-01-18 Build site.
html 269809e jens-daniel-mueller 2022-01-12 Build site.
html 1696b98 jens-daniel-mueller 2022-01-11 Build site.
html 570e738 jens-daniel-mueller 2022-01-10 Build site.
Rmd d3903e6 jens-daniel-mueller 2022-01-10 rebuild with child docs
html 7e0a36b jens-daniel-mueller 2021-11-21 Build site.
html e505a4b jens-daniel-mueller 2021-11-09 Build site.
html 18f801f jens-daniel-mueller 2021-11-03 Build site.
Rmd 0ff2960 jens-daniel-mueller 2021-11-03 updated plots
html e1743e7 jens-daniel-mueller 2021-11-03 Build site.
Rmd 2441237 jens-daniel-mueller 2021-11-03 updated plots
html f7c3da2 jens-daniel-mueller 2021-11-03 Build site.
html e534f51 jens-daniel-mueller 2021-11-02 Build site.
html 57cfc36 jens-daniel-mueller 2021-11-01 Build site.
html 4331a22 jens-daniel-mueller 2021-10-29 Build site.
html ae5ae64 jens-daniel-mueller 2021-10-26 Build site.
html 581baa0 jens-daniel-mueller 2021-10-07 Build site.
html a7af62f jens-daniel-mueller 2021-10-06 Build site.
html f9b4f93 jens-daniel-mueller 2021-10-05 Build site.
html ae93565 jens-daniel-mueller 2021-09-29 Build site.
Rmd c5eb521 jens-daniel-mueller 2021-09-29 coverage maps added
html 960d158 jens-daniel-mueller 2021-09-29 Build site.
html 0573621 jens-daniel-mueller 2021-09-29 Build site.
Rmd f5cf35e jens-daniel-mueller 2021-09-29 rebuildt with vif results

1 Read files

GLODAP_preprocessed <-
  read_csv(
    paste(
      path_preprocessing,
      "GLODAPv2.2021_preprocessed.csv",
      sep = ""
    )
  )
# land sea mask
landseamask <-
  read_csv(paste(path_files,
                  "land_sea_mask_WOA18.csv",
                  sep = ""))

2 Time series histogram

time_histo <- GLODAP_preprocessed %>% 
  drop_na() %>% 
  mutate(version = if_else(cruise <1000, "Gruber et al. (2019)", 
                           "New observations"),
         version = if_else(cruise %in% c(1041, 1042), "Gruber et al. (2019)", version)) %>% 
  count(year, version)

GLODAP_preprocessed %>% 
  drop_na() %>% 
  mutate(version = if_else(cruise <1000, "Gruber et al. (2019)", 
                           "New observations"),
         version = if_else(cruise %in% c(1041, 1042), "Gruber et al. (2019)", version)) %>% 
  count(version)
# A tibble: 2 × 2
  version                   n
  <chr>                 <int>
1 Gruber et al. (2019) 203878
2 New observations      92136
p_time_histo_G19 <-
  time_histo %>%
  filter(version == "Gruber et al. (2019)") %>% 
  ggplot() +
  geom_col(aes(year, n, fill = version),
           col = "grey20") +
  scale_fill_manual(values = c("grey70"),
                    name = "") +
  scale_x_continuous(breaks = seq(1900, 2100, 5),
                     limits = c(1981, 2021)) +
  scale_y_continuous(limits = c(0, max(time_histo$n) + 500)) +
  coord_cartesian(expand = 0) +
  labs(title = "Observations per year") +
  theme_classic() +
  theme(axis.title = element_blank())

p_time_histo_all <-
  time_histo %>%
  mutate(version = fct_rev(version)) %>% 
  ggplot() +
  geom_col(aes(year, n, fill = version),
           col = "grey20") +
  scale_fill_manual(values = c("darkgoldenrod1", "grey70"),
                    name = "") +
  scale_x_continuous(breaks = seq(1900, 2100, 5),
                     limits = c(1981, 2021)) +
  scale_y_continuous(limits = c(0, max(time_histo$n) + 500)) +
  coord_cartesian(expand = 0) +
  labs(title = "Observations per year") +
  theme_classic() +
  theme(axis.title = element_blank())


p_time_histo_G19

Version Author Date
acad2e2 jens-daniel-mueller 2022-04-09
a246221 jens-daniel-mueller 2022-02-04
570e738 jens-daniel-mueller 2022-01-10
18f801f jens-daniel-mueller 2021-11-03
e1743e7 jens-daniel-mueller 2021-11-03
p_time_histo_all

Version Author Date
acad2e2 jens-daniel-mueller 2022-04-09
d2191ad jens-daniel-mueller 2022-02-04
570e738 jens-daniel-mueller 2022-01-10
18f801f jens-daniel-mueller 2021-11-03
e1743e7 jens-daniel-mueller 2021-11-03
# ggsave(plot = p_time_histo_G19,
#        path = here::here("output/publication"),
#        filename = "time_histo_G19.png",
#        height = 2,
#        width = 10)

ggsave(plot = p_time_histo_all,
       path = here::here("output/publication"),
       filename = "FigS_coverage_time_series.png",
       height = 4,
       width = 10)

rm(
p_time_histo_G19,
p_time_histo_all
)
time_histo <- GLODAP_preprocessed %>% 
  filter(year >= 1989,
         year <= 2020) %>% 
  count(year, basin_AIP)

p_time_histo_basin <-
  time_histo %>%
  ggplot() +
  geom_col(aes(year, n, fill = basin_AIP)) +
  scale_fill_brewer(palette = "Dark2", name = "Ocean\nbasin") +
  scale_x_continuous(breaks = seq(1900, 2100, 5)) +
  scale_y_continuous(limits = c(0, NA), expand = c(0,0)) +
  labs(y = "Observations per year") +
  theme(axis.title.x = element_blank())

p_time_histo_basin

Version Author Date
acad2e2 jens-daniel-mueller 2022-04-09
d2191ad jens-daniel-mueller 2022-02-04
18f801f jens-daniel-mueller 2021-11-03
e1743e7 jens-daniel-mueller 2021-11-03
# ggsave(plot = p_time_histo_basin,
#        path = here::here("output/publication"),
#        filename = "FigS_time_series_observations.png",
#        height = 2,
#        width = 10)

rm(p_time_histo_basin)

3 Basin maps

3.1 MLR basins

MLR_basins_in <- c("1", "2", "AIP", "SO_2", "5", "SO_AIP", "SO")

basinmask <- basinmask %>%
  filter(MLR_basins %in% MLR_basins_in)

basinmask <- basinmask %>% 
  group_by(MLR_basins) %>% 
  mutate(basin = as.character(as.numeric(as.factor(basin)))) %>% 
  ungroup()


basin_maps <-
  map +
  geom_raster(data = basinmask,
              aes(lon, lat, fill = basin)) +
  scale_fill_brewer(palette = "Dark2", guide = "none") +
  facet_wrap( ~ MLR_basins) +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank())

basin_maps

Version Author Date
b52b159 jens-daniel-mueller 2022-06-27
09b0780 jens-daniel-mueller 2022-05-24
acad2e2 jens-daniel-mueller 2022-04-09
c3a6238 jens-daniel-mueller 2022-03-08
d2191ad jens-daniel-mueller 2022-02-04
ggsave(plot = basin_maps,
       path = here::here("output/publication"),
       filename = "FigS_basin_masks.png",
       height = 5,
       width = 10)

3.2 5 basins

MLR_basins_in <- c("5")

basinmask <- basinmask %>%
  filter(MLR_basins %in% MLR_basins_in)

basinmask <- basinmask %>% 
  group_by(MLR_basins) %>% 
  mutate(basin = as.character(as.numeric(as.factor(basin)))) %>% 
  ungroup()


basinmask <- basinmask %>%
  mutate(
    basin = fct_recode(
      basin,
      "N. Pacific" = "3",
      "S. Pacific" = "5",
      "N. Atlantic" = "2",
      "S. Atlantic" = "4",
      "Indian" = "1"
    )
  )

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

basin_maps <-
  map +
  geom_raster(data = basinmask,
              aes(lon, lat, fill = basin)) +
  scale_fill_brewer(palette = "Paired", guide = "none") +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank(),
        legend.title = element_blank())

basin_maps

Version Author Date
acad2e2 jens-daniel-mueller 2022-04-09
c3a6238 jens-daniel-mueller 2022-03-08
accfd87 jens-daniel-mueller 2022-02-01
# ggsave(plot = basin_maps,
#        path = here::here("output/publication"),
#        filename = "FigS_basin_mask_5.png",
#        height = 5,
#        width = 10)

3.3 Area scaling

mapped_ocean_mask <- full_join(
  landseamask %>% 
    filter(region == "ocean") %>% 
    select(lon, lat),
  basinmask %>% 
    select(lon, lat) %>% 
    mutate(mapped_ocean = "1")
) %>% 
  mutate(mapped_ocean = replace_na(mapped_ocean, 0))


map +
  geom_raster(data = mapped_ocean_mask,
              aes(lon, lat, fill = mapped_ocean)) +
  scale_fill_brewer(palette = "Set1") +
  theme(
    axis.text = element_blank(),
    axis.ticks = element_blank()
  )

Version Author Date
acad2e2 jens-daniel-mueller 2022-04-09
c3a6238 jens-daniel-mueller 2022-03-08
565224d jens-daniel-mueller 2022-02-17
mapped_ocean_mask %>% 
  mutate(surface_area = earth_surf(lat, lon)) %>% 
  group_by(mapped_ocean) %>% 
  summarise(surface_area = sum(surface_area)) %>% 
  ungroup() %>% 
  mutate(surface_area_ratio = surface_area / lead(surface_area))
# A tibble: 2 × 3
  mapped_ocean surface_area surface_area_ratio
  <chr>               <dbl>              <dbl>
1 0                 4.97e12             0.0149
2 1                 3.33e14            NA     

4 coverage maps all

GLODAP_era_grid <- GLODAP_preprocessed %>% 
  mutate(era = cut(year,
                   c(1989, 2000, 2010, 2021),
                   labels = c("1989 - 1999", "2000 - 2009", "2010 - 2020"),
                   right = FALSE)) %>% 
  group_by(lon, lat, era) %>% 
  summarise(year_max = max(year),
            year_min = min(year)) %>% 
  ungroup() %>% 
  drop_na()

coverage_map <-
  map +
  geom_tile(data = GLODAP_era_grid,
              aes(lon, lat, 
              fill = "X")) +
  scale_fill_brewer(palette = "Dark2", guide = "none") +
  facet_wrap(~ era, ncol = 2) +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank(),
        panel.grid = element_blank())

coverage_map

Version Author Date
acad2e2 jens-daniel-mueller 2022-04-09
c3a6238 jens-daniel-mueller 2022-03-08
d2191ad jens-daniel-mueller 2022-02-04
e1743e7 jens-daniel-mueller 2021-11-03
ae93565 jens-daniel-mueller 2021-09-29

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] colorspace_2.0-2 marelac_2.1.10   shape_1.4.6      ggforce_0.3.3   
 [5] metR_0.11.0      scico_1.3.0      patchwork_1.1.1  collapse_1.7.0  
 [9] forcats_0.5.1    stringr_1.4.0    dplyr_1.0.7      purrr_0.3.4     
[13] readr_2.1.1      tidyr_1.1.4      tibble_3.1.6     ggplot2_3.3.5   
[17] tidyverse_1.3.1  workflowr_1.7.0 

loaded via a namespace (and not attached):
 [1] fs_1.5.2           bit64_4.0.5        lubridate_1.8.0    gsw_1.0-6         
 [5] RColorBrewer_1.1-2 httr_1.4.2         rprojroot_2.0.2    tools_4.1.2       
 [9] backports_1.4.1    bslib_0.3.1        utf8_1.2.2         R6_2.5.1          
[13] DBI_1.1.2          withr_2.4.3        tidyselect_1.1.1   processx_3.5.2    
[17] bit_4.0.4          compiler_4.1.2     git2r_0.29.0       cli_3.1.1         
[21] rvest_1.0.2        xml2_1.3.3         labeling_0.4.2     sass_0.4.0        
[25] scales_1.1.1       checkmate_2.0.0    SolveSAPHE_2.1.0   callr_3.7.0       
[29] digest_0.6.29      rmarkdown_2.11     oce_1.5-0          pkgconfig_2.0.3   
[33] htmltools_0.5.2    highr_0.9          dbplyr_2.1.1       fastmap_1.1.0     
[37] rlang_1.0.2        readxl_1.3.1       rstudioapi_0.13    jquerylib_0.1.4   
[41] generics_0.1.1     farver_2.1.0       jsonlite_1.7.3     vroom_1.5.7       
[45] magrittr_2.0.1     Rcpp_1.0.8         munsell_0.5.0      fansi_1.0.2       
[49] lifecycle_1.0.1    stringi_1.7.6      whisker_0.4        yaml_2.2.1        
[53] MASS_7.3-55        grid_4.1.2         parallel_4.1.2     promises_1.2.0.1  
[57] crayon_1.4.2       haven_2.4.3        hms_1.1.1          seacarb_3.3.0     
[61] knitr_1.37         ps_1.6.0           pillar_1.6.4       reprex_2.0.1      
[65] glue_1.6.0         evaluate_0.14      getPass_0.2-2      data.table_1.14.2 
[69] modelr_0.1.8       vctrs_0.3.8        tzdb_0.2.0         tweenr_1.0.2      
[73] httpuv_1.6.5       cellranger_1.1.0   gtable_0.3.0       polyclip_1.10-0   
[77] assertthat_0.2.1   xfun_0.29          broom_0.7.11       later_1.3.0       
[81] ellipsis_0.3.2     here_1.0.1