Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • s2dv s2dv
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 17
    • Issues 17
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Earth SciencesEarth Sciences
  • s2dvs2dv
  • Issues
  • #81
Closed
Open
Issue created Oct 19, 2022 by vagudets@vagudetsMaintainer

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 Oct 19, 2022 by vagudets
Assignee
Assign to
Time tracking