From c2fede120d2267541c0036472f42819d30178450 Mon Sep 17 00:00:00 2001 From: aho Date: Wed, 3 Jun 2020 10:39:18 +0200 Subject: [PATCH 1/2] Change Season() time_dim default from 'sdate' to 'ftime' --- R/Season.R | 6 +++--- man/Season.Rd | 6 +++--- tests/testthat/test-Season.R | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/R/Season.R b/R/Season.R index 8de3415..b8743d3 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 fad6f22..cb10dee 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 ab9996a..4ed9b12 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)), -- GitLab From 7e4a0f6b06faf925708d2126ef7c5b110e408448 Mon Sep 17 00:00:00 2001 From: aho Date: Wed, 3 Jun 2020 10:48:09 +0200 Subject: [PATCH 2/2] Update NEWS.md --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index 8290870..c3bf8ee 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'. -- GitLab