SaveFireAreaFracs: Save Fire Area Fractions

Description Usage Arguments Value Author(s) Examples

View source: R/SaveFireAreaFracs.R

Description

Write the fire area fractions out to a text file named "fireAreaFracs.csv".

Usage

1
SaveFireAreaFracs(vegChangesLocal, fireFracsLocal)

Arguments

vegChangesLocal

the list of 5 items returned by VegTypeChanges()

fireFracsLocal

the array of year-by-year fire fractions returned by SaveFireProbabilityMultipliers

Value

Returns a matrix fireAreaFracs[yrNdx, vtNdx] containing the same data which is written out to the text file.

Author(s)

Dave Conklin

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## The function is currently defined as
function (vegChangesLocal, fireFracsLocal) 
{
    srcDataFile = vegChangesLocal[[1]]
    years = vegChangesLocal[[2]]
    nYr = length(years)
    VTs = vegChangesLocal[[3]]
    nVT = length(VTs)
    vegFracs = vegChangesLocal[[4]]
    outFile = "fireAreaFracs.csv"
    fireAreaFracs = matrix(0, nrow = nYr, ncol = nVT)
    cat(srcDataFile, file = outFile, append = FALSE)
    cat("\n", file = outFile, append = TRUE)
    cat("year", file = outFile, append = TRUE)
    for (vtNdx in 1:nVT) cat(c(", ", VTs[vtNdx]), file = outFile, 
        append = TRUE)
    cat("\n", file = outFile, append = TRUE)
    for (yrNdx in 1:nYr) {
        cat(years[yrNdx], file = outFile, append = TRUE)
        for (vtNdx in 1:nVT) {
            fireAreaFracs[yrNdx, vtNdx] = vegFracs[vtNdx, yrNdx] * 
                fireFracsLocal[yrNdx, vtNdx]
            cat(c(", ", fireAreaFracs[yrNdx, vtNdx]), file = outFile, 
                append = TRUE)
        }
        cat("\n", file = outFile, append = TRUE)
    }
    return(fireAreaFracs)
  }

MC2toPath documentation built on May 2, 2019, 6:35 a.m.