#' Triangular chilling model (Legave \emph{et al.} 2008, 2013)
#'
#' This function computes the chill according to the triangular function proposed by Legave \emph{et al.} (2008) and
#' Legave \emph{et al.} (2013). This model, which uses Tmean as input, was selected as one of the "bests" over several
#' models proposed by the same authors.
#'
#' @param ExtrDailyTemp Dataframe containing columns \emph{"Tmax"} and \emph{"Tmin"}. These values must correspond to daily
#' records
#'
#' @param summ Boolean parameter indicating whether the computed metric should be provided as cumulative values
#' over the period or as the actual accumulation for each hour
#'
#' @references Legave J., Farrera I., Almeras T. and Calleja M. 2008. Selecting models of apple flowering time
#' and understanding how global warming has had and impact on this trait. J. Horticult. Sci. Biotechnol. 83(1):
#' 76 - 84. \href{https://www.tandfonline.com/doi/abs/10.1080/14620316.2008.11512350}{doi:10.1080/14620316.2008.11512350}
#'
#' Legave J., Blanke M., Christen D., Giovannini D, Mathieu V. and Oger R. 2013. A comprehensive overview of the
#' spatial and temporal variability of apple bud dormancy release and blooming phenology in Western Europe.
#' Int. J. Biometeorol. 57(2): 317 - 331. \href{https://link.springer.com/article/10.1007/s00484-012-0551-9}{doi:10.1007/s00484-012-0551-9}
#'
#' @examples
#' library(chillR)
#'
#' tempResponse_daily(KA_weather, Start_JDay = 345, End_JDay = 58,
#' models = list(Triangular_Chill_Legave = triangular_chill_2))
#'
#' @export triangular_chill_2
triangular_chill_2 <- function (ExtrDailyTemp, summ = TRUE) {
#Computing Tmean from Tmin and Tmax
if (!("Tmean" %in% names(ExtrDailyTemp)))
ExtrDailyTemp[,"Tmean"] <- (ExtrDailyTemp["Tmax"] + ExtrDailyTemp["Tmin"]) / 2
#Threshold (Tc)reported in the paper
threshold <- 1
#Temperature interval (Ic) define the range of efficient temperatures around Threshold
temp_interval <- 24
#Giving a value of 0 to the whole record
ExtrDailyTemp[,"Triang_Chill_Legave"] <- 0
#Selecting those days which fit the condition 2: TC-Ic < Tmean < TC+Ic
rel_days_cond2 <- which(threshold - temp_interval < ExtrDailyTemp$Tmean &
threshold + temp_interval > ExtrDailyTemp$Tmean)
#Computing the chill value for such condition
ExtrDailyTemp[rel_days_cond2, "Triang_Chill_Legave"] <- 1 - (abs(ExtrDailyTemp[rel_days_cond2, "Tmean"] -
threshold) / temp_interval)
#End of the function
if (summ == TRUE)
return(cumsum(ExtrDailyTemp$Triang_Chill_Legave)) else return(ExtrDailyTemp$Triang_Chill_Legave)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.