Wrapper for climr::downscale that keeps extra columns in table of point coordinates.

.getClimVars(
  coords,
  byCombo = FALSE,
  outFormat = "data.table",
  filename = tempfile(fileext = ".rds"),
  ...
)

Arguments

coords

a data.table, or spatial points (SpatVector or sf) with point coordinates ("lon" = longitude, "lat" = latitude), elevation ("elev") and point IDs ("id").

byCombo

logical. If TRUE, climr::downscale is iterated by combinations of any arguments passed to downscale via ... (e.g., vars, gcms, ssps).

outFormat

character. Should outputs be in the form of a data.table ("data.table"), list of data.tables ("list") or written directly to disk ("disk")? If byCombo == FALSE, only "data.table" and "disk" will work.

filename

character. Passed to saveRDS(..., file) if outFormat == "disk". Defaults to tempfile(fileext = ".csv").

...

further arguments passed to climr::downscale().

Value

climate normals returned as a data.table or list of data.tables. If outFormat == "disk", the file name(s) are returned instead.

Details

If outFormat == "disk" and byCombo == TRUE, climr::downscale is iterated for combinations of GCMs, runs, periods and scenarios, and each output data.table is saved to an .rds file with saveRDS(..., file = filename2, append = TRUE), where basename(filename2) is the basename(filename) with appended values of the arguments that were iterated through – excluding the arguments "cache", "xyz", "nthread", "max_run", "return_refperiod", "ppt_lr", "out_spatial", and "plot".