Skip to contents

The download_gridmet function accesses and downloads gridded surface meteorological data from the University of California Merced Climatology Lab's gridMET dataset.

Usage

download_gridmet(
  variables = NULL,
  year = c(2018, 2022),
  directory_to_save = NULL,
  acknowledgement = FALSE,
  download = TRUE,
  remove_command = FALSE,
  show_progress = TRUE,
  hash = FALSE,
  max_tries = 20,
  rate_limit = 2
)

Arguments

variables

character. Variable(s) name(s).

year

integer(1 or more). One year, two endpoints, or a non-empty vector of years. Every year from the minimum through the maximum is requested, including gaps: c(2018, 2023) requests 2018:2023. Default is c(2018, 2022). Missing and fractional years are rejected. For SPEI/EDDI, complete multi-year files are downloaded regardless of year, but supplied years are still validated; see Details.

directory_to_save

character(1). Directory to save data.

acknowledgement

logical(1). Must be TRUE to proceed.

download

logical(1). DEPRECATED. Downloads happen automatically.

remove_command

logical(1). Deprecated, ignored.

show_progress

logical(1). Show per-file messages and download progress bars during sequential downloads. Default is TRUE. Ignored during concurrent downloads, where per-file progress is disabled. Status and summary messages may still be printed when FALSE.

hash

logical(1). Return hash of downloaded files (default FALSE)

max_tries

integer(1). Maximum retry attempts (default 20)

rate_limit

numeric(1). Request-throttling interval in seconds. Default is 2. Passed unchanged to download_run_method() for sequential downloads. For concurrent downloads, multiplied by the configured daemon count for the "default" compute profile before being passed to each worker.

Value

With download = FALSE, an invisible preview list containing urls, destfiles, and n_files. With download = TRUE and hash = FALSE, an invisible summary from download_run() containing success, failed, skipped, failed_urls, and failed_files. The two failure vectors are character(0) when no downloads failed, including when every file was skipped. With download = TRUE and hash = TRUE, a visible character scalar containing the combined MD5 hash of the output directory.

Details

EDDI uses the same native GRIDMET multi-year workflow as SPEI. Use eddi14d, eddi30d, eddi90d, eddi180d, eddi270d, eddi1y, eddi2y, or eddi5y; eddi defaults to eddi30d. Both indices retain the native 1/24-degree grid and five-day observation dates. Select dataset gridmet in the wrapper functions to use these products; the standalone drought source aliases continue to select their separate products. GRIDMET SPEI is available directly from the provider as multi-year files (one file per accumulation period), at native five-day intervals on the approximately 4-km grid. Use "spei14d", "spei30d", "spei90d", "spei180d", "spei270d", "spei1y", "spei2y", or "spei5y"; "spei" aliases "spei30d". For SPEI, year does not subset the download: the complete multi-year file is saved under its resolved code directory (e.g., spei30d/spei30d.nc). Subset dates with process_gridmet(). These files are several GB each. This is distinct from the global CSIC SPEI product in download_drought(). See https://www.northwestknowledge.net/metdata/data/.

Note

gridMET data does not require authentication.

Concurrent downloads

File downloads use configured daemons in the "default" compute profile, or run sequentially when that profile has no configured daemons. Daemon creation and shutdown are managed by the caller using mirai::daemons(). For concurrent downloads, configure a fixed local pool with mirai::daemons(n, .compute = "default") before calling this function. Daemon detection, counting, and task dispatch always use the "default" compute profile, regardless of the active profile. Daemon counting and rate scaling assume that the pool still contains the n workers configured by that call, with no workers added separately or pool resizing during downloads. Each worker receives one URL/destination pair per task; the remaining request arguments are constant across tasks.

Source-specific validation, URL discovery, archive extraction, and directory hashing run in the calling process. Only file downloads are dispatched to workers.

References

Abatzoglou JT (2013). “Development of gridded surface meteorological data for ecological applications and modelling.” International journal of climatology, 33(1), 121–131.

Author

Mitchell Manware

Examples

if (FALSE) { # \dontrun{
download_gridmet(
  variables = "pr",
  year = 2023,
  directory_to_save = tempdir(),
  acknowledgement = TRUE
)
} # }