Skip to content
Snippets Groups Projects
Commit 847b2472 authored by Jentsch, Helge's avatar Jentsch, Helge
Browse files

Merge branch '0.1.7' into 'master'

minor updates to Chelsa.CRUts-function

See merge request helgejentsch/climdatdownloadr!37
parents b67310f6 1ccb6c9f
No related branches found
No related tags found
No related merge requests found
Package: ClimDatDownloadR Package: ClimDatDownloadR
Type: Package Type: Package
Title: Downloads Climate Data from Chelsa and WorldClim Title: Downloads Climate Data from Chelsa and WorldClim
Version: 0.1.7-2 Version: 0.1.7-3
Authors@R: c(person("Helge", "Jentsch", Authors@R: c(person("Helge", "Jentsch",
email = "helge.marc.ole.jentsch@uni-hamburg.de", email = "helge.marc.ole.jentsch@uni-hamburg.de",
role = c("aut", "cre"), role = c("aut", "cre"),
...@@ -45,7 +45,7 @@ Suggests: knitr, testthat, usethis, rmarkdown ...@@ -45,7 +45,7 @@ Suggests: knitr, testthat, usethis, rmarkdown
VignetteBuilder: knitr VignetteBuilder: knitr
SystemRequirements: Tested with at least 4 GB RAM. SystemRequirements: Tested with at least 4 GB RAM.
NeedsCompilation: no 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], Author: Helge Jentsch [aut, cre],
Maria Bobrowski [aut], Maria Bobrowski [aut],
Johannes Weidinger [aut], Johannes Weidinger [aut],
......
...@@ -53,7 +53,7 @@ Chelsa.Clim.download.deprecated<- function(save.location = "./", ...@@ -53,7 +53,7 @@ Chelsa.Clim.download.deprecated<- function(save.location = "./",
delete.raw.data = FALSE, delete.raw.data = FALSE,
save.bib.file = TRUE){ save.bib.file = TRUE){
gc() 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 ----------------------------------------------------------- # initial check -----------------------------------------------------------
# normalize Path for easier application later # normalize Path for easier application later
save.location <- normalizePath(save.location, winslash = "/") save.location <- normalizePath(save.location, winslash = "/")
...@@ -126,7 +126,7 @@ Chelsa.Clim.download.deprecated<- function(save.location = "./", ...@@ -126,7 +126,7 @@ Chelsa.Clim.download.deprecated<- function(save.location = "./",
# set the 2nd order temporal save location to create a # set the 2nd order temporal save location to create a
# managable directory tree in the 1st order directory # managable directory tree in the 1st order directory
temp.temp.save.location <- paste0(temp.save.location, temp.temp.save.location <- paste0(temp.save.location,
str_replace_all(interm, stringr::str_replace_all(interm,
pattern = "/", pattern = "/",
"_"), "_"),
vers_path, "/") vers_path, "/")
...@@ -517,7 +517,7 @@ Chelsa.CMIP_5.download <- function(save.location = "./", ...@@ -517,7 +517,7 @@ Chelsa.CMIP_5.download <- function(save.location = "./",
# requireNamespace("ncdf4") # requireNamespace("ncdf4")
gc() gc()
save.location <- normalizePath(save.location, winslash = "/") 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. # the build of this function is very similar to the Chelsa.Clim.download function.
if(is.element("prec", parameter)|is.element("temp", parameter)| if(is.element("prec", parameter)|is.element("temp", parameter)|
is.element("tmax", parameter)|is.element("tmin", parameter)){ is.element("tmax", parameter)|is.element("tmin", parameter)){
...@@ -562,7 +562,7 @@ Chelsa.CMIP_5.download <- function(save.location = "./", ...@@ -562,7 +562,7 @@ Chelsa.CMIP_5.download <- function(save.location = "./",
for (model in model.var) { for (model in model.var) {
for (emission.scenario in emission.scenario.var) { for (emission.scenario in emission.scenario.var) {
temp.temp.save.location <- paste0(temp.save.location, temp.temp.save.location <- paste0(temp.save.location,
str_replace_all(interm, stringr::str_replace_all(interm,
pattern = "/", pattern = "/",
"_"), "_"),
model,"_", model,"_",
...@@ -832,7 +832,7 @@ Chelsa.lgm.download <- function(save.location = "./", ...@@ -832,7 +832,7 @@ Chelsa.lgm.download <- function(save.location = "./",
# requireNamespace("RCurl") # requireNamespace("RCurl")
# requireNamespace("ncdf4") # requireNamespace("ncdf4")
gc() 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 ----------------------------------------------------------- # initial check -----------------------------------------------------------
# normalize Path for easier application later # normalize Path for easier application later
save.location <- normalizePath(save.location, winslash = "/") save.location <- normalizePath(save.location, winslash = "/")
...@@ -883,7 +883,7 @@ Chelsa.lgm.download <- function(save.location = "./", ...@@ -883,7 +883,7 @@ Chelsa.lgm.download <- function(save.location = "./",
for (model in model.var) { for (model in model.var) {
# download of the requested datasets ------------------------------------- # download of the requested datasets -------------------------------------
temp.temp.save.location <- paste0(temp.save.location, temp.temp.save.location <- paste0(temp.save.location,
str_replace_all(interm, stringr::str_replace_all(interm,
pattern = "/", pattern = "/",
"_"), "_"),
"LGM_PMIP_", model, "/") "LGM_PMIP_", model, "/")
...@@ -1188,7 +1188,7 @@ Chelsa.timeseries.download <- function(save.location = "./", ...@@ -1188,7 +1188,7 @@ Chelsa.timeseries.download <- function(save.location = "./",
# requireNamespace("RCurl") # requireNamespace("RCurl")
# requireNamespace("ncdf4") # requireNamespace("ncdf4")
gc() 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 ----------------------------------------------------------- # initial check -----------------------------------------------------------
# normalize Path for easier application later # normalize Path for easier application later
save.location <- normalizePath(save.location, winslash = "/") save.location <- normalizePath(save.location, winslash = "/")
...@@ -1262,7 +1262,7 @@ Chelsa.timeseries.download <- function(save.location = "./", ...@@ -1262,7 +1262,7 @@ Chelsa.timeseries.download <- function(save.location = "./",
temp.save.location <- paste0(save.location, "/", i, "/") temp.save.location <- paste0(save.location, "/", i, "/")
# to go analog to the functions before # to go analog to the functions before
temp.temp.save.location <- paste0(temp.save.location, temp.temp.save.location <- paste0(temp.save.location,
str_replace_all(interm, stringr::str_replace_all(interm,
pattern = "/", pattern = "/",
"_"), "_"),
"timeseries","/") "timeseries","/")
...@@ -1452,7 +1452,7 @@ Chelsa.CRUts.download <- function(save.location = "./", ...@@ -1452,7 +1452,7 @@ Chelsa.CRUts.download <- function(save.location = "./",
# requireNamespace("RCurl") # requireNamespace("RCurl")
# requireNamespace("ncdf4") # requireNamespace("ncdf4")
gc() 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 ----------------------------------------------------------- # initial check -----------------------------------------------------------
# normalize Path for easier application later # normalize Path for easier application later
save.location <- normalizePath(save.location, winslash = "/") save.location <- normalizePath(save.location, winslash = "/")
...@@ -1531,7 +1531,7 @@ Chelsa.CRUts.download <- function(save.location = "./", ...@@ -1531,7 +1531,7 @@ Chelsa.CRUts.download <- function(save.location = "./",
temp.save.location <- paste0(save.location, "/", i, "/") temp.save.location <- paste0(save.location, "/", i, "/")
# to go analog to the functions before # to go analog to the functions before
temp.temp.save.location <- paste0(temp.save.location, temp.temp.save.location <- paste0(temp.save.location,
str_replace_all(interm, stringr::str_replace_all(interm,
pattern = "/", pattern = "/",
"_"), "_"),
"CRU_timeseries","/") "CRU_timeseries","/")
...@@ -1584,8 +1584,9 @@ Chelsa.CRUts.download <- function(save.location = "./", ...@@ -1584,8 +1584,9 @@ Chelsa.CRUts.download <- function(save.location = "./",
mustWork = T), mustWork = T),
"/temp_gdalwarped.tif") "/temp_gdalwarped.tif")
# gdalUtils::gdalwarp(dest.temp, raster.temp.file.dest) # gdalUtils::gdalwarp(dest.temp, raster.temp.file.dest)
raster.temp <- terra::rast(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(dest.temp)
raster.temp <- terra::clamp(raster.temp, lower = -1000)
raster.temp <- process.raster.int.doub(raster.temp) raster.temp <- process.raster.int.doub(raster.temp)
terra::writeRaster(x = raster.temp, terra::writeRaster(x = raster.temp,
filename = dest.temp, filename = dest.temp,
...@@ -1659,3 +1660,4 @@ Chelsa.CRUts.download <- function(save.location = "./", ...@@ -1659,3 +1660,4 @@ Chelsa.CRUts.download <- function(save.location = "./",
# Saving BIB File # Saving BIB File
if(save.bib.file == TRUE) save.citation(save.location = save.location, dataSetName = "CHELSA") if(save.bib.file == TRUE) save.citation(save.location = save.location, dataSetName = "CHELSA")
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment