diff --git a/DESCRIPTION b/DESCRIPTION index 7db48753..5de01f86 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: esd -Version: 1.10.89 -Date: 2024-09-03 +Version: 1.10.90 +Date: 2024-10-04 Title: Climate analysis and empirical-statistical downscaling (ESD) package for monthly and daily data Author: Rasmus E. Benestad, Abdelkader Mezghani, Kajsa M. Parding, Helene B. Erlandsen, Ketil Tunheim, and Cristian Lussana Maintainer: Rasmus E. Benestad diff --git a/R/as.annual.R b/R/as.annual.R index 0b8074c9..368a3f03 100644 --- a/R/as.annual.R +++ b/R/as.annual.R @@ -710,7 +710,7 @@ leapdate <- function(years="2000", dates="02-29") { # Not to confuse with season # This function extracts a given seasonal interval and aggregates a given statistic #' @export -as.seasons <- function(x,start='01-01',end='12-31',FUN='mean',verbose=FALSE,...) { +as.seasons <- function(x,start='01-01',end='12-31',nmin=NULL,FUN='mean',verbose=FALSE,...) { if(verbose) print("as.seasons") yrs <- year(x); d <- dim(x) # ns = number of stations @@ -744,15 +744,16 @@ as.seasons <- function(x,start='01-01',end='12-31',FUN='mean',verbose=FALSE,...) k[i,] <- apply(matrix(z,ceiling(length(z)/ns),ns),2,nv) y[i,] <- apply(matrix(z,ceiling(length(z)/ns),ns),2,FUN, ...) } - y <- zoo(y,order.by=as.Date(paste(years,start,sep='-'))) - y <- attrcp(x,y) + if(!is.null(nmin)) y[ k < nmin ] <- NA + y <- zoo(y, order.by = as.Date(paste(years, start, sep='-'))) + y <- attrcp(x, y) attr(y,'history') <- history.stamp(x) if (twoyears==0) { attr(y,'season.interval') <- paste(start,'to',end) } else { attr(y,'season.interval') <- paste(start,'to',end,'the following year') } - attr(y,'n.valid') <- k + attr(y, 'n.valid') <- k class(y) <- class(x) class(y)[2] <- "season" #class(y)[2] <- "annual"