Utilities Reference¶
The embrs.utilities package provides shared constants, helper functions, and support classes used throughout the EMBRS codebase. fire_util defines cell states, hexagonal grid math, and general-purpose utility functions. action provides classes for representing discrete suppression operations that can be scheduled and performed on a simulation. unit_conversions and numba_utils supply unit conversion helpers and JIT compilation wrappers respectively.
Fire Utilities¶
Core constants and utility functions for fire simulation.
This module provides essential data structures, constants, and helper functions used throughout the EMBRS codebase, including cell states, hexagonal grid math, road constants, and various utility functions.
Classes:
| Name | Description |
|---|---|
- CellStates |
Enumeration of cell states (BURNT, FUEL, FIRE). |
- CrownStatus |
Crown fire status constants. |
- CanopySpecies |
Canopy species definitions and properties. |
- RoadConstants |
Road type definitions and standard dimensions. |
- HexGridMath |
Hexagonal grid neighbor calculations. |
- SpreadDecomp |
Fire spread direction decomposition mappings. |
- UtilFuncs |
General utility functions. |
.. autoclass:: CellStates :members:
.. autoclass:: CrownStatus :members:
.. autoclass:: CanopySpecies :members:
.. autoclass:: RoadConstants :members:
.. autoclass:: HexGridMath :members:
.. autoclass:: SpreadDecomp :members:
.. autoclass:: UtilFuncs :members:
CanopySpecies
¶
Canopy species definitions and properties for spotting calculations.
Contains species identification mappings and physical properties used in firebrand lofting and spotting distance calculations.
Attributes:
| Name | Type | Description |
|---|---|---|
species_names |
dict
|
Maps species ID (int) to species name (str). |
species_ids |
dict
|
Maps species name (str) to species ID (int). |
properties |
ndarray
|
Physical properties matrix where each row corresponds to a species ID. Columns are species-specific parameters for spotting calculations. TODO:verify column definitions and units. (find the source and cite it here) |
Source code in embrs/utilities/fire_util.py
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 124 125 126 127 128 129 130 131 132 133 134 135 | |
CellStates
¶
Enumeration of possible cell states.
Attributes:
| Name | Type | Description |
|---|---|---|
BURNT |
int
|
Cell has been burnt, no fuel remaining (value: 0). |
FUEL |
int
|
Cell contains fuel and is not on fire (value: 1). |
FIRE |
int
|
Cell is currently burning (value: 2). |
Source code in embrs/utilities/fire_util.py
137 138 139 140 141 142 143 144 145 146 | |
CrownStatus
¶
Enumeration of crown fire status values.
Attributes:
| Name | Type | Description |
|---|---|---|
NONE |
int
|
No crown fire activity (value: 0). |
PASSIVE |
int
|
Passive crown fire (value: 1). |
ACTIVE |
int
|
Active crown fire (value: 2). |
Source code in embrs/utilities/fire_util.py
76 77 78 79 80 81 82 83 84 | |
HexGridMath
¶
Data structures for hexagonal grid neighbor calculations.
Provides mappings for finding neighbors of cells in a point-up hexagonal grid. Even and odd rows have different neighbor offsets due to the staggered grid layout.
Neighbor letters (A-F) identify the six directions around a hexagon, starting from the upper-right and proceeding clockwise.
Attributes:
| Name | Type | Description |
|---|---|---|
even_neighborhood |
list
|
Relative (row, col) offsets for neighbors of cells in even-numbered rows. |
even_neighbor_letters |
dict
|
Maps letter (A-F) to (row, col) offset for even rows. |
even_neighbor_rev_letters |
dict
|
Maps (row, col) offset to letter for even rows. |
odd_neighborhood |
list
|
Relative (row, col) offsets for neighbors of cells in odd-numbered rows. |
odd_neighbor_letters |
dict
|
Maps letter (A-F) to (row, col) offset for odd rows. |
odd_neighbor_rev_letters |
dict
|
Maps (row, col) offset to letter for odd rows. |
Source code in embrs/utilities/fire_util.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
RoadConstants
¶
Constants for road types imported from OpenStreetMap.
Defines standard road classifications, lane widths, shoulder widths, and visualization colors for roads used as fuel breaks in simulation.
Attributes:
| Name | Type | Description |
|---|---|---|
major_road_types |
list
|
List of supported OSM road type strings. |
lane_widths_m |
dict
|
Lane width in meters for each road type. |
shoulder_widths_m |
dict
|
Total shoulder width in meters for each road type. |
default_lanes |
int
|
Default number of lanes (2). |
road_color_mapping |
dict
|
Hex color codes for visualization by road type. |
TODO |
dict
|
verify the source for the lane widths |
Source code in embrs/utilities/fire_util.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
SpreadDecomp
¶
Mapping for fire spread direction decomposition across cell boundaries.
Maps spread endpoint locations on a cell's boundary to corresponding entry points on neighboring cells. Used for tracking fire propagation between adjacent hexagonal cells.
Attributes:
| Name | Type | Description |
|---|---|---|
self_loc_to_neighbor_loc_mapping |
dict
|
Maps edge location indices (1-12) to list of tuples (neighbor_edge_loc, neighbor_letter) indicating where fire enters the adjacent cell. |
Source code in embrs/utilities/fire_util.py
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 | |
UtilFuncs
¶
Collection of utility functions used across the codebase.
Source code in embrs/utilities/fire_util.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | |
get_cell_polygons(cells)
¶
Merge cell polygons into minimal covering polygons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cells
|
List[Cell]
|
List of Cell objects to convert. |
required |
Returns:
| Type | Description |
|---|---|
Optional[List[Polygon]]
|
Optional[List[Polygon]]: List of shapely Polygon objects representing the merged cells, or None if cells is empty. |
Source code in embrs/utilities/fire_util.py
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | |
get_dist(edge_loc, idx_diff, cell_size)
¶
Calculate distance from an edge location to an endpoint on the cell boundary.
Used internally for fire spread calculations to determine the distance fire must travel from its current position to reach a cell boundary point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_loc
|
int
|
Starting edge location index (0 for center, 1-12 for boundary positions where odd=edge midpoints, even=corners). |
required |
idx_diff
|
int
|
Absolute difference between edge_loc and target endpoint index (range 1-6 due to hexagon symmetry). |
required |
cell_size
|
float
|
Hexagon side length in meters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Distance in meters from edge_loc to the target endpoint. |
Source code in embrs/utilities/fire_util.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
get_dominant_fuel_type(fuel_map)
¶
Find the most common fuel type in a fuel map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fuel_map
|
ndarray
|
2D array of fuel type IDs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Fuel type ID that occurs most frequently. |
Source code in embrs/utilities/fire_util.py
321 322 323 324 325 326 327 328 329 330 331 332 | |
get_ign_parameters(edge_loc, cell_size)
cached
¶
Compute fire spread parameters from an ignition point within a cell.
Calculates the spread directions, distances to cell boundary endpoints, and neighbor cell entry points for fire propagating from a given ignition location. Results are cached for performance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_loc
|
int
|
Ignition location index. 0 for cell center, 1-12 for boundary positions (odd indices are edge midpoints, even indices are corner vertices). |
required |
cell_size
|
float
|
Hexagon side length in meters. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[ndarray, ndarray, tuple]
|
Tuple containing: - np.ndarray: Spread direction angles in degrees (0-360). - np.ndarray: Distances to each boundary endpoint in meters. - tuple: Nested tuples of (neighbor_edge_loc, neighbor_letter) pairs indicating where fire enters adjacent cells. |
Source code in embrs/utilities/fire_util.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | |
get_indices_from_xy(x_m, y_m, cell_size, grid_width, grid_height)
¶
Get grid indices for a point in spatial coordinates.
Calculates the (row, col) indices in the cell_grid array for the cell containing the point (x_m, y_m). Does not require a FireSim object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_m
|
float
|
X position in meters. |
required |
y_m
|
float
|
Y position in meters. |
required |
cell_size
|
float
|
Cell size in meters (hexagon side length). |
required |
grid_width
|
int
|
Number of columns in the grid. |
required |
grid_height
|
int
|
Number of rows in the grid. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[int, int]
|
Tuple[int, int]: (row, col) indices of the cell containing the point. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the point is outside the grid bounds. |
Source code in embrs/utilities/fire_util.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
get_time_str(time_s, show_sec=False)
¶
Format a time value in seconds as a human-readable string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_s
|
int
|
Time value in seconds. |
required |
show_sec
|
bool
|
If True, include seconds in output. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Formatted time string (e.g., "2 h 30 min" or "2 h 30 min 15 s"). |
Source code in embrs/utilities/fire_util.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
hexagon_vertices(x, y, s)
staticmethod
¶
Calculate vertex positions for a point-up hexagon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
X coordinate of hexagon center in meters. |
required |
y
|
float
|
Y coordinate of hexagon center in meters. |
required |
s
|
float
|
Side length of hexagon in meters. |
required |
Returns:
| Type | Description |
|---|---|
List[Tuple[float, float]]
|
List[Tuple[float, float]]: Six (x, y) vertex coordinates, starting from the top vertex and proceeding clockwise. |
Source code in embrs/utilities/fire_util.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
Action Classes¶
Suppression action classes for fire control operations.
This module defines action classes that represent discrete fire suppression operations such as setting ignitions, dropping retardant, water drops, and constructing firelines. Actions are meant to be instantiated and then performed on a fire simulation instance.
Classes:
| Name | Description |
|---|---|
- Action |
Base class for all actions. |
- SetIgnition |
Set an ignition at a specified location. |
- DropRetardant |
Drop fire retardant at a location. |
- DropWaterAsRain |
Simulate water drop as rainfall. |
- DropWaterAsMoistureInc |
Increase fuel moisture at a location. |
- ConstructFireline |
Construct a fireline along a path. |
.. autoclass:: Action :members:
.. autoclass:: SetIgnition :members:
.. autoclass:: DropRetardant :members:
.. autoclass:: DropWaterAsRain :members:
.. autoclass:: DropWaterAsMoistureInc :members:
.. autoclass:: ConstructFireline :members:
Action
¶
Base class for all fire suppression actions.
Actions are sortable by time and location for scheduling purposes. Note that the time attribute is for user reference only; actions execute at whatever simulation time they are called, not at their stored time.
Attributes:
| Name | Type | Description |
|---|---|---|
time |
float
|
Reference time for the action in seconds. |
loc |
tuple
|
Location (x, y) of the action in meters. |
Source code in embrs/utilities/action.py
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 | |
__init__(time, x, y)
¶
Initialize an action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
float
|
Reference time for the action in seconds. |
required |
x
|
float
|
X location of the action in meters. |
required |
y
|
float
|
Y location of the action in meters. |
required |
Source code in embrs/utilities/action.py
52 53 54 55 56 57 58 59 60 61 | |
__lt__(other)
¶
Compare actions for sorting by time, then location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Action
|
Another action to compare against. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if this action should come before the other. |
Source code in embrs/utilities/action.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
ConstructFireline
¶
Bases: Action
Action to construct a fireline along a path.
Constructs a fireline (fuel break) along the specified line geometry. If construction_rate is None, the fireline is applied instantly. Otherwise, the fireline is constructed progressively at the specified rate over simulation time steps.
Attributes:
| Name | Type | Description |
|---|---|---|
time |
float
|
Reference time for the action in seconds. |
loc |
tuple
|
Starting location (x, y) of the fireline in meters. |
line |
LineString
|
Shapely LineString defining the fireline path. |
width_m |
float
|
Width of the fireline in meters. |
construction_rate |
float
|
Construction rate in meters per second. If None, the fireline is applied instantly. |
Source code in embrs/utilities/action.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
__init__(time, x, y, line, width_m, construction_rate=None)
¶
Initialize a construct fireline action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
float
|
Reference time for the action in seconds. |
required |
x
|
float
|
X location of the action origin in meters. |
required |
y
|
float
|
Y location of the action origin in meters. |
required |
line
|
LineString
|
Shapely LineString defining the fireline path. |
required |
width_m
|
float
|
Width of the fireline in meters. |
required |
construction_rate
|
float
|
Construction rate in meters per second. If None, the fireline is applied instantly. Defaults to None. |
None
|
Source code in embrs/utilities/action.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
perform(fire)
¶
Execute the fireline construction on the fire simulation.
If construction_rate is None, the entire fireline is applied instantly. Otherwise, an active fireline is created that progresses over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fire
|
BaseFireSim
|
Fire simulation instance to modify. |
required |
Source code in embrs/utilities/action.py
269 270 271 272 273 274 275 276 277 278 | |
DropRetardant
¶
Bases: Action
Action to drop fire retardant at a location.
Applies long-term fire retardant to the cell at the specified location.
Attributes:
| Name | Type | Description |
|---|---|---|
time |
float
|
Reference time for the action in seconds. |
loc |
tuple
|
Location (x, y) of the drop in meters. |
duration_hr |
float
|
Duration of retardant effectiveness in hours. |
effectiveness |
float
|
Effectiveness factor of the retardant (0,1). |
Source code in embrs/utilities/action.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
__init__(time, x, y, duration_hr, effectiveness)
¶
Initialize a drop retardant action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
float
|
Reference time for the action in seconds. |
required |
x
|
float
|
X location of the drop in meters. |
required |
y
|
float
|
Y location of the drop in meters. |
required |
duration_hr
|
float
|
Duration of retardant effectiveness in hours. |
required |
effectiveness
|
float
|
Effectiveness factor of the retardant. |
required |
Source code in embrs/utilities/action.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
perform(fire)
¶
Execute the retardant drop on the fire simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fire
|
BaseFireSim
|
Fire simulation instance to modify. |
required |
Source code in embrs/utilities/action.py
147 148 149 150 151 152 153 154 155 156 | |
DropWaterAsMoistureInc
¶
Bases: Action
Action to increase fuel moisture at a location.
Directly increases the fuel moisture content of the cell at the specified location.
Attributes:
| Name | Type | Description |
|---|---|---|
time |
float
|
Reference time for the action in seconds. |
loc |
tuple
|
Location (x, y) of the action in meters. |
moisture_inc |
float
|
Moisture content increase as a fraction. |
Source code in embrs/utilities/action.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
__init__(time, x, y, moisture_inc)
¶
Initialize a moisture increase action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
float
|
Reference time for the action in seconds. |
required |
x
|
float
|
X location of the action in meters. |
required |
y
|
float
|
Y location of the action in meters. |
required |
moisture_inc
|
float
|
Moisture content increase as a fraction. |
required |
Source code in embrs/utilities/action.py
209 210 211 212 213 214 215 216 217 218 219 220 | |
perform(fire)
¶
Execute the moisture increase on the fire simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fire
|
BaseFireSim
|
Fire simulation instance to modify. |
required |
Source code in embrs/utilities/action.py
222 223 224 225 226 227 228 229 230 | |
DropWaterAsRain
¶
Bases: Action
Action to simulate water drop as rainfall at a location.
Models water application as equivalent rainfall depth to affect fuel moisture calculations.
Attributes:
| Name | Type | Description |
|---|---|---|
time |
float
|
Reference time for the action in seconds. |
loc |
tuple
|
Location (x, y) of the drop in meters. |
water_depth_cm |
float
|
Equivalent rainfall depth in centimeters. |
Source code in embrs/utilities/action.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
__init__(time, x, y, water_depth_cm=0.0)
¶
Initialize a water drop (as rain) action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
float
|
Reference time for the action in seconds. |
required |
x
|
float
|
X location of the drop in meters. |
required |
y
|
float
|
Y location of the drop in meters. |
required |
water_depth_cm
|
float
|
Equivalent rainfall depth in centimeters. Defaults to 0.0. |
0.0
|
Source code in embrs/utilities/action.py
171 172 173 174 175 176 177 178 179 180 181 182 183 | |
perform(fire)
¶
Execute the water drop on the fire simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fire
|
BaseFireSim
|
Fire simulation instance to modify. |
required |
Source code in embrs/utilities/action.py
185 186 187 188 189 190 191 192 193 194 | |
SetIgnition
¶
Bases: Action
Action to set an ignition at a specified location.
When performed, ignites the cell containing the specified (x, y) location.
Attributes:
| Name | Type | Description |
|---|---|---|
time |
float
|
Reference time for the action in seconds. |
loc |
tuple
|
Location (x, y) of the ignition in meters. |
Source code in embrs/utilities/action.py
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 | |
__init__(time, x, y)
¶
Initialize a set ignition action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
float
|
Reference time for the action in seconds. |
required |
x
|
float
|
X location of the ignition in meters. |
required |
y
|
float
|
Y location of the ignition in meters. |
required |
Source code in embrs/utilities/action.py
95 96 97 98 99 100 101 102 103 | |
perform(fire)
¶
Execute the ignition action on the fire simulation.
The ignition occurs at the current simulation time, not the stored time attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fire
|
BaseFireSim
|
Fire simulation instance to modify. |
required |
Source code in embrs/utilities/action.py
105 106 107 108 109 110 111 112 113 114 115 116 117 | |
Logger Schemas¶
Data schemas for logged simulation entries.
This module defines dataclass schemas for various log entry types used by the Logger to record simulation state over time.
Classes:
| Name | Description |
|---|---|
- CellLogEntry |
Schema for cell state log entries. |
- AgentLogEntry |
Schema for agent position log entries. |
- ActionsEntry |
Schema for suppression action log entries. |
- PredictionEntry |
Schema for fire prediction log entries. |
.. autoclass:: CellLogEntry :members:
.. autoclass:: AgentLogEntry :members:
.. autoclass:: ActionsEntry :members:
.. autoclass:: PredictionEntry :members:
ActionsEntry
dataclass
¶
Log entry for a suppression action at a simulation timestamp.
Attributes:
| Name | Type | Description |
|---|---|---|
timestamp |
int
|
Simulation time in seconds. |
action_type |
str
|
Type of action ('long_term_retardant', 'short_term_suppressant', or 'active_fireline'). |
x_coords |
List[float]
|
X coordinates of action geometry in meters. |
y_coords |
List[float]
|
Y coordinates of action geometry in meters. |
width |
float
|
Width of action (for firelines) in meters. |
effectiveness |
List[float]
|
Effectiveness values for the action. |
Source code in embrs/utilities/logger_schemas.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
to_dict()
¶
Convert entry to dictionary for serialization.
Source code in embrs/utilities/logger_schemas.py
131 132 133 | |
AgentLogEntry
dataclass
¶
Log entry for agent position at a simulation timestamp.
Attributes:
| Name | Type | Description |
|---|---|---|
timestamp |
int
|
Simulation time in seconds. |
id |
int
|
Unique agent identifier. |
label |
str
|
Agent display label. |
x |
float
|
Agent x position in meters. |
y |
float
|
Agent y position in meters. |
marker |
str
|
Matplotlib marker style. |
color |
str
|
Matplotlib color string. |
Source code in embrs/utilities/logger_schemas.py
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 | |
to_dict()
¶
Convert entry to dictionary for serialization.
Source code in embrs/utilities/logger_schemas.py
105 106 107 | |
CellLogEntry
dataclass
¶
Log entry for cell state at a simulation timestamp.
Attributes:
| Name | Type | Description |
|---|---|---|
timestamp |
int
|
Simulation time in seconds. |
id |
int
|
Unique cell identifier. |
x |
float
|
Cell center x position in meters. |
y |
float
|
Cell center y position in meters. |
fuel |
int
|
Fuel model type ID. |
state |
int
|
Cell state (0=BURNT, 1=FUEL, 2=FIRE). |
crown_state |
int
|
Crown fire status (0=NONE, 1=PASSIVE, 2=ACTIVE). |
w_n_dead |
float
|
Net dead fuel loading. |
w_n_dead_start |
float
|
Initial dead fuel loading. |
w_n_live |
float
|
Net live fuel loading. |
dfm_1hr |
float
|
1-hour dead fuel moisture content (fraction). |
dfm_10hr |
float
|
10-hour dead fuel moisture content (fraction). |
dfm_100hr |
float
|
100-hour dead fuel moisture content (fraction). |
ros |
float
|
Rate of spread in m/s. |
I_ss |
float
|
Steady-state fireline intensity. btu/ft/min |
wind_speed |
float
|
Wind speed in m/s. |
wind_dir |
float
|
Wind direction in degrees. |
retardant |
bool
|
Whether retardant is applied to this cell. |
arrival_time |
float
|
Time when fire arrived at this cell in seconds. |
Source code in embrs/utilities/logger_schemas.py
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 | |
to_dict()
¶
Convert entry to dictionary for serialization.
Source code in embrs/utilities/logger_schemas.py
78 79 80 | |
PredictionEntry
dataclass
¶
Log entry for a fire spread prediction.
Attributes:
| Name | Type | Description |
|---|---|---|
timestamp |
int
|
Simulation time when prediction was made in seconds. |
prediction |
dict
|
Prediction data mapping time to cell positions. |
Source code in embrs/utilities/logger_schemas.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
to_dict()
¶
Convert entry to dictionary with JSON-serializable prediction.
Source code in embrs/utilities/logger_schemas.py
148 149 150 151 152 153 154 | |
Unit Conversions¶
Unit conversion functions for fire modeling calculations.
This module provides conversion functions between imperial and metric units commonly used in fire behavior modeling (Rothermel equations use imperial units internally).
Functions are organized by conversion type: temperature, length, speed, fuel loading, heat flux, and heat content.
BTU_ft2_min_to_kW_m2(f_btu_ft2_min)
¶
Convert heat flux from BTU/(ft^2*min) to kW/m^2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_btu_ft2_min
|
float
|
Heat flux in BTU/(ft^2*min). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Heat flux in kW/m^2. |
Source code in embrs/utilities/unit_conversions.py
220 221 222 223 224 225 226 227 228 229 | |
BTU_ft_min_to_kW_m(f_btu_ft_min)
¶
Convert fireline intensity from BTU/(ft*min) to kW/m.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_btu_ft_min
|
float
|
Fireline intensity in BTU/(ft*min). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Fireline intensity in kW/m. |
Source code in embrs/utilities/unit_conversions.py
232 233 234 235 236 237 238 239 240 241 | |
BTU_ft_min_to_kcal_s_m(f_btu_ft_min)
¶
Convert fireline intensity from BTU/(ftmin) to kcal/(sm).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_btu_ft_min
|
float
|
Fireline intensity in BTU/(ft*min). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Fireline intensity in kcal/(s*m). |
Source code in embrs/utilities/unit_conversions.py
244 245 246 247 248 249 250 251 252 253 | |
BTU_lb_to_cal_g(f_btu_lb)
¶
Convert heat content from BTU/lb to cal/g.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_btu_lb
|
float
|
Heat content in BTU/lb. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Heat content in cal/g. |
Source code in embrs/utilities/unit_conversions.py
272 273 274 275 276 277 278 279 280 281 | |
F_to_C(f_f)
¶
Convert temperature from Fahrenheit to Celsius.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_f
|
float
|
Temperature in degrees Fahrenheit. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Temperature in degrees Celsius. |
Source code in embrs/utilities/unit_conversions.py
48 49 50 51 52 53 54 55 56 57 | |
KiSq_to_Lbsft2(f_kisq)
¶
Convert fuel loading from kg/m^2 to lb/ft^2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_kisq
|
float
|
Fuel loading in kg/m^2. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Fuel loading in lb/ft^2. |
Source code in embrs/utilities/unit_conversions.py
156 157 158 159 160 161 162 163 164 165 | |
KiSq_to_TPA(f_kisq)
¶
Convert fuel loading from kg/m^2 to tons per acre.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_kisq
|
float
|
Fuel loading in kg/m^2. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Fuel loading in tons per acre. |
Source code in embrs/utilities/unit_conversions.py
204 205 206 207 208 209 210 211 212 213 | |
Lbsft2_to_KiSq(f_libsft2)
¶
Convert fuel loading from lb/ft^2 to kg/m^2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_libsft2
|
float
|
Fuel loading in lb/ft^2. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Fuel loading in kg/m^2. |
Source code in embrs/utilities/unit_conversions.py
144 145 146 147 148 149 150 151 152 153 | |
Lbsft2_to_TPA(f_lbsft2)
¶
Convert fuel loading from lb/ft^2 to tons per acre.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_lbsft2
|
float
|
Fuel loading in lb/ft^2. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Fuel loading in tons per acre. |
Source code in embrs/utilities/unit_conversions.py
192 193 194 195 196 197 198 199 200 201 | |
TPA_to_KiSq(f_tpa)
¶
Convert fuel loading from tons per acre to kg/m^2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_tpa
|
float
|
Fuel loading in tons per acre. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Fuel loading in kg/m^2. |
Source code in embrs/utilities/unit_conversions.py
168 169 170 171 172 173 174 175 176 177 | |
TPA_to_Lbsft2(f_tpa)
¶
Convert fuel loading from tons per acre to lb/ft^2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_tpa
|
float
|
Fuel loading in tons per acre. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Fuel loading in lb/ft^2. |
Source code in embrs/utilities/unit_conversions.py
180 181 182 183 184 185 186 187 188 189 | |
cal_g_to_BTU_lb(f_cal_g)
¶
Convert heat content from cal/g to BTU/lb.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_cal_g
|
float
|
Heat content in cal/g. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Heat content in BTU/lb. |
Source code in embrs/utilities/unit_conversions.py
260 261 262 263 264 265 266 267 268 269 | |
ft_min_to_m_s(f_ft_min)
¶
Convert speed from feet per minute to meters per second.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_ft_min
|
float
|
Speed in ft/min. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Speed in m/s. |
Source code in embrs/utilities/unit_conversions.py
92 93 94 95 96 97 98 99 100 101 | |
ft_min_to_mph(f_ft_min)
¶
Convert speed from feet per minute to miles per hour.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_ft_min
|
float
|
Speed in ft/min. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Speed in mph. |
Source code in embrs/utilities/unit_conversions.py
116 117 118 119 120 121 122 123 124 125 | |
ft_to_m(f_ft)
¶
Convert length from feet to meters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_ft
|
float
|
Length in feet. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Length in meters. |
Source code in embrs/utilities/unit_conversions.py
76 77 78 79 80 81 82 83 84 85 | |
m_s_to_ft_min(m_s)
¶
Convert speed from meters per second to feet per minute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
m_s
|
float
|
Speed in m/s. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Speed in ft/min. |
Source code in embrs/utilities/unit_conversions.py
104 105 106 107 108 109 110 111 112 113 | |
m_to_ft(f_m)
¶
Convert length from meters to feet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_m
|
float
|
Length in meters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Length in feet. |
Source code in embrs/utilities/unit_conversions.py
64 65 66 67 68 69 70 71 72 73 | |
mph_to_ft_min(f_mph)
¶
Convert speed from miles per hour to feet per minute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_mph
|
float
|
Speed in mph. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Speed in ft/min. |
Source code in embrs/utilities/unit_conversions.py
128 129 130 131 132 133 134 135 136 137 | |
Numba Utilities¶
Numba JIT compilation utilities for EMBRS.
This module provides configuration and helper utilities for Numba JIT compilation used in performance-critical sections of the EMBRS codebase.
Environment Variables
EMBRS_DISABLE_JIT: Set to '1' to disable JIT compilation globally. Useful for debugging or testing without JIT overhead. NUMBA_DISABLE_JIT: Numba's built-in flag, also respected.
Usage
In modules that use JIT-compiled functions:¶
from embrs.utilities.numba_utils import jit_if_enabled, NUMBA_AVAILABLE
@jit_if_enabled(nopython=True, cache=True) def my_hot_function(x, y): # Numerical computation return x + y
Check if JIT is available:¶
if NUMBA_AVAILABLE: # Use JIT-optimized path pass else: # Fallback to pure Python pass
get_numba_status()
¶
Get information about Numba availability and configuration.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Dictionary containing: - available: bool, whether Numba is installed - version: str or None, Numba version if available - jit_enabled: bool, whether JIT compilation is enabled - disable_jit_env: bool, whether EMBRS_DISABLE_JIT is set |
Source code in embrs/utilities/numba_utils.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
get_prange()
¶
Get the appropriate parallel range function.
Returns:
| Name | Type | Description |
|---|---|---|
type |
type
|
numba.prange if available and JIT enabled, else range. |
Source code in embrs/utilities/numba_utils.py
152 153 154 155 156 157 158 159 160 | |
jit_if_enabled(**jit_kwargs)
¶
Decorator that applies Numba JIT if available and enabled.
This decorator wraps functions with Numba's @jit decorator when Numba is available and JIT is not disabled. If Numba is unavailable or JIT is disabled, the function is returned unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**jit_kwargs
|
Any
|
Keyword arguments to pass to numba.jit. Common options: - nopython=True: Compile in nopython mode (faster) - cache=True: Cache compiled functions to disk - parallel=True: Enable automatic parallelization - fastmath=True: Use fast math optimizations |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Callable |
Callable
|
Decorated function (JIT-compiled if enabled, else unchanged). |
Example
@jit_if_enabled(nopython=True, cache=True) def compute_moisture(w, t, s, params): # Numerical computation result = 0.0 for i in range(len(w)): result += w[i] * t[i] return result
Source code in embrs/utilities/numba_utils.py
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 | |
njit_if_enabled(**jit_kwargs)
¶
Decorator that applies Numba njit if available and enabled.
Equivalent to jit_if_enabled(nopython=True, **jit_kwargs). Use this for functions that must run in nopython mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**jit_kwargs
|
Any
|
Keyword arguments to pass to numba.njit. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Callable |
Callable
|
Decorated function (JIT-compiled if enabled, else unchanged). |
Source code in embrs/utilities/numba_utils.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
warmup_jit_cache()
¶
Warm up JIT-compiled functions to avoid first-call latency.
This function can be called during application startup to pre-compile JIT-decorated functions. This moves the compilation overhead from the first simulation step to the initialization phase.
Call this after all JIT-decorated functions are defined.
Source code in embrs/utilities/numba_utils.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |