diff --git a/NEWS.md b/NEWS.md index 8290870c7dc6699cee94f9dc5821b085972ccde2..c3bf8eeefa6bb8ac85cfae641d0f7d23d6403fb3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# s2dv 0.0.2 (Release date: 2020-) +- Change the default of Season() parameter 'time_dim' from 'sdate' to 'ftime'. + # s2dv 0.0.1 (Release date: 2020-02-07) - The package is the advanced version of package 's2dverification', adopting the regime of package 'multiApply' for all the analytic functions. Most of the other functions for plotting and data retrieval in 's2dverification' are also preserved in this package. - Because of the adoption of 'multiApply' regime, the functions work well with package 'startR'. diff --git a/R/Season.R b/R/Season.R index 8de341535fb327903df33d5fda227788f809ef3f..b8743d39130c84a6a25eca4b5bd9c05a88250944 100644 --- a/R/Season.R +++ b/R/Season.R @@ -6,7 +6,7 @@ #' #'@param data A named numeric array with at least one dimension 'time_dim'. #'@param time_dim A character string indicating the name of dimension along -#' which the seasonal means are computed. The default value is 'sdate'. +#' which the seasonal means are computed. The default value is 'ftime'. #'@param monini An integer indicating what the first month of the time series is. #' It can be from 1 to 12. #'@param moninf An integer indicating the starting month of the seasonal mean. @@ -26,7 +26,7 @@ #' #'@examples #'set.seed(1) -#'dat1 <- array(rnorm(144*3), dim = c(member = 2, sdate = 12*3, ftime = 2, lon = 3)) +#'dat1 <- array(rnorm(144*3), dim = c(member = 2, sdate = 2, ftime = 12*3, lon = 3)) #'res <- Season(data = dat1, monini = 1, moninf = 1, monsup = 2) #'res <- Season(data = dat1, monini = 10, moninf = 12, monsup = 2) #'dat2 <- dat1 @@ -37,7 +37,7 @@ #'res <- Season(data = dat2, monini = 3, moninf = 1, monsup = 2, na.rm = FALSE) #'@import multiApply #'@export -Season <- function(data, time_dim = 'sdate', monini, moninf, monsup, +Season <- function(data, time_dim = 'ftime', monini, moninf, monsup, method = mean, na.rm = TRUE, ncores = NULL) { # Check inputs diff --git a/man/Season.Rd b/man/Season.Rd index fad6f22c58e3259bda679864ab3ffa82193ea6ac..cb10deefb8e4353a0901b0cd471efc9fd28e8106 100644 --- a/man/Season.Rd +++ b/man/Season.Rd @@ -4,14 +4,14 @@ \alias{Season} \title{Compute seasonal mean} \usage{ -Season(data, time_dim = "sdate", monini, moninf, monsup, method = mean, +Season(data, time_dim = "ftime", monini, moninf, monsup, method = mean, na.rm = TRUE, ncores = NULL) } \arguments{ \item{data}{A named numeric array with at least one dimension 'time_dim'.} \item{time_dim}{A character string indicating the name of dimension along -which the seasonal means are computed. The default value is 'sdate'.} +which the seasonal means are computed. The default value is 'ftime'.} \item{monini}{An integer indicating what the first month of the time series is. It can be from 1 to 12.} @@ -43,7 +43,7 @@ accounted. } \examples{ set.seed(1) -dat1 <- array(rnorm(144*3), dim = c(member = 2, sdate = 12*3, ftime = 2, lon = 3)) +dat1 <- array(rnorm(144*3), dim = c(member = 2, sdate = 2, ftime = 12*3, lon = 3)) res <- Season(data = dat1, monini = 1, moninf = 1, monsup = 2) res <- Season(data = dat1, monini = 10, moninf = 12, monsup = 2) dat2 <- dat1 diff --git a/tests/testthat/test-Season.R b/tests/testthat/test-Season.R index ab9996a26f84fce734315ed037f6e0c57503e600..4ed9b12e8f94782be6dedd36d84f5ca5571f94c0 100644 --- a/tests/testthat/test-Season.R +++ b/tests/testthat/test-Season.R @@ -3,7 +3,7 @@ context("s2dv::Season tests") ############################################## # dat1 set.seed(1) - dat1 <- array(rnorm(144*3), dim = c(member = 2, sdate = 12*3, ftime = 2, lon = 3)) + dat1 <- array(rnorm(144*3), dim = c(member = 2, ftime = 12*3, sdate = 2, lon = 3)) # dat2 dat2 <- dat1 @@ -70,15 +70,15 @@ test_that("2. Output checks: dat1", { expect_equal( dim(Season(dat1, monini = 1, moninf = 1, monsup = 2)), - c(sdate = 3, member = 2, ftime = 2, lon = 3) + c(ftime = 3, member = 2, sdate = 2, lon = 3) ) expect_equal( dim(Season(dat1, time_dim = 'lon', monini = 1, moninf = 1, monsup = 2)), - c(lon = 1, member = 2, sdate = 36, ftime = 2) + c(lon = 1, member = 2, ftime = 36, sdate = 2) ) expect_equal( dim(Season(dat1, monini = 10, moninf = 12, monsup = 2)), - c(sdate = 3, member = 2, ftime = 2, lon = 3) + c(ftime = 3, member = 2, sdate = 2, lon = 3) ) expect_equal( median(Season(dat1, monini = 10, moninf = 12, monsup = 2)),