Skip to main content

Python bindings and API for Behave extended Rothermel fire models

Project description

Pyrothermel

Model fire rate of spread, fire intensity, tree mortality, and more for surface fires and crown fires using the extended Rothermel model. Pyrothermel provides a Python interface to the same C++ code that underlies Behave, Flammap, and other software tools maintained by the Missoula Fire Lab*.

Please submit bugs and feature requests as Github issues. Expect significant API changes in early versions of this package.

*Pyrothermel and its authors are not associated with the Missoula Fire Lab or the US Government.

Dependencies

  • CMake
  • Python >= 3.8
  • setuptools
  • A C++ compiler
  • LLVM/Clang (not sure if this is still required)

Download

git clone https://github.com/j-tenny/pyrothermel.git

Build

python setup.py bdist_wheel

Install

Replace filename of wheel as needed

pip install dist/pyrothermel-0.0.1-cp38-cp38-win_amd64.whl --force-reinstall

Test example

python example.py

Quickstart

import pyrothermel
import pandas as pd
import seaborn as sns

Setup Base Fuel Model and Moisture Scenario

moisture = pyrothermel.MoistureScenario.from_existing(dead_fuel_moisture_class='low',live_fuel_moisture_class='moderate')
fuel = pyrothermel.FuelModel.from_existing(identifier='TL8')
canopy_base_height = 2.5 # default unit is m
canopy_bulk_density = .1 # default unit is kg/m^3

# Print some fuel loading values from fuel model TL8
print([fuel.fuel_load_one_hour, fuel.fuel_load_ten_hour, fuel.fuel_load_hundred_hour])
print(fuel.units.loading_units)
[1.300187341185569, 0.31383832373444764, 0.2465872543627803]
LoadingUnitsEnum.KilogramsPerSquareMeter

Run Rothermel Models Across Range of Wind Speeds

results_list = []
for wind_speed in range(0,60):
    run = pyrothermel.PyrothermelRun(fuel,moisture,wind_speed,wind_input_mode='ten_meter',canopy_base_height=canopy_base_height,canopy_bulk_density=canopy_bulk_density,canopy_cover=.5,canopy_height=20,canopy_ratio=.6)
    results_surface = run.run_surface_fire_in_direction_of_max_spread()
    results_final = run.run_crown_fire_scott_and_reinhardt()
    results_final['wind_speed'] = wind_speed
    results_final['treatment'] = 'untreated'
    results_list.append(results_final)
    
untreated_crowning_index = run.calculate_crowning_index()
untreated_torching_index = run.calculate_torching_index()
    
df = pd.DataFrame(results_list)
df
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
spread_rate flame_length fireline_intensity scorch_height transition_ratio active_ratio fire_type wind_speed treatment
0 0.035297 0.850504 182.940784 5.005403 0.274758 0.025974 Surface 0 untreated
1 0.035734 0.855332 185.205905 5.059386 0.278160 0.028804 Surface 1 untreated
2 0.036477 0.863471 189.058483 5.150455 0.283946 0.033603 Surface 2 untreated
3 0.037407 0.873532 193.880284 5.263140 0.291188 0.039601 Surface 3 untreated
4 0.038485 0.885015 199.463628 5.391881 0.299574 0.046541 Surface 4 untreated
5 0.039686 0.897621 205.691534 5.533368 0.308928 0.054277 Surface 5 untreated
6 0.040997 0.911142 212.486479 5.685303 0.319133 0.062713 Surface 6 untreated
7 0.042407 0.925421 219.792338 5.845960 0.330106 0.071779 Surface 7 untreated
8 0.043907 0.940336 227.566123 6.013981 0.341781 0.081423 Surface 8 untreated
9 0.045490 0.955787 235.773581 6.188266 0.354108 0.091601 Surface 9 untreated
10 0.047152 0.971693 244.386618 6.367902 0.367044 0.102279 Surface 10 untreated
11 0.048888 0.987985 253.381662 6.552121 0.380553 0.113428 Surface 11 untreated
12 0.050693 1.004603 262.738585 6.740268 0.394606 0.125023 Surface 12 untreated
13 0.052565 1.021499 272.439946 6.931781 0.409177 0.137042 Surface 13 untreated
14 0.054500 1.038631 282.470446 7.126172 0.424242 0.149466 Surface 14 untreated
15 0.056496 1.055960 292.816532 7.323014 0.439780 0.162279 Surface 15 untreated
16 0.058551 1.073456 303.466091 7.521935 0.455775 0.175465 Surface 16 untreated
17 0.060662 1.091090 314.408215 7.722604 0.472209 0.189011 Surface 17 untreated
18 0.062828 1.108839 325.633015 7.924731 0.489067 0.202906 Surface 18 untreated
19 0.065046 1.126682 337.131476 8.128056 0.506337 0.217136 Surface 19 untreated
20 0.067316 1.144599 348.895334 8.332347 0.524005 0.231694 Surface 20 untreated
21 0.069635 1.162575 360.916984 8.537398 0.542060 0.246568 Surface 21 untreated
22 0.072003 1.180595 373.189391 8.743023 0.560492 0.261751 Surface 22 untreated
23 0.074418 1.198648 385.706028 8.949054 0.579291 0.277235 Surface 23 untreated
24 0.076879 1.216721 398.460819 9.155342 0.598447 0.293011 Surface 24 untreated
25 0.079385 1.234805 411.448086 9.361748 0.617953 0.309073 Surface 25 untreated
26 0.081935 1.252892 424.662512 9.568151 0.637799 0.325414 Surface 26 untreated
27 0.084527 1.270975 438.099102 9.774438 0.657980 0.342028 Surface 27 untreated
28 0.087161 1.289045 451.753155 9.980508 0.678487 0.358909 Surface 28 untreated
29 0.089837 1.307098 465.620233 10.186267 0.699314 0.376053 Surface 29 untreated
30 0.092553 1.325129 479.696141 10.391632 0.720454 0.393453 Surface 30 untreated
31 0.095308 1.343132 493.976906 10.596526 0.741903 0.411104 Surface 31 untreated
32 0.098102 1.361104 508.458756 10.800878 0.763653 0.429003 Surface 32 untreated
33 0.100935 1.379041 523.138104 11.004625 0.785700 0.447144 Surface 33 untreated
34 0.103804 1.396940 538.011536 11.207708 0.808038 0.465524 Surface 34 untreated
35 0.106711 1.414798 553.075797 11.410073 0.830663 0.484138 Surface 35 untreated
36 0.109653 1.432613 568.327776 11.611672 0.853570 0.502983 Surface 36 untreated
37 0.112632 1.450384 583.764502 11.812459 0.876754 0.522055 Surface 37 untreated
38 0.115645 1.468107 599.383126 12.012394 0.900212 0.541350 Surface 38 untreated
39 0.118693 1.485781 615.180922 12.211439 0.923939 0.560865 Surface 39 untreated
40 0.121775 1.503406 631.155270 12.409561 0.947930 0.580597 Surface 40 untreated
41 0.124891 1.520979 647.303657 12.606728 0.972184 0.600542 Surface 41 untreated
42 0.128040 1.538500 663.623663 12.802911 0.996695 0.620699 Surface 42 untreated
43 0.179121 2.670320 1004.322097 12.998085 1.021460 0.641063 Torching 43 untreated
44 0.241603 3.448728 1474.064719 13.192226 1.046476 0.661632 Torching 44 untreated
45 0.308449 4.277088 2035.871156 13.385313 1.071740 0.682403 Torching 45 untreated
46 0.379762 5.160256 2697.956066 13.577327 1.097248 0.703375 Torching 46 untreated
47 0.455643 6.101520 3468.846986 13.768249 1.122998 0.724544 Torching 47 untreated
48 0.536191 7.103385 4357.386068 13.958064 1.148986 0.745907 Torching 48 untreated
49 0.621508 8.167919 5372.731790 14.146758 1.175210 0.767464 Torching 49 untreated
50 0.711691 9.296938 6524.360652 14.334319 1.201667 0.789210 Torching 50 untreated
51 0.806841 10.492099 7822.068863 14.520735 1.228355 0.811145 Torching 51 untreated
52 0.907056 11.754955 9275.974007 14.705996 1.255270 0.833266 Torching 52 untreated
53 1.012435 13.086990 10896.516695 14.890094 1.282410 0.855571 Torching 53 untreated
54 1.123074 14.489637 12694.462206 15.073021 1.309773 0.878058 Torching 54 untreated
55 1.239071 15.964297 14680.902109 15.254770 1.337357 0.900726 Torching 55 untreated
56 1.360525 17.512343 16867.255868 15.435336 1.365159 0.923571 Torching 56 untreated
57 1.487530 19.135129 19265.272442 15.614715 1.393177 0.946593 Torching 57 untreated
58 1.620185 20.833995 21887.031854 15.792902 1.421409 0.969790 Torching 58 untreated
59 1.758584 22.610265 24744.946765 15.969896 1.449853 0.993159 Torching 59 untreated

Modify Fuel Loading and Recalculate

fuel.fuel_load_one_hour *= .5
fuel.fuel_load_ten_hour *= .5
fuel.fuel_load_hundred_hour *= .75
fuel.fuel_bed_depth *= .5

results_list = []
for wind_speed in range(0,60):
    run = pyrothermel.PyrothermelRun(fuel,moisture,wind_speed,wind_input_mode='ten_meter',canopy_base_height=2.5,canopy_bulk_density=.1,canopy_cover=.5,canopy_height=20,canopy_ratio=.6)
    results_surface = run.run_surface_fire_in_direction_of_max_spread()
    results_final = run.run_crown_fire_scott_and_reinhardt()
    results_final['wind_speed'] = wind_speed
    results_final['treatment'] = 'treated'
    results_list.append(results_final)

treated_crowning_index = run.calculate_crowning_index()
treated_torching_index = run.calculate_torching_index()

df_treated = pd.DataFrame(results_list)
df = pd.concat([df,df_treated])

Display Results

sns.lineplot(df,x='wind_speed',y='flame_length',hue='treatment').set(xlabel='Wind Speed (km/hr)',ylabel='Flame Length (m)')
[Text(0.5, 0, 'Wind Speed (km/hr)'), Text(0, 0.5, 'Flame Length (m)')]

png

print('Wind Speed to initiate crown fire in untreated stand: ', untreated_torching_index, ' km/hr')
print('Wind Speed to initiate crown fire in treated stand: ', treated_torching_index, ' km/hr')
print('Wind Speed to propagate crown fire in untreated stand: ', untreated_crowning_index, ' km/hr')
print('Wind Speed to propagate crown fire in treated stand: ', treated_crowning_index, ' km/hr')
Wind Speed to initiate crown fire in untreated stand:  43  km/hr
Wind Speed to initiate crown fire in treated stand:  98  km/hr
Wind Speed to propagate crown fire in untreated stand:  60  km/hr
Wind Speed to propagate crown fire in treated stand:  60  km/hr

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrothermel-0.0.1.tar.gz (192.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrothermel-0.0.1-cp312-cp312-win_amd64.whl (264.8 kB view details)

Uploaded CPython 3.12Windows x86-64

File details

Details for the file pyrothermel-0.0.1.tar.gz.

File metadata

  • Download URL: pyrothermel-0.0.1.tar.gz
  • Upload date:
  • Size: 192.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pyrothermel-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7ecd75552db61d57745cafeff2d8d57d2053f43423ceadaca8b3024bbb7f0660
MD5 6abf9df25f225a64891a639ad28b8cf7
BLAKE2b-256 d850e7c66477f447abd7d8a577a555ee78aa7178e097f2be751521e3d35316f0

See more details on using hashes here.

File details

Details for the file pyrothermel-0.0.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyrothermel-0.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ac056b698915cce5a85efdf7b7ffc2b7e55e2a12d8d16c2cb64551a97725e39b
MD5 0112d076754663562dd38fd404ecdb0a
BLAKE2b-256 e2e95a20322ff45666f9ea259fcfd15b4eae71cf74b759183b99b12dde83d986

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page