Last updated: 2024-06-07

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 b7e3e82. 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:    .Rproj.user/

Untracked files:
    Untracked:  analysis/draft.Rmd
    Untracked:  load_argo_core_output.txt
    Untracked:  poster_profile_argo.png

Unstaged changes:
    Modified:   analysis/CESM_comparison.Rmd
    Deleted:    analysis/MHWs_categorisation.Rmd
    Modified:   analysis/MHWs_vertical_anomaly.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:   analysis/temp_core_align_climatology.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
html b7e3e82 mlarriere 2024-06-07 Build site.
Rmd 450d23a mlarriere 2024-06-07 mixed layer depth
html 068357b mlarriere 2024-06-07 Build site.
Rmd ea00b64 mlarriere 2024-06-07 mixed layer depth
html 730d809 mlarriere 2024-06-06 Build site.
Rmd deda25c mlarriere 2024-06-06 cleaning code
html 2722ba9 mlarriere 2024-06-06 Build site.
Rmd 38021de mlarriere 2024-06-06 cleaning code
html 711edb9 mlarriere 2024-05-15 Build site.
Rmd c65d468 mlarriere 2024-05-15 East extent map
html 96d4b76 mlarriere 2024-05-14 Build site.
html af6594f mlarriere 2024-05-13 Build site.
html af44bcd mlarriere 2024-04-26 Build site.
html f0289cd mlarriere 2024-04-23 Build site.
Rmd ae8003f mlarriere 2024-04-23 Building test
html 9938047 mlarriere 2024-04-22 Build site.
Rmd 2fc79bb mlarriere 2024-04-22 Adding SST anomaly subsection
html 9cac35e mlarriere 2024-04-22 Build site.
Rmd 86f2f02 mlarriere 2024-04-22 Adding SST anomaly subsection

Task

Dependencies

VLIZ-SOM_FFN_inputs.nc - outputs of the SOM-FFN mode: SST (variable of interest here), CO2 atm, MLD, SSS, chl, wind

Outputs

SST_anomaly2023_NorthAtlantic_clim2004-2019.rds - file with the SST anomalies for 2023 using SOM-FNN climatology

#Area of interest: North Atlantic north west - lat:(60,30), lon:(-70,-30), North Atlantic east - lat:(0,40), lon:(-30,0)
chosen_extent <- list(
  lat_min = 0, #30
  lat_max = 40, #60
  lon_min = -30, #-70
  lon_max = 0 #-30
)  

name_extent<- "East" #Northwest

#base map for the plots
world_coordinates <- map_data("world") 

#year of interest
target_year<-2023
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/"

Sea Surface Temperature

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

#Read SOM-FFN outputs
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)))

# Extract data for each 15th of the month
pco2_product <-  pco2_product %>%
  mutate(year = year(time),
         month =  factor(format(time, "%m")),
         date = time)
  
#Extract data for computing the climatology: period 2004.2019 to match with BOA-Argo. 
sst_2004_2019_natlantic<- pco2_product %>% 
  filter(year>2004, year<2019, !is.na(sst), lat > 0, lon <30, lon >-100)

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

SST map

#Plot the SST climatology from the SOM-FFN
mean_temperature_map<- ggplot()+
  geom_map(data = world_coordinates, map = world_coordinates, aes(long, lat, map_id = region), fill = "grey") + #base map
  lims(x= c(-100, 50), y = c(0, 80))+ #North Atlantic
  geom_tile(data=climato_2004_2019, aes(x = lon, y = lat, fill = mean_temp)) +
  scale_fill_viridis_c(option='plasma') +
  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)

Version Author Date
2722ba9 mlarriere 2024-06-06
9cac35e mlarriere 2024-04-22

SST anomaly map

#SOM-FFN SST output for 2023 in North Atlantic
sst_2023_natlantic<- pco2_product %>% 
  filter(year==target_year, !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$SST_anomaly<- merged_data$sst - merged_data$mean_temp

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



# Define colors palette to match ~ color of ClimateReanalyser (for comparison)
colors <- c("lavender", "#9867C5", "darkblue", "lightblue", "white", "orange", "darkred", "red", "#FFCBCB")
palette <- colorRampPalette(colors)
n <- 20 #number of colors 
continuous_palette <- palette(n) #continuous color palette
scale_limits <- c(-10, 10)
scale_breaks <- seq(scale_limits[1], scale_limits[2], length.out = n + 1)


anomaly_sst_2023_map <- ggplot()+
  geom_map(data = world_coordinates, map = world_coordinates, aes(long, lat, map_id = region), fill = "grey") + #base map
  lims(x= c(-100, 50), y = c(0, 80))+ #North Atlantic 
  geom_tile(data=sst_anomaly_2023_natlantic, aes(x = lon, y = lat, fill = SST_anomaly)) +
  scale_fill_gradient2(name='T°C anomaly', low = "darkblue", high = "darkred")+  
  labs(title = "Temperature Anomaly per month in North Atlantic (2023)", 
       subtitle = "climatology 2004-2019",
       x = "Longitude", y = "Latitude") +
  theme(legend.position = 'right', legend.key.height = unit(2, "cm")) +  
  facet_wrap(~ month, ncol=2) 

print(anomaly_sst_2023_map)

Version Author Date
730d809 mlarriere 2024-06-06
2722ba9 mlarriere 2024-06-06
f0289cd mlarriere 2024-04-23
9938047 mlarriere 2024-04-22
9cac35e mlarriere 2024-04-22

Area of interest

We focus our study on the east part of the North Atlantic ocean.

#------Defining area of interest spatially and temporally depending on SST anomaly
#Annual hotspot (+MAM + JJA + a bit SON) in agreement with climate reanaliser
east_sst_anomaly<-sst_anomaly_2023_natlantic%>% 
   filter(lat > chosen_extent$lat_min, lat < chosen_extent$lat_max, 
         lon > chosen_extent$lon_min, lon < chosen_extent$lon_max)


map_anomaly_east <- ggplot()+
  geom_map(data = world_coordinates, map = world_coordinates, aes(long, lat, map_id = region), fill = "grey") + #base map
  lims(x= c(chosen_extent$lon_min, chosen_extent$lon_max), 
       y = c(chosen_extent$lat_min, chosen_extent$lat_max))+ #North Atlantic 
  geom_tile(data=east_sst_anomaly, aes(x = lon, y = lat, fill = SST_anomaly)) +
  scale_fill_gradient2(name='T°C anomaly', low = "darkblue", high = "darkred")+  
   labs(title = paste0("Temperature Anomaly (°C) in North Atlantic", target_year),
       subtitle = paste0("Extent: ", name_extent),
       x = "Longitude", y = "Latitude") +
  theme(legend.position = 'right', 
        legend.key.height = unit(2, "cm")) +
  facet_wrap(~ month, ncol=4)

print(map_anomaly_east)

Version Author Date
730d809 mlarriere 2024-06-06
2722ba9 mlarriere 2024-06-06
711edb9 mlarriere 2024-05-15

Write file

write_rds(sst_anomaly_2023_natlantic, 
          file = paste0(path_argo_core_preprocessed,"/", 
                        "SST_anomaly", target_year,"_NorthAtlantic_clim2004-2019.rds"))

Mixed Layer Depth

#Read Mixed Layer Depth - SOM-FFN outputs. units: [ln(re 1 m)] 
pco2_product <- read_ncdf(paste0(path_pCO2_products, "VLIZ-SOM_FFN/VLIZ-SOM_FFN_inputs.nc"),
                          var = "mld",
                          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)))

#unit transformation
pco2_product <- pco2_product %>% 
  mutate(mld=exp(mld))

# Extract data for each 15th of the month
pco2_product <-  pco2_product %>%
  mutate(year = year(time),
         month =  factor(format(time, "%m")),
         date = time)

# Extract MLD for the eastern North Atlantic region 
mld_eastern_NorthAtltantic<-pco2_product %>% 
  filter(!is.na(mld), 
         lat > chosen_extent$lat_min, lat < chosen_extent$lat_max, 
         lon > chosen_extent$lon_min, lon < chosen_extent$lon_max)


# Select only data in 2023
mld_eastern_NorthAtltantic_2023<-mld_eastern_NorthAtltantic %>% 
  filter(year==target_year)
#plot
ggplot()+
  geom_tile(data=mld_eastern_NorthAtltantic_2023, aes(x = lon, y = lat, fill = mld )) +
  geom_map(data = world_coordinates, map = world_coordinates, aes(long, lat, map_id = region), fill = "grey") + #base map
  lims(x = c(chosen_extent$lon_min, chosen_extent$lon_max), y=c(chosen_extent$lat_min, chosen_extent$lat_max)) + 
  scale_fill_viridis_c(option='plasma') +
  labs(title= "Mixed Layer Depth in the eastern North atlantic - 2023", 
       x = "Longitude", y = "Latitude", fill = "Mixed Layer Depth (m)") +
  facet_wrap(~month)+
  theme(legend.position = 'right')

Version Author Date
b7e3e82 mlarriere 2024-06-07
068357b mlarriere 2024-06-07
mld_eastern_NorthAtltantic_2023_2months <- mld_eastern_NorthAtltantic_2023 %>% 
  mutate(period=(as.numeric(month)+1)%/%2) %>% 
  group_by(period, lat, lon) %>% 
  summarize(mean_mld=mean(mld, na.rm=TRUE))

ggplot()+
  geom_tile(data=mld_eastern_NorthAtltantic_2023_2months, aes(x = lon, y = lat, fill = mean_mld )) +
  geom_map(data = world_coordinates, map = world_coordinates, aes(long, lat, map_id = region), fill = "grey") + #base map
  lims(x = c(chosen_extent$lon_min, chosen_extent$lon_max), y=c(chosen_extent$lat_min, chosen_extent$lat_max)) + 
  scale_fill_viridis_c(option='plasma') +
  labs(title= "Mean Mixed Layer Depth in the eastern North atlantic - 2023",
       subtitle = '2months average',
       x = "Longitude", y = "Latitude", fill = "Mixed Layer Depth (m)") +
  facet_wrap(~period)+
  theme(legend.position = 'right')

Version Author Date
b7e3e82 mlarriere 2024-06-07
068357b mlarriere 2024-06-07
write_rds(mld_eastern_NorthAtltantic_2023, 
          file = paste0(path_argo_core_preprocessed,"/", 
                        "mld_", target_year,"_NorthAtlantic_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