R/tfac.R

Defines functions tfac

Documented in tfac

#' @title Calculate \code{tfac}, the model temperature factor
#' @description Calculates the model parameter \code{tfac} from monthly temperature 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 temp Numeric vector of length 12 indicating monthly temperature, in degrees Celsius.
#' @param params A named list containing model parameters. Defaults to the package default parameter
#' set \code{soilc_params}.
#' @export
tfac <- function(temp, params = soilc_params) {
  prelim <- (params$tmax$be - temp) / (params$tmax$be - params$topt$be)
  t_i <- prelim ^ params$ta$be * exp(0.076 * (1 - prelim ^ params$tb$be))
  tfac <- 1 / 12 * sum(t_i)
  return(tfac)
}
aj-sykes92/soilc.ipcc documentation built on March 19, 2021, 11:52 a.m.