From 8489b0031e5736b1b7d1d705aec5e08fc4020bd0 Mon Sep 17 00:00:00 2001 From: Kiri Date: Thu, 17 Oct 2024 11:40:06 -0700 Subject: [PATCH] add local option --- R/append_clim_vars.R | 2 +- R/downscale.R | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/R/append_clim_vars.R b/R/append_clim_vars.R index dde278c..35ca471 100644 --- a/R/append_clim_vars.R +++ b/R/append_clim_vars.R @@ -717,5 +717,5 @@ append_clim_vars <- function(dt, vars) { } # Reorder to match vars - setcolorder(dt, c(names(dt)[names(dt) %in% c("id", "DATASET", "GCM", "SSP", "RUN", "PERIOD")], vars)) + setcolorder(dt, c(names(dt)[names(dt) %in% c("id", "DATASET", "GCM", "SSP", "RUN", "PERIOD")], unique(vars))) } diff --git a/R/downscale.R b/R/downscale.R index e3df4d5..1dc653b 100644 --- a/R/downscale.R +++ b/R/downscale.R @@ -50,6 +50,7 @@ #' @template max_run #' @template run_nm #' @param cache logical. Cache data locally? Default `TRUE` +#' @param local logical. Is the postgres database local? Default `FALSE` #' @param ... other arguments passed to [`downscale_core()`]. Namely: `return_refperiod`, #' `vars`, `out_spatial` and `plot` @@ -110,7 +111,9 @@ downscale <- function(xyz, which_refmap = "auto", gcm_periods = NULL, gcm_ssp_years = NULL, gcm_hist_years = NULL, max_run = 0L, run_nm = NULL, - cache = TRUE, ...) { + cache = TRUE, + local = FALSE, + ...) { message("Welcome to climr!") ## checks @@ -123,7 +126,7 @@ downscale <- function(xyz, which_refmap = "auto", expectedCols <- c("lon", "lat", "elev", "id") xyz <- .checkXYZ(copy(xyz), expectedCols) - dbCon <- data_connect() + dbCon <- data_connect(local = local) thebb <- get_bb(xyz) ## get bounding box based on input points rmCols <- setdiff(names(xyz), expectedCols)