R/get_thermal_units.R

Defines functions get_thermal_units

Documented in get_thermal_units

get_thermal_units <-
function(Tmin, Tmax, Tbase, Tmean) {
  alpha <- (Tmax - Tmin)/2
  theta <- asin((Tbase - Tmean)/alpha)
  theta[is.nan(theta)] <- 0
  thermal_units <- 1/pi * ((Tmean - Tbase) * (pi/2 - theta) + (alpha * cos(theta)))
  thermal_units[Tmin >= Tbase] <- Tmean[Tmin >= Tbase] - Tbase
  thermal_units[Tmax < Tbase] <- 0
  return(cumsum(thermal_units))
}

Try the phenModel package in your browser

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

phenModel documentation built on Aug. 2, 2019, 5:05 p.m.