Fire Model
dissmodel.models.ca.fire_model.FireModel
Bases: CellularAutomaton
Spatial cellular automaton simulating forest fire spread.
The fire spreads to any forest cell that has at least one burning neighbor (Rook neighborhood — 4 cardinal directions).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
GeoDataFrame with geometries and a |
required |
**kwargs
|
Any
|
Extra keyword arguments forwarded to
:class: |
{}
|
Examples:
>>> from dissmodel.geo import regular_grid
>>> from dissmodel.core import Environment
>>> gdf = regular_grid(dimension=(10, 10), resolution=1, attrs={"state": 0})
>>> env = Environment(end_time=10)
>>> fire = FireModel(gdf=gdf)
>>> fire.initialize()
Source code in dissmodel/models/ca/fire_model.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
initialize()
Fill the grid with a random initial state.
Uses :attr:initial_fire_density to determine the proportion of
cells that start as burning. The remaining cells start as forest.
Source code in dissmodel/models/ca/fire_model.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
rule(idx)
Apply the fire spread transition rule to cell idx.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
any
|
Index of the cell being evaluated. |
required |
Returns:
| Type | Description |
|---|---|
int
|
New state for the cell:
|
Source code in dissmodel/models/ca/fire_model.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
setup(initial_fire_density=0.05, seed=42)
Configure the model and build the neighborhood.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_fire_density
|
float
|
Proportion of cells that start as burning, by default 0.05. Must be between 0.0 and 1.0. |
0.05
|
seed
|
int
|
Random seed used during initialization, by default 42. |
42
|
Source code in dissmodel/models/ca/fire_model.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
dissmodel.models.ca.fire_model.FireState
Bases: IntEnum
Possible states for a cell in :class:FireModel.
Attributes:
| Name | Type | Description |
|---|---|---|
FOREST |
int
|
Healthy tree, can catch fire. |
BURNING |
int
|
Actively burning, spreads fire to neighbors. |
BURNED |
int
|
Already burned, no longer spreads. |
Source code in dissmodel/models/ca/fire_model.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |