Skip to content

Commit

Permalink
Address Issue #44, added D0 as its own variable to ensure FBP reports…
Browse files Browse the repository at this point in the history
… an effective date of minimum foliar moisture.
  • Loading branch information
BadgerOnABike committed Sep 18, 2024
1 parent 2975dc8 commit 31451f5
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 28 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ Suggests:
Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
3 changes: 3 additions & 0 deletions R/fire_behaviour_prediction.r
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,15 @@ fire_behaviour_prediction <- function(
}
CBH <- crown_base_height(FUELTYPE, CBH, SD, SH)
CFL <- crown_fuel_load(FUELTYPE, CFL)
D0 <- ifelse(D0 <= 0, foliar_moisture_content_minimum(LAT, LONG, ELV, DJ, D0), D0)
FMC <- ifelse(
FMC <= 0 | FMC > 120 | is.na(FMC),
foliar_moisture_content(LAT, LONG, ELV, DJ, D0),
FMC
)

FMC <- ifelse(FUELTYPE %in% c("D1", "S1", "S2", "S3", "O1A", "O1B"), 0, FMC)

############################################################################
# END
############################################################################
Expand Down
45 changes: 18 additions & 27 deletions R/foliar_moisture_content.r
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,39 @@
#' @noRd

foliar_moisture_content <- function(LAT, LONG, ELV, DJ, D0) {
# Initialize vectors
FMC <- rep(-1, length(LAT))
LATN <- rep(0, length(LAT))
# Calculate Normalized Latitude
# Eqs. 1 & 3 (FCFDG 1992)
LATN <- ifelse(
D0 <= 0,
ifelse(
ELV <= 0,
46 + 23.4 * exp(-0.0360 * (150 - LONG)),
43 + 33.7 * exp(-0.0351 * (150 - LONG))
),
LATN
)
# Calculate Date of minimum foliar moisture content
# Eqs. 2 & 4 (FCFDG 1992)
D0 <- ifelse(
D0 <= 0,
ifelse(
ELV <= 0,
151 * (LAT / LATN),
142.1 * (LAT / LATN) + 0.0172 * ELV
),
D0
)
# Round D0 to the nearest integer because it is a date
D0 <- round(D0, 0)

D0 <- foliar_moisture_content_minimum(LAT, LONG, ELV, DJ, D0)

# Number of days between day of year and date of min FMC

# Eq. 5 (FCFDG 1992)

ND <- abs(DJ - D0)

# Calculate final FMC

# Eqs. 6, 7, & 8 (FCFDG 1992)

FMC <- ifelse(

ND < 30,

85 + 0.0189 * ND^2,

ifelse(

ND >= 30 & ND < 50,

32.9 + 3.17 * ND - 0.0288 * ND^2,

120

)

)

return(FMC)

}

.FMCcalc <- function(...) {
Expand Down
59 changes: 59 additions & 0 deletions R/foliar_moisture_content_minimum.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#' Foliar Moisture Content Minimum Calculator
#'
#' @description Calculate date of Foliar Moisture Content Minimum.
#' All variables names are laid out in the same manner as Forestry Canada
#' Fire Danger Group (FCFDG) (1992). Development and Structure of the
#' Canadian Forest Fire Behavior Prediction System." Technical Report
#' ST-X-3, Forestry Canada, Ottawa, Ontario.
#'
#' @param LAT Latitude (decimal degrees)
#' @param LONG Longitude (decimal degrees)
#' @param ELV Elevation (metres)
#' @param DJ Day of year (offeren referred to as julian date)
#' @param D0 Date of minimum foliar moisture content. _If D0, date of min
#' FMC, is not known then D0 = NULL._
#'
#' @return D0: Date of minimum foliar moisture content
#' @noRd

foliar_moisture_content_minimum <- function(LAT, LONG, ELV, DJ, D0) {

# Initialize vectors

FMC <- rep(-1, length(LAT))
LATN <- rep(0, length(LAT))

# Calculate Normalized Latitude

# Eqs. 1 & 3 (FCFDG 1992)

LATN <- ifelse(
D0 <= 0,
ifelse(
ELV <= 0,
46 + 23.4 * exp(-0.0360 * (150 - LONG)),
43 + 33.7 * exp(-0.0351 * (150 - LONG))
),
LATN
)

# Calculate Date of minimum foliar moisture content

# Eqs. 2 & 4 (FCFDG 1992)

D0 <- ifelse(
D0 <= 0,
ifelse(
ELV <= 0,
151 * (LAT / LATN),
142.1 * (LAT / LATN) + 0.0172 * ELV
),
D0
)

# Round D0 to the nearest integer because it is a date

D0 <- round(D0, 0)
return(D0)

}

0 comments on commit 31451f5

Please sign in to comment.