You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi guys, when there is insufficient base period data (as determined by min.base.data.fraction.present when creating the climdex object) no values should be returned for any month/year of a percentile index. However, I find in such cases that months/years inside the base period that do have data still get values reported back. Specifically by the function percent.days.op.threshold.
e.g. I'm calculating tx90p and base period is 1971-1990 but only 1971 has data and I set min.base.data.fraction.present=0.5, so I expect no calculations to be made for any year. But I'm finding I'll still get a non-NA value for 1971 (a zero). So the treatment of the mask inside the base period isn't quite right. Basically what I think is happening is that sum(c(NA,NA),na.rm=TRUE) equals zero when we want it to equal NA in the case where ALL values are NA.
The following replacement in percent.days.op.threshold seems to fix it. dat[inset] <- rowSums(f.result, na.rm=TRUE) / (byrs - 1)
Hi guys, when there is insufficient base period data (as determined by min.base.data.fraction.present when creating the climdex object) no values should be returned for any month/year of a percentile index. However, I find in such cases that months/years inside the base period that do have data still get values reported back. Specifically by the function percent.days.op.threshold.
e.g. I'm calculating tx90p and base period is 1971-1990 but only 1971 has data and I set min.base.data.fraction.present=0.5, so I expect no calculations to be made for any year. But I'm finding I'll still get a non-NA value for 1971 (a zero). So the treatment of the mask inside the base period isn't quite right. Basically what I think is happening is that sum(c(NA,NA),na.rm=TRUE) equals zero when we want it to equal NA in the case where ALL values are NA.
The following replacement in percent.days.op.threshold seems to fix it.
dat[inset] <- rowSums(f.result, na.rm=TRUE) / (byrs - 1)
replaced by
dat[inset] <- apply(f.result,1,function(x) if (all(is.na(x))) x[NA_integer_] else sum(x, na.rm = TRUE) / (byrs - 1))
The text was updated successfully, but these errors were encountered: