Last updated: 2024-04-22

Checks: 7 0

Knit directory: bgc_argo_r_argodata/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(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 86f2f02. 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/

Untracked files:
    Untracked:  analysis/draft.Rmd

Unstaged changes:
    Modified:   analysis/MHWs_categorisation.Rmd
    Modified:   analysis/_site.yml
    Modified:   analysis/child/cluster_analysis_base.Rmd
    Modified:   analysis/coverage_maps_North_Atlantic.Rmd
    Modified:   analysis/load_broullon_DIC_TA_clim.Rmd
    Modified:   code/Workflowr_project_managment.R
    Modified:   code/start_background_job.R
    Modified:   code/start_background_job_load.R
    Modified:   code/start_background_job_partial.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/anomaly_SST_2023.Rmd) and HTML (docs/anomaly_SST_2023.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 86f2f02 mlarriere 2024-04-22 Adding SST anomaly subsection

Task

Dependencies

Outputs

path_emlr_utilities <- "/nfs/kryo/work/jenmueller/emlr_cant/utilities/files/"
path_basin_mask <- "/nfs/kryo/work/datasets/gridded/ocean/interior/reccap2/supplementary/"
path_argo <- '/nfs/kryo/work/datasets/ungridded/3d/ocean/floats/bgc_argo'
path_argo_core <- '/nfs/kryo/work/datasets/ungridded/3d/ocean/floats/core_argo_r_argodata_2024-03-13'

path_argo_core_preprocessed <- paste0(path_argo_core, "/preprocessed_core_data")
path_argo_preprocessed <- paste0(path_argo, "/preprocessed_bgc_data")

# path_mhw<- '/net/kryo/work/datasets/gridded/ocean/2d/obs/mhw'
path_basin_mask <- "/nfs/kryo/work/datasets/gridded/ocean/interior/reccap2/supplementary/"

path_pCO2_products <- "/nfs/kryo/work/datasets/gridded/ocean/2d/observation/pco2/"

SST

Load data and create climatology 2004-2019 (mean value)

pco2_product <- read_ncdf(paste0(path_pCO2_products, "VLIZ-SOM_FFN/VLIZ-SOM_FFN_inputs.nc"),
                          var = "sst",
                          ignore_bounds = TRUE,
                          make_units = FALSE)
 
pco2_product <- pco2_product %>%
  as_tibble()

pco2_product <- pco2_product %>%
  mutate(across(-c(lon, lat, time), ~ replace(., . >= 1e+19, NA)))

pco2_product <-  pco2_product %>%
  mutate(year = year(time),
         month = month(time))
  
sst_2004_2019_natlantic<- pco2_product %>% 
  filter(year>2004, year<2019, !is.na(sst), lat > 0, lon <30, lon >-100)

climato_2004_2019<-sst_2004_2019_natlantic %>% 
  group_by(month, lat, lon) %>% 
  summarize(mean_temp=mean(sst, na.rm=TRUE))

SST map

#Base map 
world_coordinates <- map_data("world") 
  
base_map <-ggplot() +  
  geom_map(data = world_coordinates, map = world_coordinates, 
    aes(long, lat, map_id = region))

#Restrict base map to North Atlantic Ocean
base_map <- base_map + lims(x= c(-100, 50), y = c(0, 80))


mean_temperature_map<- base_map +
  geom_tile(data=climato_2004_2019, aes(x = lon, y = lat, fill = mean_temp)) +
  scale_fill_viridis_c() +
  labs(title= "Mean temperature in North atlantic", 
       subtitle= "Period: 2004 - 2019", 
       x = "Longitude", y = "Latitude", fill = "Mean SST (°C)") +
  theme(legend.position = 'right')

print(mean_temperature_map)

SST anomaly map

sst_2023_natlantic<- pco2_product %>% 
  filter(year==2023, !is.na(sst), lat > 0, lon <30, lon >-100)

merged_data <- merge(sst_2023_natlantic, climato_2004_2019, by = c("month", "lat", "lon")) %>% 
  as.tibble()
merged_data$anomaly<- merged_data$sst - merged_data$mean_temp

sst_anomaly_2023_natlantic<-merged_data %>% 
  select(lat,lon,month, time, anomaly)

anomaly_sst_2023_map <- 
  base_map + 
  geom_tile(data=sst_anomaly_2023_natlantic, aes(x = lon, y = lat, fill = anomaly)) +
  scale_fill_distiller(palette = "RdBu", direction = -1) +
  labs(title = "Temperature Anomaly per month in North Atlantic (2023)", 
       subtitle = "climatology 2004-2019",
       x = "Longitude", y = "Latitude") +
  theme(legend.position = 'right') +
  facet_wrap(~ month, ncol=2) 

print(anomaly_sst_2023_map)

Write file

write_rds(sst_anomaly_2023_natlantic, 
          file = paste0(path_argo_core_preprocessed,"/", "SST_anomaly2023_clim2004-2019.rds"))

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

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] RColorBrewer_1.1-3   stars_0.6-0          sf_1.0-9            
 [4] abind_1.4-5          broom_1.0.5          paletteer_1.6.0     
 [7] cluster_2.1.6        gridExtra_2.3        scatterplot3d_0.3-44
[10] viridis_0.6.2        viridisLite_0.4.1    ggOceanMaps_1.3.4   
[13] ggspatial_1.1.7      oce_1.7-10           gsw_1.1-1           
[16] lubridate_1.9.0      timechange_0.1.1     forcats_0.5.2       
[19] stringr_1.5.0        dplyr_1.1.3          purrr_1.0.2         
[22] readr_2.1.3          tidyr_1.3.0          tibble_3.2.1        
[25] ggplot2_3.4.4        tidyverse_1.3.2      workflowr_1.7.0     

loaded via a namespace (and not attached):
 [1] googledrive_2.0.0   colorspace_2.0-3    ellipsis_0.3.2     
 [4] class_7.3-20        rprojroot_2.0.3     fs_1.5.2           
 [7] rstudioapi_0.15.0   proxy_0.4-27        farver_2.1.1       
[10] fansi_1.0.3         xml2_1.3.3          codetools_0.2-18   
[13] cachem_1.0.6        knitr_1.41          jsonlite_1.8.3     
[16] dbplyr_2.2.1        rgeos_0.5-9         compiler_4.2.2     
[19] httr_1.4.4          backports_1.4.1     assertthat_0.2.1   
[22] fastmap_1.1.0       gargle_1.2.1        cli_3.6.1          
[25] later_1.3.0         htmltools_0.5.8.1   tools_4.2.2        
[28] gtable_0.3.1        glue_1.6.2          maps_3.4.1         
[31] Rcpp_1.0.10         cellranger_1.1.0    jquerylib_0.1.4    
[34] RNetCDF_2.6-1       raster_3.6-11       vctrs_0.6.4        
[37] lwgeom_0.2-10       xfun_0.35           ps_1.7.2           
[40] rvest_1.0.3         lifecycle_1.0.3     ncmeta_0.3.5       
[43] googlesheets4_1.0.1 terra_1.7-65        getPass_0.2-2      
[46] scales_1.2.1        hms_1.1.2           promises_1.2.0.1   
[49] parallel_4.2.2      rematch2_2.1.2      yaml_2.3.6         
[52] sass_0.4.4          stringi_1.7.8       highr_0.9          
[55] e1071_1.7-12        rlang_1.1.1         pkgconfig_2.0.3    
[58] evaluate_0.18       lattice_0.20-45     labeling_0.4.2     
[61] processx_3.8.0      tidyselect_1.2.0    magrittr_2.0.3     
[64] R6_2.5.1            generics_0.1.3      DBI_1.2.2          
[67] pillar_1.9.0        haven_2.5.1         whisker_0.4        
[70] withr_2.5.0         units_0.8-0         sp_1.5-1           
[73] modelr_0.1.10       crayon_1.5.2        KernSmooth_2.23-20 
[76] utf8_1.2.2          tzdb_0.3.0          rmarkdown_2.18     
[79] grid_4.2.2          readxl_1.4.1        callr_3.7.3        
[82] git2r_0.30.1        reprex_2.0.2        digest_0.6.30      
[85] classInt_0.4-8      httpuv_1.6.6        munsell_0.5.0      
[88] bslib_0.4.1