Last updated: 2021-06-08
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 4664034. 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/
Untracked files:
Untracked: emlr_mod_preprocessing.Rproj
Unstaged changes:
Deleted: Cant_eMLR.Rproj
Modified: analysis/_site.yml
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/surface_ocean.Rmd
) and HTML (docs/surface_ocean.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 | 4664034 | jens-daniel-mueller | 2021-06-08 | testrun surface ocean data |
html | fe31dfb | jens-daniel-mueller | 2021-06-08 | Build site. |
Rmd | bb1bfa9 | jens-daniel-mueller | 2021-06-08 | testrun surface ocean data |
path_cmorized <-
"/nfs/kryo/work/loher/CESM_output/RECCAP2/submit_June2021/"
path_preprocessing <-
paste(path_root, "/model/preprocessing/", sep = "")
# 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)
Here we subset cmorized (1x1) surface ocean data from the model with variable forcing.
Besides, Model results are given in [mol m-3], whereas GLODAP data are in [µmol kg-1]. This refers to the variables:
For comparison, model results were converted from [mol m-3] to [µmol kg-1]
# set name of model to be subsetted
model_IDs <- c("A", "D")
# for loop across variables
variables <-
c("spco2",
"fgco2",
"talkos",
"dissicos",
"po4os",
"sios",
"sos",
"tos")
for (i_model_ID in model_IDs) {
# i_model_ID <- model_IDs[1]
for (i_variable in variables) {
# i_variable <- variables[1]
# read list of all files
file <- paste(i_variable,
"_CESM-ETHZ_",
i_model_ID,
"_1_gr_1980-2018_v20210607.nc",
sep = "")
print(file)
# read in data
variable_data <-
read_ncdf(paste(path_cmorized,
file,
sep = ""),
make_units = FALSE)
# convert to tibble
variable_data_tibble <- variable_data %>%
as_tibble()
# remove open link to nc file
rm(variable_data)
# remove na values
variable_data_tibble <-
variable_data_tibble %>%
drop_na()
# harmonize longitudes
variable_data_tibble <- variable_data_tibble %>%
mutate(lon = if_else(lon < 20, lon + 360, lon))
# only consider model grids within basinmask
variable_data_tibble <-
inner_join(variable_data_tibble, basinmask) %>%
select(-basin_AIP)
# mutate variables
variable_data_tibble <- variable_data_tibble %>%
mutate(year = year(time_mon)) %>%
select(-time_mon)
# calculate annual average variable
variable_data_tibble_annual_average <- variable_data_tibble %>%
fgroup_by(lat, lon, year) %>% {
add_vars(fgroup_vars(., "unique"),
fmean(., keep.group_vars = FALSE))
}
# calculate climatology
variable_data_tibble_climatology <-
variable_data_tibble_annual_average %>%
fselect(-year) %>%
fgroup_by(lat, lon) %>% {
add_vars(fgroup_vars(., "unique"),
fmean(., keep.group_vars = FALSE))
}
# surface map of variable
print(
map +
geom_raster(data = variable_data_tibble_climatology,
aes(lon, lat, fill = !!sym(i_variable))) +
scale_fill_viridis_c(name = i_variable)
)
# write raw data file for GLODAP-based subsetting model variables
variable_data_tibble_annual_average %>%
write_csv(file = paste(path_preprocessing,
"surface_ocean_",
i_model_ID,
"/",
i_variable,
".csv",
sep = ""))
}
}
[1] "spco2_CESM-ETHZ_A_1_gr_1980-2018_v20210607.nc"
[1] "fgco2_CESM-ETHZ_A_1_gr_1980-2018_v20210607.nc"
[1] "talkos_CESM-ETHZ_A_1_gr_1980-2018_v20210607.nc"
[1] "dissicos_CESM-ETHZ_A_1_gr_1980-2018_v20210607.nc"
[1] "po4os_CESM-ETHZ_A_1_gr_1980-2018_v20210607.nc"
[1] "sios_CESM-ETHZ_A_1_gr_1980-2018_v20210607.nc"
[1] "sos_CESM-ETHZ_A_1_gr_1980-2018_v20210607.nc"
[1] "tos_CESM-ETHZ_A_1_gr_1980-2018_v20210607.nc"
[1] "spco2_CESM-ETHZ_D_1_gr_1980-2018_v20210607.nc"
[1] "fgco2_CESM-ETHZ_D_1_gr_1980-2018_v20210607.nc"
[1] "talkos_CESM-ETHZ_D_1_gr_1980-2018_v20210607.nc"
[1] "dissicos_CESM-ETHZ_D_1_gr_1980-2018_v20210607.nc"
[1] "po4os_CESM-ETHZ_D_1_gr_1980-2018_v20210607.nc"
[1] "sios_CESM-ETHZ_D_1_gr_1980-2018_v20210607.nc"
[1] "sos_CESM-ETHZ_D_1_gr_1980-2018_v20210607.nc"
[1] "tos_CESM-ETHZ_D_1_gr_1980-2018_v20210607.nc"
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] reticulate_1.18 oce_1.2-0 marelac_2.1.10 shape_1.4.5
[5] gsw_1.0-5 testthat_2.3.2 rqdatatable_1.2.9 rquery_1.4.6
[9] wrapr_2.0.4 lubridate_1.7.9 stars_0.5-2 sf_0.9-8
[13] abind_1.4-5 metR_0.9.0 scico_1.2.0 patchwork_1.1.1
[17] collapse_1.5.0 forcats_0.5.0 stringr_1.4.0 dplyr_1.0.5
[21] purrr_0.3.4 readr_1.4.0 tidyr_1.1.2 tibble_3.0.4
[25] ggplot2_3.3.3 tidyverse_1.3.0 workflowr_1.6.2
loaded via a namespace (and not attached):
[1] fs_1.5.0 httr_1.4.2 rprojroot_2.0.2
[4] tools_4.0.3 backports_1.1.10 R6_2.5.0
[7] KernSmooth_2.23-17 DBI_1.1.0 colorspace_1.4-1
[10] withr_2.3.0 tidyselect_1.1.0 compiler_4.0.3
[13] git2r_0.27.1 cli_2.1.0 rvest_0.3.6
[16] RNetCDF_2.4-2 xml2_1.3.2 labeling_0.4.2
[19] scales_1.1.1 checkmate_2.0.0 classInt_0.4-3
[22] digest_0.6.27 rmarkdown_2.5 pkgconfig_2.0.3
[25] htmltools_0.5.0 dbplyr_1.4.4 rlang_0.4.10
[28] readxl_1.3.1 rstudioapi_0.11 farver_2.0.3
[31] generics_0.0.2 jsonlite_1.7.1 magrittr_1.5
[34] ncmeta_0.3.0 Matrix_1.2-18 Rcpp_1.0.5
[37] munsell_0.5.0 fansi_0.4.1 lifecycle_1.0.0
[40] stringi_1.5.3 whisker_0.4 yaml_2.2.1
[43] grid_4.0.3 blob_1.2.1 parallel_4.0.3
[46] promises_1.1.1 crayon_1.3.4 lattice_0.20-41
[49] haven_2.3.1 seacarb_3.2.14 hms_0.5.3
[52] knitr_1.30 pillar_1.4.7 reprex_0.3.0
[55] glue_1.4.2 evaluate_0.14 RcppArmadillo_0.10.1.2.0
[58] data.table_1.13.2 modelr_0.1.8 vctrs_0.3.5
[61] httpuv_1.5.4 cellranger_1.1.0 gtable_0.3.0
[64] assertthat_0.2.1 xfun_0.18 lwgeom_0.2-5
[67] broom_0.7.5 RcppEigen_0.3.3.7.0 e1071_1.7-4
[70] later_1.1.0.1 viridisLite_0.3.0 class_7.3-17
[73] units_0.6-7 ellipsis_0.3.1