#' Update the seasons for LU
#'
#' Update the seasons for LU
#' @param season.sites the season calculated for each site.
#' @param p.sites the composition of each site.
#' @keywords updating season
#' @export
#' @examples
#' data("wq_analysis_week2")
#' SPTMData(wq.raw.obs, frequency = "quarter")
updateSeason = function(season.sites, basis = NULL, p.sites){
dim.s = dim(season.sites)
if(length(dim.s)==3){dim.s = dim.s[2]
}else{dim.s=1}
ss = season.sites
ss[which(is.na(ss))] <- 0
season.lu = t(apply(ss, 1, function(x) t(x %*% p.sites)))
season.lu = apply(season.lu,2,
function(x){
delta = diff(range(x));
e = 1
if(delta==0){delta = x[1]
e = 2};
new.x = x/delta*2
nx = (new.x - min(new.x) - 1)^e
return(nx)
}
)
rownames(season.lu) <- rownames(season.sites)
class(season.lu) <- 'SPTMseason'
attr(season.lu, "dimSeason") <- dim.s
attr(season.lu, "nameComp") <- colnames(p.sites)
attr(season.lu, "nameBasis") <- colnames(ss)
return(season.lu)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.