Skip to content

Commit

Permalink
MOD06_L2; document
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellmanware committed Oct 7, 2024
1 parent 4d788a3 commit acd3fa1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions R/download.R
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,7 @@ download_koppen_geiger <- function(
#' @return
#' * For \code{hash = FALSE}, NULL
#' * For \code{hash = TRUE}, an \code{rlang::hash_file} character.
#' * HDF (.hdf) files will be stored in
#' * HDF (.hdf) files will be stored in year/day_of_year sub-directories within
#' \code{directory_to_save}.
#' @importFrom Rdpack reprompt
#' @references
Expand Down Expand Up @@ -2493,17 +2493,27 @@ download_modis <- function(
nasa_earth_data_token,
"\" -O ",
directory_to_save,
splitter,
download_name,
"\n"
)

#### filter commands to non-existing files
download_command <- download_command[
which(
!file.exists(paste0(directory_to_save, download_name))
!file.exists(paste0(directory_to_save, splitter, download_name))
)
]

new_dirs <- unique(
sprintf("%s%s", directory_to_save, splitter)
)

lapply(
new_dirs,
function(x) dir.create(x, recursive = TRUE, showWarnings = FALSE)
)

# avoid any possible errors by removing existing command files
download_sink(commands_txt)
#### cat command only if file does not already exist
Expand Down
2 changes: 1 addition & 1 deletion man/download_modis.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-terraclimate.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ testthat::test_that("download_terraclimate (single year)", {
# function parameters
year <- 2019
variables <- "Precipitation"
directory_to_save <- paste0(tempdir(), "/terracclimate/")
directory_to_save <- paste0(tempdir(), "/terraclimate/")
# run download function
download_data(dataset_name = "terraclimate",
year = year,
Expand Down

0 comments on commit acd3fa1

Please # to comment.