R/download_trmm_3b43.R

Defines functions download_trmm_3b43

Documented in download_trmm_3b43

#' TRMM_3B43 data downloader
#'
#' Function for downloading TRMM 3B43 v7.
#'
#' @importFrom utils download.file
#' @param folder_path a character string with the path where the data will be downloaded.
#' @param domain a character string with the desired domain data set. Suitable options are:
#' \itemize{
#' \item{"raw" for default available spatial coverage,}
#' \item{"global" for data sets with global (land and ocean) coverage,}
#' \item{"land" for data sets with land only coverage,}
#' \item{"ocean", for data sets with ocean only coverage.}
#' }
#' @param time_res a character string with the desired time resolution. Suitable options are:
#' \itemize{
#' \item{"monthly",}
#' \item{"yearly".}
#' }
#' @return No return value, called to download the data set.
#' @keywords internal

download_trmm_3b43 <- function(folder_path = ".", domain = "raw", time_res = "monthly"){
  old_options <- options()
  options(timeout = 6000)
  on.exit(options(old_options))
  if (domain == "raw"){domain <- "global"}
  zenodo_base <- "https://zenodo.org/record/7808922/files/"
  zenodo_end <- "?download=1"
  file_name <- paste0("trmm-3b43_tp_mm_", domain, "50s50n_199801_201912_025_", time_res, ".nc")
  file_url <- paste0(zenodo_base, file_name, zenodo_end)
  file_destination <- paste(folder_path, file_name, sep = "/")
  try(download.file(file_url, file_destination, mode = "wb"), silent = TRUE)
}

Try the pRecipe package in your browser

Any scripts or data that you put into this service are public.

pRecipe documentation built on May 29, 2024, 9:11 a.m.