Last updated: 2020-03-18
Checks: 7 0
Knit directory: Baltic_Productivity/
This reproducible R Markdown analysis was created with workflowr (version 1.6.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(20191017)
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 version displayed above was the version of the Git repository at the time these results were generated.
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: data/ARGO/
Ignored: data/Finnmaid/
Ignored: data/GETM/
Ignored: data/OSTIA/
Ignored: data/_merged_data_files/
Ignored: data/_merged_data_files_2019V1/
Ignored: data/_summarized_data_files/
Ignored: data/_summarized_data_files_2019V1/
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.
There are no past versions. Publish this analysis with wflow_publish()
to start tracking its development.
library(tidyverse)
library(ncdf4)
library(vroom) #'rlang' needs to be installed
library(lubridate)
library(geosphere)
library(dygraphs)
library(xts)
library(here)
library(metR)
# route
select_route <- "E"
# variable names in 2d and 3d GETM files
var <- "SSS_east"
# latitude limits
low_lat <- 57.5
high_lat <- 58.5
The mean salinity was calculated across all measurments made between march - september in the NGS subregion.
filesList_2d <- list.files(path= "data", pattern = "Finnmaid.E.2d.20", recursive = TRUE)
nc <- nc_open(paste("data/Finnmaid/", "FM_all_2019_on_standard_tracks.nc", sep = ""))
# read required vectors from netcdf file
route <- ncvar_get(nc, "route")
route <- unlist(strsplit(route, ""))
date_time <- ncvar_get(nc, "time")
latitude_east <- ncvar_get(nc, "latitude_east")
array <- ncvar_get(nc, var) # store the data in a 2-dimensional array
#dim(array) # should have 2 dimensions: 544 coordinate, 2089 time steps
fillvalue <- ncatt_get(nc, var, "_FillValue")
array[array == fillvalue$value] <- NA
rm(fillvalue)
#i <- 5
for (i in seq(1,length(route),1)){
if(route[i] == select_route) {
slice <- array[i,]
value <- mean(slice[latitude_east > low_lat & latitude_east < high_lat], na.rm = TRUE)
sd <- sd(slice[latitude_east > low_lat & latitude_east < high_lat], na.rm = TRUE)
date <- ymd("2000-01-01") + date_time[i]
temp <- bind_cols(date = date, var=var, value = value, sd = sd)
if (exists("timeseries", inherits = FALSE)){
timeseries <- bind_rows(timeseries, temp)
} else{timeseries <- temp}
rm(temp, value, date, sd)
}
}
nc_close(nc)
fm_sss__ngs <- timeseries %>%
mutate(sss = value,
year = year(date),
month = month(date))
fm_sss_ngs_monthlymean <- fm_sss__ngs %>%
filter(month >=3 , month <=9) %>%
summarise(sss_mean = mean(sss, na.rm = TRUE))
rm(array,fm_sss__ngs,nc, timeseries, date_time, filesList_2d, high_lat, i, latitude_east, low_lat, route, select_route, slice, var )
The mean salinity between March and September for the NGS subregion for all years is 6.73.
In the following section, we create a dygraph with two y-axis, combining the pCO2 measurments from VOS Finnmaid with the MLD5 calculations of the GETM Model.
gt_mld_fm_pco2_ngs <-
vroom::vroom(here::here("data/_merged_data_files/", file = "gt_mld_fm_pco2_ngs.csv"))
gt_mld_fm_pco2_ngs <- gt_mld_fm_pco2_ngs %>%
mutate(as.POSIXct(date))
pco2 <- xts(cbind(gt_mld_fm_pco2_ngs$value_pCO2, gt_mld_fm_pco2_ngs$min_pCO2, gt_mld_fm_pco2_ngs$max_pCO2), order.by = gt_mld_fm_pco2_ngs$date)
names(pco2) <- c("pCO2 Finnmaid", "lwr", "upr")
mld5 <- xts(gt_mld_fm_pco2_ngs$value_mld5, order.by = gt_mld_fm_pco2_ngs$date)
plotdata <- cbind(pco2,mld5)
dygraph(plotdata) %>%
dySeries("mld5", axis = 'y2') %>%
dySeries(c("lwr","pCO2.Finnmaid", "upr")) %>%
dyRangeSelector(dateWindow = c("2014-01-01", "2016-12-31")) %>%
dyOptions(drawPoints = TRUE, pointSize = 1.5, connectSeparatedPoints=TRUE, strokeWidth=0.5,
drawAxesAtZero=TRUE)
rm(pco2, mld5, plotdata, fm_sss_ngs_monthlymean, gt_mld_fm_pco2_ngs)
sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] metR_0.5.0 here_0.1 xts_0.11-2 zoo_1.8-6
[5] dygraphs_1.1.1.6 geosphere_1.5-10 lubridate_1.7.4 vroom_1.2.0
[9] ncdf4_1.17 forcats_0.4.0 stringr_1.4.0 dplyr_0.8.3
[13] purrr_0.3.3 readr_1.3.1 tidyr_1.0.0 tibble_2.1.3
[17] ggplot2_3.3.0 tidyverse_1.3.0
loaded via a namespace (and not attached):
[1] nlme_3.1-137 bitops_1.0-6 fs_1.3.1
[4] bit64_0.9-7 httr_1.4.1 rprojroot_1.3-2
[7] tools_3.5.0 backports_1.1.5 utf8_1.1.4
[10] R6_2.4.0 DBI_1.0.0 colorspace_1.4-1
[13] withr_2.1.2 sp_1.3-2 tidyselect_0.2.5
[16] gridExtra_2.3 bit_1.1-14 compiler_3.5.0
[19] git2r_0.26.1 cli_1.1.0 rvest_0.3.5
[22] xml2_1.2.2 scales_1.0.0 checkmate_1.9.4
[25] digest_0.6.22 foreign_0.8-70 rmarkdown_2.0
[28] pkgconfig_2.0.3 htmltools_0.4.0 dbplyr_1.4.2
[31] maps_3.3.0 htmlwidgets_1.5.1 rlang_0.4.5
[34] readxl_1.3.1 rstudioapi_0.10 generics_0.0.2
[37] jsonlite_1.6 RCurl_1.95-4.12 magrittr_1.5
[40] Formula_1.2-3 dotCall64_1.0-0 Matrix_1.2-14
[43] fansi_0.4.0 Rcpp_1.0.2 munsell_0.5.0
[46] lifecycle_0.1.0 stringi_1.4.3 yaml_2.2.0
[49] plyr_1.8.4 grid_3.5.0 maptools_0.9-8
[52] formula.tools_1.7.1 parallel_3.5.0 promises_1.1.0
[55] crayon_1.3.4 lattice_0.20-35 haven_2.2.0
[58] hms_0.5.2 zeallot_0.1.0 knitr_1.26
[61] pillar_1.4.2 reprex_0.3.0 glue_1.3.1
[64] evaluate_0.14 data.table_1.12.6 modelr_0.1.5
[67] operator.tools_1.6.3 vctrs_0.2.0 spam_2.3-0.2
[70] httpuv_1.5.2 cellranger_1.1.0 gtable_0.3.0
[73] assertthat_0.2.1 xfun_0.10 broom_0.5.3
[76] later_1.0.0 memoise_1.1.0 fields_9.9
[79] workflowr_1.6.0