diff --git a/DESCRIPTION b/DESCRIPTION index 080f7598a99722d325162d90ed00cf5c43b26d77..8af0e5477bdd1f15b50ec1ac91adc4437b18989e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: ClimDatDownloadR Type: Package Title: Downloads Climate Data from Chelsa and WorldClim -Version: 0.1.7-2 +Version: 0.1.7-3 Authors@R: c(person("Helge", "Jentsch", email = "helge.marc.ole.jentsch@uni-hamburg.de", role = c("aut", "cre"), @@ -45,7 +45,7 @@ Suggests: knitr, testthat, usethis, rmarkdown VignetteBuilder: knitr SystemRequirements: Tested with at least 4 GB RAM. NeedsCompilation: no -Packaged: 2023-07-06 09:14:58 UTC; admin +Packaged: 2023-07-18 09:50:31 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 f4224b54df61dd985dc7759cb05290e99d161927..76904d3abaf479bdf9deafc898e798bf885f40df 100644 --- a/R/Chelsa_Download_functions.R +++ b/R/Chelsa_Download_functions.R @@ -53,7 +53,7 @@ Chelsa.Clim.download.deprecated<- function(save.location = "./", delete.raw.data = FALSE, save.bib.file = TRUE){ gc() - call.time <- str_replace_all(str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") + call.time <- stringr::str_replace_all(stringr::str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") # initial check ----------------------------------------------------------- # normalize Path for easier application later save.location <- normalizePath(save.location, winslash = "/") @@ -126,7 +126,7 @@ Chelsa.Clim.download.deprecated<- function(save.location = "./", # set the 2nd order temporal save location to create a # managable directory tree in the 1st order directory temp.temp.save.location <- paste0(temp.save.location, - str_replace_all(interm, + stringr::str_replace_all(interm, pattern = "/", "_"), vers_path, "/") @@ -517,7 +517,7 @@ Chelsa.CMIP_5.download <- function(save.location = "./", # requireNamespace("ncdf4") gc() save.location <- normalizePath(save.location, winslash = "/") - call.time <- str_replace_all(str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") + call.time <- stringr::str_replace_all(stringr::str_replace_all(paste0(Sys.time()), 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)){ @@ -562,7 +562,7 @@ Chelsa.CMIP_5.download <- function(save.location = "./", for (model in model.var) { for (emission.scenario in emission.scenario.var) { temp.temp.save.location <- paste0(temp.save.location, - str_replace_all(interm, + stringr::str_replace_all(interm, pattern = "/", "_"), model,"_", @@ -832,7 +832,7 @@ Chelsa.lgm.download <- function(save.location = "./", # requireNamespace("RCurl") # requireNamespace("ncdf4") gc() - call.time <- str_replace_all(str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") + call.time <- stringr::str_replace_all(stringr::str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") # initial check ----------------------------------------------------------- # normalize Path for easier application later save.location <- normalizePath(save.location, winslash = "/") @@ -883,7 +883,7 @@ Chelsa.lgm.download <- function(save.location = "./", for (model in model.var) { # download of the requested datasets ------------------------------------- temp.temp.save.location <- paste0(temp.save.location, - str_replace_all(interm, + stringr::str_replace_all(interm, pattern = "/", "_"), "LGM_PMIP_", model, "/") @@ -1188,7 +1188,7 @@ Chelsa.timeseries.download <- function(save.location = "./", # requireNamespace("RCurl") # requireNamespace("ncdf4") gc() - call.time <- str_replace_all(str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") + call.time <- stringr::str_replace_all(stringr::str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") # initial check ----------------------------------------------------------- # normalize Path for easier application later save.location <- normalizePath(save.location, winslash = "/") @@ -1262,7 +1262,7 @@ Chelsa.timeseries.download <- function(save.location = "./", temp.save.location <- paste0(save.location, "/", i, "/") # to go analog to the functions before temp.temp.save.location <- paste0(temp.save.location, - str_replace_all(interm, + stringr::str_replace_all(interm, pattern = "/", "_"), "timeseries","/") @@ -1447,12 +1447,12 @@ Chelsa.CRUts.download <- function(save.location = "./", combine.raw.zip = FALSE, delete.raw.data = FALSE, save.bib.file = TRUE -){ + ){ # requireNamespace("stringr") # requireNamespace("RCurl") # requireNamespace("ncdf4") gc() - call.time <- str_replace_all(str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") + call.time <- stringr::str_replace_all(stringr::str_replace_all(paste0(Sys.time()), pattern = ":", replacement = "-"), pattern = " ", replacement = "_") # initial check ----------------------------------------------------------- # normalize Path for easier application later save.location <- normalizePath(save.location, winslash = "/") @@ -1531,7 +1531,7 @@ Chelsa.CRUts.download <- function(save.location = "./", temp.save.location <- paste0(save.location, "/", i, "/") # to go analog to the functions before temp.temp.save.location <- paste0(temp.save.location, - str_replace_all(interm, + stringr::str_replace_all(interm, pattern = "/", "_"), "CRU_timeseries","/") @@ -1584,8 +1584,9 @@ Chelsa.CRUts.download <- function(save.location = "./", mustWork = T), "/temp_gdalwarped.tif") # gdalUtils::gdalwarp(dest.temp, raster.temp.file.dest) - raster.temp <- terra::rast(raster.temp.file.dest) - raster.temp <- terra::clamp(raster.temp, lower = -1000, useValues = FALSE) + # raster.temp <- terra::rast(raster.temp.file.dest) + raster.temp <- terra::rast(dest.temp) + raster.temp <- terra::clamp(raster.temp, lower = -1000) raster.temp <- process.raster.int.doub(raster.temp) terra::writeRaster(x = raster.temp, filename = dest.temp, @@ -1659,3 +1660,4 @@ Chelsa.CRUts.download <- function(save.location = "./", # Saving BIB File if(save.bib.file == TRUE) save.citation(save.location = save.location, dataSetName = "CHELSA") } +