diff --git a/DESCRIPTION b/DESCRIPTION index d36c898a2b20a453e41201f55896a3c82852da87..bf75372b7692fe229b72764520e5d7c50c77d0d9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: s2dverification Title: Set of Common Tools for Forecast Verification -Version: 2.8.2 +Version: 2.8.3 Authors@R: c( person("BSC-CNS", role = c("aut", "cph")), person("Virginie", "Guemas", , "virginie.guemas@bsc.es", role = "aut"), diff --git a/R/CDORemap.R b/R/CDORemap.R index 49bd9dbe1d280f64248442f9a66c37b3c741682f..55f12904cc86274ee2ba8b81424543d636233c2e 100644 --- a/R/CDORemap.R +++ b/R/CDORemap.R @@ -395,6 +395,12 @@ CDORemap <- function(data_array = NULL, lons, lats, grid, method, if (nchar(Sys.which('cdo')[1]) < 1) { stop("CDO must be installed in order to use the .CDORemap.") } + cdo_version <- as.numeric_version( + strsplit(suppressWarnings(system2("cdo", args = '-V', stderr = TRUE))[[1]], ' ')[[1]][5] + ) + if ((cdo_version >= as.numeric_version('1.7.0')) && (method == 'con')) { + method <- 'ycon' + } # CDO takes arrays of 3 dimensions or 4 if one of them is unlimited. # The unlimited dimension can only be the left-most (right-most in R). # There are no restrictions for the dimension names or variable names. diff --git a/R/Load.R b/R/Load.R index efcc74c13ea9d37dbd282da71901f54ec2c84946..056496618d08c063c1812c96d23cbd74d1a45ee6 100644 --- a/R/Load.R +++ b/R/Load.R @@ -262,8 +262,8 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, if (is.null(method) || !(method %in% c('bilinear', 'bicubic', 'conservative', 'distance-weighted'))) { stop("Error: parameter 'method' is wrong, can take value 'bilinear', 'bicubic', 'conservative' or 'distance-weighted'.") } - remap <- switch(method, 'bilinear' = 'remapbil', 'bicubic' = 'remapbic', - 'conservative' = 'remapcon', 'distance-weighted' = 'remapdis') + remap <- switch(method, 'bilinear' = 'bil', 'bicubic' = 'bic', + 'conservative' = 'con', 'distance-weighted' = 'dis') # grid if (!is.null(grid)) { diff --git a/R/PlotLayout.R b/R/PlotLayout.R index 7d5eee1efc2d184e50bb535ba4088fcf9b736c65..0eb1254e8da6fbfed977ed2ee2057f742b2b8ed9 100644 --- a/R/PlotLayout.R +++ b/R/PlotLayout.R @@ -251,6 +251,7 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, #n_plots <- n_plots + prod(head(c(rep(1, length(dim_ids)), dim(plot_array)), length(dim(plot_array)))) if (length(dim(var[[plot_array_i]])) == length(dim_ids)) { dim(var[[plot_array_i]]) <- c(1, dim(var[[plot_array_i]])) + dim_ids <- dim_ids + 1 } plot_dims[[plot_array_i]] <- dim_ids } diff --git a/R/Utils.R b/R/Utils.R index c748a50876375c615c7b8d7c8a387475bc727614..603d47163f48771ae6310b7e27e13666e98939dd 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -202,8 +202,11 @@ } else { is_2d_var <- work_piece[['is_2d_var']] } - if ((is_2d_var || work_piece[['is_file_per_dataset']]) && (Sys.which("cdo")[[1]] == "")) { - stop("Error: CDO libraries not available") + if ((is_2d_var || work_piece[['is_file_per_dataset']])) { + if (Sys.which("cdo")[[1]] == "") { + stop("Error: CDO libraries not available") + } + cdo_version <- as.numeric_version(strsplit(suppressWarnings(system2("cdo", args = '-V', stderr = TRUE))[[1]], ' ')[[1]][5]) } # If the variable to load is 2-d, we need to determine whether: # - interpolation is needed @@ -331,6 +334,10 @@ common_grid_name <- grid_name remove_shift <- TRUE } + if (remap_needed && (work_piece[['remap']] == 'con') && + (cdo_version >= as.numeric_version('1.7.0'))) { + work_piece[['remap']] <- 'ycon' + } if (remove_shift && !explore_dims) { if (!is.null(work_piece[['progress_amount']])) { cat("\n") @@ -404,7 +411,7 @@ filecopy <- tempfile(pattern = "load", fileext = ".nc") file.copy(filein, filecopy) filein <- tempfile(pattern = "loadRegridded", fileext = ".nc") - system(paste0("cdo -s ", work_piece[['remap']], ",", + system(paste0("cdo -s remap", work_piece[['remap']], ",", common_grid_name, " -selname,", namevar, " ", filecopy, " ", filein, " 2>/dev/null", sep = "")) @@ -741,7 +748,7 @@ } else { paste0(lonmin, ",", lonmax, ",") }, latmin, ",", latmax, - " -", work_piece[['remap']], ",", common_grid_name, + " -remap", work_piece[['remap']], ",", common_grid_name, " ", filein2, " ", filein, " 2>/dev/null", sep = "")) file.remove(filein2) fnc <- nc_open(filein) @@ -778,7 +785,7 @@ fnc_mask <- nc_create(mask_file, list(ncdf_var)) ncvar_put(fnc_mask, ncdf_var, array(rep(0, 4), dim = c(2, 2))) nc_close(fnc_mask) - system(paste0("cdo -s ", work_piece[['remap']], ",", common_grid_name, + system(paste0("cdo -s remap", work_piece[['remap']], ",", common_grid_name, " ", mask_file, " ", mask_file_remap, " 2>/dev/null", sep = "")) fnc_mask <- nc_open(mask_file_remap) mask_lons <- ncvar_get(fnc_mask, 'lon') @@ -808,7 +815,7 @@ ### } else { ### paste0(lonmin, ",", lonmax, ",") ### }, latmin, ",", latmax, - ### " -", work_piece[['remap']], ",", common_grid_name, + ### " -remap", work_piece[['remap']], ",", common_grid_name, ###This is wrong: same files ### " ", mask_file, " ", mask_file, " 2>/dev/null", sep = "")) ### fnc_mask <- nc_open(mask_file) diff --git a/man/s2dverification.Rd b/man/s2dverification.Rd index ee3fca8036ed945a86a8253a531e73bf8124c685..23d31299fe781177a445de3cbfc50ad9609d8ed8 100644 --- a/man/s2dverification.Rd +++ b/man/s2dverification.Rd @@ -10,8 +10,8 @@ Set of tools to verify forecasts through the computation of typical prediction s \tabular{ll}{ Package: \tab s2dverification\cr Type: \tab Package\cr -Version: \tab 2.8.2\cr -Date: \tab 2017-05-15\cr +Version: \tab 2.8.3\cr +Date: \tab 2017-05-22\cr License: \tab LGPLv3\cr } Check an overview of the package functionalities and its modules at \url{https://earth.bsc.es/gitlab/es/s2dverification/wikis/home}. diff --git a/s2dverification-manual.pdf b/s2dverification-manual.pdf index 8c8bdc7fc49c2a8c052aefcaa8a4d462386c393c..73866213b995894800577557a2ec44459e2bb07f 100644 Binary files a/s2dverification-manual.pdf and b/s2dverification-manual.pdf differ