Last updated: 2021-11-11
Checks: 7 0
Knit directory: bgc_argo_r_argodata/
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(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 fb668ef. 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/
Untracked files:
Untracked: code/creating_dataframe.R
Untracked: code/creating_map.R
Untracked: code/pH_data_timeseries.R
Unstaged changes:
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/oxygen_data.Rmd
) and HTML (docs/oxygen_data.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 | fb668ef | pasqualina-vonlanthendinenna | 2021-11-11 | added oxygen data page |
Rmd | f7807db | pasqualina-vonlanthendinenna | 2021-11-11 | added oxygen data page |
Explore BGC-Argo oxygen data through timeseries and climatological maps
path_argo <- '/nfs/kryo/work/updata/bgc_argo_r_argodata'
path_emlr_utilities <- "/nfs/kryo/work/jenmueller/emlr_cant/utilities/files/"
Load in delayed-mode, adjusted oxygen data from the BGC-Argo synthetic profile files
# set cache directory
argo_set_cache_dir(cache_dir = path_argo)
# periodically update the cached files
argo_update_global(max_global_cache_age = Inf)
argo_update_data(max_data_cache_age = Inf)
# load synthetic Argo files containing delayed-mode data between 2013 and now
bgc_subset <- argo_global_synthetic_prof() %>%
argo_filter_data_mode(data_mode = 'delayed') %>% # load in delayed-mode data
argo_filter_date(date_min = '2013-01-01',
date_max = Sys.time())
Loading argo_global_synthetic_prof()
# read in the oxygen data (with corresponding CTD variables)
oxy_data <- argo_prof_levels(
path = bgc_subset,
vars =
c(
'PRES_ADJUSTED',
'PRES_ADJUSTED_QC',
'PRES_ADJUSTED_ERROR',
'PSAL_ADJUSTED',
'PSAL_ADJUSTED_QC',
'PSAL_ADJUSTED_ERROR',
'TEMP_ADJUSTED',
'TEMP_ADJUSTED_QC',
'TEMP_ADJUSTED_ERROR',
'DOXY_ADJUSTED',
'DOXY_ADJUSTED_QC',
'DOXY_ADJUSTED_ERROR'
),
quiet = TRUE
)
# read in corresponding metadata
oxy_metadata <- argo_prof_prof(path = bgc_subset)
Extracting from 138081 files
# merge the data and metadata
oxy_merge <-
full_join(oxy_data, oxy_metadata)
Joining, by = c("file", "n_prof")
oxy_merge <- oxy_merge %>%
rename(lon = longitude,
lat = latitude) %>%
mutate(lon = if_else(lon < 20, lon + 360, lon)) %>%
mutate(
lat = cut(lat, seq(-90, 90, 2), seq(-89.5, 89.5, 2)),
lat = as.numeric(as.character(lat)),
lon = cut(lon, seq(20, 380, 2), seq(20.5, 379.5, 2)), # change to 2x2º grid
lon = as.numeric(as.character(lon))
) %>%
select(
-c(profile_nitrate_qc:profile_up_radiance555_qc)
) # remove profile_qc columns for non existent variables
Focus on surface oxygen (top 10 m of the watercolumn) in the Southern Ocean, south of 30ºS
# select only best pH data (with QC flag 1) below 30ºS, for the top 10 m of the watercolumn
oxy_surface <- oxy_merge %>%
mutate(depth = swDepth(pres_adjusted, latitude = lat), .before = pres_adjusted) %>%
filter(doxy_adjusted_qc == '1', # keep only 'good' data
lat <= -30, # keep only data at or south of 30ºS
depth <= 10) %>% # keep only data above or at 10 m depth
mutate(
year = year(date), # separate the year and month from the date column
month = month(date), .after = n_prof
)
# check the correct latitudes, QC flags, and depth levels have been filtered
# max(oxy_surface$lat)
# min(oxy_surface$lat)
# table(oxy_surface$doxy_adjusted_qc)
# max(oxy_surface$depth)
# max(oxy_surface$date)
# min(oxy_surface$date)
Create a map of climatological monthly oxygen values, from January 2013 to August 2021, for the region south of 30ºS
# average oxygen values in the top 10 m for each month in each 2 x 2º longitude/latitude grid
oxy_mean <- oxy_surface %>%
group_by(lat, lon, month) %>%
summarise(oxy_ave_month = mean(doxy_adjusted))
`summarise()` has grouped output by 'lat', 'lon'. You can override using the `.groups` argument.
# read in the map from updata
map <-
read_rds(paste(path_emlr_utilities,
"map_landmask_WOA18.rds",
sep = ""))
# map a monthly climatology of surface oxygen (Jan 2013 - September 2021)
map +
geom_tile(data = oxy_mean,
aes(lon, lat, fill = oxy_ave_month)) +
lims(y = c(-85, -25)) +
scale_fill_gradientn(colors = oceColorsJet(n = oxy_mean$oxy_ave_month)) +
labs(x = 'lon',
y = 'lat',
fill = 'dissolved oxygen \n(µmol kg-1)',
title = 'Monthly average surface dissolved oxygen values (Jan 2013-Sep 2021)') +
theme(legend.position = 'bottom')+
facet_wrap(~month)
Warning in seq.int(0, 1, length.out = n): first element used of 'length.out'
argument
Warning: Raster pixels are placed at uneven vertical intervals and will be
shifted. Consider using geom_tile() instead.
Warning: Removed 153708 rows containing missing values (geom_raster).
Plot a timeseries of monthly-mean dissolved oxygen for the region south of 30ºS for the upper 10 m of the watercolumn
# plot a timeseries of monthly values over the whole southern ocean south of 30ºS
oxy_month <- oxy_surface %>%
group_by(year, month) %>%
summarise(oxy_ave = mean(doxy_adjusted))
`summarise()` has grouped output by 'year'. You can override using the `.groups` argument.
# timeseries of monthly pH values over 2013-2021 (separate panels for each month)
oxy_month %>%
ggplot(aes(x = year, y = oxy_ave)) +
facet_wrap(~month) +
geom_line() +
geom_point() +
scale_x_continuous(breaks = seq(2013, 2021, 2))+
labs(x = 'year',
y = 'dissolved O2 (µmol kg-1)',
title = 'monthly mean dissolved oxygen (Jan 2013-Sep 2021, south of 30ºS)')
Monthly average dissolved oxygen, per year (January 2013 - December 2020; plotting only full years), over the whole region south of 30ºS
# timeseries of monthly oxygen values for each year (separate years on the same plot)
oxy_month %>%
filter(year != 2021) %>% # keep only years with full data
ggplot(aes(x = month, y = oxy_ave, group = year, col = as.character(year)))+
geom_line()+
geom_point()+
scale_x_continuous(breaks = seq(1, 12, 1))+
labs(x = 'month',
y = 'dissolved O2 (µmol kg-1)',
title = 'monthly mean dissolved oxygen (Jan 2013-Dec 2020, south of 30ºS)',
col = 'year')
Focus on surface oxygen (upper 10 m) in the north-west Pacific (10ºN - 70ºN, -190ºE, -140ºE)
# select only best oxygen data (with QC flag 1) between 10 and 70ºN, and 190 and 140ºW, for the top 10 m of the watercolumn
oxy_nwpacific <- oxy_merge %>%
mutate(depth = swDepth(pres_adjusted, latitude = lat), .before = pres_adjusted) %>%
filter(doxy_adjusted_qc == '1', # keep only 'good' data
between(lat, 10, 70),
between(lon, 190, 240), # keep only data at or south of 30ºS
depth <= 10) %>% # keep only data above or at 10 m depth
mutate(
year = year(date), # separate the year and month from the date column
month = month(date), .after = n_prof
)
# longitudes larger than -180ºE are lon-380
Create a map of climatological monthly surface oxygen values, in the north-west Pacific ocean (10ºN - 70ºN, -190ºE, -140ºE), for January 2013 - August 2021
# average oxygen values in the top 10 m for each month in each 2 x 2º longitude/latitude grid
oxy_mean_nwpacific <- oxy_nwpacific %>%
group_by(lat, lon, month) %>%
summarise(oxy_ave_month = mean(doxy_adjusted))
`summarise()` has grouped output by 'lat', 'lon'. You can override using the `.groups` argument.
# map a monthly climatology of surface oxygen (Jan 2013 - August 2021)
map +
geom_tile(data = oxy_mean_nwpacific,
aes(lon, lat, fill = oxy_ave_month)) +
lims(y = c(5, 60),
x = c(180, 250)) +
scale_fill_gradientn(colors = oceColorsJet(n = oxy_mean_nwpacific$oxy_ave_month)) +
labs(x = 'lon',
y = 'lat',
fill = 'dissolved oxygen \n(µmol kg-1)',
title = 'Monthly average surface dissolved oxygen values (Jan 2013-Aug 2021)') +
theme(legend.position = 'right')+
facet_wrap(~month)
Warning in seq.int(0, 1, length.out = n): first element used of 'length.out'
argument
Warning: Removed 219516 rows containing missing values (geom_raster).
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] oce_1.4-0 testthat_3.0.4 sf_1.0-2
[4] gsw_1.0-6 lubridate_1.7.9 argodata_0.0.0.9000
[7] forcats_0.5.0 stringr_1.4.0 dplyr_1.0.5
[10] purrr_0.3.4 readr_1.4.0 tidyr_1.1.3
[13] tibble_3.1.3 ggplot2_3.3.5 tidyverse_1.3.0
[16] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] fs_1.5.0 bit64_4.0.5 progress_1.2.2 httr_1.4.2
[5] rprojroot_2.0.2 tools_4.0.3 backports_1.1.10 bslib_0.2.5.1
[9] utf8_1.2.2 R6_2.5.1 KernSmooth_2.23-17 DBI_1.1.1
[13] colorspace_2.0-2 withr_2.4.2 tidyselect_1.1.0 prettyunits_1.1.1
[17] bit_4.0.4 compiler_4.0.3 git2r_0.27.1 cli_3.0.1
[21] rvest_0.3.6 RNetCDF_2.4-2 xml2_1.3.2 labeling_0.4.2
[25] sass_0.4.0 scales_1.1.1 classInt_0.4-3 proxy_0.4-26
[29] digest_0.6.27 rmarkdown_2.10 pkgconfig_2.0.3 htmltools_0.5.1.1
[33] dbplyr_1.4.4 highr_0.8 rlang_0.4.11 readxl_1.3.1
[37] rstudioapi_0.13 jquerylib_0.1.4 generics_0.1.0 farver_2.1.0
[41] jsonlite_1.7.2 vroom_1.5.5 magrittr_2.0.1 Rcpp_1.0.7
[45] munsell_0.5.0 fansi_0.5.0 lifecycle_1.0.0 stringi_1.5.3
[49] whisker_0.4 yaml_2.2.1 grid_4.0.3 blob_1.2.1
[53] parallel_4.0.3 promises_1.2.0.1 crayon_1.4.1 haven_2.3.1
[57] hms_0.5.3 knitr_1.33 pillar_1.6.2 reprex_0.3.0
[61] glue_1.4.2 evaluate_0.14 modelr_0.1.8 vctrs_0.3.8
[65] tzdb_0.1.2 httpuv_1.6.2 cellranger_1.1.0 gtable_0.3.0
[69] assertthat_0.2.1 xfun_0.25 broom_0.7.9 e1071_1.7-8
[73] later_1.3.0 class_7.3-17 units_0.7-2 ellipsis_0.3.2