Skip to content

Wang-Engel temperature function (WEFT)#

Wang-Engel temperature function1: A simplified Arrhenius-type function, developed for responses to temperature and depending on minimum, optimum, and maximum temperatures (Wang et al., 2017)

F T = 2 T d a y - T m i n a T o p t - T m i n a - T d a y - T m i n 2 a T o p t - T m i n 2 α β   ; a =   l n 2 l n T m a x - T m i n T o p t - T m i n ,   β = 0 ~ 1

Code for WETF:

# -----------------------------------------------
# The Wang-Engel temperature function (WETF)
# -----------------------------------------------
@numba.jit(nopython=True)
def calculate_wang_engel_temperature( Tday, Tmin, Topt, Tmax):
    if (Topt <= Tmin):
        y = 0
    else:
        alpha = math.log(2) / math.log((Tmax - Tmin)/(Topt - Tmin))
        beta = 1 
        y = ( (2 * (Tday - Tmin)**alpha * (Topt - Tmin)**alpha - (Tday - Tmin)**(2*alpha)) / (Topt - Tmin)**(2*alpha) )**beta
        #y = 0 if (Tday < Tmin) else y
        #y = 0 if (Tday > Tmax) else y
        y = np.where(((Tday < Tmin) | (Tday > Tmax) ), 0, y)
    return y

@numba.jit(parallel=True) 
def apply_WETF(col_Tday, Tmin, Topt, Tmax):
    n = len(col_Tday)
    result = np.empty(n, dtype="float64")
    assert len(col_Tday) == n
    for i in prange(n):
        result[i] = calculate_wang_engel_temperature(col_Tday[i], Tmin, Topt, Tmax)
    return result

def compute_WETF(df, Tmin, Topt, Tmax):
    df["WETFTMAX"] = apply_WETF( df["Tdaymax"].to_numpy(), Tmin, Topt, Tmax )
    return df

# The Wang–Engel temperature function
calculate_wang_engel_temperature <- function( Tday, Tmin, Topt, Tmax) {
  if (Topt <= Tmin){
    y <- 0
  } else {
    alpha <- log(2) / log((Tmax - Tmin)/(Topt - Tmin))
    beta <- 1 
    y <- ( (2 * (Tday - Tmin)^alpha * (Topt - Tmin)^alpha - (Tday - Tmin)^(2*alpha)) / (Topt - Tmin)^(2*alpha) )^beta
    y <- if_else(Tday < Tmin, 0, y)
    y <- if_else(Tday > Tmax, 0, y)
  }
  return(y)
}
calculate_WETF_wrap <- function( Tday, Tmin, Topt, Tmax) {
  y <- vector("numeric", length (Tday)) 
  for (i in 1:length(Tday)) {
    y[[i]] <- calculate_wang_engel_temperature( Tday=Tday[[i]], Tmin, 
                                                Topt=Topt, Tmax) 
  }
  return(y)
}
The whole R code can be found in the Github repository at Rcode folder.


  1. Three cardinal temperatures