Skip to content

Error in subsetting Dates

I found an error in CSIndicators v1.1.0 regarding Dates subset.

Summary

The resulting Dates are not correct when the order of the Dates dimension is: 'sdate' 'ftime'. It works well for: 'ftime' 'sdate'

Example

library(CSIndicators)

exp <- CSTools::lonlat_prec_st

res <- CST_PeriodAccumulation(data = exp, time_dim = 'ftime',
                              start = list(10, 03), end = list(20, 03))
res$attrs$Dates
# [1] "2011-03-10 12:00:00 UTC" "2013-03-10 12:00:00 UTC"
# [3] "2011-03-11 12:00:00 UTC"

exp$attrs$Dates <- Reorder(exp$attrs$Dates, c(2,1))
res <- CST_PeriodAccumulation(data = exp, time_dim = 'ftime',
                              start = list(10, 03), end = list(20, 03))
res$attrs$Dates
# [1] "2011-03-10 12:00:00 UTC" "2012-03-10 12:00:00 UTC"
# [3] "2013-03-10 12:00:00 UTC"

Other Relevant Information

I think that it would be good that the sample data from start has the following order for Dates: 'ftime' 'sdate'.