Last updated: 2020-11-18

Checks: 7 0

Knit directory: Cant_eMLR/

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 a38e217. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rproj.user/
    Ignored:    data/WOCE/
    Ignored:    data/auxillary/
    Ignored:    data/eMLR/
    Ignored:    data/input/
    Ignored:    data/interim/
    Ignored:    data/mapping/
    Ignored:    data/output/
    Ignored:    dump/

Untracked files:
    Untracked:  output/figure/analysis_this_study/

Unstaged changes:
    Modified:   analysis/analysis_this_study.Rmd
    Deleted:    code/inventory_calculation.R
    Modified:   code/mapping_functions.R
    Modified:   code/plotting_functions.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/read_GLODAPv2_2016_MappedClimatologies.Rmd) and HTML (docs/read_GLODAPv2_2016_MappedClimatologies.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 29a642d jens-daniel-mueller 2020-11-17 Build site.
Rmd 2087408 jens-daniel-mueller 2020-11-17 avoid NA fill beyond bottom depth
html 6e1bc47 jens-daniel-mueller 2020-11-17 Build site.
Rmd 486d9e1 jens-daniel-mueller 2020-11-17 avoid NA fill beyond bottom depth
html 41367c3 jens-daniel-mueller 2020-11-17 Build site.
Rmd 6d7a0d5 jens-daniel-mueller 2020-11-17 filled NAs
html fc70a34 jens-daniel-mueller 2020-11-10 Build site.
html b170b79 jens-daniel-mueller 2020-11-03 Build site.
html 411a35b jens-daniel-mueller 2020-10-02 Build site.
html 0d38979 jens-daniel-mueller 2020-10-01 Build site.
html 80e9b77 jens-daniel-mueller 2020-09-30 Build site.
Rmd 1794dc7 jens-daniel-mueller 2020-09-30 added 3d globe vis
html 4578cfa jens-daniel-mueller 2020-09-19 Build site.
html abe1788 jens-daniel-mueller 2020-09-19 Build site.
Rmd fd2de12 jens-daniel-mueller 2020-09-19 plotted NA column inventory
html d4fdb2f jens-daniel-mueller 2020-09-19 Build site.
Rmd 42dbf62 jens-daniel-mueller 2020-09-19 plotted column NA
html 2f85af8 jens-daniel-mueller 2020-09-19 Build site.
Rmd b4afd14 jens-daniel-mueller 2020-09-19 plotted column NA
html d59f716 jens-daniel-mueller 2020-09-18 Build site.
html f5a20ac jens-daniel-mueller 2020-09-17 Build site.
html cf64460 jens-daniel-mueller 2020-09-17 Build site.
html d43d9e2 jens-daniel-mueller 2020-09-16 Build site.
html 1f3319a jens-daniel-mueller 2020-09-16 Build site.
html da91d98 jens-daniel-mueller 2020-09-10 Build site.
html f6f30c0 jens-daniel-mueller 2020-09-10 Build site.
Rmd f74449b jens-daniel-mueller 2020-09-10 global section plots added
html 3e3cef5 jens-daniel-mueller 2020-09-10 Build site.
Rmd e093533 jens-daniel-mueller 2020-09-10 global section plots added
html a34a239 jens-daniel-mueller 2020-09-10 Build site.
html c3ffdfd jens-daniel-mueller 2020-09-08 Build site.
Rmd 04ee730 jens-daniel-mueller 2020-09-08 rebuild after revision
html 6550cb3 jens-daniel-mueller 2020-09-08 Build site.
Rmd a81b920 jens-daniel-mueller 2020-09-08 applied spatial boundaries
html a50f053 jens-daniel-mueller 2020-09-07 Build site.
html da445a6 jens-daniel-mueller 2020-09-04 Build site.
html fa11a74 jens-daniel-mueller 2020-09-02 Build site.
html 429aab3 jens-daniel-mueller 2020-09-01 Build site.
html f4216dd jens-daniel-mueller 2020-09-01 Build site.
html 13a76d5 jens-daniel-mueller 2020-08-28 Build site.
html 27404de jens-daniel-mueller 2020-08-27 Build site.
html 06c2578 jens-daniel-mueller 2020-08-27 Build site.
Rmd c54a7fc jens-daniel-mueller 2020-08-27 updated plots
html b6d0e6a jens-daniel-mueller 2020-08-27 Build site.
html f40e48b jens-daniel-mueller 2020-08-26 Build site.
html ec20f40 jens-daniel-mueller 2020-08-24 Build site.
html 5ffe187 jens-daniel-mueller 2020-08-20 Build site.
html 1064ef8 jens-daniel-mueller 2020-08-19 Build site.
html 29a537a jens-daniel-mueller 2020-08-18 Build site.
Rmd 7fb61d5 jens-daniel-mueller 2020-08-18 rerun with all parameters in one file
html a3b6b68 jens-daniel-mueller 2020-08-13 Build site.
html 00c2120 jens-daniel-mueller 2020-08-13 Build site.
html b43777a jens-daniel-mueller 2020-08-13 Build site.
html 0db5801 jens-daniel-mueller 2020-08-13 Build site.
Rmd df165f1 jens-daniel-mueller 2020-08-13 sourced params, masks, functions
html bf69270 jens-daniel-mueller 2020-08-13 Build site.
html 1176c9a jens-daniel-mueller 2020-08-12 Build site.
html 8b32ee1 jens-daniel-mueller 2020-08-12 Build site.
Rmd 092a504 jens-daniel-mueller 2020-08-12 harmonized coordinates, labels, plots and basin mask
html 426ac40 jens-daniel-mueller 2020-08-12 Build site.
Rmd c76d1ab jens-daniel-mueller 2020-08-12 Show Ind ocean lon
html 1bb24c5 jens-daniel-mueller 2020-08-12 Build site.
Rmd 109ef2a jens-daniel-mueller 2020-08-12 quiet nc opening, print each parameter name
html f76390c jens-daniel-mueller 2020-08-12 Build site.
Rmd 33a3d29 jens-daniel-mueller 2020-08-12 Applied basin mask, updated plots and harmoized variable names
html f143b2d jens-daniel-mueller 2020-08-12 Build site.
html 2d179e7 jens-daniel-mueller 2020-08-12 Build site.
html 5d33341 jens-daniel-mueller 2020-08-11 Build site.
html 8a010ca jens-daniel-mueller 2020-08-11 Build site.
html a01041a jens-daniel-mueller 2020-08-11 Build site.
html e18e59a jens-daniel-mueller 2020-08-10 Build site.
html 7d7900a jens-daniel-mueller 2020-08-07 Build site.
html 5382e24 jens-daniel-mueller 2020-07-31 Build site.
Rmd 7ed9e6d jens-daniel-mueller 2020-07-31 text formating
html f232972 jens-daniel-mueller 2020-07-31 Build site.
Rmd 2cd68a7 jens-daniel-mueller 2020-07-31 separate criteria chunk and explanations added
html 9dc5d7f jens-daniel-mueller 2020-07-29 Build site.
html 21524b4 jens-daniel-mueller 2020-07-29 Build site.
html 30db5de jens-daniel-mueller 2020-07-29 Build site.
Rmd 973c193 jens-daniel-mueller 2020-07-29 formating
html 2e2412d jens-daniel-mueller 2020-07-29 Build site.
Rmd a9fbf3a jens-daniel-mueller 2020-07-29 formating
html 2e08795 jens-daniel-mueller 2020-07-24 Build site.
html 556e6cc jens-daniel-mueller 2020-07-23 Build site.
html c1289a2 jens-daniel-mueller 2020-07-23 Build site.
html 2890e73 jens-daniel-mueller 2020-07-23 Build site.
html fdfa7b9 jens-daniel-mueller 2020-07-22 Build site.
html 23038c8 jens-daniel-mueller 2020-07-22 Build site.
Rmd 09b3ca8 jens-daniel-mueller 2020-07-22 eding plain text, restructuring some code
html bb9c002 jens-daniel-mueller 2020-07-21 Build site.
Rmd d2ed0f8 jens-daniel-mueller 2020-07-21 harmonied lat lon labeling
html a268ace jens-daniel-mueller 2020-07-21 Build site.
Rmd 48de3ae jens-daniel-mueller 2020-07-21 added pacific section
html ca73a98 jens-daniel-mueller 2020-07-21 Build site.
Rmd e6c4220 jens-daniel-mueller 2020-07-21 added section plots atlantic ocean
html a842785 jens-daniel-mueller 2020-07-21 Build site.
Rmd 16cb19e jens-daniel-mueller 2020-07-21 added section plots atlantic ocean
html 55d905d jens-daniel-mueller 2020-07-21 Build site.
Rmd 87cc2f4 jens-daniel-mueller 2020-07-21 added section plots atlantic ocean
html b557574 jens-daniel-mueller 2020-07-21 Build site.
Rmd f881ecf jens-daniel-mueller 2020-07-21 added section plots atlantic ocean
html ce60bed jens-daniel-mueller 2020-07-21 Build site.
Rmd f9548b0 jens-daniel-mueller 2020-07-21 added section plots atlantik
html 21eb4f3 jens-daniel-mueller 2020-07-21 Build site.
Rmd e3d90cd jens-daniel-mueller 2020-07-21 added section plots atlantik
html 97dbf5b jens-daniel-mueller 2020-07-21 Build site.
Rmd 5def7e8 jens-daniel-mueller 2020-07-21 create csvs for each parameter
html 22b588c jens-daniel-mueller 2020-07-18 Build site.
Rmd 87a4680 jens-daniel-mueller 2020-07-18 added WOA blank script
html b82f4ea jens-daniel-mueller 2020-07-17 Build site.
Rmd 93fd22b jens-daniel-mueller 2020-07-17 cleaned maps
html 0f483e4 jens-daniel-mueller 2020-07-17 Build site.
Rmd 81f9f3f jens-daniel-mueller 2020-07-17 Plots for all Glodap mapped variables
html 30e2e22 jens-daniel-mueller 2020-07-14 Build site.
Rmd a48c8f0 jens-daniel-mueller 2020-07-14 Read plot netcdf woth tidync
html fc4cf4c jens-daniel-mueller 2020-07-14 Build site.
Rmd c18812a jens-daniel-mueller 2020-07-14 Read plot netcdf woth tidync
html 2979fdf jens-daniel-mueller 2020-07-14 Build site.
Rmd 6823c5d jens-daniel-mueller 2020-07-14 Read plot netcdf woth tidync
html 56c3ed9 jens-daniel-mueller 2020-07-14 Build site.
Rmd aed89af jens-daniel-mueller 2020-07-14 added Rmd for MappedClimatologies

library(tidyverse)
library(stars)
library(patchwork)

1 Read source files

Data source: Globally mapped climatologies from Lauvset et al. (2016) downloaded in June 2020 from glodap.info.

Following files were used:

file_list <- list.files(path = "data/input/GLODAPv2_2016b_Mappedclimatologies", pattern = "*.nc")
print(file_list)
[1] "GLODAPv2.2016b.Cant.nc"        "GLODAPv2.2016b.NO3.nc"        
[3] "GLODAPv2.2016b.oxygen.nc"      "GLODAPv2.2016b.PO4.nc"        
[5] "GLODAPv2.2016b.salinity.nc"    "GLODAPv2.2016b.silicate.nc"   
[7] "GLODAPv2.2016b.TAlk.nc"        "GLODAPv2.2016b.TCO2.nc"       
[9] "GLODAPv2.2016b.temperature.nc"

2 Plot data and write csv

Below, subsets of the climatologies are plotted, which display for all relevant parameters:

  • number of NA between surface and inventory depth
  • maps at depth levels -concentration along global section

The global section path is indicated as white line in maps.

# file <- file_list[2]

for (file in file_list) {
 
clim <- read_stars(here::here("data/input/GLODAPv2_2016b_Mappedclimatologies",
                          file),
                   quiet = TRUE)

# extract parameter name

parameter <- str_split(file, pattern = "6b.", simplify = TRUE)[2]
parameter <- str_split(parameter, pattern = ".nc", simplify = TRUE)[1]
print(parameter)

# extract parameter

clim <- clim %>% select(all_of(parameter))

#convert to table

clim_tibble <- clim %>% 
  as_tibble()

# harmonize column names

clim_tibble <- clim_tibble %>% 
  rename(lat = y,
         lon = x,
         depth = depth_surface)

# join with basin mask and remove data outside basin mask

clim_tibble <- inner_join(clim_tibble, basinmask)

# determine bottomdepth

bottom_depth <- clim_tibble %>% 
  filter(!is.na(!!sym(parameter))) %>% 
  group_by(lon, lat) %>% 
  summarise(bottom_depth = max(depth)) %>%
  ungroup()

map +
  geom_raster(data = bottom_depth,
              aes(lon, lat, fill=bottom_depth)) +
  scale_fill_viridis_c(direction = -1) +
  labs(title = parameter)

# remove data below bottom depth
clim_tibble <- left_join(clim_tibble, bottom_depth)
rm(bottom_depth)
clim_tibble <- clim_tibble %>% 
  filter(depth <= bottom_depth) %>% 
  select(-bottom_depth)

# fill NAs with closest value along longitude

clim_tibble <- clim_tibble %>%
  group_by(lat, depth, basin, basin_AIP) %>%
  arrange(lon) %>%
  fill(!!sym(parameter), .direction = "downup") %>%
  ungroup()

# # plot column NA inventory
# 
# clim_tibble_grid <- clim_tibble %>%
#   filter(!is.na(!!sym(parameter))) %>%
#   group_by(lat, lon) %>%
#   summarise(depth_max = max(depth)) %>%
#   ungroup()
# 
# clim_tibble_grid <- full_join(clim_tibble, clim_tibble_grid)
# 
# clim_tibble_grid <- clim_tibble_grid %>%
#   filter(depth <= depth_max) %>%
#   select(-depth_max)
# 
# clim_tibble_grid <- clim_tibble_grid %>%
#   filter(is.na(!!sym(parameter)),
#          depth <= parameters$inventory_depth) %>%
#   count(lat, lon)
# 
# # plot NA map
# print(
# 
#   map +
#     geom_raster(data = clim_tibble_grid,
#                 aes(lon, lat, fill = n)) +
#     scale_fill_viridis_c() +
#     theme(axis.title = element_blank()) +
#     labs(title = paste(parameter, "colum NA"))
# 
# )
# 
# rm(clim_tibble_grid)

# remove NAs

clim_tibble <- clim_tibble %>% 
  drop_na()

# plot maps

print(
map_climatology(clim_tibble,
                parameter)
)


# plot sections

print(
section_global(clim_tibble,
               parameter,
               "GLODAPv2_2016_Mapped_Climatology")
)


# write csv file

clim_tibble %>% 
  write_csv(here::here("data/interim",
                       paste("GLODAPv2_2016_MappedClimatology",parameter,".csv", sep = "")))



}
[1] "Cant"

[1] "NO3"

[1] "oxygen"

[1] "PO4"

[1] "salinity"

[1] "silicate"

[1] "TAlk"

[1] "TCO2"

[1] "temperature"


sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_Germany.1252  LC_CTYPE=English_Germany.1252   
[3] LC_MONETARY=English_Germany.1252 LC_NUMERIC=C                    
[5] LC_TIME=English_Germany.1252    

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

other attached packages:
 [1] patchwork_1.0.1 stars_0.4-3     sf_0.9-5        abind_1.4-5    
 [5] forcats_0.5.0   stringr_1.4.0   dplyr_1.0.0     purrr_0.3.4    
 [9] readr_1.3.1     tidyr_1.1.0     tibble_3.0.3    ggplot2_3.3.2  
[13] tidyverse_1.3.0 workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5         here_0.1           lubridate_1.7.9    class_7.3-17      
 [5] assertthat_0.2.1   rprojroot_1.3-2    digest_0.6.25      R6_2.4.1          
 [9] cellranger_1.1.0   backports_1.1.8    reprex_0.3.0       evaluate_0.14     
[13] e1071_1.7-3        httr_1.4.2         pillar_1.4.6       rlang_0.4.7       
[17] readxl_1.3.1       rstudioapi_0.11    whisker_0.4        blob_1.2.1        
[21] rmarkdown_2.3      labeling_0.3       munsell_0.5.0      broom_0.7.0       
[25] compiler_4.0.2     httpuv_1.5.4       modelr_0.1.8       xfun_0.16         
[29] pkgconfig_2.0.3    htmltools_0.5.0    tidyselect_1.1.0   viridisLite_0.3.0 
[33] fansi_0.4.1        crayon_1.3.4       dbplyr_1.4.4       withr_2.2.0       
[37] later_1.1.0.1      grid_4.0.2         lwgeom_0.2-5       jsonlite_1.7.0    
[41] gtable_0.3.0       lifecycle_0.2.0    DBI_1.1.0          git2r_0.27.1      
[45] magrittr_1.5       units_0.6-7        scales_1.1.1       KernSmooth_2.23-17
[49] cli_2.0.2          stringi_1.4.6      farver_2.0.3       fs_1.4.2          
[53] promises_1.1.1     xml2_1.3.2         ellipsis_0.3.1     generics_0.0.2    
[57] vctrs_0.3.2        tools_4.0.2        glue_1.4.1         hms_0.5.3         
[61] parallel_4.0.2     yaml_2.2.1         colorspace_1.4-1   isoband_0.2.2     
[65] classInt_0.4-3     rvest_0.3.6        knitr_1.30         haven_2.3.1