diff --git a/modules/Crossval/Crossval_anomalies.R b/modules/Crossval/Crossval_anomalies.R index fe0a2e0576ca4694112b9b416f20bc8cd518e72c..280850ddb3de7e2f69e1f79019d1d122a1466249 100644 --- a/modules/Crossval/Crossval_anomalies.R +++ b/modules/Crossval/Crossval_anomalies.R @@ -81,14 +81,14 @@ Crossval_anomalies <- function(recipe, data) { fun = function(x, prob_lims) { lapply(prob_lims, function(ps) { as.array(quantile(as.vector(x), ps, - na.rm = na.rm))})}, + na.rm = TRUE))})}, prob_lims = list(unlist(categories)), ncores = ncores)$output1 lims_ano_obs_tr <- Apply(ano_obs_tr, target_dims = c('syear', 'ensemble'), fun = function(x, prob_lims) { lapply(prob_lims, function(ps) { as.array(quantile(as.vector(x), ps, - na.rm = na.rm))})}, + na.rm = TRUE))})}, prob_lims = list(unlist(categories)), ncores = ncores)$output1 if (tolower(recipe$Analysis$Horizon) == 'subseasonal') { @@ -176,7 +176,7 @@ Crossval_anomalies <- function(recipe, data) { fun = function(x, prob_lims) { lapply(prob_lims, function(ps) { as.array(quantile(as.vector(x), ps, - na.rm = na.rm))})}, + na.rm = TRUE))})}, output_dims = lapply(categories, function(x) {'bin'}), prob_lims = categories, ncores = ncores) @@ -190,7 +190,7 @@ Crossval_anomalies <- function(recipe, data) { fun = function(x, prob_lims) { lapply(prob_lims, function(ps) { as.array(quantile(as.vector(x), ps, - na.rm = na.rm))})}, + na.rm = TRUE))})}, output_dims = lapply(categories, function(x) {'bin'}), prob_lims = categories, ncores = ncores) @@ -328,12 +328,13 @@ Crossval_anomalies <- function(recipe, data) { save_probabilities(recipe = recipe, probs = probs_obs, data_cube = data$hcst, agg = agg, type = "obs") - if (!is.null(probs_fcst)) { + if (length(probs_fcst) > 0) { save_probabilities(recipe = recipe, probs = probs_fcst, data_cube = data$fcst, agg = agg, type = "fcst") } } + # Save ensemble mean for multimodel option: hcst_EM <- MeanDims(ano_hcst$data, 'ensemble', drop = T) # save_metrics(recipe = recipe, @@ -349,6 +350,8 @@ Crossval_anomalies <- function(recipe, data) { # Subset(fcst_EM, along = 'dat', indices = 1, drop = 'selected')), # data_cube = data$fcst, agg = agg, # module = "statistics") + } else { + fcst_EM <- NULL } return(list(hcst = ano_hcst, obs = ano_obs, fcst = data$fcst, hcst.full_val = data$hcst, obs.full_val = data$obs,