Last updated: 2022-04-29

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 2d44f8a. 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:    .RData
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    output/

Untracked files:
    Untracked:  code/OceanSODA_argo_extremes.R
    Untracked:  code/creating_dataframe.R
    Untracked:  code/creating_map.R
    Untracked:  code/merging_oceanSODA_Argo.R
    Untracked:  code/pH_data_timeseries.R

Unstaged changes:
    Modified:   analysis/_site.yml
    Deleted:    analysis/load_OceanSODA_biomes.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/load_biomes.Rmd) and HTML (docs/load_biomes.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 2d44f8a pasqualina-vonlanthendinenna 2022-04-29 Build site.
html e61c08e pasqualina-vonlanthendinenna 2022-04-27 Build site.
html 10036ed pasqualina-vonlanthendinenna 2022-04-26 Build site.
Rmd 3e1ac14 pasqualina-vonlanthendinenna 2022-04-26 separated loading data pages, added mayot biomes, switched to pH and temp flag A

Task

Load in biome information and regional separations

RECCAP-2 Biome Separations

# load in the RECCAP biome separations 
region_masks_all <-
  stars::read_ncdf(paste(
    path_basin_mask, "RECCAP2_region_masks_all_v20210412.nc", sep = "")) %>%
  as_tibble() %>% 
  mutate(seamask = as.factor(seamask))

Harmonise RECCAP biomes

# harmonise the latitude longitude bands of the biomes to the pH data (2x2 grid)
region_masks_all_seamask_2x2 <- region_masks_all %>% 
  select(lat, lon, seamask) %>% 
  mutate(lon = if_else(lon < 20, lon + 360, lon)) %>% 
  mutate(
    lat = cut(lat, seq(-90, 90, 2), seq(-89, 89, 2)),
    lat = as.numeric(as.character(lat)),
    lon = cut(lon, seq(20, 380, 2), seq(21, 379, 2)),
    lon = as.numeric(as.character(lon))
  )

region_masks_all_seamask_1x1 <- region_masks_all %>% 
  select(lat, lon, seamask) %>% 
  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))
  )

region_masks_all <- region_masks_all %>% 
  select(-seamask) %>% 
  pivot_longer(open_ocean:southern, 
               names_to = 'region',
               values_to = 'value') %>% 
  mutate(value = as.factor(value))

# harmonise the lat/lon of the regional separations to our pH data 
region_masks_all_1x1 <- region_masks_all %>% 
  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))
)

region_masks_all_2x2 <- region_masks_all %>% 
  mutate(lon = if_else(lon < 20, lon + 360, lon)) %>% 
  mutate(
    lat = cut(lat, seq(-90, 90, 2), seq(-89, 89, 2)),
    lat = as.numeric(as.character(lat)),
    lon = cut(lon, seq(20, 380, 2), seq(21, 379, 2)),
    lon = as.numeric(as.character(lon))
  )

# add the region names to the surface pH dataframes

ph_surface_1x1 <- read_rds(file = paste0(path_argo_preprocessed, "/ph_surface_1x1.rds"))
ph_surface_2x2 <- read_rds(file = paste0(path_argo_preprocessed, "/ph_surface_2x2.rds"))

ph_surface_2x2 <- inner_join(ph_surface_2x2, region_masks_all_2x2)
ph_surface_1x1 <- inner_join(ph_surface_1x1, region_masks_all_1x1)

Maps of Southern Ocean RECCAP biomes

map <-
  read_rds(paste(path_emlr_utilities,
                 "map_landmask_WOA18.rds",
                 sep = ""))
# restrict base map to Southern Ocean
map <- map +
  lims(y = c(-85, -30))

region_masks_all_1x1 <- region_masks_all_1x1 %>%
  filter(region == 'southern',
         value != 0) %>%
  mutate(coast = as.character(coast))

Coastal regions

map +
  geom_tile(data = region_masks_all_1x1,
            aes(x = lon,
                y = lat,
                fill = coast))+
  scale_fill_brewer(palette = 'Dark2')

Version Author Date
10036ed pasqualina-vonlanthendinenna 2022-04-26

Biomes

map+
  geom_tile(data = region_masks_all_1x1,
            aes(x = lon,
                y = lat,
                fill = value))+
  scale_fill_brewer(palette = 'Dark2')+
  labs(title = 'RECCAP biomes')

Version Author Date
10036ed pasqualina-vonlanthendinenna 2022-04-26
basemap(limits = -30)+
  geom_spatial_tile(data = region_masks_all_1x1,
                    aes(x = lon,
                        y = lat,
                        fill = value),
                    col = NA)+
  scale_fill_brewer(palette = 'Dark2')+
  labs(title = 'RECCAP biomes')

Version Author Date
10036ed pasqualina-vonlanthendinenna 2022-04-26

Write RECCAP biomes to file

region_masks_all_seamask_1x1 %>% 
  write_rds(file = paste0(path_argo_preprocessed, "/region_masks_all_seamask_1x1.rds"))

region_masks_all_seamask_2x2 %>% 
  write_rds(file = paste0(path_argo_preprocessed, "/region_masks_all_seamask_2x2.rds"))

region_masks_all_1x1 %>% 
  write_rds(file = paste0(path_argo_preprocessed, "/region_masks_all_1x1.rds"))

region_masks_all_2x2 %>% 
  write_rds(file = paste0(path_argo_preprocessed, "/region_masks_all_2x2.rds"))

# joined RECCAP-biomes to surface pH data 
ph_surface_1x1 %>% 
  write_rds(file = paste0(path_argo_preprocessed, "/ph_surface_1x1.rds"))

ph_surface_2x2 %>% 
  write_rds(file = paste0(path_argo_preprocessed, "/ph_surface_2x2.rds"))

Mayot biomes

nm_biomes <- tidync::hyper_tibble(paste0(path_argo, "/SouthernOcean_mask_NM.nc"))
# 1 degree lon/lat grid

# table(nm_regions$LATITUDE) # 1 degree intervals
# table((nm_regions$LONGITUDE)) # 1 degree longitude intervals

Harmonise Mayot biomes

nm_biomes <- nm_biomes %>% 
  rename(lon = LONGITUDE,
         lat = LATITUDE) %>% 
  mutate(lon = if_else(lon < 20, lon + 360, lon))

nm_biomes <- nm_biomes %>% 
  filter(ICE == 1 | STSS == 1 | SPSS == 1)

nm_biomes <- nm_biomes %>% 
  pivot_longer(cols = c(STSS, SPSS, ICE),
               values_to = 'biome_mask',
               names_to = 'biome_name')

nm_biomes <- nm_biomes %>% 
  filter(biome_mask==1,
         lat <= -30)

Maps of Southern Ocean Mayot biomes

map+
  geom_tile(data = nm_biomes,
            aes(x = lon,
                y = lat,
                fill = biome_name))+
  scale_fill_brewer(palette = 'Dark2')+
  labs(title = 'Mayot biomes')

Version Author Date
10036ed pasqualina-vonlanthendinenna 2022-04-26
basemap(limits = -30)+
  geom_spatial_tile(data = nm_biomes,
                    aes(x = lon, 
                        y = lat, 
                        fill = biome_name),
                    col = NA)+
  scale_fill_brewer(palette = 'Dark2')+
  labs(title = 'Mayot biomes')

Version Author Date
10036ed pasqualina-vonlanthendinenna 2022-04-26

Write Mayot biomes to file

# write data to file 

nm_biomes %>% 
  write_rds(file = paste0(path_argo_preprocessed, "/nm_biomes.rds"))

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] lubridate_1.8.0   ggOceanMaps_1.2.6 ggspatial_1.1.5   forcats_0.5.1    
 [5] stringr_1.4.0     dplyr_1.0.7       purrr_0.3.4       readr_2.1.1      
 [9] tidyr_1.1.4       tibble_3.1.6      ggplot2_3.3.5     tidyverse_1.3.1  
[13] workflowr_1.7.0  

loaded via a namespace (and not attached):
 [1] fs_1.5.2              sf_1.0-5              RColorBrewer_1.1-2   
 [4] httr_1.4.2            rprojroot_2.0.2       tools_4.1.2          
 [7] backports_1.4.1       bslib_0.3.1           utf8_1.2.2           
[10] rgdal_1.5-28          R6_2.5.1              KernSmooth_2.23-20   
[13] rgeos_0.5-9           DBI_1.1.2             colorspace_2.0-2     
[16] raster_3.5-11         withr_2.4.3           sp_1.4-6             
[19] tidyselect_1.1.1      processx_3.5.2        compiler_4.1.2       
[22] git2r_0.29.0          cli_3.1.1             rvest_1.0.2          
[25] RNetCDF_2.5-2         xml2_1.3.3            labeling_0.4.2       
[28] sass_0.4.0            scales_1.1.1          classInt_0.4-3       
[31] ggOceanMapsData_1.0.1 callr_3.7.0           proxy_0.4-26         
[34] digest_0.6.29         rmarkdown_2.11        pkgconfig_2.0.3      
[37] htmltools_0.5.2       highr_0.9             dbplyr_2.1.1         
[40] fastmap_1.1.0         tidync_0.2.4          rlang_1.0.2          
[43] readxl_1.3.1          rstudioapi_0.13       farver_2.1.0         
[46] jquerylib_0.1.4       generics_0.1.1        jsonlite_1.7.3       
[49] magrittr_2.0.1        ncmeta_0.3.0          Rcpp_1.0.8           
[52] munsell_0.5.0         fansi_1.0.2           abind_1.4-5          
[55] lifecycle_1.0.1       terra_1.5-12          stringi_1.7.6        
[58] whisker_0.4           yaml_2.2.1            grid_4.1.2           
[61] parallel_4.1.2        promises_1.2.0.1      crayon_1.4.2         
[64] lattice_0.20-45       haven_2.4.3           stars_0.5-5          
[67] hms_1.1.1             knitr_1.37            ps_1.6.0             
[70] pillar_1.6.4          codetools_0.2-18      reprex_2.0.1         
[73] glue_1.6.0            evaluate_0.14         getPass_0.2-2        
[76] modelr_0.1.8          vctrs_0.3.8           tzdb_0.2.0           
[79] httpuv_1.6.5          cellranger_1.1.0      gtable_0.3.0         
[82] assertthat_0.2.1      xfun_0.29             lwgeom_0.2-8         
[85] broom_0.7.11          e1071_1.7-9           later_1.3.0          
[88] ncdf4_1.19            class_7.3-20          units_0.7-2          
[91] ellipsis_0.3.2