# DTRIndicator() examples
DTRIndicator()
DTRIndicator(tmax = NULL)
DTRIndicator(tmax = NULL, tmin = NULL)
DTRIndicator(tmax = 0, tmin = NULL)
DTRIndicator(tmax = 0, tmin = 1)
tmax = 1:10
tmin = 1:10
DTRIndicator(tmax = tmax, tmin = tmin, ref = -5:5)
dates = seq(ISOdate(1900,1,1), ISOdate(1900,1,10), "day")
DTRIndicator(tmax = tmax, tmin = tmin, ref = list(dtr.ref = -5 : 5, season = 'JJA'))

dim(tmax) <- c(2, 5)
dim(tmin) <- c(2, 5)
DTRIndicator(tmax = tmax, tmin = tmin)
DTRIndicator(tmax = tmax, tmin = tmin, ref = NULL)
tmax <- 1:(2 * 3 * 730 * 1)
dim(tmax) <- c(lon = 2, lat = 3, time = 730, model = 1)
tmin <- (1:(2 * 3 * 730 * 1))-1
dim(tmin) <- c(lon = 2, lat = 3, time = 730, model = 1)
time <- seq(as.POSIXct("1900-01-01 12:00:00", tz = "", format = "%Y-%d-%m %H:%M:%S"), as.POSIXct("1901-31-12 18:00:00", 
                                                                                                 tz = "", format = "%Y-%d-%m %H:%M:%S"), "day")
time <- as.POSIXct(time, tz = "CET")
metadata <- list(time = list(standard_name = 'time', long_name = 'time', 
                             calendar = 'noleap',
                             units = 'days since 1970-01-01 00:00:00', prec = 'double', 
                             dim = list(list(name ='time', unlim = FALSE))))
attr(time, "variables") <- metadata
attr(tmax, 'Variables')$dat1$time <- time
attr(tmax, 'Variables')$common[[2]]$dim[[3]]$len = length(time)
attr(tmax, 'Variables')$common[[2]]$dim[[3]]$vals <- time
attr(tmin, 'Variables')$dat1$time <- time
attr(tmin, 'Variables')$common[[2]]$dim[[3]]$len = length(time)
attr(tmin, 'Variables')$common[[2]]$dim[[3]]$vals <- time
a <- DTRRef(tmax, tmin, by.seasons = FALSE, ncores = NULL)

aa <- DTRIndicator(tmax, tmin, ref = a, by.seasons = FALSE, ncores = NULL)
str(aa)
dim(aa$indicator)

tmax <- 1:(2 * 3 * 730 * 1)
dim(tmax) <- c(lon = 2, lat = 3, time = 730, model = 1)
tmax[1,1,1,1] <- NA
tmin <- (1:(2 * 3 * 730 * 1))-1
dim(tmin) <- c(lon = 2, lat = 3, time = 730, model = 1)
time <- seq(as.POSIXct("1900-01-01 12:00:00", tz = "", format = "%Y-%d-%m %H:%M:%S"), as.POSIXct("1901-31-12 18:00:00", 
                                                                                                 tz = "", format = "%Y-%d-%m %H:%M:%S"), "day")
time <- as.POSIXct(time, tz = "CET")
metadata <- list(time = list(standard_name = 'time', long_name = 'time', 
                             calendar = 'noleap',
                             units = 'days since 1970-01-01 00:00:00', prec = 'double', 
                             dim = list(list(name ='time', unlim = FALSE))))
attr(time, "variables") <- metadata
attr(tmax, 'Variables')$dat1$time <- time
attr(tmax, 'Variables')$common[[2]]$dim[[3]]$len = length(time)
attr(tmax, 'Variables')$common[[2]]$dim[[3]]$vals <- time
attr(tmin, 'Variables')$dat1$time <- time
attr(tmin, 'Variables')$common[[2]]$dim[[3]]$len = length(time)
attr(tmin, 'Variables')$common[[2]]$dim[[3]]$vals <- time
a <- DTRRef(tmax, tmin, by.seasons = FALSE, ncores = NULL, na.rm = FALSE)

aa <- DTRIndicator(tmax, tmin, ref = a, by.seasons = FALSE, ncores = NULL)
str(aa)
dim(aa$indicator)
aa$indicator