pacificclimate / climdex.pcic

Routines to compute ETCCDI Climdex indices
GNU General Public License v3.0
23 stars 13 forks source link

Monthly frequency for precipitation indices? #22

Closed thiagoveloso closed 4 years ago

thiagoveloso commented 4 years ago

Thanks for this awesome package, it is really useful.

From the 27 indices, there are 16 for temperature and 11 for precipitation. Currently, for the precipitation ones, only Rx1day and Rx5day can be calculated on a monthly basis.

Would it be possible to calculate some of other precip indices (for instance, PRCPTOT and CWD) on a monthly frequency as well?

Thanks in advance, T.

thiagoveloso commented 4 years ago

Issue solved. I solved it by changing the original function climdex.prcptot from

function (ci) 
{
  stopifnot(!is.null(ci@data$prec))
  return(total.precip.op.threshold(ci@data$prec, ci@date.factors$annual, 
    1, ">=") * ci@namasks$annual$prec)
}

to

function (ci) 
{
  stopifnot(!is.null(ci@data$prec))
  return(total.precip.op.threshold(ci@data$prec, ci@date.factors$monthly, 
    1, ">=") * ci@namasks$monthly$prec)
}

Notice annual being replaced by monthly, which I suppose will work in other functions as well.