Open ysubash opened 5 years ago
@ysubash you can always create your own custom function. If you're on RStudio, you can type View
and take a look at the function code. For cdd
:
function (ci, spells.can.span.years = TRUE)
{
stopifnot(!is.null(ci@data$prec))
return(spell.length.max(ci@data$prec, ci@date.factors$annual,
1, "<", spells.can.span.years) * ci@namasks$annual$prec)
}
where the number 1 is the default value the function is using. Then you can change it to, say:
climdex.cdd.2.5 <- function (ci, spells.can.span.years = TRUE)
{
stopifnot(!is.null(ci@data$prec))
return(spell.length.max(ci@data$prec, ci@date.factors$annual,
2.5, "<", spells.can.span.years) * ci@namasks$annual$prec)
}
where the new value used is 2.5. You can even define a generic function, using a custom threshold:
climdex.cdd.cus <- function (ci, spells.can.span.years = TRUE, thre)
{
stopifnot(!is.null(ci@data$prec))
return(spell.length.max(ci@data$prec, ci@date.factors$annual,
thre, "<", spells.can.span.years) * ci@namasks$annual$prec)
}
I wish to compute the Consecutive wet and dry days with custom threshold of 2.5 mm. The default threshold is 1 mm. Is it possible ?