diff --git a/R/Analogs.R b/R/Analogs.R index 7f18625993f943e0ab7f9a43dfba2e0d868983e5..1cbea151b6a34824decac424cd9321b43945b928 100644 --- a/R/Analogs.R +++ b/R/Analogs.R @@ -381,7 +381,7 @@ Analogs <- function(exp, obs, exp_lats, exp_lons, obs_lats, obs_lons, grid_exp, method_remap = "conservative", region = region, ncores = ncores) # If after interpolating 'obs' data the coordinates do not match, the exp data is interpolated to # the same grid to force the matching - if (!.check_coords(lat1 = obs_interpolated$lat, lat2 = exp_lats, lon1 = obs_interpolated$lon, lon2 = exp_lons)) { + if (!.check_coords(lat1 = as.numeric(obs_interpolated$lat), lat2 = exp_lats, lon1 = as.numeric(obs_interpolated$lon), lon2 = exp_lons)) { exp_interpolated <- Interpolation(exp = exp, lats = exp_lats, lons = exp_lons, target_grid = grid_exp, lat_dim = lat_dim, lon_dim = lon_dim, method_remap = "conservative", region = region, ncores = ncores)$data diff --git a/R/Intlr.R b/R/Intlr.R index f16517f3eff720c9c9cecb8b4f91a881922df572..36a7f11b27964650836d80dea0ed30703e567ee2 100644 --- a/R/Intlr.R +++ b/R/Intlr.R @@ -408,9 +408,7 @@ Intlr <- function(exp, obs, exp_lats, exp_lons, obs_lats, obs_lons, lr_method, t predictor <- .find_nn(coar = exp, lats_hres = obs_lats, lons_hres = obs_lons, lats_coar = exp_lats, lons_coar = exp_lons, lat_dim = lat_dim, lon_dim = lon_dim, nn = 4, ncores = ncores) - - - if (is.null(points)) { + if (is.null(points) | ("location" %in% names(dim(obs)))) { if (!is.null(target_grid)) { warning("Interpolating to the 'obs' grid") } diff --git a/R/LogisticReg.R b/R/LogisticReg.R index 29b41b8a99f17c47844c40480b56248ce19a0cdb..a85a1b3ff2d36741c3371e63be57f8b44d7b57ee 100644 --- a/R/LogisticReg.R +++ b/R/LogisticReg.R @@ -272,13 +272,13 @@ LogisticReg <- function(exp, obs, exp_lats, exp_lons, obs_lats, obs_lons, target stop("Parameter 'loocv' must be set to TRUE or FALSE") } - if (is.na(match(lon_dim, names(dim(exp)))) | is.na(match(lon_dim, names(dim(obs))))) { - stop("Missing longitude dimension in 'exp' and/or 'obs', or does not match the parameter ", + if (is.na(match(lon_dim, names(dim(exp))))) { + stop("Missing longitude dimension in 'exp', or does not match the parameter ", "'lon_dim'") } - if (is.na(match(lat_dim, names(dim(exp)))) | is.na(match(lat_dim, names(dim(obs))))) { - stop("Missing latitude dimension in 'exp' and/or 'obs', or does not match the parameter ", + if (is.na(match(lat_dim, names(dim(exp))))) { + stop("Missing latitude dimension in 'exp', or does not match the parameter ", "'lat_dim'") } @@ -351,6 +351,9 @@ LogisticReg <- function(exp, obs, exp_lats, exp_lons, obs_lats, obs_lons, target target_dims_predictor <- sdate_dim } else if (log_reg_method == "ens_mean_sd") { + + require(abind) + ens_mean_anom <- .get_ens_mean_anom(obj_ens = exp_interpolated$data, member_dim = member_dim, sdate_dim = sdate_dim, ncores = ncores) ens_sd <- .get_ens_sd(obj_ens = exp_interpolated$data, member_dim = member_dim, ncores = ncores) @@ -370,8 +373,8 @@ LogisticReg <- function(exp, obs, exp_lats, exp_lons, obs_lats, obs_lons, target # If after interpolating 'exp' data the coordinates do not match, the obs data is interpolated to # the same grid to force the matching - if ((!.check_coords(lat1 = exp_interpolated$lat, lat2 = obs_lats, - lon1 = exp_interpolated$lon, lon2 = obs_lons)) | !(point_obs)) { + if ((!.check_coords(lat1 = as.numeric(exp_interpolated$lat), lat2 = obs_lats, + lon1 = as.numeric(exp_interpolated$lon), lon2 = obs_lons)) | !(point_obs)) { obs_interpolated <- Interpolation(exp = obs, lats = obs_lats, lons = obs_lons, target_grid = target_grid, method_remap = int_method, points = points, source_file = source_file_obs, lat_dim = lat_dim, lon_dim = lon_dim, method_point_interp = method_point_interp,