
Repair and re-derive a table of BioSIM FWI_Daily records
repair_fwi_daily.RdThe single entry point for making BioSIM FWI_Daily output trustworthy. Used by
get_fwi_daily(), and exported so that projects with their own BioSIM fetch apply
exactly the same correction rather than reimplementing it.
Arguments
- fwi_daily
data frame of
FWI_Dailyrecords with at leastFFMC,DMC,DCandWS.- validate
logical. Check the repaired values against physical bounds and error on a violation. Default
TRUE; a violation means a failure mode the repair does not characterise, which must not reach a weather database silently.
Details
Two steps:
Repair the three moisture codes
FFMC,DMCandDCin place, viarepair_fwi_exponent(). These are recursive, precipitation-driven daily codes, andFWI_Dailydoes not return precipitation in every configuration, so they cannot in general be recomputed from the other columns and must be recovered as they stand. RepairingDMCandDCmatters as much asFFMC: a corruptDMCotherwise flows into the buildup index and from there intoFWI.Discard and re-derive the three behaviour indices
BUI,ISIandFWIfrom the repaired codes usingcffdrs. These carry the same artifact as the codes –BUIdrops below1e-4wheneverDMCdoes – but they are pure functions of the codes, so recomputing is strictly safer than repairing: it needs no threshold and cannot mistake a genuine extreme for corruption. Nothing is lost by doing so. On uncorrupted records the recomputed values reproduce BioSIM's own to within5e-6relative forBUIand 0.8% forISIandFWI.
Records BioSIM did not model (-9999 sentinels, which callers map to NA before
calling) pass through as NA.