flammap_cli.py
provides a Python interface for running fire modeling simulations using applications developed by the Missoula Fire Lab. This module enables the setup, execution, and handling of various fire behavior models, including FlamMap, MTT, TOM, and Farsite, through a command-line interface.
- Download Required Application Data: Downloads necessary fire modeling application data and executable files.
- Generate Landscape File: Create landscape files (LCP) by merging required raster files.
- Generate Command & Input Files: Generate command and input files for running simulations with different fire models.
- Run Fire Models: Execute simulations for FlamMap, MTT, TOM, and Farsite via the command line.
- Test Application: Run sample datasets to validate installations and configurations.
- Python 3.6+
- Modules:
os
,glob
,subprocess
,rasterio
,typing
,requests
(fordownloadApps
function),shutil
(for file operations), andzipfile
(for handling zip files).
pip install -r requirements.txt
To download necessary files for running the applications, use:
downloadApps()
Use genLCP
to create an LCP file from 8 input TIF files.
genLCP(
lcp_file="output.lcp",
elev_path="elevation.tif",
slope_path="slope.tif",
aspect_path="aspect.tif",
fbfm_path="fbfm.tif",
cc_path="canopy_cover.tif",
ch_path="canopy_height.tif",
cbh_path="cbh.tif",
cbd_path="cbd.tif"
)
To create a command file for a simulation, use genCommandFile
:
genCommandFile(
out_path="command_file.txt",
command_list=[["FlamMap", "input.lcp", "output.tif", "condition_file", "wind_file", "options"]],
suppress_messages=False
)
To generate an input file for a specified fire model:
genInputFile(
out_folder="output_folder",
out_name="input_file",
app_select="FlamMap",
output_list=["FLAMELENGTH", "SPREADRATE", "INTENSITY"],
fuel_moisture_data=[3, "0 2 2 3 4 5"]
)
Execute a fire model using runApp
:
runApp(
app_select="FlamMap",
command_file_path="command_file.txt",
suppress_messages=False
)
To run a sample dataset for a specific fire model:
appTest(app_selection="FlamMap")
Downloads necessary fire behavior modeling application data.
genLCP(lcp_file, elev_path, slope_path, aspect_path, fbfm_path, cc_path, ch_path, cbh_path, cbd_path)
Generates an LCP (Landscape) file by merging multiple raster files.
Generates a command file for running a fire model.
Generates an input file with parameters specific to the selected fire model.
Runs the selected fire model using the generated command file.
Tests the specified fire modeling application using sample data provided by the Missoula Fire Lab.
This project is licensed under the MIT License.
Gregory A. Greene, map.n.trowel@gmail.com
"Fire behavior and First Order Fire Effects calculations produced with the command line applications developed by the Missoula Fire Sciences Laboratory, Missoula, MT"