R/FireTypeLowToHigh.R

Defines functions fireTypeLowToHigh

Documented in fireTypeLowToHigh

#' FireType Low to high
#'
#' Helper function to deal with cases where there is a LOW intensity fire ( planned Burn)
#' shortly after a HIGH intensity Fire, shortly after is defined as <= max_interval
#'
#' @param max_interval the maximum inter fire interval where a LOW firetyppe for the second fire should be coverted to HIGH
#' @param Interval_Matrix matrix of sequential intervals between fire in unique fire history sequence
#'  ( generated internally as party of FAMEFMR::fhProcess())
#' @param Firetype_Matrix firetype matrix giving fireTypes (1=LOW 2=HIGH) for fires in unique fire history sequence
#'  ( generated internally as party of FAMEFMR::fhProcess())
#'
#' @return modified Firetype_Matrix where the fireytpe of LOW fires have been changed to HIGH if the interval since the last
#' LOW fire is <=
#' @export
#'
#' @examples
#' #firetype matrix giving fitetypes (1=LOW 2=HIGH) for fires in unique fire hsitory sequence ( generated internally as party of FAMEFMR::fhProcess())
#' FT_matrix<-structure(c(2, 2, 2, 2, NA, 1, 2, 2, NA, NA, NA, 1), dim = 4:3, dimnames = list(NULL, c("FireType01", "FireType02", "FireType03")))
#'
#' #Fire interval matrix
#' Interval<-structure(c(NA, 245L, 235L, 235L, NA, NA, NA, 10L), dim = c(4L, 2L), dimnames = list(NULL, c("INT01", "INT02")))
#' fireTypeLowToHigh(max_interval = 5,Interval_Matrix = Interval,Firetype_Matrix = FT_matrix)
fireTypeLowToHigh<-function(max_interval = NULL,Interval_Matrix = Interval,Firetype_Matrix = FT_matrix){
  print ("WARNING you are using the fireTypeLowToHigh() function to modify the fhProcess this may lead to
         unexpected TFI status and BBTFI values")
  correction_Matrix<-Interval_Matrix<=max_interval
  correction_Matrix<- cbind(rep(0,nrow(correction_Matrix)),correction_Matrix)
  correction_Matrix
  Firetype_Matrix[correction_Matrix==TRUE]<-2
  return(Firetype_Matrix)
  
}
nevilamos/FAMEFMR documentation built on April 17, 2025, 9:32 p.m.