R/ef.R

Defines functions ef

Documented in ef

#' Evaporative Fraction
#'
#'
#'
#' @param LE Latent heat (units).
#' @param H Sensible heat (units).
#' @param dates Dates vector.
#' @param aggregation.time Can be "NULL", "day", "month", "year", growing season "gs". if it's
#' a number it's considered as a time window in number of days. If "optim" the optimum number of days will be estimate to reduce the sd of each chunck. See \code{\link[ecofunr]{aggreg}}.
#' @param aggregation.metric Can be "mean", "max", "min", "median", and "quant". if "quant" a number between 0 and 1 need to be provided for prob parameter.
#' @param overlapping Can be "NULL" or a number. If it's a number equivale to the parameter by of the \cite{\link[zoo]{rollapply}} function.
#' @param prob Only used if aggregation.metric is "quant", a number between 0 and 1. By default 0.9.
#' @return An object of class "vector".
#'
#' @description
#'
#' Evaporative fraction (EF) is the ration between Latent heat and the sum of sensible heat and latent heat. EF is used to "characterize the energy partition over land surfaces"
#' \insertCite{nichols_evaluation_1993}{ecofunr}.
#'
#' \deqn{EF = \frac{LE}{LE + H}}{uWUE = LE / (LE + H)}
#'
#' @export
#'
#'
#' @references
#' \insertAllCited{}
#' @examples
#'
#'
ef <- function(LE, H, dates, aggregation.time = NULL, aggregation.metric = 'median', overlapping = F, prob = 0.9) {
  EF <- LE / (LE + H)
  if (is.null(aggregation.time)) {
    return(EF)
  }else{
    return(aggreg(EF, aggregation.time, aggregation.metric, dates, overlapping, prob))
  }
}
dpabon/ecofunr documentation built on July 15, 2020, 12:58 p.m.