R/calc_tsum.R

Defines functions calc_tsum

Documented in calc_tsum

#' Calculate temperature sum
#'
#' @param tmean numeric - mean temperature
#' @param ldt numeric - lower development threshold aka base temperature.
#' @description
#' The function is vectorized.
#' To use it with SpatRaster-Data see ?terra::lapp.
#'
#' @returns The temperature sum over the lower development threshold.
#' @family Temperature sum methods
#' @keywords internal

calc_tsum <- function(tmean, ldt) {

  tmean[tmean <= ldt & !is.na(tmean)] <- 0
  tmean[tmean > ldt & !is.na(tmean)] <- tmean[tmean > ldt & !is.na(tmean)] - ldt

  return(tmean)
}

Try the PHENTHAUproc package in your browser

Any scripts or data that you put into this service are public.

PHENTHAUproc documentation built on June 22, 2024, 7:12 p.m.