Skip to content

Commit

Permalink
update ffmc coefficient as per email 'If you want the EXACT number it…
Browse files Browse the repository at this point in the history
…s 250.0*59.5/101.0'
  • Loading branch information
jordan-evens committed May 29, 2024
1 parent f66c948 commit 30aa5ec
Show file tree
Hide file tree
Showing 31 changed files with 398 additions and 395 deletions.
2 changes: 1 addition & 1 deletion R/Slopecalc.r
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ slope_adjustment <- function(
},
{
# Eq. 46 (FCFDG 1992)
m <- 147.27723 * (101 - FFMC) / (59.5 + FFMC)
m <- FFMC_COEFFICIENT * (101 - FFMC) / (59.5 + FFMC)
# Eq. 45 (FCFDG 1992) - FFMC function from the ISI equation
fF <- 91.9 * exp(-.1386 * m) * (1 + (m**5.31) / 4.93e7)
# Eqs. 44a, 44d (Wotton 2009) - Slope equivalent wind speed
Expand Down
2 changes: 1 addition & 1 deletion R/back_rate_of_spread.r
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ back_rate_of_spread <- function(
FMC, SFC, PC, PDF, CC, CBH) {
# Eq. 46 (FCFDG 1992)
# Calculate the FFMC function from the ISI equation
m <- 147.27723 * (101 - FFMC) / (59.5 + FFMC)
m <- FFMC_COEFFICIENT * (101 - FFMC) / (59.5 + FFMC)
# Eq. 45 (FCFDG 1992)
fF <- 91.9 * exp(-0.1386 * m) * (1.0 + (m**5.31) / 4.93e7)
# Eq. 75 (FCFDG 1992)
Expand Down
7 changes: 5 additions & 2 deletions R/fine_fuel_moisture_code.r
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# used in conversion between FFMC and moisture content
FFMC_COEFFICIENT <- 250.0 * 59.5 / 101.0

#' Fine Fuel Moisture Code Calculation
#'
#' @description Fine Fuel Moisture Code Calculation. All code is based on a C
Expand Down Expand Up @@ -26,7 +29,7 @@

fine_fuel_moisture_code <- function(ffmc_yda, temp, rh, ws, prec) {
# Eq. 1
wmo <- 147.27723 * (101 - ffmc_yda) / (59.5 + ffmc_yda)
wmo <- FFMC_COEFFICIENT * (101 - ffmc_yda) / (59.5 + ffmc_yda)
# Eq. 2 Rain reduction to allow for loss in
# overhead canopy
ra <- ifelse(prec > 0.5, prec - 0.5, prec)
Expand Down Expand Up @@ -73,7 +76,7 @@ fine_fuel_moisture_code <- function(ffmc_yda, temp, rh, ws, prec) {
# Eq. 9
wm <- ifelse(wmo > ed, ed + (wmo - ed) / (10^x), wm)
# Eq. 10 Final ffmc calculation
ffmc1 <- (59.5 * (250 - wm)) / (147.27723 + wm)
ffmc1 <- (59.5 * (250 - wm)) / (FFMC_COEFFICIENT + wm)
# Constraints
ffmc1 <- ifelse(ffmc1 > 101, 101, ffmc1)
ffmc1 <- ifelse(ffmc1 < 0, 0, ffmc1)
Expand Down
2 changes: 1 addition & 1 deletion R/grass_fuel_moisture.r
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ grass_fuel_moisture <- function(
temp, rh, ws, prec,
isol, GFMCold, roFL=0.3, time.step=1) {
# Eq. 13 - Calculate previous moisture code
MCold <- 147.27723 * ((101 - GFMCold) / (59.5 + GFMCold))
MCold <- FFMC_COEFFICIENT * ((101 - GFMCold) / (59.5 + GFMCold))
# Eq. 11 - Calculate the moisture content of the layer in % after rainfall
MCr <- ifelse(prec > 0, MCold + 100 * (prec / roFL), MCold)
# Constrain to 250
Expand Down
2 changes: 1 addition & 1 deletion R/grass_fuel_moisture_code.r
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

grass_fuel_moisture_code <- function(MC0) {
# Eq. 12 - Calculate GFMC
GFMC0 <- 59.5 * ((250 - MC0) / (147.27723 + MC0))
GFMC0 <- 59.5 * ((250 - MC0) / (FFMC_COEFFICIENT + MC0))
return(GFMC0)
}
6 changes: 3 additions & 3 deletions R/hourly_fine_fuel_moisture_code.r
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@

hourly_fine_fuel_moisture_code <- function(temp, rh, ws, prec, Fo, t0) {
# Eq. 1 (with a more precise multiplier than the daily)
mo <- 147.27723 * (101 - Fo) / (59.5 + Fo)
mo <- FFMC_COEFFICIENT * (101 - Fo) / (59.5 + Fo)
rf <- prec
# Eqs. 3a & 3b (Van Wagner & Pickett 1985)
mr <- ifelse(
Expand Down Expand Up @@ -201,8 +201,8 @@ hourly_fine_fuel_moisture_code <- function(temp, rh, ws, prec, Fo, t0) {
# Constraints
m <- ifelse(mo > Ed, md, mw)
m <- ifelse(Ed >= mo & mo >= Ew, mo, m)
# Eq. 6 - Final hffmc calculation (modified 3rd constant to 147.27723)
Fo <- 59.5 * (250 - m) / (147.27723 + m)
# Eq. 6 - Final hffmc calculation
Fo <- 59.5 * (250 - m) / (FFMC_COEFFICIENT + m)
Fo <- ifelse(Fo <= 0, 0, Fo)
return(Fo)
}
2 changes: 1 addition & 1 deletion R/initial_spread_index.r
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ initial_spread_index <- function(
ws,
fbpMod = FALSE) {
# Eq. 10 - Moisture content
fm <- 147.27723 * (101 - ffmc) / (59.5 + ffmc)
fm <- FFMC_COEFFICIENT * (101 - ffmc) / (59.5 + ffmc)
# Eq. 24 - Wind Effect
# the ifelse, also takes care of the ISI modification for the fbp functions
# This modification is Equation 53a in FCFDG (1992)
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/data/BackRateOfSpread.csv
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ C6,25.8,218.7,-10,437.4,19683,0,54,27,0,7.675e-11
M3,47.7,0,427.4,437.4,19683,0,54,27,0,4.969e-15
M4,67.2,874.8,-10,0,0,27,54,27,0,0.5239
O1B,89.1,656.1,427.4,0,0,27,54,27,0,2.101e-17
C1,10.2,656.1,208.7,218.7,0,27,54,27,0,6.548e-51
C1,10.2,656.1,208.7,218.7,0,27,54,27,0,6.549e-51
C6,32.1,437.4,-10,437.4,0,27,54,27,0,NA
M3,54,218.7,427.4,437.4,0,27,54,27,0,1.652e-14
O1A,75.9,0,208.7,0,6561,27,54,27,0,9.197e-09
Expand Down Expand Up @@ -1428,7 +1428,7 @@ C6,25.8,218.7,-10,437.4,19683,0,54,0,72.9,7.675e-11
M3,47.7,0,427.4,437.4,19683,0,54,0,72.9,4.969e-15
M4,67.2,874.8,-10,0,0,27,54,0,72.9,0.5239
O1B,89.1,656.1,427.4,0,0,27,54,0,72.9,1e-06
C1,10.2,656.1,208.7,218.7,0,27,54,0,72.9,6.548e-51
C1,10.2,656.1,208.7,218.7,0,27,54,0,72.9,6.549e-51
C6,32.1,437.4,-10,437.4,0,27,54,0,72.9,1.737e-08
M3,54,218.7,427.4,437.4,0,27,54,0,72.9,1.652e-14
O1A,75.9,0,208.7,0,6561,27,54,0,72.9,1e-06
Expand Down Expand Up @@ -2366,7 +2366,7 @@ C6,25.8,218.7,-10,437.4,19683,0,54,81,72.9,7.675e-11
M3,47.7,0,427.4,437.4,19683,0,54,81,72.9,4.969e-15
M4,67.2,874.8,-10,0,0,27,54,81,72.9,0.5239
O1B,89.1,656.1,427.4,0,0,27,54,81,72.9,6.216e-16
C1,10.2,656.1,208.7,218.7,0,27,54,81,72.9,6.548e-51
C1,10.2,656.1,208.7,218.7,0,27,54,81,72.9,6.549e-51
C6,32.1,437.4,-10,437.4,0,27,54,81,72.9,1.737e-08
M3,54,218.7,427.4,437.4,0,27,54,81,72.9,1.652e-14
O1A,75.9,0,208.7,0,6561,27,54,81,72.9,2.721e-07
Expand Down Expand Up @@ -3304,7 +3304,7 @@ C6,25.8,218.7,-10,437.4,19683,0,54,54,145.8,7.675e-11
M3,47.7,0,427.4,437.4,19683,0,54,54,145.8,4.969e-15
M4,67.2,874.8,-10,0,0,27,54,54,145.8,0.5239
O1B,89.1,656.1,427.4,0,0,27,54,54,145.8,1.301e-16
C1,10.2,656.1,208.7,218.7,0,27,54,54,145.8,6.548e-51
C1,10.2,656.1,208.7,218.7,0,27,54,54,145.8,6.549e-51
C6,32.1,437.4,-10,437.4,0,27,54,54,145.8,1.737e-08
M3,54,218.7,427.4,437.4,0,27,54,54,145.8,1.652e-14
O1A,75.9,0,208.7,0,6561,27,54,54,145.8,5.694e-08
Expand Down
174 changes: 87 additions & 87 deletions tests/testthat/data/HourlyFineFuelMoistureCode.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,109 +2,109 @@ temp,rh,ws,prec,ffmc_old,time.step,HourlyFineFuelMoistureCode
-30,-10,0,-10,0,0,NA
42.9,-10,0,-10,0,0,NA
25.7,-2.71,0,-10,0,0,NA
8.5,4.58,0,-10,0,0,0
-8.7,11.87,0,-10,0,0,0
-25.9,19.16,0,-10,0,0,0
47,19.16,0,-10,0,0,0
29.8,26.45,0,-10,0,0,0
12.6,33.74,0,-10,0,0,0
-4.6,41.03,0,-10,0,0,0
-21.8,48.32,0,-10,0,0,0
51.1,48.32,0,-10,0,0,0
33.9,55.61,0,-10,0,0,0
16.7,62.9,0,-10,0,0,0
-0.5,70.19,0,-10,0,0,0
-17.7,77.48,0,-10,0,0,0
55.2,77.48,0,-10,0,0,0
38,84.77,0,-10,0,0,0
20.8,92.06,0,-10,0,0,0
3.6,99.35,0,-10,0,0,0
-13.6,106.64,0,-10,0,0,0
59.3,106.64,0,-10,0,0,0
8.5,4.58,0,-10,0,0,4.257e-15
-8.7,11.87,0,-10,0,0,4.257e-15
-25.9,19.16,0,-10,0,0,4.257e-15
47,19.16,0,-10,0,0,4.257e-15
29.8,26.45,0,-10,0,0,4.257e-15
12.6,33.74,0,-10,0,0,4.257e-15
-4.6,41.03,0,-10,0,0,4.257e-15
-21.8,48.32,0,-10,0,0,4.257e-15
51.1,48.32,0,-10,0,0,4.257e-15
33.9,55.61,0,-10,0,0,4.257e-15
16.7,62.9,0,-10,0,0,4.257e-15
-0.5,70.19,0,-10,0,0,4.257e-15
-17.7,77.48,0,-10,0,0,4.257e-15
55.2,77.48,0,-10,0,0,4.257e-15
38,84.77,0,-10,0,0,4.257e-15
20.8,92.06,0,-10,0,0,4.257e-15
3.6,99.35,0,-10,0,0,4.257e-15
-13.6,106.64,0,-10,0,0,4.257e-15
59.3,106.64,0,-10,0,0,4.257e-15
42,-10,72.9,-10,0,0,NA
24.8,-2.71,72.9,-10,0,0,NA
7.6,4.58,72.9,-10,0,0,0
-9.6,11.87,72.9,-10,0,0,0
7.6,4.58,72.9,-10,0,0,4.257e-15
-9.6,11.87,72.9,-10,0,0,4.257e-15
-26.8,19.16,72.9,-10,0,0,0
46.1,19.16,72.9,-10,0,0,0
28.9,26.45,72.9,-10,0,0,0
11.7,33.74,72.9,-10,0,0,0
-5.5,41.03,72.9,-10,0,0,0
46.1,19.16,72.9,-10,0,0,4.257e-15
28.9,26.45,72.9,-10,0,0,4.257e-15
11.7,33.74,72.9,-10,0,0,4.257e-15
-5.5,41.03,72.9,-10,0,0,4.257e-15
-22.7,48.32,72.9,-10,0,0,0
50.2,48.32,72.9,-10,0,0,0
33,55.61,72.9,-10,0,0,0
15.8,62.9,72.9,-10,0,0,0
-1.4,70.19,72.9,-10,0,0,0
-18.6,77.48,72.9,-10,0,0,0
54.3,77.48,72.9,-10,0,0,0
37.1,84.77,72.9,-10,0,0,0
19.9,92.06,72.9,-10,0,0,0
50.2,48.32,72.9,-10,0,0,4.257e-15
33,55.61,72.9,-10,0,0,4.257e-15
15.8,62.9,72.9,-10,0,0,4.257e-15
-1.4,70.19,72.9,-10,0,0,8.513e-15
-18.6,77.48,72.9,-10,0,0,4.257e-15
54.3,77.48,72.9,-10,0,0,4.257e-15
37.1,84.77,72.9,-10,0,0,4.257e-15
19.9,92.06,72.9,-10,0,0,4.257e-15
2.7,99.35,72.9,-10,0,0,0
-14.5,106.64,72.9,-10,0,0,0
58.4,106.64,72.9,-10,0,0,0
-14.5,106.64,72.9,-10,0,0,4.257e-15
58.4,106.64,72.9,-10,0,0,4.257e-15
41.1,-10,145.8,-10,0,0,NA
23.9,-2.71,145.8,-10,0,0,NA
6.7,4.58,145.8,-10,0,0,0
-10.5,11.87,145.8,-10,0,0,0
-27.7,19.16,145.8,-10,0,0,0
45.2,19.16,145.8,-10,0,0,0
28,26.45,145.8,-10,0,0,0
10.8,33.74,145.8,-10,0,0,0
-6.4,41.03,145.8,-10,0,0,0
-23.6,48.32,145.8,-10,0,0,0
49.3,48.32,145.8,-10,0,0,0
32.1,55.61,145.8,-10,0,0,0
14.9,62.9,145.8,-10,0,0,0
-2.3,70.19,145.8,-10,0,0,0
-19.5,77.48,145.8,-10,0,0,0
53.4,77.48,145.8,-10,0,0,0
36.2,84.77,145.8,-10,0,0,0
6.7,4.58,145.8,-10,0,0,4.257e-15
-10.5,11.87,145.8,-10,0,0,4.257e-15
-27.7,19.16,145.8,-10,0,0,4.257e-15
45.2,19.16,145.8,-10,0,0,4.257e-15
28,26.45,145.8,-10,0,0,4.257e-15
10.8,33.74,145.8,-10,0,0,4.257e-15
-6.4,41.03,145.8,-10,0,0,4.257e-15
-23.6,48.32,145.8,-10,0,0,4.257e-15
49.3,48.32,145.8,-10,0,0,4.257e-15
32.1,55.61,145.8,-10,0,0,4.257e-15
14.9,62.9,145.8,-10,0,0,4.257e-15
-2.3,70.19,145.8,-10,0,0,4.257e-15
-19.5,77.48,145.8,-10,0,0,4.257e-15
53.4,77.48,145.8,-10,0,0,4.257e-15
36.2,84.77,145.8,-10,0,0,4.257e-15
19,92.06,145.8,-10,0,0,0
1.8,99.35,145.8,-10,0,0,0
-15.4,106.64,145.8,-10,0,0,0
57.5,106.64,145.8,-10,0,0,0
1.8,99.35,145.8,-10,0,0,4.257e-15
-15.4,106.64,145.8,-10,0,0,4.257e-15
57.5,106.64,145.8,-10,0,0,4.257e-15
40.2,-10,218.7,-10,0,0,NA
23,-2.71,218.7,-10,0,0,NA
5.8,4.58,218.7,-10,0,0,0
-11.4,11.87,218.7,-10,0,0,0
-28.6,19.16,218.7,-10,0,0,0
44.3,19.16,218.7,-10,0,0,0
27.1,26.45,218.7,-10,0,0,0
9.9,33.74,218.7,-10,0,0,0
-7.3,41.03,218.7,-10,0,0,0
-24.5,48.32,218.7,-10,0,0,0
5.8,4.58,218.7,-10,0,0,4.257e-15
-11.4,11.87,218.7,-10,0,0,4.257e-15
-28.6,19.16,218.7,-10,0,0,4.257e-15
44.3,19.16,218.7,-10,0,0,4.257e-15
27.1,26.45,218.7,-10,0,0,4.257e-15
9.9,33.74,218.7,-10,0,0,4.257e-15
-7.3,41.03,218.7,-10,0,0,8.513e-15
-24.5,48.32,218.7,-10,0,0,4.257e-15
48.4,48.32,218.7,-10,0,0,0
31.2,55.61,218.7,-10,0,0,0
14,62.9,218.7,-10,0,0,0
31.2,55.61,218.7,-10,0,0,4.257e-15
14,62.9,218.7,-10,0,0,8.513e-15
-3.2,70.19,218.7,-10,0,0,0
-20.4,77.48,218.7,-10,0,0,0
52.5,77.48,218.7,-10,0,0,0
35.3,84.77,218.7,-10,0,0,0
18.1,92.06,218.7,-10,0,0,0
0.9,99.35,218.7,-10,0,0,0
-16.3,106.64,218.7,-10,0,0,0
-20.4,77.48,218.7,-10,0,0,4.257e-15
52.5,77.48,218.7,-10,0,0,4.257e-15
35.3,84.77,218.7,-10,0,0,4.257e-15
18.1,92.06,218.7,-10,0,0,4.257e-15
0.9,99.35,218.7,-10,0,0,4.257e-15
-16.3,106.64,218.7,-10,0,0,8.513e-15
56.6,106.64,218.7,-10,0,0,0
39.3,-10,291.6,-10,0,0,NA
22.1,-2.71,291.6,-10,0,0,NA
4.9,4.58,291.6,-10,0,0,0
-12.3,11.87,291.6,-10,0,0,0
-29.5,19.16,291.6,-10,0,0,0
43.4,19.16,291.6,-10,0,0,0
26.2,26.45,291.6,-10,0,0,0
9,33.74,291.6,-10,0,0,0
-8.2,41.03,291.6,-10,0,0,0
-25.4,48.32,291.6,-10,0,0,0
47.5,48.32,291.6,-10,0,0,0
30.3,55.61,291.6,-10,0,0,0
13.1,62.9,291.6,-10,0,0,0
-4.1,70.19,291.6,-10,0,0,0
-21.3,77.48,291.6,-10,0,0,0
51.6,77.48,291.6,-10,0,0,0
4.9,4.58,291.6,-10,0,0,4.257e-15
-12.3,11.87,291.6,-10,0,0,4.257e-15
-29.5,19.16,291.6,-10,0,0,4.257e-15
43.4,19.16,291.6,-10,0,0,4.257e-15
26.2,26.45,291.6,-10,0,0,4.257e-15
9,33.74,291.6,-10,0,0,8.513e-15
-8.2,41.03,291.6,-10,0,0,4.257e-15
-25.4,48.32,291.6,-10,0,0,4.257e-15
47.5,48.32,291.6,-10,0,0,4.257e-15
30.3,55.61,291.6,-10,0,0,4.257e-15
13.1,62.9,291.6,-10,0,0,4.257e-15
-4.1,70.19,291.6,-10,0,0,4.257e-15
-21.3,77.48,291.6,-10,0,0,4.257e-15
51.6,77.48,291.6,-10,0,0,4.257e-15
34.4,84.77,291.6,-10,0,0,0
17.2,92.06,291.6,-10,0,0,0
0,99.35,291.6,-10,0,0,0
-17.2,106.64,291.6,-10,0,0,0
55.7,106.64,291.6,-10,0,0,0
17.2,92.06,291.6,-10,0,0,4.257e-15
0,99.35,291.6,-10,0,0,4.257e-15
-17.2,106.64,291.6,-10,0,0,4.257e-15
55.7,106.64,291.6,-10,0,0,4.257e-15
37.5,-10,0,55.61,0,0,NA
20.3,-2.71,0,55.61,0,0,NA
3.1,4.58,0,55.61,0,0,0
Expand Down
Loading

0 comments on commit 30aa5ec

Please sign in to comment.