# WaveDuration examples
WaveDuration()
WaveDuration(data = NULL)
WaveDuration(data = NULL, threshold = NULL)
WaveDuration(data = 1, threshold = 1)
time <-  seq(ISOdate(1901,1,1), ISOdate(1904,1,1), "year")
WaveDuration(data = 1, threshold = 1, dates = time)
metadata <- list(time = list(standard_name = 'time', long_name = 'time', 
                             calendar = 'standard',
                             units = 'days since 1970-01-01 00:00:00', prec = 'double', 
                             dim = list(list(name ='time', unlim = FALSE))))
attr(time, "variables") <- metadata
WaveDuration(data = 1, threshold = 1, dates = time)
WaveDuration(data = 1 : length(time), threshold = 2, dates = time)
WaveDuration(data = 1 : length(time), threshold = 2, dates = time, spell.length = 1)
WaveDuration(data = 1 : length(time), threshold = 2, dates = time, spell.length = 1, by.seasons = FALSE)
WaveDuration(data = 1 : length(time), threshold = 2, op = "<", dates = time, spell.length = 1, by.seasons = FALSE)
WaveDuration(data = 1 : length(time), threshold = 2, op = "<=", dates = time, spell.length = 1, by.seasons = FALSE)
WaveDuration(data = 1 : length(time), threshold = 2, op = ">=", dates = time, spell.length = 1, by.seasons = FALSE)
time <-  seq(ISOdate(1901,1,1), ISOdate(1901,10,31), "day")
attr(time, "variables") <- metadata
WaveDuration(data = 1:length(time), threshold = 1, op = ">=", dates = time, spell.length = 1, by.seasons = FALSE)
WaveDuration(data = 1:length(time), threshold = 1, op = ">=", dates = time, spell.length = 1, by.seasons = TRUE)
WaveDuration(data = 1:length(time), threshold = 1, op = "<", dates = time, spell.length = 1, by.seasons = FALSE)
WaveDuration(data = 1:length(time), threshold = 1, op = "<=", dates = time, spell.length = 1, by.seasons = FALSE)
time <-  seq(ISOdate(1901,1,1), ISOdate(1902,1,1), "day")
attr(time, "variables") <- metadata
WaveDuration(data = 1:length(time), threshold = 1, op = ">=", dates = time, spell.length = 1, by.seasons = FALSE)
time <-  seq(ISOdate(1901,1,1), ISOdate(1901,12,31), "day")
attr(time, "variables") <- metadata
WaveDuration(data = 1:length(time), threshold = 1, op = ">=", dates = time, spell.length = 1, by.seasons = FALSE)
WaveDuration(data = 1:length(time), threshold = 1, op = ">=", dates = time, spell.length = 1, by.seasons = TRUE)


time <-  seq(ISOdate(1903,1,1), ISOdate(1904,12,31), "day")
attr(time, "variables") <- metadata
WaveDuration(data = 1:length(time), threshold = 1, op = ">=", dates = time, spell.length = 1, by.seasons = FALSE)
WaveDuration(data = 1:length(time), threshold = 1, op = ">=", dates = time, spell.length = 1, by.seasons = TRUE)



data <- as.numeric(strftime(time, "%j"))
a <- Threshold(data = data, dates = time, base.range = c(1902, 1903), qtiles = 0.9, ncores = NULL)


threshold.exceedance.duration.index(daily.temp = 1:(2*length(time)), date.factor = as.factor(c(rep("win", 59), rep("spr", 92), rep("sum", 92), rep("aut", 91), rep("win", 31), rep("win", 59), rep("spr", 92), rep("sum", 92), rep("aut", 91), rep("win", 31))), jdays = rep(1: 365,2), thresholds = rep(1, 2*365), op = ">", min.length = 1, spells.can.span.years = TRUE, max.missing.days = 0)

threshold.exceedance.duration.index(daily.temp = 1:length(time), date.factor = as.factor(substr(time, 6, 7)), jdays = c(1:59, 61:length(time)), threshold = rep(1, length(time)), op = ">", min.length = 1, spells.can.span.years = TRUE, max.missing.days = 1)
threshold.exceedance.duration.index(daily.temp = 1:length(time), date.factor = as.factor(substr(time, 6, 7)), jdays = c(1:59, 61:366), threshold = rep(1, length(time)), op = ">", min.length = 1, spells.can.span.years = TRUE, max.missing.days = 1)

