diff --git a/DESCRIPTION b/DESCRIPTION index 6f52079d06333433bbfbbb043deefd247085ac22..6bb4d73cb829bb7ed61cbc08b8d89d7db495ecb4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -45,7 +45,7 @@ Suggests: knitr, testthat, usethis, rmarkdown VignetteBuilder: knitr SystemRequirements: Tested with at least 4 GB RAM. NeedsCompilation: no -Packaged: 2023-08-14 18:54:05 UTC; helge +Packaged: 2023-08-28 18:21:08 UTC; helge Author: Helge Jentsch [aut, cre], Maria Bobrowski [aut], Johannes Weidinger [aut], diff --git a/R/Chelsa_Download_functions.R b/R/Chelsa_Download_functions.R index d1cdd2303a923b905d84c404f8c4f39b89f38d67..68caa2cc32dee84a9169d5ea90debe42a9199761 100644 --- a/R/Chelsa_Download_functions.R +++ b/R/Chelsa_Download_functions.R @@ -53,7 +53,15 @@ Chelsa.Clim.download.deprecated<- function(save.location = "./", delete.raw.data = FALSE, save.bib.file = TRUE){ gc() - call.time <- stringr::str_replace_all(stringr::str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") + call.time <- stringr::str_replace_all( + stringr::str_replace_all( + stringr::str_split(string = paste0(Sys.time()), + pattern = "\\.")[[1]][1], + pattern = ":", + replacement = "-"), + pattern = " ", + replacement = "_") + # initial check ----------------------------------------------------------- # normalize Path for easier application later save.location <- normalizePath(save.location, winslash = "/") @@ -517,7 +525,15 @@ Chelsa.CMIP_5.download <- function(save.location = "./", # requireNamespace("ncdf4") gc() save.location <- normalizePath(save.location, winslash = "/") - call.time <- stringr::str_replace_all(stringr::str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") + call.time <- stringr::str_replace_all( + stringr::str_replace_all( + stringr::str_split(string = paste0(Sys.time()), + pattern = "\\.")[[1]][1], + pattern = ":", + replacement = "-"), + pattern = " ", + replacement = "_") + # the build of this function is very similar to the Chelsa.Clim.download function. if(is.element("prec", parameter)|is.element("temp", parameter)| is.element("tmax", parameter)|is.element("tmin", parameter)){ @@ -832,7 +848,15 @@ Chelsa.lgm.download <- function(save.location = "./", # requireNamespace("RCurl") # requireNamespace("ncdf4") gc() - call.time <- stringr::str_replace_all(stringr::str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") + call.time <- stringr::str_replace_all( + stringr::str_replace_all( + stringr::str_split(string = paste0(Sys.time()), + pattern = "\\.")[[1]][1], + pattern = ":", + replacement = "-"), + pattern = " ", + replacement = "_") + # initial check ----------------------------------------------------------- # normalize Path for easier application later save.location <- normalizePath(save.location, winslash = "/") @@ -1187,7 +1211,14 @@ Chelsa.timeseries.download <- function(save.location = "./", # requireNamespace("RCurl") # requireNamespace("ncdf4") gc() - call.time <- stringr::str_replace_all(stringr::str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") + call.time <- stringr::str_replace_all( + stringr::str_replace_all( + stringr::str_split(string = paste0(Sys.time()), + pattern = "\\.")[[1]][1], + pattern = ":", + replacement = "-"), + pattern = " ", + replacement = "_") # initial check ----------------------------------------------------------- # normalize Path for easier application later save.location <- normalizePath(save.location, winslash = "/") @@ -1451,7 +1482,15 @@ Chelsa.CRUts.download <- function(save.location = "./", # requireNamespace("RCurl") # requireNamespace("ncdf4") gc() - call.time <- stringr::str_replace_all(stringr::str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") + call.time <- stringr::str_replace_all( + stringr::str_replace_all( + stringr::str_split(string = paste0(Sys.time()), + pattern = "\\.")[[1]][1], + pattern = ":", + replacement = "-"), + pattern = " ", + replacement = "_") + # initial check ----------------------------------------------------------- # normalize Path for easier application later save.location <- normalizePath(save.location, winslash = "/") diff --git a/R/Chelsa_new_download_functions.R b/R/Chelsa_new_download_functions.R index 743b7a763c65d712898afae118f9e0a60b8d8400..9a5b6e986429dd21e697143940d7bc619792661e 100644 --- a/R/Chelsa_new_download_functions.R +++ b/R/Chelsa_new_download_functions.R @@ -56,9 +56,11 @@ Chelsa.Clim.download <- function(save.location = "./", save.bib.file = TRUE){ gc() call.time <- stringr::str_replace_all( - stringr::str_replace_all(paste0(Sys.time()), - pattern = ":", - replacement = "-"), + stringr::str_replace_all( + stringr::str_split(string = paste0(Sys.time()), + pattern = "\\.")[[1]][1], + pattern = ":", + replacement = "-"), pattern = " ", replacement = "_") # initial check ----------------------------------------------------------- @@ -544,9 +546,11 @@ Chelsa.CMIP_6.download <- function(save.location = "./", ){ gc() call.time <- stringr::str_replace_all( - stringr::str_replace_all(as.character(Sys.time()), - pattern = ":", - replacement = "-"), + stringr::str_replace_all( + stringr::str_split(string = paste0(Sys.time()), + pattern = "\\.")[[1]][1], + pattern = ":", + replacement = "-"), pattern = " ", replacement = "_") @@ -941,11 +945,15 @@ Chelsa.timeseries.download <- function(save.location = "./", delete.raw.data = FALSE, save.bib.file = TRUE){ gc() - call.time <- stringr::str_replace_all(stringr::str_replace_all(paste0(Sys.time()), - pattern = ":", - replacement = "-"), - pattern = " ", - replacement = "_") + call.time <- stringr::str_replace_all( + stringr::str_replace_all( + stringr::str_split(string = paste0(Sys.time()), + pattern = "\\.")[[1]][1], + pattern = ":", + replacement = "-"), + pattern = " ", + replacement = "_") + # stringr::str_replace_all(stringr::str_replace_all(stringr::str_split(string = paste0(Sys.time()), pattern = "\."), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") # initial check ----------------------------------------------------------- # normalize Path for easier application later save.location <- normalizePath(save.location, @@ -1009,7 +1017,6 @@ Chelsa.timeseries.download <- function(save.location = "./", 2, 'left', pad = "0") - # print(include.month.var) } if(start.year.var < 1979 | end.year.var > 2019 | end.year.var < 1979 | start.year.var > 2019) { stop("Timeseries only available from 02.1979 to 12.2019. \n Please check input!") @@ -1028,13 +1035,12 @@ Chelsa.timeseries.download <- function(save.location = "./", ts_string <- format.Date(ts_string, format = "%m_%Y") # ts_string <- str_sub(ts_string, 1, end = str_length(ts_string)-3) # ts_string <- str_replace_all(ts_string, pattern = "-", replacement = "_") - if(length(include.month.var)!=12){ ts.string.temp <- c() for (incl.month in include.month.var) { # print(incl.month) ts.string.temp <- c(ts.string.temp, - ts_string[grep(pattern = paste0("_", incl.month) + ts_string[grep(pattern = paste0(incl.month, "_") , ts_string)] ) } diff --git a/R/WorldClim_download_functions.R b/R/WorldClim_download_functions.R index 3cf33a64008e88bc11f16879b73d54fa06076735..93f1991c89832ff79ef61302ce516a26199c2cc1 100644 --- a/R/WorldClim_download_functions.R +++ b/R/WorldClim_download_functions.R @@ -72,11 +72,14 @@ WorldClim.HistClim.download <- function(save.location = "./", # requireNamespace("raster") gc() call.time <- stringr::str_replace_all( - stringr::str_replace_all(paste0(Sys.time()), - pattern = ":", - replacement = "-"), + stringr::str_replace_all( + stringr::str_split(string = paste0(Sys.time()), + pattern = "\\.")[[1]][1], + pattern = ":", + replacement = "-"), pattern = " ", replacement = "_") + # initial check ----------------------------------------------------------- # normalize Path for easier application later save.location <- base::normalizePath(save.location, winslash = "/") @@ -658,12 +661,15 @@ WorldClim.CMIP_5.download <- function(save.location = "./", # requireNamespace("ncdf4") # requireNamespace("raster") gc() - call.time <- stringr::str_replace_all(stringr::str_replace_all( - paste0(Sys.time()), - pattern = ":", - replacement = "-"), + call.time <- stringr::str_replace_all( + stringr::str_replace_all( + stringr::str_split(string = paste0(Sys.time()), + pattern = "\\.")[[1]][1], + pattern = ":", + replacement = "-"), pattern = " ", - replacement = "_") + replacement = "_") + # initial check ----------------------------------------------------------- # normalize Path for easier application later save.location <- normalizePath(save.location, winslash = "/") @@ -1168,7 +1174,14 @@ WorldClim.CMIP_6.download <- function(save.location = "./", # requireNamespace("ncdf4") # requireNamespace("raster") gc() - call.time <- stringr::str_replace_all(stringr::str_replace_all(as.character(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") + call.time <- stringr::str_replace_all( + stringr::str_replace_all( + stringr::str_split(string = paste0(Sys.time()), + pattern = "\\.")[[1]][1], + pattern = ":", + replacement = "-"), + pattern = " ", + replacement = "_") # initial check ----------------------------------------------------------- # normalize Path for easier application later save.location <- normalizePath(save.location, winslash = "/")