source("/esarchive/scratch/ptrascas/R/dev-test_bigpredidata/sunset/sunset/scripts/MergeRefToExp.R")

library(CSTools)
data_dates <- c(seq(as.Date("01-07-1993", "%d-%m-%Y", tz = 'UTC'),
                    as.Date("01-12-1993","%d-%m-%Y", tz = 'UTC'), "day"),
                seq(as.Date("01-07-1994", "%d-%m-%Y", tz = 'UTC'),
                    as.Date("01-12-1994","%d-%m-%Y", tz = 'UTC'), "day"))
dim(data_dates) <- c(time = 154, sdate = 2)
data <- NULL
data$data <- array(1:(2*154*2), c(time = 154, sdate = 2, member = 2))
data$attrs$Dates<- data_dates
class(data) <- 's2dv_cube'
ref_dates <- seq(as.Date("01-01-1993", "%d-%m-%Y", tz = 'UTC'),
                 as.Date("01-12-1994","%d-%m-%Y", tz = 'UTC'), "day")
dim(ref_dates) <- c(time = 350, sdate = 2)
ref <- NULL
ref$data <- array(1001:1700, c(time = 350, sdate = 2))
ref$attrs$Dates <- ref_dates
class(ref) <- 's2dv_cube'
new_data <- CST_MergeRefToExp(data1 = ref, data2 = data, 
                              start1 = list(21, 6), end1 = list(30, 6),
                              start2 = list(1, 7), end2 = list(21, 9))
