Last updated: 2022-05-12
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 018f4b4. 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/
Unstaged changes:
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_broullon_DIC_TA_clim.Rmd
) and HTML (docs/load_broullon_DIC_TA_clim.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 | 018f4b4 | jens-daniel-mueller | 2022-05-12 | scaled DIC to 2019 (rather than 2015) |
html | 4173c20 | jens-daniel-mueller | 2022-05-12 | Build site. |
Rmd | 78acca9 | jens-daniel-mueller | 2022-05-12 | run with DIC clim scaled to 2016 |
html | dfe89d7 | jens-daniel-mueller | 2022-05-12 | Build site. |
html | 710edd4 | jens-daniel-mueller | 2022-05-11 | Build site. |
Rmd | 2f20a76 | jens-daniel-mueller | 2022-05-11 | rebuild all after subsetting AB profiles and code cleaning |
Explore the Broullón et al. (2020) DIC / TA climatology
library(tidyverse)
library(lubridate)
library(stars)
library(seacarb)
library(gsw)
path_argo <- '/nfs/kryo/work/updata/bgc_argo_r_argodata'
path_argo_preprocessed <- paste0(path_argo, "/preprocessed_bgc_data")
path_emlr_utilities <- "/nfs/kryo/work/jenmueller/emlr_cant/utilities/files/"
path_emlr_preprocessing <- "/nfs/kryo/work/jenmueller/emlr_cant/observations/preprocessing/"
path_updata <- '/nfs/kryo/work/updata'
path_broullon_clim <- paste0(path_updata, "/broullon_co2_monthly_climatology")
path_woa13_temp <- paste0(path_updata, "/woa2013/temperature/decav/1.00/")
path_woa13_sal <- paste0(path_updata, "/woa2013/salinity/decav/1.00/")
theme_set(theme_bw())
map <- map <-
read_rds(paste(path_emlr_utilities,
"map_landmask_WOA18.rds",
sep = ""))
nm_biomes <- read_rds(file = paste0(path_argo_preprocessed, "/nm_biomes.rds"))
# WOA 18 basin mask
basinmask <-
read_csv(
paste(path_emlr_utilities,
"basin_mask_WOA18.csv",
sep = ""),
col_types = cols("MLR_basins" = col_character())
)
basinmask <- basinmask %>%
filter(MLR_basins == unique(basinmask$MLR_basins)[1]) %>%
select(-c(MLR_basins, basin))
DIC_clim <- tidync::hyper_tibble(paste0(path_broullon_clim, "/TCO2_NNGv2LDEO_climatology.nc"))
nc_depth <- read_ncdf(paste0(path_broullon_clim, "/TCO2_NNGv2LDEO_climatology.nc"),
var = c("depth"))
nc_depth <- as_tibble(nc_depth)
nc_depth <- nc_depth %>%
mutate(depth_level = depth_level+0.5)
DIC_clim <- full_join(DIC_clim, nc_depth)
DIC_clim <- DIC_clim %>%
rename(DIC = TCO2_NNGv2LDEO,
month = time)
rm(nc_depth)
# table(unique(DIC_clim$latitude))
# table(unique(DIC_clim$longitude))
# table(unique(DIC_clim$time))
# table(unique(DIC_clim$depth))
# text <- read_file(paste0(path_broullon_clim, "/README_global_monthly_2020.txt"))
# Depth goes down to 5500 m, but below 1500 m DIC is an annual climatological value, rather than a monthly climatological value
TA_clim <- tidync::hyper_tibble(paste0(path_broullon_clim, "/AT_NNGv2_climatology.nc"))
nc_depth <- read_ncdf(paste0(path_broullon_clim, "/AT_NNGv2_climatology.nc"),
var = c('depth'))
nc_depth <- as_tibble(nc_depth)
nc_depth <- nc_depth %>%
mutate(depth_level = depth_level+0.5)
TA_clim <- full_join(TA_clim, nc_depth)
rm(nc_depth)
# read_file(paste0(path_broullon_clim, "/README_Global_monthly_2019.txt"))
TA_clim <- TA_clim %>%
rename(TA = AT_NNGv2,
month = time)
# Depth goes down to 5500 m, but below 1500 m TA is an annual climatological value, rather than a monthly climatological value
pco2_clim <- tidync::hyper_tibble(paste0(path_broullon_clim, "/pCO2_NNGv2LDEO_climatology.nc"))
pco2_clim <- pco2_clim %>%
mutate(depth_level = 1) %>%
rename(pco2 = pCO2_NNGv2LDEO,
month = time)
broullon_clim <- full_join(DIC_clim, TA_clim)
# broullon_clim <- full_join(broullon_clim, pco2_clim)
rm(DIC_clim, TA_clim)
months <- sprintf("%02d", seq(1,12,1))
for (i_month in months) {
# i_month <- months[1]
# read temperature climatology
woa13_temp <-
read_ncdf(
paste0(path_woa13_temp, "woa13_decav_t", i_month, "_01.nc"),
var = "t_an",
make_units = FALSE,
make_time = FALSE
)
woa13_temp <- woa13_temp %>%
as_tibble()
woa13_temp <- woa13_temp %>%
mutate(month = i_month) %>%
select(-time) %>%
rename(temp = t_an) %>%
drop_na()
# read salinity climatology
woa13_sal <-
read_ncdf(
paste0(path_woa13_sal, "woa13_decav_s", i_month, "_01.nc"),
var = "s_an",
make_units = FALSE,
make_time = FALSE
)
woa13_sal <- woa13_sal %>%
as_tibble()
woa13_sal <- woa13_sal %>%
mutate(month = i_month) %>%
select(-time) %>%
rename(sal = s_an) %>%
drop_na()
# join temperature and salinity climatology
woa13_temp <- full_join(woa13_temp,
woa13_sal)
# bind months into joined data frame
if (exists("woa13")) {
woa13 <- bind_rows(woa13, woa13_temp)
}
if (!exists("woa13")) {
woa13 <- woa13_temp
}
}
woa13 <- woa13 %>%
mutate(month = as.numeric(month))
rm(woa13_temp, woa13_sal, months, i_month)
# put longitude and latitude labels to the center of the grid (.5º)
broullon_clim <- broullon_clim %>%
rename(lon = longitude,
lat = latitude) %>%
select(-depth_level) %>%
mutate(lon = if_else(lon < 20, lon + 360, lon))
broullon_clim <- broullon_clim %>%
drop_na()
# put longitude and latitude labels to the center of the grid (.5º)
woa13 <- woa13 %>%
mutate(lon = if_else(lon < 20, lon + 360, lon))
broullon_clim <- full_join(broullon_clim,
woa13)
# remove grid cells with only one sal value to allow for interpolation
broullon_clim <- broullon_clim %>%
group_by(month, lat, lon) %>%
mutate(n = sum(!is.na(sal))) %>%
ungroup()
broullon_clim <- broullon_clim %>%
filter(n > 1) %>%
select(-n)
# interpolate sal/temp to broullon depth levels
broullon_clim <- broullon_clim %>%
group_by(lon, lat, month) %>%
arrange(depth) %>%
mutate(sal := approxfun(depth, sal, rule = 2)(depth),
temp := approxfun(depth, temp, rule = 2)(depth)) %>%
ungroup()
# remove sal/temp data on original woa13 depth levels
broullon_clim <- broullon_clim %>%
filter(!is.na(DIC))
# subset Southerh Ocean data
broullon_clim_SO <- broullon_clim %>%
filter(lat <= -30,
depth <= 2000)
# join regional separations
broullon_clim_SO <- inner_join(broullon_clim_SO, nm_biomes)
broullon_clim_SO <- inner_join(broullon_clim_SO, basinmask)
broullon_clim <- inner_join(broullon_clim, basinmask)
broullon_clim %>%
write_rds(file = paste0(path_argo_preprocessed, "/broullon_TA_DIC_clim_all.rds"))
G19_dcant_3d <-
read_csv(paste0(path_emlr_preprocessing,
"G19_dcant_3d.csv"))
G19_dcant_3d <- G19_dcant_3d %>%
select(lon, lat, depth, dcant = dcant_pos)
G19_dcant_3d <- inner_join(G19_dcant_3d,
nm_biomes %>% select(lon, lat))
# unique(G19_dcant_3d$depth)
# unique(broullon_clim_SO$depth)
broullon_clim_SO <-
full_join(broullon_clim_SO,
G19_dcant_3d %>% filter(depth <= 2000))
# remove grid cells with only one sal value to allow for interpolation
broullon_clim_SO <- broullon_clim_SO %>%
group_by(month, lat, lon) %>%
mutate(n = sum(!is.na(dcant))) %>%
ungroup()
broullon_clim_SO <- broullon_clim_SO %>%
filter(n > 1) %>%
select(-n)
# interpolate dcant to Broullon clim depth levels
broullon_clim_SO <- broullon_clim_SO %>%
group_by(lon, lat, month) %>%
arrange(depth) %>%
mutate(dcant := approxfun(depth, dcant, rule = 2)(depth)) %>%
ungroup()
# remove sal/temp data on original woa13 depth levels
broullon_clim_SO <- broullon_clim_SO %>%
filter(!is.na(DIC))
broullon_clim_SO <- broullon_clim_SO %>%
mutate(DIC = DIC + dcant * ((2019-1995)/(2007-1994))) %>%
select(-dcant)
rm(broullon_clim, woa13)
# calculate pressure from depth
broullon_clim_SO <- broullon_clim_SO %>%
mutate(pressure = gsw_p_from_z(z = -depth,
latitude = lat))
# broullon_clim_SO <- broullon_clim_SO %>%
# arrange(lon, lat)
#
# # calculate pHT from DIC, TA and ancillary parameters
# for (i_lon in unique(broullon_clim_SO$lon)) {
# print("***")
# print(i_lon)
#
# broullon_clim_SO_lon <- broullon_clim_SO %>%
# filter(lon == i_lon)
#
# for (i_lat in unique(broullon_clim_SO_lon$lat)) {
# print(i_lat)
#
# broullon_clim_SO_lon_lat <-
# broullon_clim_SO_lon %>%
# filter(lat == i_lat) %>%
# mutate(
# pH = carb(
# flag = 15,
# var1 = TA * 1e-6,
# var2 = DIC * 1e-6,
# S = sal,
# T = temp,
# P = pressure / 10,
# Pt = phosphate * 1e-6,
# Sit = silicate * 1e-6,
# k1k2 = "l"
# )[,6]
# )
#
# # bind months into joined data frame
# if (exists("broullon_clim_SO_pH")) {
# broullon_clim_SO_pH <- bind_rows(broullon_clim_SO_pH, broullon_clim_SO_lon_lat)
# }
#
# if (!exists("broullon_clim_SO_pH")) {
# broullon_clim_SO_pH <- broullon_clim_SO_lon_lat
# }
#
# }
# }
#
# rm(broullon_clim_SO_lon_lat, broullon_clim_SO_lon)
broullon_clim_SO_pH <-
broullon_clim_SO %>%
mutate(
pH = carb(
flag = 15,
var1 = TA * 1e-6,
var2 = DIC * 1e-6,
S = sal,
T = temp,
P = pressure / 10,
Pt = phosphate * 1e-6,
Sit = silicate * 1e-6,
k1k2 = "l"
)[, 6]
)
broullon_clim_SO_pH %>%
write_rds(file = paste0(path_argo_preprocessed, "/broullon_TA_DIC_clim_SO_pH.rds"))
broullon_clim_SO_pH %>%
group_split(depth) %>%
head(2) %>%
map(
~map +
geom_tile(data = .x,
aes(x = lon,
y = lat,
fill = pH))+
scale_fill_viridis_c()+
lims(y = c(-85, -28))+
facet_wrap(~month, ncol = 2)+
labs(title = paste0('Broullon et al. (2020) pH clim, depth: ', unique(.x$depth)))
)
[[1]]
[[2]]
broullon_clim_SO_pH %>%
# filter(depth <= 1500) %>%
group_split(month) %>%
head(2) %>%
map(
~ ggplot(data = .x,
aes(x = pH,
y = depth))+
geom_point(data = .x,
aes(x = pH,
y = depth),
size = 0.2,
pch = 1)+
scale_y_reverse()+
facet_grid(biome_name~basin_AIP)+
labs(title = paste0('Broullon et al. clim pH, month: ', unique(.x$month)),
x = 'pH')
)
[[1]]
[[2]]
broullon_clim_SO_pH %>%
group_split(depth) %>%
head(2) %>%
map(
~map +
geom_tile(data = .x,
aes(x = lon,
y = lat,
fill = DIC))+
scale_fill_viridis_c()+
lims(y = c(-85, -28))+
facet_wrap(~month, ncol = 2)+
labs(title = paste0('Broullon et al. (2020) DIC clim, depth: ', unique(.x$depth)))
)
[[1]]
[[2]]
broullon_clim_SO_pH %>%
# filter(depth <= 1500) %>%
group_split(month) %>%
head(2) %>%
map(
~ ggplot(data = .x,
aes(x = DIC,
y = depth))+
geom_point(data = .x,
aes(x = DIC,
y = depth),
size = 0.2,
pch = 1)+
scale_y_reverse()+
facet_grid(biome_name~basin_AIP)+
labs(title = paste0('Broullon et al. clim DIC, month: ', unique(.x$month)),
x = 'DIC')
)
[[1]]
[[2]]
broullon_clim_SO_pH %>%
group_split(depth) %>%
head(2) %>%
map(
~map +
geom_tile(data = .x,
aes(x = lon,
y = lat,
fill = TA))+
scale_fill_viridis_c()+
lims(y = c(-85, -28))+
facet_wrap(~month, ncol = 2)+
labs(title = paste0('Broullon et al. (2020) TA clim, depth: ', unique(.x$depth)))
)
[[1]]
[[2]]
broullon_clim_SO_pH %>%
# filter(depth <= 1500) %>%
group_split(month) %>%
head(2) %>%
map(
~ ggplot(data = .x,
aes(x = TA,
y = depth))+
geom_point(data = .x,
aes(x = TA,
y = depth),
size = 0.2,
pch = 1)+
scale_y_reverse()+
facet_grid(biome_name~basin_AIP)+
labs(title = paste0('Broullon et al. clim TA, month: ', unique(.x$month)))
)
[[1]]
[[2]]
broullon_clim_SO_pH %>%
group_split(depth) %>%
head(2) %>%
map(
~map +
geom_tile(data = .x,
aes(x = lon,
y = lat,
fill = oxygen))+
scale_fill_viridis_c()+
lims(y = c(-85, -28))+
facet_wrap(~month, ncol = 2)+
labs(title = paste0('Broullon et al. (2020) oxygen clim, depth: ', unique(.x$depth)))
)
[[1]]
[[2]]
broullon_clim_SO_pH %>%
# filter(depth <= 1500) %>%
group_split(month) %>%
head(2) %>%
map(
~ ggplot(data = .x,
aes(x = oxygen,
y = depth))+
geom_point(data = .x,
aes(x = oxygen,
y = depth),
size = 0.2,
pch = 1)+
scale_y_reverse()+
facet_grid(biome_name~basin_AIP)+
labs(title = paste0('Broullon et al. clim oxygen, month: ', unique(.x$month)))
)
[[1]]
[[2]]
broullon_clim_SO_pH %>%
group_split(depth) %>%
head(2) %>%
map(
~map +
geom_tile(data = .x,
aes(x = lon,
y = lat,
fill = nitrate))+
scale_fill_viridis_c()+
lims(y = c(-85, -28))+
facet_wrap(~month, ncol = 2)+
labs(title = paste0('Broullon et al. (2020) nitrate clim, depth: ', unique(.x$depth)))
)
[[1]]
[[2]]
broullon_clim_SO_pH %>%
# filter(depth <= 1500) %>%
group_split(month) %>%
head(2) %>%
map(
~ ggplot(data = .x,
aes(x = nitrate,
y = depth))+
geom_point(data = .x,
aes(x = nitrate,
y = depth),
size = 0.2,
pch = 1)+
scale_y_reverse()+
facet_grid(biome_name~basin_AIP)+
labs(title = paste0('Broullon et al. clim nitrate, month: ', unique(.x$month)))
)
[[1]]
[[2]]
broullon_clim_SO_pH %>%
group_split(depth) %>%
head(2) %>%
map(
~map +
geom_tile(data = .x,
aes(x = lon,
y = lat,
fill = phosphate))+
scale_fill_viridis_c()+
lims(y = c(-85, -28))+
facet_wrap(~month, ncol = 2)+
labs(title = paste0('Broullon et al. (2020) phosphate clim, depth: ', unique(.x$depth)))
)
[[1]]
[[2]]
broullon_clim_SO_pH %>%
# filter(depth <= 1500) %>%
group_split(month) %>%
head(2) %>%
map(
~ ggplot(data = .x,
aes(x = phosphate,
y = depth))+
geom_point(data = .x,
aes(x = phosphate,
y = depth),
size = 0.2,
pch = 1)+
scale_y_reverse()+
facet_grid(biome_name~basin_AIP)+
labs(title = paste0('Broullon et al. clim phosphate, month: ', unique(.x$month)))
)
[[1]]
[[2]]
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] seacarb_3.3.0 SolveSAPHE_2.1.0 oce_1.5-0 gsw_1.0-6
[5] stars_0.5-5 sf_1.0-5 abind_1.4-5 lubridate_1.8.0
[9] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7 purrr_0.3.4
[13] readr_2.1.1 tidyr_1.1.4 tibble_3.1.6 ggplot2_3.3.5
[17] tidyverse_1.3.1 workflowr_1.7.0
loaded via a namespace (and not attached):
[1] fs_1.5.2 bit64_4.0.5 httr_1.4.2 rprojroot_2.0.2
[5] tools_4.1.2 backports_1.4.1 bslib_0.3.1 utf8_1.2.2
[9] R6_2.5.1 KernSmooth_2.23-20 DBI_1.1.2 colorspace_2.0-2
[13] withr_2.4.3 tidyselect_1.1.1 processx_3.5.2 bit_4.0.4
[17] compiler_4.1.2 git2r_0.29.0 cli_3.1.1 rvest_1.0.2
[21] RNetCDF_2.5-2 xml2_1.3.3 labeling_0.4.2 sass_0.4.0
[25] scales_1.1.1 classInt_0.4-3 callr_3.7.0 proxy_0.4-26
[29] digest_0.6.29 rmarkdown_2.11 pkgconfig_2.0.3 htmltools_0.5.2
[33] highr_0.9 dbplyr_2.1.1 fastmap_1.1.0 rlang_1.0.2
[37] tidync_0.2.4 readxl_1.3.1 rstudioapi_0.13 farver_2.1.0
[41] jquerylib_0.1.4 generics_0.1.1 jsonlite_1.7.3 vroom_1.5.7
[45] magrittr_2.0.1 ncmeta_0.3.0 Rcpp_1.0.8 munsell_0.5.0
[49] fansi_1.0.2 lifecycle_1.0.1 stringi_1.7.6 whisker_0.4
[53] yaml_2.2.1 grid_4.1.2 parallel_4.1.2 promises_1.2.0.1
[57] crayon_1.4.2 haven_2.4.3 hms_1.1.1 knitr_1.37
[61] ps_1.6.0 pillar_1.6.4 reprex_2.0.1 glue_1.6.0
[65] evaluate_0.14 getPass_0.2-2 modelr_0.1.8 vctrs_0.3.8
[69] tzdb_0.2.0 httpuv_1.6.5 cellranger_1.1.0 gtable_0.3.0
[73] assertthat_0.2.1 xfun_0.29 lwgeom_0.2-8 broom_0.7.11
[77] e1071_1.7-9 later_1.3.0 viridisLite_0.4.0 ncdf4_1.19
[81] class_7.3-20 units_0.7-2 ellipsis_0.3.2