cffdrs / cffdrs_r

FWI and FBP components of CFFDRS in R
GNU General Public License v2.0
11 stars 5 forks source link

[CFFDRS R Bug]: Slopecalc.R Throwing NaNs, likely to be rejected by CRAN for this. #31

Open BadgerOnABike opened 7 months ago

BadgerOnABike commented 7 months ago

Contact Details

No response

What happened?

NaNs being thrown from https://github.com/cffdrs/cffdrs_r/blob/e4ae5688af8939d9460fe0465e41616bc5e73a11/R/Slopecalc.r#L95-L105

It seems like the if else isn't being respected?

I'm pretty sure its because the Fueltype is being trimmed but the RSF isn't.

Any ideas @jordan-evens? I'll keep prodding.

Relevant log output

ISF <- ifelse(
     FUELTYPE %in% c(
       "C1", "C2", "C3", "C4", "C5", "C6", "C7", "D1", "S1", "S2", "S3"
     ),
     ifelse(
       (1 - (RSF / a[FUELTYPE])**(1 / c0[FUELTYPE])) >= 0.01,
       log(1 - (RSF / a[FUELTYPE])**(1 / c0[FUELTYPE])) / (-b[FUELTYPE]),
       log(0.01) / (-b[FUELTYPE])
     ),
     ISF
   )
Warning in log(1 - (RSF/a[FUELTYPE])^(1/c0[FUELTYPE])) : NaNs produced

Approvals Process

BadgerOnABike commented 7 months ago
ifelse(FUELTYPE %in% c("C1", "C2", "C3", "C4", "C5", "C6", "C7", "D1", "S1", "S2", "S3"), 
print(RSF), 
"what is happening")

 [1]   0.22117729 157.59492225   3.57139293  16.09203015   0.08928563   3.48303960   0.70153699   9.44993112   5.14183700   9.75228357   6.95070765  33.63871789  93.31758536   0.38545877   2.32371542
[16]  18.17252958   1.01076009   1.80172101   0.91589852   2.40384829

 [1] "0.221177292533175"  "157.594922253295"   "3.57139293408702"   "16.0920301545284"   "0.0892856266010389" "3.4830396007684"    "0.70153698952755"   "9.4499311236549"    "what is happening" 
[10] "what is happening"  "what is happening"  "what is happening"  "what is happening"  "what is happening"  "what is happening"  "18.1725295809577"   "1.01076009037511"   "1.80172101134922"  
[19] "0.915898523680011"  "2.40384828885359" 

FUELTYPE  [1] "C1"  "C2"  "C3"  "C4"  "C5"  "C6"  "C7"  "D1"  "M1"  "M2"  "M3"  "M4"  "O1A" "O1B" "O1B" "S1"  "S2"  "S3"  "C6"  "C6"

So what I would want, is for it to drop RSF values that are false in the condition and then have a "what is happening" for all the falsey conditions. yet i get all for both in both (with the falseys replaced in the false)...