Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute CWD and CDD with custom threshold #20

Open
ysubash opened this issue Nov 6, 2019 · 1 comment
Open

Compute CWD and CDD with custom threshold #20

ysubash opened this issue Nov 6, 2019 · 1 comment

Comments

@ysubash
Copy link

ysubash commented Nov 6, 2019

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 ?

@thiagoveloso
Copy link

@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, [email protected]$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, [email protected]$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, [email protected]$annual, 
    thre, "<", spells.can.span.years) * ci@namasks$annual$prec)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants