Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • CSIndicators CSIndicators
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Graph
    • Compare revisions
  • Issues 18
    • Issues 18
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Earth SciencesEarth Sciences
  • CSIndicatorsCSIndicators
  • Issues
  • #24
Closed
Open
Issue created Oct 26, 2022 by vagudets@vagudetsMaintainer

CST_PeriodMean() and CST_PeriodAccumulation(): Dates in s2dv_cube do not change to reflect aggregation

Hi @aho

Opening this to continue the discussion we had offline about the behavior of CST_PeriodMean() and CST_PeriodAccumulation() re: the s2dv_cube Dates attribute.

Trying to summarize, I have identified two different scenarios:

Scenario 1: parameters start and end are not defined. In this case, the mean or sum for the entire period is computed, and $Dates is returned with no modification. The time steps in $Dates do not reflect the new time steps in the array. Here's an example:

library(CSIndicators)

# Create s2dv_cube
exp <- NULL
exp$data <- array(rnorm(45), dim = c(member = 7, ftime = 8))
class(exp) <- 's2dv_cube'

# Assign Dates
exp$Dates$start <- seq(from = as.Date("01-01-1993", "%d-%m-%Y", tz = 'UTC'),
                       to = as.Date("01-08-1993", "%d-%m-%Y", tz = 'UTC'),
                       by = "month")
dim(exp$Dates$start) <- c(ftime = 8)
exp$Dates$start
# [1] "1993-01-01" "1993-02-01" "1993-03-01" "1993-04-01" "1993-05-01"
# [6] "1993-06-01" "1993-07-01" "1993-08-01"

# Compute mean for the whole period (default setting)
exp_mean <- CST_PeriodMean(exp)
dim(exp_mean$data)
# member 
#      7
dim(exp_mean$Dates$start)
# ftime 
#     8 
exp_mean$Dates$start
# [1] "1993-01-01" "1993-02-01" "1993-03-01" "1993-04-01" "1993-05-01"
# [6] "1993-06-01" "1993-07-01" "1993-08-01"

Scenario 2: start and end are provided. In this case, the array in Dates$start is cropped to the period defined by start and end and stored in $Dates (not in Datesstart). The time steps in $Dates still do not reflect the new time steps in the array. Example:

exp$Dates$start
# [1] "1993-01-01" "1993-02-01" "1993-03-01" "1993-04-01" "1993-05-01"
# [6] "1993-06-01" "1993-07-01" "1993-08-01"

# Compute mean for the period between January 1st and March 31st
exp_mean_JFM <- CST_PeriodMean(exp, start = list(1, 1), end = list(31, 3))
dim(exp_mean_JFM$data)
# member 
#      7

# The dates are now stored in a different location...
exp_mean_JFM$Dates$start
# Error in exp_mean$Dates$start : $ operator is invalid for atomic vectors
exp_mean_JFM$Dates
# [1] "1993-01-01" "1993-02-01" "1993-03-01"

Let me know if you need more details or want to discuss this further.

Thanks,

Victòria

Assignee
Assign to
Time tracking