Last updated: 2021-07-07

Checks: 7 0

Knit directory: emlr_obs_preprocessing/

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 6312bd4. 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/

Unstaged changes:
    Modified:   README.md
    Modified:   analysis/_site.yml
    Deleted:    analysis/read_Gruber_2019_Cant.Rmd
    Deleted:    analysis/read_Sabine_2004_Cant.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/read_Gruber_2019.Rmd) and HTML (docs/read_Gruber_2019.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 6312bd4 jens-daniel-mueller 2021-07-07 Build site.
Rmd 4905409 jens-daniel-mueller 2021-07-07 rerun with new setup_obs.Rmd file
html 58bc706 jens-daniel-mueller 2021-07-06 Build site.
Rmd 0db89e1 jens-daniel-mueller 2021-07-06 rerun with revised variable names

1 Data source

2 Read nc files

Here, we use the standard case V101 for public and raw data sets.

2.1 Public data sets

The publicly available data sets contain only positive Cant estimates.

2.1.1 3d fields

# open file
dcant <- tidync(paste(
  path_gruber_2019,
  "dcant_emlr_cstar_gruber_94-07_vs1.nc",
  sep = ""
))

# read gamma field as tibble
dcant <- dcant %>%  activate(GAMMA_DENS)
dcant_gamma <- dcant %>% hyper_tibble()

# read delta cant field
dcant <- dcant %>%  activate(DCANT_01)
dcant <- dcant %>% hyper_tibble()

# join cant and gamma fields
dcant <- left_join(dcant, dcant_gamma)

# harmonize column names and coordinates
dcant <- dcant %>% 
  rename(lon = LONGITUDE,
         lat = LATITUDE,
         depth = DEPTH,
         gamma = GAMMA_DENS,
         dcant_pos = DCANT_01) %>% 
  mutate(lon = if_else(lon < 20, lon + 360, lon))

rm(dcant_gamma)

2.1.2 Column inventories

dcant_inv <- tidync(paste(
  path_gruber_2019,
  "inv_dcant_emlr_cstar_gruber_94-07_vs1.nc",
  sep = ""
))

dcant_inv <- dcant_inv %>%  activate(DCANT_INV01)
dcant_inv <- dcant_inv %>% hyper_tibble()

# harmonize column names and coordinates
dcant_inv <- dcant_inv %>% 
  rename(lon = LONGITUDE,
         lat = LATITUDE,
         dcant_pos = DCANT_INV01) %>% 
  mutate(lon = if_else(lon < 20, lon + 360, lon))

2.2 Raw data

Internally available data sets also contain negative Cant estimates, as they are generated in the “raw” output of the eMLR mapping step.

# open v 101 file
V101 <- tidync(paste(path_gruber_2019,
                     "Cant_V101new.nc",
                     sep = ""))

# create tibble
V101 <- V101 %>%  activate(Cant)
V101 <- V101 %>% hyper_tibble()

# harmonize column names and coordinates
V101 <- V101 %>% 
  rename(lon = longitude,
         lat = latitude,
         dcant = Cant) %>% 
  filter(dcant != -999) %>% 
  mutate(lon = if_else(lon < 20, lon + 360, lon))

3 Apply basin mask

# use only three basin to assign general basin mask
# ie this is not specific to the MLR fitting
basinmask <- basinmask %>% 
  filter(MLR_basins == "2") %>% 
  select(lat, lon, basin_AIP)

dcant <- inner_join(dcant, basinmask)
dcant_inv_publ <- inner_join(dcant_inv, basinmask)
V101 <- inner_join(V101, basinmask)

4 Join pos and all delta Cant

# join files
dcant_3d <- inner_join(dcant, V101)

rm(dcant, V101)

5 Zonal mean section

dcant_zonal <- m_zonal_mean_sd(dcant_3d)

6 Column inventory

6.1 Calculation

dcant_inv_layers <- m_dcant_inv(dcant_3d)

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

6.2 Plots

6.2.1 All Cant

p_map_cant_inv(
  df = dcant_inv,
  var = "dcant",
  col = "divergent")

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06

6.2.2 Pos Cant

p_map_cant_inv(
  df = dcant_inv,
  var = "dcant_pos")

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06

6.2.3 Published inventories

p_map_cant_inv(
  df = dcant_inv,
  var = "dcant_pos")

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06

6.2.4 Published vs calculated

# join published and calculated data sets
dcant_inv_offset <- inner_join(
  dcant_inv %>% rename(dcant_re = dcant_pos),
  dcant_inv_publ %>% rename(dcant_pub = dcant_pos)
)

# calculate offset
dcant_inv_offset <- dcant_inv_offset %>% 
  mutate(dcant_offset = dcant_re - dcant_pub)

# plot map
p_map_cant_inv_offset(df = dcant_inv_offset,
                      var = "dcant_offset",
                      breaks = seq(-3,3,0.25))

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06
rm(dcant_inv_offset, dcant_inv_publ)

7 Horizontal plane maps

7.1 All Cant

p_map_climatology(
  df = dcant_3d,
  var = "dcant",
  col = "divergent")

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06

7.2 Positive Cant

p_map_climatology(
  df = dcant_3d,
  var = "dcant_pos")

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06

7.3 Neutral density

p_map_climatology(
  df = dcant_3d,
  var = "gamma")

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06

8 Zonal mean section plot

8.1 Positive Cant

dcant_zonal %>%
  group_split(basin_AIP) %>%
  head(1) %>%
  map(
    ~ p_section_zonal(
      df = .x,
      var = "dcant_pos_mean",
      plot_slabs = "n",
      subtitle_text = paste("Basin:", unique(.x$basin_AIP))
    )
  )
[[1]]

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06

9 Global sections plot

9.1 All Cant

p_section_global(
  df = dcant_3d,
  var = "dcant",
  col = "divergent")

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06

9.2 Positive Cant

p_section_global(
  df = dcant_3d,
  var = "dcant_pos")

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06

10 Sections at regular longitudes

10.1 All Cant

p_section_climatology_regular(
  df = dcant_3d,
  var = "dcant",
  col = "divergent")

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06

10.2 Positive Cant

p_section_climatology_regular(
  df = dcant_3d,
  var = "dcant_pos")

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06

10.3 Neutral density

p_section_climatology_regular(
  df = dcant_3d,
  var = "gamma")

Version Author Date
58bc706 jens-daniel-mueller 2021-07-06

11 Write files

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

dcant_inv %>%
  write_csv(paste(path_preprocessing,
                  "G19_dcant_inv.csv",
                  sep = ""))

dcant_zonal %>%
  write_csv(paste(path_preprocessing,
                  "G19_dcant_zonal.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] tidync_0.2.4    ggforce_0.3.3   metR_0.9.0      scico_1.2.0    
 [5] patchwork_1.1.1 collapse_1.5.0  forcats_0.5.0   stringr_1.4.0  
 [9] dplyr_1.0.5     purrr_0.3.4     readr_1.4.0     tidyr_1.1.2    
[13] tibble_3.0.4    ggplot2_3.3.3   tidyverse_1.3.0 workflowr_1.6.2

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