Last updated: 2021-02-06
Checks: 7 0
Knit directory: emlr_mod_preprocessing/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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(20200707)
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 e104fb2. 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/
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/Cant_AD.Rmd
) and HTML (docs/Cant_AD.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 | 2eb6652 | Donghe-Zhu | 2021-01-27 | Build site. |
Rmd | e36b6ae | Donghe-Zhu | 2021-01-20 | zonal mean plot for offset |
html | 843587f | Donghe-Zhu | 2021-01-11 | Build site. |
Rmd | 0ea5b9f | Donghe-Zhu | 2021-01-11 | complete rebuild after add constant climate |
Rmd | 0269854 | Donghe-Zhu | 2021-01-10 | adding constant climate for regular and random sampling |
html | 279e0e0 | jens-daniel-mueller | 2021-01-06 | Build site. |
Rmd | 056177f | jens-daniel-mueller | 2021-01-06 | revised depth level rounding |
html | 2c85faf | Donghe-Zhu | 2021-01-05 | Build site. |
Rmd | 0f5903f | Donghe-Zhu | 2020-12-31 | model D |
# use only three basin to assign general basin mask
# ie this is not specific to the MLR fitting
basinmask <- basinmask %>%
filter(MLR_basins == "2") %>%
select(lat, lon, basin_AIP)
# read in cmorized variable forcing model file
A_annual <- tidync(paste(path_cmorized,
"RECCAP2_RunA.nc",
sep = ""))
A_annual <- A_annual %>% hyper_tibble()
# harmonize column names and coordinates
A_annual <- A_annual %>%
select(
year = time_ann,
lon,
lat,
depth,
tco2_A = dissic,
sal = so,
theta = thetao
) %>%
# mutate year from seconds since Jan 1, 1980
mutate(year = (year - 15638400) / 31536000 + 1980) %>%
mutate(lon = if_else(lon < 20, lon + 360, lon))
# calculate model temperature
A_annual <- A_annual %>%
mutate(temp = gsw_pt_from_t(
SA = sal,
t = theta,
p = 10.1325,
p_ref = depth
))
# unit transfer from mol/m3 to µmol/kg
A_annual <- A_annual %>%
mutate(
rho = gsw_pot_rho_t_exact(
SA = sal,
t = temp,
p = depth,
p_ref = 10.1325
),
tco2_A = tco2_A * (1e+6 / rho)
) %>%
select(year, lon, lat, depth, tco2_A)
# read in cmorized variable forcing model file
D_annual <- tidync(paste(path_cmorized,
"RECCAP2_RunD.nc",
sep = ""))
D_annual <- D_annual %>% hyper_tibble()
# harmonize column names and coordinates
D_annual <- D_annual %>%
select(
year = time_ann,
lon,
lat,
depth,
tco2_D = dissic,
sal = so,
theta = thetao
) %>%
# mutate year from seconds since Jan 1, 1980
mutate(year = (year - 15638400) / 31536000 + 1980) %>%
mutate(lon = if_else(lon < 20, lon + 360, lon))
# calculate model temperature
D_annual <- D_annual %>%
mutate(temp = gsw_pt_from_t(
SA = sal,
t = theta,
p = 10.1325,
p_ref = depth
))
# unit transfer from mol/m3 to µmol/kg
D_annual <- D_annual %>%
mutate(
rho = gsw_pot_rho_t_exact(
SA = sal,
t = temp,
p = depth,
p_ref = 10.1325
),
tco2_D = tco2_D * (1e+6 / rho)
) %>%
select(year, lon, lat, depth, tco2_D)
cant <- inner_join(A_annual, D_annual)
rm(A_annual, D_annual)
cant <- cant %>%
mutate(depth = round(depth))
# restrict Cant field to basin mask grid
cant <- inner_join(cant, basinmask)
cant <- cant %>%
mutate(cant_total = tco2_A - tco2_D) %>%
select(-c(tco2_A, tco2_D))
# write annual Cant files
years <- c(1982:2019)
for (i_year in years) {
# i_year = years[1]
cant_year <- cant %>%
filter(year == i_year)
cant_year %>%
write_csv(paste(path_preprocessing,
"cant_annual_field_AD/cant_", i_year, ".csv",
sep = ""))
}
cant_1994 <- cant %>%
filter(year == 1994) %>%
select(-c(year)) %>%
rename(cant_1994 = cant_total)
cant_2007 <- cant %>%
filter(year == 2007) %>%
select(-c(year)) %>%
rename(cant_2007 = cant_total)
cant_gruber <- left_join(cant_1994, cant_2007) %>%
mutate(cant = cant_2007 - cant_1994)
cant_gruber <- cant_gruber %>%
mutate(cant_pos = if_else(cant <= 0, 0, cant))
rm(cant_1994, cant_2007)
cant_gruber <- cant_gruber %>%
mutate(eras = "JGOFS/WOCE")
cant_gruber_zonal <- m_zonal_mean_section(cant_gruber)
for (i_basin_AIP in unique(cant_gruber_zonal$basin_AIP)) {
print(
p_section_zonal(
cant_gruber_zonal %>% filter(basin_AIP == i_basin_AIP),
var = "cant_pos_mean",
plot_slabs = "n",
subtitle_text = paste("Basin: ", i_basin_AIP)
)
)
}
for (i_basin_AIP in unique(cant_gruber_zonal$basin_AIP)) {
print(
p_section_zonal(
cant_gruber_zonal %>% filter(basin_AIP == i_basin_AIP),
var = "cant_1994_mean",
plot_slabs = "n",
breaks = seq(0,100,10),
subtitle_text = paste("Basin: ", i_basin_AIP)
)
)
}
Version | Author | Date |
---|---|---|
2eb6652 | Donghe-Zhu | 2021-01-27 |
Version | Author | Date |
---|---|---|
2eb6652 | Donghe-Zhu | 2021-01-27 |
Version | Author | Date |
---|---|---|
2eb6652 | Donghe-Zhu | 2021-01-27 |
for (i_basin_AIP in unique(cant_gruber_zonal$basin_AIP)) {
print(
p_section_zonal(
cant_gruber_zonal %>% filter(basin_AIP == i_basin_AIP),
var = "cant_2007_mean",
plot_slabs = "n",
breaks = seq(0,100,10),
subtitle_text = paste("Basin: ", i_basin_AIP)
)
)
}
cant_gruber_inv <- m_cant_inv(cant_gruber)
p_map_cant_inv(cant_gruber_inv %>% filter(inv_depth == 3000))
# this is just a work around, because the function is designed to calculate cant inventories, but not cant_total inventories
cant_gruber_total_inv <- m_cant_inv(
cant_gruber %>%
select(-cant_pos) %>%
rename(cant_pos = cant_1994))
p_map_cant_inv(cant_gruber_total_inv %>% filter(inv_depth == 3000),
breaks = seq(0,100,10),
subtitle_text = "Cant total in 1994")
Version | Author | Date |
---|---|---|
2eb6652 | Donghe-Zhu | 2021-01-27 |
# this is just a work around, because the function is designed to calculate cant inventories, but not cant_total inventories
cant_gruber_total_inv <- m_cant_inv(
cant_gruber %>%
select(-cant_pos) %>%
rename(cant_pos = cant_2007))
p_map_cant_inv(cant_gruber_total_inv %>% filter(inv_depth == 3000),
breaks = seq(0,100,10),
subtitle_text = "Cant total in 2007")
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: openSUSE Leap 15.2
Matrix products: default
BLAS: /usr/local/R-4.0.3/lib64/R/lib/libRblas.so
LAPACK: /usr/local/R-4.0.3/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] gsw_1.0-5 testthat_3.0.1 stars_0.4-3 sf_0.9-6
[5] abind_1.4-5 tidync_0.2.4 metR_0.9.0 scico_1.2.0
[9] patchwork_1.1.1 collapse_1.5.0 forcats_0.5.0 stringr_1.4.0
[13] dplyr_1.0.2 purrr_0.3.4 readr_1.4.0 tidyr_1.1.2
[17] tibble_3.0.4 ggplot2_3.3.3 tidyverse_1.3.0 workflowr_1.6.2
loaded via a namespace (and not attached):
[1] fs_1.5.0 lubridate_1.7.9 httr_1.4.2
[4] rprojroot_2.0.2 tools_4.0.3 backports_1.1.10
[7] R6_2.5.0 KernSmooth_2.23-17 DBI_1.1.0
[10] colorspace_2.0-0 withr_2.3.0 tidyselect_1.1.0
[13] compiler_4.0.3 git2r_0.27.1 cli_2.2.0
[16] rvest_0.3.6 RNetCDF_2.4-2 xml2_1.3.2
[19] isoband_0.2.3 labeling_0.4.2 scales_1.1.1
[22] checkmate_2.0.0 classInt_0.4-3 digest_0.6.27
[25] rmarkdown_2.5 pkgconfig_2.0.3 htmltools_0.5.0
[28] dbplyr_1.4.4 rlang_0.4.10 readxl_1.3.1
[31] rstudioapi_0.13 farver_2.0.3 generics_0.1.0
[34] jsonlite_1.7.2 magrittr_2.0.1 ncmeta_0.3.0
[37] Matrix_1.2-18 Rcpp_1.0.5 munsell_0.5.0
[40] fansi_0.4.1 lifecycle_0.2.0 stringi_1.5.3
[43] whisker_0.4 yaml_2.2.1 grid_4.0.3
[46] blob_1.2.1 parallel_4.0.3 promises_1.1.1
[49] crayon_1.3.4 lattice_0.20-41 haven_2.3.1
[52] hms_0.5.3 knitr_1.30 pillar_1.4.7
[55] reprex_0.3.0 glue_1.4.2 evaluate_0.14
[58] RcppArmadillo_0.10.1.2.2 data.table_1.13.6 modelr_0.1.8
[61] vctrs_0.3.6 httpuv_1.5.4 cellranger_1.1.0
[64] gtable_0.3.0 assertthat_0.2.1 xfun_0.20
[67] lwgeom_0.2-5 broom_0.7.3 RcppEigen_0.3.3.9.1
[70] e1071_1.7-4 later_1.1.0.1 class_7.3-17
[73] ncdf4_1.17 units_0.6-7 ellipsis_0.3.1