• Task
    • Set cache directory
    • Load index file
    • Read data
    • Read metadata
    • Join data
    • Harmonise metadata
    • Write data
    • Core-Temperature Flag A profiles
    • Core-Temperature Flag A and B

Last updated: 2023-10-06

Checks: 7 0

Knit directory: bgc_argo_r_argodata/

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(20211008) 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 2bd702c. 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:    output/

Untracked files:
    Untracked:  code/start_background_job_bgc_load.R
    Untracked:  code/start_background_job_core_load.R
    Untracked:  code/vertical_alignment.Rmd

Unstaged changes:
    Modified:   analysis/argo_oxygen.Rmd
    Modified:   analysis/argo_ph.Rmd
    Modified:   analysis/argo_temp.Rmd
    Modified:   analysis/argo_temp_core.Rmd
    Modified:   analysis/coverage_maps.Rmd
    Modified:   analysis/coverage_timeseries.Rmd
    Modified:   analysis/extreme_temp_core.Rmd
    Modified:   analysis/oceanSODA_argo_temp.Rmd
    Modified:   analysis/variability_pH.Rmd
    Modified:   analysis/variability_temp.Rmd
    Modified:   code/Workflowr_project_managment.R
    Modified:   code/start_background_job.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/load_argo_core.Rmd) and HTML (docs/load_argo_core.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
Rmd 2bd702c ds2n19 2023-10-06 Changed core Argo location folders and run for 2022
html c3381d0 ds2n19 2023-10-06 Build site.
Rmd bc8d46d ds2n19 2023-10-06 Changed core Argo location folders and run for 2022
html 8d5c853 pasqualina-vonlanthendinenna 2022-08-30 Build site.
Rmd 9bde106 pasqualina-vonlanthendinenna 2022-08-30 added 6 months of core data (still have to fix the dates
html 7b3d8c5 pasqualina-vonlanthendinenna 2022-08-29 Build site.
Rmd 8e81570 pasqualina-vonlanthendinenna 2022-08-29 load and add in core-argo data (1 month)

Task

Load core-Argo temperature data for comparison with BGC-Argo temperature data

Set cache directory

Directory where the core-Argo profile files are stored

# set cache directory
argo_set_cache_dir(cache_dir = path_argo_core)

# check cache directory
argo_cache_dir()
[1] "/nfs/kryo/work/datasets/ungridded/3d/ocean/floats/core_argo_r_argodata"
# check argo mirror
argo_mirror()
[1] "https://data-argo.ifremer.fr"
argo_update_global(max_global_cache_age = Inf)  # age argument: age of the cached files to update in hours (Inf means always use the cached file, and -Inf means always download from the server) 
# ex: max_global_cache_age = 5 updates files that have been in the cache for more than 5 hours, max_global_cache_age = 0.5 updates files that have been in the cache for more than 30 minutes, etc.
argo_update_data(max_data_cache_age = Inf)

Load index file

Load in delayed-mode core-Argo (CTD) data index file

#------------------------------------------------------------------------------
# Imnportant - file are loaded for the given year and saved in the preprocessed folder with a year prefix.
#------------------------------------------------------------------------------
load_year = "2014"

# core_index <- argo_global_prof() %>%
#   argo_filter_data_mode(data_mode = 'delayed') %>%  # load in delayed-mode data
#   argo_filter_date(date_min = '2013-01-01',
#                    date_max = Sys.time())  

core_index <- argo_global_prof() %>% 
  argo_filter_data_mode(data_mode = 'delayed') %>% 
  argo_filter_date(date_min = paste0(load_year, "-01-01"),
                   date_max = paste0(load_year, "-12-31"))
# 1 month worth of data for test purposes 

# check dates 
# max(core_index$date, na.rm = TRUE)
# min(core_index$date, na.rm = TRUE)

Read data

Read in the core CTD variables corresponding to the index defined above

core_data <- argo_prof_levels(
  path = core_index,
  vars =
    c(
      'PRES_ADJUSTED',
      'PRES_ADJUSTED_QC',
      'PSAL_ADJUSTED',
      'PSAL_ADJUSTED_QC',
      'TEMP_ADJUSTED',
      'TEMP_ADJUSTED_QC'),
  quiet = TRUE
) 
# read in the profiles (takes a while)

Read metadata

Read in the corresponding metadata:

core_metadata <- argo_prof_prof(path = core_index)

Join data

core_merge <- full_join(core_data, core_metadata)

core_merge <- core_merge %>%
  rename(lon = longitude,
         lat = latitude) %>%
  mutate(lon = if_else(lon < 20, lon + 360, lon)) %>%
  mutate(
    lat = cut(lat, seq(-90, 90, 1), seq(-89.5, 89.5, 1)),
    lat = as.numeric(as.character(lat)),
    lon = cut(lon, seq(20, 380, 1), seq(20.5, 379.5, 1)),
    lon = as.numeric(as.character(lon))
  ) %>%
  mutate(depth = swDepth(pres_adjusted, latitude =  lat),
         .before = pres_adjusted)

Harmonise metadata

core_metadata <- core_metadata %>%
  rename(lon = longitude,
         lat = latitude) %>%
  mutate(lon = if_else(lon < 20, lon + 360, lon)) %>%
  mutate(
    lat = cut(lat, seq(-90, 90, 1), seq(-89.5, 89.5, 1)),
    lat = as.numeric(as.character(lat)),
    lon = cut(lon, seq(20, 380, 1), seq(20.5, 379.5, 1)),
    lon = as.numeric(as.character(lon))
  )

Write data

core_data %>% 
  write_rds(file = paste0(path_argo_core_preprocessed, "/", load_year, "_core_data.rds"))

core_metadata %>% 
  write_rds(file = paste0(path_argo_core_preprocessed, "/", load_year, "_core_metadata.rds"))

core_merge %>% 
  write_rds(file = paste0(path_argo_core_preprocessed, "/", load_year, "_core_merge.rds"))

Core-Temperature Flag A profiles

core_merge_flag_A <- core_merge %>% 
  filter(profile_temp_qc == 'A') %>% 
  select(lat, lon, date, 
         depth, temp_adjusted, temp_adjusted_qc,
         platform_number, cycle_number,
         profile_temp_qc)

core_merge_flag_A %>% 
  write_rds(file = paste0(path_argo_core_preprocessed, "/", load_year, "_core_merge_flag_A.rds"))

Core-Temperature Flag A and B

core_merge_flag_AB <- core_merge %>% 
  filter(profile_temp_qc == 'A' | profile_temp_qc == 'B') %>% 
  filter(temp_adjusted_qc == '1' | temp_adjusted_qc == '8') %>% 
  select(lat, lon, date,
         depth, temp_adjusted, temp_adjusted_qc,
         platform_number, cycle_number,
         profile_temp_qc)

core_merge_flag_AB %>% 
  write_rds(file = paste0(path_argo_core_preprocessed, "/", load_year, "_core_merge_flag_AB.rds"))

sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: openSUSE Leap 15.4

Matrix products: default
BLAS:   /usr/local/R-4.2.2/lib64/R/lib/libRblas.so
LAPACK: /usr/local/R-4.2.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] oce_1.7-10       gsw_1.1-1        sf_1.0-9         lubridate_1.9.0 
 [5] timechange_0.1.1 argodata_0.1.0   forcats_0.5.2    stringr_1.4.1   
 [9] dplyr_1.0.10     purrr_0.3.5      readr_2.1.3      tidyr_1.2.1     
[13] tibble_3.1.8     ggplot2_3.4.0    tidyverse_1.3.2 

loaded via a namespace (and not attached):
 [1] httr_1.4.4          sass_0.4.4          bit64_4.0.5        
 [4] vroom_1.6.0         jsonlite_1.8.3      modelr_0.1.10      
 [7] bslib_0.4.1         assertthat_0.2.1    googlesheets4_1.0.1
[10] cellranger_1.1.0    progress_1.2.2      yaml_2.3.6         
[13] pillar_1.8.1        backports_1.4.1     glue_1.6.2         
[16] digest_0.6.30       promises_1.2.0.1    rvest_1.0.3        
[19] colorspace_2.0-3    htmltools_0.5.3     httpuv_1.6.6       
[22] pkgconfig_2.0.3     broom_1.0.1         haven_2.5.1        
[25] scales_1.2.1        whisker_0.4         later_1.3.0        
[28] tzdb_0.3.0          git2r_0.30.1        proxy_0.4-27       
[31] googledrive_2.0.0   generics_0.1.3      ellipsis_0.3.2     
[34] cachem_1.0.6        withr_2.5.0         cli_3.4.1          
[37] magrittr_2.0.3      crayon_1.5.2        readxl_1.4.1       
[40] evaluate_0.18       fs_1.5.2            fansi_1.0.3        
[43] xml2_1.3.3          class_7.3-20        prettyunits_1.1.1  
[46] tools_4.2.2         hms_1.1.2           gargle_1.2.1       
[49] lifecycle_1.0.3     munsell_0.5.0       reprex_2.0.2       
[52] compiler_4.2.2      jquerylib_0.1.4     e1071_1.7-12       
[55] RNetCDF_2.6-1       rlang_1.1.1         classInt_0.4-8     
[58] units_0.8-0         grid_4.2.2          rstudioapi_0.14    
[61] rmarkdown_2.18      gtable_0.3.1        DBI_1.1.3          
[64] R6_2.5.1            knitr_1.41          bit_4.0.5          
[67] fastmap_1.1.0       utf8_1.2.2          workflowr_1.7.0    
[70] rprojroot_2.0.3     KernSmooth_2.23-20  stringi_1.7.8      
[73] parallel_4.2.2      Rcpp_1.0.10         vctrs_0.5.1        
[76] dbplyr_2.2.1        tidyselect_1.2.0    xfun_0.35