R/wfac.R

Defines functions wfac

Documented in wfac

#' @title Calculate \code{wfac}, the model soil water factor
#' @description Calculates the model parameter \code{wfac} from monthly precipitation and potential
#' evapotranspiration data. Expects monthly data for a single-year dataframe; \code{map} over a list
#' of annual dataframes, or use to \code{mutate} a grouped tibble.
#' @param precip Numeric vector of length 12 indicating monthly precipitation, in mm.
#' @param pet Numeric vector of length 12 indicating monthly potential evapotranspiration, in mm.
#' @param params A named list containing model parameters. Defaults to the package default parameter
#' set \code{soilc_params}.
#' @export
wfac <- function(precip, pet, params = soilc_params) {
  mappet_i <- pmin(1.25, precip / pet)
  w_i <- params$wfacpar1$be + params$wfacpar2$be * mappet_i + params$wfacpar3$be * mappet_i ^ 2
  wfac <- 1.5 * (1 / 12 * sum(w_i))
  return(wfac)
}
aj-sykes92/soilc.ipcc documentation built on March 19, 2021, 11:52 a.m.