s2dv::Season() does not return any error or warning when out-of-range parameters are provided
Hi @aho,
As we discussed offline, s2dv::Season() has parameters mon_ini, mon_inf and mon_sup, which indicate along which months the seasonal value should be computed; however, the function seems to have no checks to ensure that the values of these parameters are consistent with the array. This may sometimes result in unexpected behavior with no warning.
Here I provide a few examples:
library(s2dv)
dat1 <- array(rnorm(2*10*3*3), dim = c(member = 2, sdate = 10, ftime = 3, lon = 3))
# Seasonal mean of all three months
res <- Season(data = dat1, monini = 1, moninf = 1, monsup = 3)
## Example 1: More months than the length of the ftime dimension
res_1 <- Season(data = dat1, monini = 1, moninf = 1, monsup = 9)
dim(res_1)
# ftime member sdate lon
# 1 2 10 3
max(res - res1)
# [1] 0
## Example 2: Months that do not exist in the array
res_2 <- Season(data = dat1, monini = 1, moninf = 5, monsup = 6)
dim(res_2)
# ftime member sdate lon
# 1 2 10 3
summary(res_2)
# Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
# NA NA NA NaN NA NA 60
## Example 3: Both previous examples combined
res_3 <- Season(data = dat1, monini = 1, moninf = 5, monsup = 9)
dim(res_3)
# ftime member sdate lon
# 1 2 10 3
summary(res_3)
# Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
# NA NA NA NaN NA NA 60
## Example 4: Same as example one, but with na.rm = FALSE
res_4 <- Season(data = dat1, monini = 1, moninf = 1, monsup = 5, na.rm = F)
summary(res_4)
# Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
# NA NA NA NaN NA NA 60
No rush on my side for this to be changed, just reporting.
Cheers,
Victòria
Edited by vagudets