diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ee4c80918fa3999a444af9367d700aee1652ca4c..cbe09a22ac03d801b1ae1a2c0f07cc6c4b59f8ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,8 +3,8 @@ stages: build: stage: build script: - - module load R + - module load R/3.6.1-foss-2015a-bare # - module load CDO - R CMD build --resave-data . - R CMD check --as-cran --no-manual --run-donttest s2dv_*.tar.gz - - R -e 'covr::package_coverage()' +# - R -e 'covr::package_coverage()' diff --git a/DESCRIPTION b/DESCRIPTION index ecf2fa02bd9fbef6bcb562d2a7a9275a1aa1f066..c2dbf9d5120f8e134ee8b7d3dd91872960c618ff 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,13 @@ Package: s2dv Title: A Set of Common Tools for Seasonal to Decadal Verification -Version: 0.1.1 +Version: 1.0.0 Authors@R: c( person("BSC-CNS", role = c("aut", "cph")), person("An-Chi", "Ho", , "an.ho@bsc.es", role = c("aut", "cre")), person("Nuria", "Perez-Zanon", , "nuria.perez@bsc.es", role = "aut"), person("Roberto", "Bilbao", , "roberto.bilbao@bsc.es", role = "ctb"), person("Carlos", "Delgado", , "carlos.delgado@bsc.es", role = "ctb"), + person("Llorenç", "Lledó", , "llorenc.lledo@bsc.es", role = "ctb"), person("Andrea", "Manrique", , "andrea.manrique@bsc.es", role = "ctb"), person("Deborah", "Verfaillie", , "deborah.verfaillie@bsc.es", role = "ctb")) Description: The advanced version of package 's2dverification'. It is @@ -21,7 +22,7 @@ Description: The advanced version of package 's2dverification'. It is Depends: maps, methods, - R (>= 3.2.0) + R (>= 3.6.0) Imports: abind, bigmemory, diff --git a/NEWS.md b/NEWS.md index b54387343d1c4010844ddbf95fe15a5fe5dfb524..e537e95964bc8453030f091399a1a66bc81cd3f0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,19 @@ -# s2dv 1.0.0 (Release date: 2021-) -- Add parameter 'memb_dim' and 'memb' in Corr(). They allow the existence of the member dimension +# s2dv 1.0.0 (Release date: 2021-06-16) +- New functions: +ACC, Ano_CrossValid, BrierScore, CDORemap, Cluster, Consistent_Trend, EOF, EuroAtlanticTC, Filter, Histo2Hindcast, +NAO, Plot2VarsVsLTime, PlotACC, PlotBoxWhisker, PlotVsLTime, ProbBins, ProjectField, RatioRMS, +RatioSDRMS, REOF, Spectrum, Spread, StatSeasAtlHurr, UltimateBrier +- Season(): Accept one-dimension input. +- Persistence(): Add parameters checks for 'start' and 'end'; correct the output 'AR.lowCI' and 'AR.highCI'. +- Corr(): Add parameter 'member' and 'memb_dim'. They allow the existence of the member dimension which can have different length between exp and obs, and users can choose to do the ensemble mean -first before correlation or calculate the correlation for individual member. -- Improve Persistence() input checks, and correct the output 'AR.lowCI' and 'AR.highCI'. +first before correlation or calculate the correlation for individual member. +- InsertDim(): Remove Apply() to improve the efficiency. +- Reorder(): Improve efficiency. +- Indices functions take the case without 'memb_dim' into consideration. The climatology calculation for the anomaly is member-dependent if member exists. +- PlotStereoMap(): Add contour and arrow feature. +- PlotAno(): Add parameter check for 'sdates'. +- PlotEquiMap(): Add new arguments 'contour_draw_label', 'lake_color', 'lab_dist_x', 'lab_dist_y', and 'degree_sym'. Fix the border error; the border grids are fully plotted now. Add ocean mask feature. # s2dv 0.1.1 (Release date: 2020-11-16) - Change the lincense to Apache License 2.0. diff --git a/R/InsertDim.R b/R/InsertDim.R index 950479c44297ce0eb8c96392e5961792da70bfe6..36ce2f87e4512e99577dd92aadfdef1a1fb97b60 100644 --- a/R/InsertDim.R +++ b/R/InsertDim.R @@ -8,6 +8,8 @@ #'@param lendim An integer indicating the length of the new dimension. #'@param name A character string indicating the name for the new dimension. #' The default value is NULL. +#'@param ncores An integer indicating the number of cores to use for parallel +#' computation. The default value is NULL. This parameter is deprecated now. #' #'@return An array as parameter 'data' but with the added named dimension. #' @@ -18,7 +20,7 @@ #' #'@import multiApply #'@export -InsertDim <- function(data, posdim, lendim, name = NULL) { +InsertDim <- function(data, posdim, lendim, name = NULL, ncores = NULL) { # Check inputs ## data @@ -59,6 +61,9 @@ InsertDim <- function(data, posdim, lendim, name = NULL) { stop("Parameter 'name' must be a character string.") } } + ## ncores + if (!missing("ncores")) + warning("Argument 'ncores' is deprecated.") ############################### # Calculate InsertDim diff --git a/R/NAO.R b/R/NAO.R index 4af0308865db2b9e6975851448b1434f4a0019c3..af4893ad0c5b904d0f62893f986282b4883d401d 100644 --- a/R/NAO.R +++ b/R/NAO.R @@ -307,13 +307,15 @@ NAO <- function(exp = NULL, obs = NULL, lat, lon, time_dim = 'sdate', target_dims = list(exp = c(memb_dim, time_dim, space_dim), obs = c(time_dim, space_dim)), fun = .NAO, - obsproj = obsproj, wght = wght, add_member_back = add_member_back, + lat = lat, wght = wght, + obsproj = obsproj, add_member_back = add_member_back, ncores = ncores) } else if (!is.null(exp)) { res <- Apply(list(exp = exp), target_dims = list(exp = c(memb_dim, time_dim, space_dim)), fun = .NAO, - obsproj = obsproj, wght = wght, obs = NULL, add_member_back = FALSE, + lat = lat, wght = wght, obs = NULL, + obsproj = obsproj, add_member_back = FALSE, ncores = ncores) } else if (!is.null(obs)) { if (add_member_back) { @@ -325,13 +327,14 @@ NAO <- function(exp = NULL, obs = NULL, lat, lon, time_dim = 'sdate', target_dims = list(obs = c(time_dim, space_dim)), output_dims = output_dims, fun = .NAO, - obsproj = obsproj, wght = wght, exp = NULL, add_member_back = add_member_back, + lat = lat, wght = wght, exp = NULL, + obsproj = obsproj, add_member_back = add_member_back, ncores = ncores) } return(res) } -.NAO <- function(exp = NULL, obs = NULL, wght, obsproj = TRUE, add_member_back = FALSE) { +.NAO <- function(exp = NULL, obs = NULL, lat, wght, obsproj = TRUE, add_member_back = FALSE) { # exp: [memb_exp, sdate, lat, lon] # obs: [sdate, lat, lon] # wght: [lat, lon] diff --git a/R/Persistence.R b/R/Persistence.R index 184092756d25f8332f0a8af281a58fdd78fec940..5a53857f797c47db5e99bb912c2be44d52e8b001 100644 --- a/R/Persistence.R +++ b/R/Persistence.R @@ -74,18 +74,18 @@ #'# Case 1: year #'# Building an example dataset with yearly start dates from 1920 to 2009 #'set.seed(1) -#'obs1 <- rnorm(1 * 70 * 6 * 7) -#'dim(obs1) <- c(member = 1, time = 70, lat = 6, lon = 7) +#'obs1 <- rnorm(1 * 70 * 2 * 2) +#'dim(obs1) <- c(member = 1, time = 70, lat = 2, lon = 2) #'dates <- seq(1920, 1989, 1) #'res <- Persistence(obs1, dates = dates, start = 1961, end = 1980, ft_start = 1, -#' nmemb = 40) +#' nmemb = 2) #'# Case 2: day #'dates <- seq(as.Date(ISOdate(1990, 1, 1)), as.Date(ISOdate(1990, 4, 1)) ,1) #'start <- as.Date(ISOdate(1990, 2, 15)) #'end <- as.Date(ISOdate(1990, 4, 1)) #'set.seed(1) -#'data <- rnorm(1 * length(dates) * 6 * 7) -#'dim(data) <- c(member = 1, time = length(dates), lat = 6, lon = 7) +#'data <- rnorm(1 * length(dates)) +#'dim(data) <- c(member = 1, time = length(dates)) #'res <- Persistence(data, dates = dates, start = start, end = end, ft_start = 1) #' #'@import multiApply diff --git a/man/InsertDim.Rd b/man/InsertDim.Rd index 7a866a37c2887855ea5d5885f2d23a6569c8fbf2..51418f0ba6624687dd12466e0edfeda3cfc98168 100644 --- a/man/InsertDim.Rd +++ b/man/InsertDim.Rd @@ -4,7 +4,7 @@ \alias{InsertDim} \title{Add a named dimension to an array} \usage{ -InsertDim(data, posdim, lendim, name = NULL) +InsertDim(data, posdim, lendim, name = NULL, ncores = NULL) } \arguments{ \item{data}{An array to which the additional dimension to be added.} @@ -15,6 +15,9 @@ InsertDim(data, posdim, lendim, name = NULL) \item{name}{A character string indicating the name for the new dimension. The default value is NULL.} + +\item{ncores}{An integer indicating the number of cores to use for parallel +computation. The default value is NULL. This parameter is deprecated now.} } \value{ An array as parameter 'data' but with the added named dimension. diff --git a/man/Persistence.Rd b/man/Persistence.Rd index b2bd2765d529580c093a154cbfe672007717d0a2..9b09ac3546a880d605f0b48c6772c3a1c38ceaf8 100644 --- a/man/Persistence.Rd +++ b/man/Persistence.Rd @@ -104,18 +104,18 @@ uncertainty (prediction interval) based on Coelho et al., 2004.\cr\cr # Case 1: year # Building an example dataset with yearly start dates from 1920 to 2009 set.seed(1) -obs1 <- rnorm(1 * 70 * 6 * 7) -dim(obs1) <- c(member = 1, time = 70, lat = 6, lon = 7) +obs1 <- rnorm(1 * 70 * 2 * 2) +dim(obs1) <- c(member = 1, time = 70, lat = 2, lon = 2) dates <- seq(1920, 1989, 1) res <- Persistence(obs1, dates = dates, start = 1961, end = 1980, ft_start = 1, - nmemb = 40) + nmemb = 2) # Case 2: day dates <- seq(as.Date(ISOdate(1990, 1, 1)), as.Date(ISOdate(1990, 4, 1)) ,1) start <- as.Date(ISOdate(1990, 2, 15)) end <- as.Date(ISOdate(1990, 4, 1)) set.seed(1) -data <- rnorm(1 * length(dates) * 6 * 7) -dim(data) <- c(member = 1, time = length(dates), lat = 6, lon = 7) +data <- rnorm(1 * length(dates)) +dim(data) <- c(member = 1, time = length(dates)) res <- Persistence(data, dates = dates, start = start, end = end, ft_start = 1) } diff --git a/man/s2dv-package.Rd b/man/s2dv-package.Rd index 043b081c5295080af7072eb52c7d4115d3d28128..557692115e5ac3f458a52161ca4323658bfb8a25 100644 --- a/man/s2dv-package.Rd +++ b/man/s2dv-package.Rd @@ -40,6 +40,7 @@ Other contributors: \itemize{ \item Roberto Bilbao \email{roberto.bilbao@bsc.es} [contributor] \item Carlos Delgado \email{carlos.delgado@bsc.es} [contributor] + \item Llorenç Lledó \email{llorenc.lledo@bsc.es} [contributor] \item Andrea Manrique \email{andrea.manrique@bsc.es} [contributor] \item Deborah Verfaillie \email{deborah.verfaillie@bsc.es} [contributor] } diff --git a/s2dv-manual.pdf b/s2dv-manual.pdf index 8c9d1cac06d9fffc9d59bc28e9427d11643c27f3..de5dc4cb860f84e21a44781861245233d13c7fdf 100644 Binary files a/s2dv-manual.pdf and b/s2dv-manual.pdf differ