flame-components 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Flame Components — fire behavior calculations for surface and crown fires.
|
|
4
|
+
|
|
5
|
+
Public API is implemented in :mod:`flame_components.core`; this module
|
|
6
|
+
re-exports it.
|
|
7
|
+
"""
|
|
8
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
__version__ = version('flame-components')
|
|
12
|
+
except PackageNotFoundError:
|
|
13
|
+
# Package is not installed (e.g. running directly from a source checkout)
|
|
14
|
+
__version__ = 'unknown'
|
|
15
|
+
|
|
16
|
+
from flame_components.core import (
|
|
17
|
+
get_mid_flame_ws,
|
|
18
|
+
get_flame_length,
|
|
19
|
+
get_flame_height,
|
|
20
|
+
get_flame_tilt,
|
|
21
|
+
get_flame_residence_time,
|
|
22
|
+
get_flame_depth,
|
|
23
|
+
flame_component_array_multiprocessing,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
'get_mid_flame_ws',
|
|
28
|
+
'get_flame_length',
|
|
29
|
+
'get_flame_height',
|
|
30
|
+
'get_flame_tilt',
|
|
31
|
+
'get_flame_residence_time',
|
|
32
|
+
'get_flame_depth',
|
|
33
|
+
'flame_component_array_multiprocessing',
|
|
34
|
+
]
|
flame_components/core.py
ADDED
|
@@ -0,0 +1,846 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created on Wed Oct 11 13:25:52 2023
|
|
4
|
+
|
|
5
|
+
@author: Gregory A. Greene
|
|
6
|
+
|
|
7
|
+
Flame Components — fire behavior calculations for surface and crown fires.
|
|
8
|
+
|
|
9
|
+
NaN handling: All functions accept numpy arrays containing NaN values. NaNs are
|
|
10
|
+
automatically masked via numpy.ma and propagate silently through calculations —
|
|
11
|
+
masked input cells produce masked (NaN) output cells without warning. To inspect
|
|
12
|
+
how many cells were masked, check ``result_array[numpy.isnan(result_array)].size``
|
|
13
|
+
on the returned array.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import numbers
|
|
17
|
+
import warnings
|
|
18
|
+
from numpy import ma, ndarray, nan, isnan
|
|
19
|
+
from numpy.ma import sin, arccos, arcsin, arctan, sqrt, log, power
|
|
20
|
+
from numpy import pi, degrees, radians
|
|
21
|
+
from typing import Union, Optional
|
|
22
|
+
# import inspect
|
|
23
|
+
import multiprocessing as mp
|
|
24
|
+
# from multiprocessing import current_process
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# FUNCTION TO CALCULATE MID-FLAME WIND SPEED
|
|
28
|
+
def get_mid_flame_ws(wind_speed: Union[int, float, ndarray],
|
|
29
|
+
canopy_cover: Union[int, float, ndarray],
|
|
30
|
+
canopy_ht: Union[int, float, ndarray],
|
|
31
|
+
canopy_baseht: Union[int, float, ndarray],
|
|
32
|
+
units: str = 'SI') -> Union[int, float, ndarray]:
|
|
33
|
+
"""
|
|
34
|
+
Function to calculate mid-flame wind speed.
|
|
35
|
+
:param wind_speed: reference-height wind speed.
|
|
36
|
+
SI mode → 10-m wind speed (km/h) measured above open ground or canopy top.
|
|
37
|
+
IMP mode → 20-ft wind speed (mi/h).
|
|
38
|
+
WARNING: The 10-m reference height used here differs from the canopy-top wind
|
|
39
|
+
speed formula used in getFlameTilt (Butler model). Do not use the output of
|
|
40
|
+
this function as input to the Butler tilt model.
|
|
41
|
+
:param canopy_cover: canopy cover (percent)
|
|
42
|
+
:param canopy_ht: stand height (m for SI, ft for IMP). Values of 0 will be replaced
|
|
43
|
+
with 0.5 m equivalent (1.6404 ft) and a UserWarning will be issued.
|
|
44
|
+
:param canopy_baseht: canopy base height (m for SI, ft for IMP)
|
|
45
|
+
:param units: units of input data ("SI" or "IMP")
|
|
46
|
+
SI = metric (10-m ws in km/h, height in m, cbh in m)
|
|
47
|
+
IMP = imperial (20-ft ws in mi/h, height in ft, cbh in ft)
|
|
48
|
+
:return: mid-flame wind speed (m/s). Always metres per second regardless of input units.
|
|
49
|
+
For SI inputs, heights are converted to feet internally before applying the
|
|
50
|
+
Albini and Baughman (1979) equation (defined in US customary units).
|
|
51
|
+
|
|
52
|
+
Divide by 3.6 to convert from km/h to m/s\n
|
|
53
|
+
Divide windspeed by 1.15 to convert from 10-m to 20-ft equivalent (Lawson and Armitage 2008)\n
|
|
54
|
+
Calculate mid-flame windspeed (m/s) using under canopy equations (Albini and Baughman 1979)
|
|
55
|
+
Uc/Uh = 0.555 / (sqrt(f*H) * ln((20 + 0.36*H) / (0.13*H)))\n
|
|
56
|
+
where f = crown ratio * canopy cover (proportion) / 3, H = stand height (ft)\n
|
|
57
|
+
Equations explained well in Andrews (2012) - Modeling wind adjustment factor and
|
|
58
|
+
midflame wind speed for Rothermel's surface fire spread model\n
|
|
59
|
+
"""
|
|
60
|
+
# ### CHECK FOR NUMPY ARRAYS IN INPUT PARAMETERS
|
|
61
|
+
if any(isinstance(data, ndarray) for data in [wind_speed, canopy_cover, canopy_ht, canopy_baseht]):
|
|
62
|
+
return_array = True
|
|
63
|
+
else:
|
|
64
|
+
return_array = False
|
|
65
|
+
|
|
66
|
+
# ### VERIFY ALL INPUTS AND CONVERT TO MASKED NUMPY ARRAYS
|
|
67
|
+
# Verify windspeed
|
|
68
|
+
if not isinstance(wind_speed, (numbers.Real, ndarray)):
|
|
69
|
+
raise TypeError('windspeed must be either int, float or numpy ndarray data types')
|
|
70
|
+
elif isinstance(wind_speed, ndarray):
|
|
71
|
+
wind_speed = ma.array(wind_speed, mask=isnan(wind_speed))
|
|
72
|
+
elif isinstance(wind_speed, numbers.Real):
|
|
73
|
+
wind_speed = ma.array([float(wind_speed)], mask=isnan([wind_speed]))
|
|
74
|
+
|
|
75
|
+
# Verify canopy_cover
|
|
76
|
+
if not isinstance(canopy_cover, (numbers.Real, ndarray)):
|
|
77
|
+
raise TypeError('canopy_cover must be either int, float or numpy ndarray data types')
|
|
78
|
+
elif isinstance(canopy_cover, ndarray):
|
|
79
|
+
canopy_cover = ma.array(canopy_cover, mask=isnan(canopy_cover))
|
|
80
|
+
elif isinstance(canopy_cover, numbers.Real):
|
|
81
|
+
canopy_cover = ma.array([float(canopy_cover)], mask=isnan([canopy_cover]))
|
|
82
|
+
|
|
83
|
+
# Verify canopy_ht
|
|
84
|
+
if not isinstance(canopy_ht, (numbers.Real, ndarray)):
|
|
85
|
+
raise TypeError('canopy_ht must be either int, float or numpy ndarray data types')
|
|
86
|
+
elif isinstance(canopy_ht, ndarray):
|
|
87
|
+
canopy_ht = ma.array(canopy_ht, mask=isnan(canopy_ht))
|
|
88
|
+
elif isinstance(canopy_ht, numbers.Real):
|
|
89
|
+
canopy_ht = ma.array([float(canopy_ht)], mask=isnan([canopy_ht]))
|
|
90
|
+
|
|
91
|
+
# Verify canopy_baseht
|
|
92
|
+
if not isinstance(canopy_baseht, (numbers.Real, ndarray)):
|
|
93
|
+
raise TypeError('canopy_baseht must be either int, float or numpy ndarray data types')
|
|
94
|
+
elif isinstance(canopy_baseht, ndarray):
|
|
95
|
+
canopy_baseht = ma.array(canopy_baseht, mask=isnan(canopy_baseht))
|
|
96
|
+
elif isinstance(canopy_baseht, numbers.Real):
|
|
97
|
+
canopy_baseht = ma.array([float(canopy_baseht)], mask=isnan([canopy_baseht]))
|
|
98
|
+
|
|
99
|
+
# Verify units
|
|
100
|
+
if not isinstance(units, str):
|
|
101
|
+
raise TypeError('The "units" parameter must be a str data type')
|
|
102
|
+
elif units not in ['SI', 'IMP']:
|
|
103
|
+
raise ValueError('The "units" parameter must be either "SI" or "IMP"')
|
|
104
|
+
|
|
105
|
+
# Convert input units
|
|
106
|
+
if units == 'SI':
|
|
107
|
+
wind_speed = wind_speed / (3.6 * 1.15) # convert 10m (km/hr) windspeed to 20ft equivalent (1.15) and m/s (3.6)
|
|
108
|
+
canopy_ht = canopy_ht * 3.28084 # convert height in meters to feet
|
|
109
|
+
canopy_baseht = canopy_baseht * 3.28084 # convert cbh in meters to feet
|
|
110
|
+
elif units == 'IMP':
|
|
111
|
+
wind_speed = wind_speed / 2.23694 # convert mi/h to m/s
|
|
112
|
+
|
|
113
|
+
if ma.any(canopy_ht == 0):
|
|
114
|
+
warnings.warn(
|
|
115
|
+
'One or more canopy_ht values are 0. These will be replaced with 1.6404 ft (0.5 m) '
|
|
116
|
+
'to avoid division-by-zero in the Albini & Baughman (1979) equation. '
|
|
117
|
+
'Note: by this point canopy_ht has been converted to feet internally.',
|
|
118
|
+
UserWarning,
|
|
119
|
+
stacklevel=2,
|
|
120
|
+
)
|
|
121
|
+
canopy_ht = ma.where(canopy_ht == 0,
|
|
122
|
+
0.5 * 3.28084,
|
|
123
|
+
canopy_ht)
|
|
124
|
+
|
|
125
|
+
crown_ratio = (canopy_ht - canopy_baseht) / canopy_ht # calculate crown ratio
|
|
126
|
+
f = crown_ratio * canopy_cover / 300
|
|
127
|
+
|
|
128
|
+
# Calculate the mid-flame wind speed
|
|
129
|
+
midflame_ws = ma.where(f <= 5,
|
|
130
|
+
# Calculate unsheltered midflame windspeed
|
|
131
|
+
# ws * 0.4
|
|
132
|
+
wind_speed * 1.83 / log((20 + (0.36 * canopy_ht)) / (0.13 * canopy_ht)),
|
|
133
|
+
# Calculate sheltered midflame windspeed
|
|
134
|
+
wind_speed * 0.555 / (
|
|
135
|
+
sqrt(f * canopy_ht) * log((20 + (0.36 * canopy_ht)) / (0.13 * canopy_ht))))
|
|
136
|
+
|
|
137
|
+
# Ensure midflame_ws >= 0
|
|
138
|
+
midflame_ws[midflame_ws < 0] = 0
|
|
139
|
+
|
|
140
|
+
if return_array:
|
|
141
|
+
return midflame_ws.filled(nan)
|
|
142
|
+
else:
|
|
143
|
+
return midflame_ws.filled(nan)[0]
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# FUNCTION TO CALCULATE FLAME LENGTH
|
|
147
|
+
def get_flame_length(model: str,
|
|
148
|
+
fire_intensity: Union[int, float, ndarray],
|
|
149
|
+
flame_depth: Optional[Union[int, float, ndarray]] = None,
|
|
150
|
+
params_only: bool = False) -> Union[int, float, ndarray]:
|
|
151
|
+
"""
|
|
152
|
+
Function to estimate flame length from a variety of published models.
|
|
153
|
+
Equation from Nelson and Adkins (1986) - referenced in Cruz and Alexander (2018)
|
|
154
|
+
:param model: flame length model (refer to "model_dict" for list of options)
|
|
155
|
+
All models come from Finney and Grumstrup (2023), including their own 2023 model.
|
|
156
|
+
:param fire_intensity: head fire intensity (kW/m)
|
|
157
|
+
:param flame_depth: head fire flame depth (m) [OPTIONAL]
|
|
158
|
+
Only required for "Finney_HEAD" model
|
|
159
|
+
:param params_only: return only the model parameters ("True" or "False"; Default = False)
|
|
160
|
+
:return: flame length (m) or model parameters
|
|
161
|
+
"""
|
|
162
|
+
# Published correlations of flame length with fire intensity (from Finney and Grumstrup 2023)
|
|
163
|
+
model_dict = {
|
|
164
|
+
# Fire = No wind, flat
|
|
165
|
+
'Fons_NOWIND': (0.024018, 2 / 3), # Fons et al. (1963); Source = Cribs; Lab
|
|
166
|
+
'Thomas_NOWIND': (0.026700, 2 / 3), # Thomas (1963); Source = Cribs; Lab + Field
|
|
167
|
+
'Yuana_NOWIND': (0.034000, 2 / 3), # Yuana and Cox (1996); Source = Gas slot burner; Lab
|
|
168
|
+
'Barbon_iNOWIND': (0.062000, 0.5336), # Yuana and Cox (1996); Source = Pine needles; Lab + Field
|
|
169
|
+
# Fire = Backing
|
|
170
|
+
'Nelson_BACK': (0.027973, 2 / 3), # Nelson (1980); Source = Needles; Lab + Field
|
|
171
|
+
'Fernandes_BACK': (0.029000, 0.7240), # Fernandes et al. (2009); Source = Pine Needles; Field
|
|
172
|
+
'Clark_BACK': (0.001600, 1.7450), # Clark (1983); Source = Grass; Field
|
|
173
|
+
'Vega_BACK': (0.087000, 0.4930), # Vega et al. (1998); Source = Shrubs; Field
|
|
174
|
+
# Fire = Heading
|
|
175
|
+
'Byram_HEAD': (0.0775, 0.4600), # Byram (1959); Source = Needles; Field
|
|
176
|
+
'Anderson1_HEAD': (0.013876, 0.6510), # Anderson et al. (1966); Source = Lodgepole pine slash; Field
|
|
177
|
+
'Anderson2_HEAD': (0.008800, 0.6700), # Anderson et al. (1996); Source = Douglas-fir slash; Field
|
|
178
|
+
'Newman_HEAD': (0.05770, 0.5000), # Newman (1974); Source = Unkn; Field
|
|
179
|
+
'Sneewujagt_HEAD': (0.037680, 0.5000), # Sneewujagt and Frandsen (1977); Source = Needles; Field
|
|
180
|
+
'Nelson1_HEAD': (0.044230, 0.5000), # Nelson (1980); Source = Needles; Field
|
|
181
|
+
'Clark_HEAD': (0.000722, 0.9934), # Clark (1983); Source = Grass; Field
|
|
182
|
+
'Nelson2_HEAD': (0.047500, 0.4930), # Nelson and Adkins (1986); Source = Needles/Palmetto; Lab + Field
|
|
183
|
+
'VanWilgen_HEAD': (0.046000, 0.4128), # Van Wilgen (1986); Source = Grass; Field
|
|
184
|
+
'Burrows_HEAD': (0.040480, 0.5740), # Burrows (1994, p. 102); Source = Needles; Field
|
|
185
|
+
'MarsdenSmedley_HEAD': (0.148, 0.403), # Marsden-Smedley and Catchpole (1995); Source = Button grass; Field
|
|
186
|
+
'Weise1_HEAD': (0.016000, 0.7000), # Weise and Biging (1996); Source = Excelsior & birch stir sticks; Lab
|
|
187
|
+
'Catchpole_HEAD': (0.032500, 0.5600), # Catchpole et al. (1998); Source = Heath; Field
|
|
188
|
+
'Fernandes1_HEAD': (0.051600, 0.4530), # Fernandes et al. (2000); Source = Shrubs; Field
|
|
189
|
+
'Butler_HEAD': (0.017500, 2 / 3), # Butler et al. (2004); Source = Crownfire (add to avg. stand ht); Unkn
|
|
190
|
+
'Fernandes_HEAD': (0.045000, 0.5430), # Fernandes et al. (2009); Source = Needles; Field
|
|
191
|
+
'Nelson3_HEAD': (0.014200, 2 / 3), # Nelson et al. (2012); Source = Needles/southern Fuel; Lab
|
|
192
|
+
'Nelson4_HEAD': (0.015500, 2 / 3), # Nelson et al. (2012); Source = Needles/southern Fuel; Field
|
|
193
|
+
'Weise2_HEAD': (0.2000000, 0.3400), # Weise et al. (2016); Source = Chaparral; Lab
|
|
194
|
+
'Davies_HEAD': (0.220000, 0.2900), # Davies et al. (2019); Source = Heathlands; Field
|
|
195
|
+
'Finney_HEAD': (0.01051, 0.774, 0.161) # Finney and Grumstrup (2023); Source = Gas slot burner; Lab
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
# ### CHECK FOR NUMPY ARRAYS IN INPUT PARAMETERS
|
|
199
|
+
if any(isinstance(data, ndarray) for data in [fire_intensity, flame_depth]):
|
|
200
|
+
return_array = True
|
|
201
|
+
else:
|
|
202
|
+
return_array = False
|
|
203
|
+
|
|
204
|
+
# ### VERIFY ALL INPUTS AND CONVERT TO MASKED NUMPY ARRAYS
|
|
205
|
+
# Verify model
|
|
206
|
+
if not isinstance(model, str):
|
|
207
|
+
raise TypeError('The "model" parameter must be a str data type')
|
|
208
|
+
elif model not in list(model_dict.keys()):
|
|
209
|
+
raise ValueError(f'The "model" parameter must be one of the following:\n'
|
|
210
|
+
f'{list(model_dict.keys())}')
|
|
211
|
+
|
|
212
|
+
# Verify inputs for the selected model are valid
|
|
213
|
+
if model == 'Finney_HEAD':
|
|
214
|
+
if any(isinstance(data, type(None)) for data in [fire_intensity, flame_depth]):
|
|
215
|
+
raise ValueError('The "Finney_HEAD" model requires "fire_intensity" and "flame_depth" as inputs')
|
|
216
|
+
|
|
217
|
+
# Verify fire_intensity
|
|
218
|
+
if not isinstance(fire_intensity, (numbers.Real, ndarray)):
|
|
219
|
+
raise TypeError('fire_intensity must be either int, float or numpy ndarray data types')
|
|
220
|
+
elif isinstance(fire_intensity, ndarray):
|
|
221
|
+
fire_intensity = ma.array(fire_intensity, mask=isnan(fire_intensity))
|
|
222
|
+
else: # isinstance(fire_intensity, numbers.Real):
|
|
223
|
+
fire_intensity = ma.array([float(fire_intensity)], mask=isnan([fire_intensity]))
|
|
224
|
+
|
|
225
|
+
# Verify flame_depth
|
|
226
|
+
if not isinstance(flame_depth, (numbers.Real, ndarray, type(None))):
|
|
227
|
+
raise TypeError('flame_depth must be either int, float or numpy ndarray data types')
|
|
228
|
+
elif isinstance(flame_depth, ndarray):
|
|
229
|
+
flame_depth = ma.array(flame_depth, mask=isnan(flame_depth))
|
|
230
|
+
elif isinstance(flame_depth, numbers.Real):
|
|
231
|
+
flame_depth = ma.array([float(flame_depth)], mask=isnan([flame_depth]))
|
|
232
|
+
|
|
233
|
+
# Verify params_only
|
|
234
|
+
if not isinstance(params_only, bool):
|
|
235
|
+
raise TypeError('The "params_only" parameter must be bool data type')
|
|
236
|
+
|
|
237
|
+
# Get model parameters
|
|
238
|
+
model_params = model_dict.get(model)
|
|
239
|
+
|
|
240
|
+
if params_only:
|
|
241
|
+
return model_params
|
|
242
|
+
|
|
243
|
+
if model == 'Finney_HEAD':
|
|
244
|
+
fl = (model_params[0] *
|
|
245
|
+
power(fire_intensity, model_params[1]) /
|
|
246
|
+
power(flame_depth, model_params[2]))
|
|
247
|
+
else:
|
|
248
|
+
fl = model_params[0] * power(fire_intensity, model_params[1])
|
|
249
|
+
|
|
250
|
+
# Ensure fl >= 0
|
|
251
|
+
fl[fl < 0] = 0
|
|
252
|
+
|
|
253
|
+
if return_array:
|
|
254
|
+
return fl.filled(nan)
|
|
255
|
+
else:
|
|
256
|
+
return fl.filled(nan)[0]
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
# FUNCTION TO CALCULATE FLAME HEIGHT
|
|
260
|
+
def get_flame_height(model: str,
|
|
261
|
+
flame_length: Union[int, float, ndarray], # For all models
|
|
262
|
+
fire_type: Optional[Union[str, int]] = None, # For Nelson model
|
|
263
|
+
fire_intensity: Optional[Union[int, float, ndarray]] = None, # For Nelson model
|
|
264
|
+
midflame_ws: Optional[Union[int, float, ndarray]] = None, # For Nelson model
|
|
265
|
+
flame_tilt: Optional[Union[int, float, ndarray]] = None, # For Finney model
|
|
266
|
+
slope_angle: Optional[Union[int, float, ndarray]] = None, # For Finney model
|
|
267
|
+
slope_units: Optional[str] = None # For Finney model
|
|
268
|
+
) -> Union[int, float, ndarray]:
|
|
269
|
+
"""
|
|
270
|
+
Equations from Nelson and Adkins (1986) or Finney and Martin (1992) - referenced in Cruz and Alexander (2018)
|
|
271
|
+
:param model: model used to estimate flame height ("Nelson", "Finney")
|
|
272
|
+
The Finney (Simard) model is suggested if you already know tilt angle
|
|
273
|
+
:param flame_length: [Both models] head fire flame length (m)
|
|
274
|
+
:param fire_type: [Nelson model only] type of fire (1 or "surface", 2 or "passive crown", 3 or "active crown")
|
|
275
|
+
:param fire_intensity: [Nelson model only] head fire intensity (kW/m)
|
|
276
|
+
:param midflame_ws: [Nelson model only] mid-flame wind speed (m/s)
|
|
277
|
+
:param flame_tilt: [Finney model only] head fire flame tilt relative to vertical (degrees)
|
|
278
|
+
:param slope_angle: [Finney model only] Slope angle of ground (degrees or percent)
|
|
279
|
+
:param slope_units: [Finney model only] Units of slope-angle ("degrees" or "percent")
|
|
280
|
+
:return: head fire flame height (m)
|
|
281
|
+
"""
|
|
282
|
+
# Create the fire type dictionary to convert string inputs to integer
|
|
283
|
+
fire_type_dict = {
|
|
284
|
+
'surface': 1,
|
|
285
|
+
'passive crown': 2,
|
|
286
|
+
'active crown': 3
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
# ### CHECK FOR NUMPY ARRAYS IN INPUT PARAMETERS
|
|
290
|
+
if any(isinstance(data, ndarray) for data in [flame_length, fire_type, fire_intensity,
|
|
291
|
+
midflame_ws, flame_tilt, slope_angle, slope_units]):
|
|
292
|
+
return_array = True
|
|
293
|
+
else:
|
|
294
|
+
return_array = False
|
|
295
|
+
|
|
296
|
+
# ### VERIFY ALL INPUTS AND CONVERT TO MASKED NUMPY ARRAYS
|
|
297
|
+
# Verify model
|
|
298
|
+
if not isinstance(model, str):
|
|
299
|
+
raise TypeError('The "model" parameter must be a str data type')
|
|
300
|
+
elif model not in ['Nelson', 'Finney']:
|
|
301
|
+
raise ValueError(f'The "model" parameter must be one of the following: "Nelson", "Finney"')
|
|
302
|
+
|
|
303
|
+
# Verify inputs for the selected model are valid
|
|
304
|
+
if model == 'Nelson':
|
|
305
|
+
if any(isinstance(data, type(None)) for data in [fire_type, fire_intensity, midflame_ws]):
|
|
306
|
+
raise ValueError('The "Nelson" model requires "fire_type", "fire_intensity", and "midflame_ws" as inputs')
|
|
307
|
+
elif model == 'Finney':
|
|
308
|
+
if any(isinstance(data, type(None)) for data in [flame_tilt, slope_angle, slope_units]):
|
|
309
|
+
raise ValueError('The "Finney" model requires "flame_tilt", "slope_angle", and "slope_units" as inputs')
|
|
310
|
+
|
|
311
|
+
# Verify flame_length
|
|
312
|
+
if not isinstance(flame_length, (numbers.Real, ndarray)):
|
|
313
|
+
raise TypeError('flame_length must be either int, float or numpy ndarray data types')
|
|
314
|
+
elif isinstance(flame_length, ndarray):
|
|
315
|
+
flame_length = ma.array(flame_length, mask=isnan(flame_length))
|
|
316
|
+
elif isinstance(flame_length, numbers.Real):
|
|
317
|
+
flame_length = ma.array([float(flame_length)], mask=isnan([flame_length]))
|
|
318
|
+
|
|
319
|
+
# Verify fire_type
|
|
320
|
+
if model == 'Nelson':
|
|
321
|
+
if not isinstance(fire_type, (numbers.Real, float, str, ndarray, type(None))): # Bug 1 fix: added str
|
|
322
|
+
raise TypeError('fire_type must be either None, str, int or numpy ndarray data types')
|
|
323
|
+
elif isinstance(fire_type, (str, type(None))):
|
|
324
|
+
if fire_type not in ['surface', 'passive crown', 'active crown']:
|
|
325
|
+
raise ValueError(f'The "fire_type" parameter must be one of the following: '
|
|
326
|
+
f'"surface", "passive crown", "active crown"')
|
|
327
|
+
else:
|
|
328
|
+
fire_type = fire_type_dict.get(fire_type, nan) # Convert fire_type to integer value
|
|
329
|
+
if isinstance(fire_type, ndarray):
|
|
330
|
+
fire_type = ma.array(fire_type, mask=isnan(fire_type))
|
|
331
|
+
elif isinstance(fire_type, numbers.Real): # Bug 2 fix: was isinstance(midflame_ws, ...)
|
|
332
|
+
fire_type = ma.array([float(fire_type)], mask=isnan([fire_type]))
|
|
333
|
+
|
|
334
|
+
# Verify fire_type values are within the valid domain (1, 2, or 3)
|
|
335
|
+
if ma.any(~ma.getmaskarray(fire_type) & ~ma.isin(fire_type, [1, 2, 3])):
|
|
336
|
+
raise ValueError('The "fire_type" parameter must be 1 ("surface"), '
|
|
337
|
+
'2 ("passive crown"), or 3 ("active crown")')
|
|
338
|
+
|
|
339
|
+
# Verify fire_intensity
|
|
340
|
+
if not isinstance(fire_intensity, (numbers.Real, ndarray, type(None))):
|
|
341
|
+
raise TypeError('fire_intensity must be either iNone, nt, float or numpy ndarray data types')
|
|
342
|
+
elif isinstance(fire_intensity, ndarray):
|
|
343
|
+
fire_intensity = ma.array(fire_intensity, mask=isnan(fire_intensity))
|
|
344
|
+
elif isinstance(fire_intensity, numbers.Real):
|
|
345
|
+
fire_intensity = ma.array([float(fire_intensity)], mask=isnan([fire_intensity]))
|
|
346
|
+
|
|
347
|
+
# Verify midflame_ws
|
|
348
|
+
if not isinstance(midflame_ws, (numbers.Real, ndarray, type(None))):
|
|
349
|
+
raise TypeError('midflame_ws must be either None, int, float or numpy ndarray data types')
|
|
350
|
+
elif isinstance(midflame_ws, ndarray):
|
|
351
|
+
midflame_ws = ma.array(midflame_ws, mask=isnan(midflame_ws))
|
|
352
|
+
elif isinstance(midflame_ws, numbers.Real):
|
|
353
|
+
midflame_ws = ma.array([float(midflame_ws)], mask=isnan([midflame_ws]))
|
|
354
|
+
|
|
355
|
+
# Verify flame_tilt
|
|
356
|
+
if not isinstance(flame_tilt, (numbers.Real, ndarray, type(None))):
|
|
357
|
+
raise TypeError('flame_tilt must be either None, int, float or numpy ndarray data types')
|
|
358
|
+
elif isinstance(flame_tilt, ndarray):
|
|
359
|
+
flame_tilt = ma.array(flame_tilt, mask=isnan(flame_tilt))
|
|
360
|
+
elif isinstance(flame_tilt, numbers.Real):
|
|
361
|
+
flame_tilt = ma.array([float(flame_tilt)], mask=isnan([flame_tilt]))
|
|
362
|
+
|
|
363
|
+
# Verify slope_angle
|
|
364
|
+
if not isinstance(slope_angle, (numbers.Real, ndarray, type(None))):
|
|
365
|
+
raise TypeError('slope_angle must be either None, int, float or numpy ndarray data types')
|
|
366
|
+
elif isinstance(slope_angle, ndarray):
|
|
367
|
+
slope_angle = ma.array(slope_angle, mask=isnan(slope_angle))
|
|
368
|
+
elif isinstance(slope_angle, numbers.Real):
|
|
369
|
+
slope_angle = ma.array([slope_angle], mask=isnan([slope_angle]))
|
|
370
|
+
|
|
371
|
+
# Verify slope_units
|
|
372
|
+
if not isinstance(slope_units, (str, type(None))):
|
|
373
|
+
raise TypeError('slope_units must be str or None data types')
|
|
374
|
+
elif (slope_units is not None) and (slope_units not in ['degrees', 'percent']):
|
|
375
|
+
raise ValueError(f'The "slope_units" parameter must be one of the following: "degrees", "percent"')
|
|
376
|
+
|
|
377
|
+
if model == 'Nelson':
|
|
378
|
+
# Calculate fire parameter (a)
|
|
379
|
+
a = ma.where(ma.isin(fire_type, [1, 2]),
|
|
380
|
+
# parameter for experimental lab and field fires (Nelson and Adkins 1986; Nelson et al. 2012)
|
|
381
|
+
1 / 360,
|
|
382
|
+
# parameter for crown fires (Butler et al. 2004)
|
|
383
|
+
0.0175)
|
|
384
|
+
|
|
385
|
+
# Calculate height
|
|
386
|
+
height = ma.where(midflame_ws == 0,
|
|
387
|
+
flame_length,
|
|
388
|
+
a * fire_intensity / midflame_ws)
|
|
389
|
+
|
|
390
|
+
# Rescale height to match flame length if it is predicted to exceed flame length
|
|
391
|
+
height = ma.where(height > flame_length,
|
|
392
|
+
flame_length,
|
|
393
|
+
height)
|
|
394
|
+
|
|
395
|
+
else: # model == 'Finney':
|
|
396
|
+
# Convert slope to radians
|
|
397
|
+
if slope_units == 'percent':
|
|
398
|
+
slope_rad = arctan(slope_angle / 100)
|
|
399
|
+
elif slope_units == 'degrees':
|
|
400
|
+
slope_rad = radians(slope_angle)
|
|
401
|
+
else:
|
|
402
|
+
raise Exception('Unable to calculate flame height - Slope tilt')
|
|
403
|
+
|
|
404
|
+
# Convert flame tilt so it is relative to horizontal
|
|
405
|
+
tilt_h = pi / 2 - radians(flame_tilt)
|
|
406
|
+
|
|
407
|
+
height = ma.where(slope_angle <= 1,
|
|
408
|
+
flame_length * sin(tilt_h),
|
|
409
|
+
# Calculate Finney and Martin (1992) flame height
|
|
410
|
+
flame_length * sin(tilt_h - slope_rad) / sin(radians(90) - slope_rad))
|
|
411
|
+
|
|
412
|
+
# Ensure height >= 0
|
|
413
|
+
height[height < 0] = 0
|
|
414
|
+
|
|
415
|
+
if return_array:
|
|
416
|
+
return height.filled(nan)
|
|
417
|
+
else:
|
|
418
|
+
return height.filled(nan)[0]
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
# FUNCTION TO CALCULATE FLAME TILT
|
|
422
|
+
def get_flame_tilt(model: str,
|
|
423
|
+
flame_length: Optional[Union[int, float, ndarray]] = None,
|
|
424
|
+
flame_height: Optional[Union[int, float, ndarray]] = None,
|
|
425
|
+
slope_angle: Optional[Union[int, float, ndarray]] = None,
|
|
426
|
+
slope_units: Optional[str] = None,
|
|
427
|
+
wind_speed: Optional[Union[int, float, ndarray]] = None,
|
|
428
|
+
wind_speed_units: Optional[str] = None,
|
|
429
|
+
canopy_ht: Optional[Union[int, float, ndarray]] = None) -> Union[int, float, ndarray]:
|
|
430
|
+
"""
|
|
431
|
+
Function calculates flame tilt using Finney and Martin (1992) and Butler et al. (2004) equations
|
|
432
|
+
:param model: The flame tilt model to use ("Standard", "Finney", "Butler")
|
|
433
|
+
Standard = Use standard geometry calculations (for flat ground)
|
|
434
|
+
Finney = Use Finney and Martin (1992) (aka "Simard" model) model (for sloped ground)
|
|
435
|
+
Butler = Use Butler et al. (2004) model (for crown fires only)
|
|
436
|
+
:param flame_length: [Standard & Finney models only]
|
|
437
|
+
Head fire flame length (m)
|
|
438
|
+
:param flame_height: [Standard & Finney models only]
|
|
439
|
+
Head fire flame height (m)
|
|
440
|
+
:param slope_angle: [Finney model only]
|
|
441
|
+
Slope angle of ground (degrees or percent)
|
|
442
|
+
:param slope_units: [Finney model only]
|
|
443
|
+
Units of slope-angle ("degrees" or "percent")
|
|
444
|
+
:param wind_speed: [Butler model only]
|
|
445
|
+
10m wind speed (i.e., measured 10m above open ground or forest canopy)
|
|
446
|
+
:param wind_speed_units: [Butler model only]
|
|
447
|
+
Units of "wind_speed" parameter ("kph", "mps", "mph")
|
|
448
|
+
kph = kilometers per hour
|
|
449
|
+
mps = meters per second
|
|
450
|
+
mph = miles per hour
|
|
451
|
+
:param canopy_ht: [Butler model only]
|
|
452
|
+
Height of the canopy above the ground (m)
|
|
453
|
+
:return: angle of head fire flame tilt (degrees)
|
|
454
|
+
"""
|
|
455
|
+
# ### CHECK FOR NUMPY ARRAYS IN INPUT PARAMETERS
|
|
456
|
+
if any(isinstance(data, ndarray) for data in [flame_length, flame_height, slope_angle, wind_speed, canopy_ht]):
|
|
457
|
+
return_array = True
|
|
458
|
+
else:
|
|
459
|
+
return_array = False
|
|
460
|
+
|
|
461
|
+
# ### VERIFY ALL INPUTS AND CONVERT TO MASKED NUMPY ARRAYS
|
|
462
|
+
# Verify model
|
|
463
|
+
if not isinstance(model, str):
|
|
464
|
+
raise TypeError('The "model" parameter must be a str data type')
|
|
465
|
+
elif model not in ['Standard', 'Finney', 'Butler']:
|
|
466
|
+
raise ValueError(f'The "model" parameter must be one of the following: "Nelson", "Finney"')
|
|
467
|
+
|
|
468
|
+
# Verify inputs for the selected model are valid
|
|
469
|
+
if model == 'Standard':
|
|
470
|
+
if any(isinstance(data, type(None)) for data in [flame_length, flame_height]):
|
|
471
|
+
raise ValueError('The "Standard" model requires "flame_length" and "flame_height" as inputs')
|
|
472
|
+
elif model == 'Finney':
|
|
473
|
+
if any(isinstance(data, type(None)) for data in [flame_length, flame_height, slope_angle, slope_units]):
|
|
474
|
+
raise ValueError('The "Finney" model requires "flame_length", "flame_height", '
|
|
475
|
+
'"slope_angle", and "slope_units" as inputs')
|
|
476
|
+
else: # model == 'Butler':
|
|
477
|
+
if any(isinstance(data, type(None)) for data in [wind_speed, wind_speed_units, canopy_ht]):
|
|
478
|
+
raise ValueError('The "Butler" model requires "windspeed", "windspeed_units", and "canopy_ht" as inputs')
|
|
479
|
+
|
|
480
|
+
# Verify flame_length
|
|
481
|
+
if not isinstance(flame_length, (numbers.Real, ndarray, type(None))):
|
|
482
|
+
raise TypeError('flame_length must be either None, int, float or numpy ndarray data types')
|
|
483
|
+
elif isinstance(flame_length, ndarray):
|
|
484
|
+
flame_length = ma.array(flame_length, mask=isnan(flame_length))
|
|
485
|
+
elif isinstance(flame_length, numbers.Real):
|
|
486
|
+
flame_length = ma.array([flame_length], mask=isnan([flame_length]))
|
|
487
|
+
|
|
488
|
+
# Verify flame_height
|
|
489
|
+
if not isinstance(flame_height, (numbers.Real, ndarray, type(None))):
|
|
490
|
+
raise TypeError('flame_height must be either None, int, float or numpy ndarray data types')
|
|
491
|
+
elif isinstance(flame_height, ndarray):
|
|
492
|
+
flame_height = ma.array(flame_height, mask=isnan(flame_height))
|
|
493
|
+
elif isinstance(flame_height, numbers.Real):
|
|
494
|
+
flame_height = ma.array([flame_height], mask=isnan([flame_height]))
|
|
495
|
+
|
|
496
|
+
# Verify slope_angle
|
|
497
|
+
if not isinstance(slope_angle, (numbers.Real, ndarray, type(None))):
|
|
498
|
+
raise TypeError('slope_angle must be either None, int, float or numpy ndarray data types')
|
|
499
|
+
elif isinstance(slope_angle, ndarray):
|
|
500
|
+
slope_angle = ma.array(slope_angle, mask=isnan(slope_angle))
|
|
501
|
+
elif isinstance(slope_angle, numbers.Real):
|
|
502
|
+
slope_angle = ma.array([slope_angle], mask=isnan([slope_angle]))
|
|
503
|
+
|
|
504
|
+
# Verify slope_units
|
|
505
|
+
if not isinstance(slope_units, (str, type(None))):
|
|
506
|
+
raise TypeError('slope_units must be str or None data types')
|
|
507
|
+
elif slope_units not in ['degrees', 'percent', None]:
|
|
508
|
+
raise ValueError(f'The "slope_units" parameter must be one of the following: "degrees", "percent"')
|
|
509
|
+
|
|
510
|
+
# Verify wind_speed
|
|
511
|
+
if not isinstance(wind_speed, (numbers.Real, ndarray, type(None))):
|
|
512
|
+
raise TypeError('wind_speed must be either None, int, float or numpy ndarray data types')
|
|
513
|
+
elif isinstance(wind_speed, ndarray):
|
|
514
|
+
wind_speed = ma.array(wind_speed, mask=isnan(wind_speed))
|
|
515
|
+
elif isinstance(wind_speed, numbers.Real):
|
|
516
|
+
wind_speed = ma.array([wind_speed], mask=isnan([wind_speed]))
|
|
517
|
+
|
|
518
|
+
# Verify wind_speed_units
|
|
519
|
+
if not isinstance(wind_speed_units, (str, type(None))):
|
|
520
|
+
raise TypeError('wind_speed_units must be str or None data types')
|
|
521
|
+
elif wind_speed_units not in ['kph', 'mps', 'mph', None]:
|
|
522
|
+
raise ValueError(f'The "wind_speed_units" parameter must be one of the following: "kph", "mps", "mph')
|
|
523
|
+
|
|
524
|
+
# Verify canopy_ht
|
|
525
|
+
if not isinstance(canopy_ht, (numbers.Real, ndarray, type(None))):
|
|
526
|
+
raise TypeError('canopy_ht must be either None, int, float or numpy ndarray data types')
|
|
527
|
+
elif isinstance(canopy_ht, ndarray):
|
|
528
|
+
canopy_ht = ma.array(canopy_ht, mask=isnan(canopy_ht))
|
|
529
|
+
elif isinstance(canopy_ht, numbers.Real):
|
|
530
|
+
canopy_ht = ma.array([float(canopy_ht)], mask=isnan([canopy_ht]))
|
|
531
|
+
|
|
532
|
+
# Verify canopy_ht is positive (Butler model divides by it; canopy_ht <= 0 is not physical)
|
|
533
|
+
if model == 'Butler' and ma.any(~ma.getmaskarray(canopy_ht) & (canopy_ht <= 0)):
|
|
534
|
+
raise ValueError('The "canopy_ht" parameter must be greater than 0 for the "Butler" model')
|
|
535
|
+
|
|
536
|
+
# Calculate flame tilt angle (radians)
|
|
537
|
+
if model == 'Standard':
|
|
538
|
+
tilt_v = arccos(flame_height / flame_length)
|
|
539
|
+
elif model == 'Finney':
|
|
540
|
+
# Convert slope to radians
|
|
541
|
+
if slope_units == 'percent':
|
|
542
|
+
slope_rad = arctan(slope_angle / 100)
|
|
543
|
+
elif slope_units == 'degrees':
|
|
544
|
+
slope_rad = radians(slope_angle)
|
|
545
|
+
else:
|
|
546
|
+
raise Exception('Unable to calculate flame tilt - Invalid slope units provided')
|
|
547
|
+
|
|
548
|
+
# Calculate Finney and Martin (1992) flame tilt angle
|
|
549
|
+
# This equation calculates tilt relative to horizontal (tilting up from horizontal flat ground)
|
|
550
|
+
tilt_h = arcsin(radians(flame_height * degrees(sin(radians(90) - slope_rad)) / flame_length)) + slope_rad
|
|
551
|
+
tilt_v = ma.where(flame_height == flame_length,
|
|
552
|
+
0,
|
|
553
|
+
# Get equivalent tilt relative to vertical rather than horizontal (tilting down from vertical)
|
|
554
|
+
pi / 2 - tilt_h)
|
|
555
|
+
|
|
556
|
+
else: # model == 'Butler':
|
|
557
|
+
# THIS MODEL (Butler et al. 2004) IS MADE FOR TILT OF CROWN FIRES
|
|
558
|
+
# ONLY REQUIRES 10m WIND SPEED AS AN INPUT
|
|
559
|
+
# ONLY USE FOR CROWN FIRES, OTHERWISE TILT WILL BE TOO LOW
|
|
560
|
+
|
|
561
|
+
# Convert wind speed units if necessary
|
|
562
|
+
if wind_speed_units == 'kph':
|
|
563
|
+
wind_speed = wind_speed / 3.6 # convert kilometers/hour to meters/second
|
|
564
|
+
elif wind_speed_units == 'mph':
|
|
565
|
+
wind_speed = wind_speed / 2.23694 # convert miles/hour to meters/second
|
|
566
|
+
|
|
567
|
+
# Wind speed at the top of the forest canopy (Albini and Baughman 1979; Butler et al. 2004)
|
|
568
|
+
uc = wind_speed / (3.6 * (1 + log(1 + (28 / canopy_ht))))
|
|
569
|
+
|
|
570
|
+
# acceleration of gravity (m/s^2)
|
|
571
|
+
g = 9.81
|
|
572
|
+
|
|
573
|
+
# Calculate Butler et al. (2004) flame tilt angle
|
|
574
|
+
# This equation already calculates tilt relative to vertical rather than horizontal
|
|
575
|
+
tilt_v = arctan(sqrt((3 * power(uc, 3)) / (2 * g * 10)))
|
|
576
|
+
|
|
577
|
+
# Ensure tilt_v >= 0
|
|
578
|
+
tilt_v[tilt_v < 0] = 0
|
|
579
|
+
|
|
580
|
+
# Return flame tilt angle relative to vertical (degrees)
|
|
581
|
+
if return_array:
|
|
582
|
+
return degrees(tilt_v).filled(nan)
|
|
583
|
+
else:
|
|
584
|
+
return degrees(tilt_v).filled(nan)[0]
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
# FUNCTION TO CALCULATE FLAME RESIDENCE TIME
|
|
588
|
+
def get_flame_residence_time(ros: Union[int, float, ndarray],
|
|
589
|
+
fuel_consumption: Union[int, float, ndarray],
|
|
590
|
+
midflame_ws: Union[int, float, ndarray],
|
|
591
|
+
units: str) -> Union[int, float, ndarray]:
|
|
592
|
+
"""
|
|
593
|
+
Function to calculate flame residence time using equation from Nelson and Adkins (1988).
|
|
594
|
+
:param ros: Fire rate of spread (m/min). NOTE: input units are always m/min.
|
|
595
|
+
The "units" parameter below controls the OUTPUT unit only.
|
|
596
|
+
:param fuel_consumption: Amount of fuel consumed by fire front (kg/m^2)
|
|
597
|
+
:param midflame_ws: Mid-flame wind speed (m/s)
|
|
598
|
+
:param units: Output unit for flame residence time ("sec" or "min").
|
|
599
|
+
This parameter does NOT affect the expected input unit for ros — ros must
|
|
600
|
+
always be provided in m/min.
|
|
601
|
+
:return: Flame residence time in seconds ("sec") or minutes ("min").
|
|
602
|
+
"""
|
|
603
|
+
# ### CHECK FOR NUMPY ARRAYS IN INPUT PARAMETERS
|
|
604
|
+
if any(isinstance(data, ndarray) for data in [ros, fuel_consumption, midflame_ws]):
|
|
605
|
+
return_array = True
|
|
606
|
+
else:
|
|
607
|
+
return_array = False
|
|
608
|
+
|
|
609
|
+
# ### VERIFY ALL INPUTS AND CONVERT TO MASKED NUMPY ARRAYS
|
|
610
|
+
# Verify ros
|
|
611
|
+
if not isinstance(ros, (numbers.Real, ndarray)):
|
|
612
|
+
raise TypeError('ros must be either int, float or numpy ndarray data types')
|
|
613
|
+
elif isinstance(ros, ndarray):
|
|
614
|
+
ros = ma.array(ros, mask=isnan(ros))
|
|
615
|
+
else: # if isinstance(ros, numbers.Real):
|
|
616
|
+
ros = ma.array([ros], mask=isnan([ros]))
|
|
617
|
+
|
|
618
|
+
# Verify fuel_consumption
|
|
619
|
+
if not isinstance(fuel_consumption, (numbers.Real, ndarray)):
|
|
620
|
+
raise TypeError('fuel_consumption must be either int, float or numpy ndarray data types')
|
|
621
|
+
elif isinstance(fuel_consumption, ndarray):
|
|
622
|
+
fuel_consumption = ma.array(fuel_consumption, mask=isnan(fuel_consumption))
|
|
623
|
+
else: # isinstance(fuel_consumption, numbers.Real):
|
|
624
|
+
fuel_consumption = ma.array([fuel_consumption], mask=isnan([fuel_consumption]))
|
|
625
|
+
|
|
626
|
+
# Verify midflame_ws
|
|
627
|
+
if not isinstance(midflame_ws, (numbers.Real, ndarray)):
|
|
628
|
+
raise TypeError('fuel_consumption must be either int, float or numpy ndarray data types')
|
|
629
|
+
elif isinstance(midflame_ws, ndarray):
|
|
630
|
+
midflame_ws = ma.array(midflame_ws, mask=isnan(midflame_ws))
|
|
631
|
+
else: # isinstance(midflame_ws, numbers.Real):
|
|
632
|
+
midflame_ws = ma.array([midflame_ws], mask=isnan([midflame_ws]))
|
|
633
|
+
|
|
634
|
+
# Verify units
|
|
635
|
+
if not isinstance(units, str):
|
|
636
|
+
raise TypeError('The "units" parameter must be a str data type')
|
|
637
|
+
elif units not in ['sec', 'min']:
|
|
638
|
+
raise ValueError('The "units" parameter must be either "sec" or "min"')
|
|
639
|
+
|
|
640
|
+
# Calculate flame residence time
|
|
641
|
+
res_time = (0.39 * power(fuel_consumption, 0.25) * power(midflame_ws, 1.51)) / (ros / 60)
|
|
642
|
+
if units == 'min':
|
|
643
|
+
res_time = res_time / 60
|
|
644
|
+
|
|
645
|
+
# Ensure res_time >= 0
|
|
646
|
+
res_time[res_time < 0] = 0
|
|
647
|
+
|
|
648
|
+
# Return flame residence time
|
|
649
|
+
if return_array:
|
|
650
|
+
return res_time.filled(nan)
|
|
651
|
+
else:
|
|
652
|
+
return res_time.filled(nan)[0]
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
# FUNCTION TO CALCULATE FLAME DEPTH
|
|
656
|
+
def get_flame_depth(ros: Union[int, float, ndarray],
|
|
657
|
+
res_time: Union[int, float, ndarray]) -> Union[int, float, ndarray]:
|
|
658
|
+
"""
|
|
659
|
+
Calculate flame depth using equation from Fons et al. (1963)
|
|
660
|
+
:param ros: Fire rate of spread (m/min)
|
|
661
|
+
:param res_time: Time from initial temp rise to the time of definite drop after reaching peak temp (min).
|
|
662
|
+
Definition per Rothermel and Deeming (1980)
|
|
663
|
+
:return: flame depth (m)
|
|
664
|
+
"""
|
|
665
|
+
# ### CHECK FOR NUMPY ARRAYS IN INPUT PARAMETERS
|
|
666
|
+
if any(isinstance(data, ndarray) for data in [ros, res_time]):
|
|
667
|
+
return_array = True
|
|
668
|
+
else:
|
|
669
|
+
return_array = False
|
|
670
|
+
|
|
671
|
+
# ### VERIFY ALL INPUTS AND CONVERT TO MASKED NUMPY ARRAYS
|
|
672
|
+
# Verify ros
|
|
673
|
+
if not isinstance(ros, (numbers.Real, ndarray)):
|
|
674
|
+
raise TypeError('ros must be either int, float or numpy ndarray data types')
|
|
675
|
+
elif isinstance(ros, ndarray):
|
|
676
|
+
ros = ma.array(ros, mask=isnan(ros))
|
|
677
|
+
else: # isinstance(ros, numbers.Real):
|
|
678
|
+
ros = ma.array([ros], mask=isnan([ros]))
|
|
679
|
+
|
|
680
|
+
# Verify res_time
|
|
681
|
+
if not isinstance(res_time, (numbers.Real, ndarray)):
|
|
682
|
+
raise TypeError('res_time must be either int, float or numpy ndarray data types')
|
|
683
|
+
elif isinstance(res_time, ndarray):
|
|
684
|
+
res_time = ma.array(res_time, mask=isnan(res_time))
|
|
685
|
+
else: # isinstance(res_time, numbers.Real):
|
|
686
|
+
res_time = ma.array([res_time], mask=isnan([res_time]))
|
|
687
|
+
|
|
688
|
+
# Calculate flame depth
|
|
689
|
+
fd = ros * res_time
|
|
690
|
+
|
|
691
|
+
# Ensure fd >= 0
|
|
692
|
+
fd[fd < 0] = 0
|
|
693
|
+
|
|
694
|
+
# Return flame depth
|
|
695
|
+
if return_array:
|
|
696
|
+
return fd.filled(nan)
|
|
697
|
+
else:
|
|
698
|
+
return fd.filled(nan)[0]
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
def _multiprocessing_worker(func_name: str, kwargs_dict: dict):
|
|
702
|
+
"""
|
|
703
|
+
Module-level worker for flameComponent_ArrayMultiprocessing.
|
|
704
|
+
Must be at module level (not a closure) so multiprocessing can pickle it.
|
|
705
|
+
:param func_name: name of the flame_components function to call
|
|
706
|
+
:param kwargs_dict: keyword arguments to pass to that function
|
|
707
|
+
"""
|
|
708
|
+
func = globals().get(func_name)
|
|
709
|
+
return func(**kwargs_dict)
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
def _gen_blocks(array, block_size, stride):
|
|
713
|
+
"""
|
|
714
|
+
Function to generate blocks
|
|
715
|
+
:param array: The array to process
|
|
716
|
+
:param block_size: The size of each block
|
|
717
|
+
:param stride:
|
|
718
|
+
:return:
|
|
719
|
+
"""
|
|
720
|
+
num_blocks = (array.shape[0] - block_size) // stride + 1
|
|
721
|
+
blocks = [array[i * stride:i * stride + block_size] for i in range(num_blocks)]
|
|
722
|
+
positions = [(i * stride, (i * stride + block_size)) for i in range(num_blocks)]
|
|
723
|
+
return blocks, positions
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
def _estimate_optimal_block_size(array_shape: tuple,
|
|
727
|
+
num_processors: int) -> int:
|
|
728
|
+
"""
|
|
729
|
+
Function to estimate optimal block size
|
|
730
|
+
:param array_shape: Shape of the array being processed
|
|
731
|
+
:param num_processors: Number of processors being used for multiprocessing
|
|
732
|
+
:return: Estimated block size
|
|
733
|
+
"""
|
|
734
|
+
# Estimate block size based on array shape and number of processors being used
|
|
735
|
+
return array_shape[0] // num_processors
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
def flame_component_array_multiprocessing(flame_function: str,
|
|
739
|
+
num_processors: int = 2,
|
|
740
|
+
block_size: int = None,
|
|
741
|
+
**kwargs) -> list:
|
|
742
|
+
"""
|
|
743
|
+
Function breaks input arrays into blocks and processes each block with a different worker/processor.
|
|
744
|
+
Uses the function requested in the "flame_function" parameter.
|
|
745
|
+
|
|
746
|
+
**flame_function options**
|
|
747
|
+
"midflame_ws", "flame_length", "flame_height",
|
|
748
|
+
"flame_tilt", "flame_residence" (→ get_flame_residence_time), "flame_depth"
|
|
749
|
+
|
|
750
|
+
:param flame_function: The flame components function to implement.
|
|
751
|
+
:param num_processors: Number of cores for multiprocessing
|
|
752
|
+
:param block_size: Size of blocks (# raster cells) for multiprocessing.
|
|
753
|
+
If block_size is None, an optimal block size will be estimated automatically.
|
|
754
|
+
:param kwargs: A dictionary of inputs for the requested flame_components function.
|
|
755
|
+
The dictionary keys must match the required input parameters for the requested function.
|
|
756
|
+
Refer to the function docstring for parameter requirements.
|
|
757
|
+
:return: List of per-block output arrays, one per worker, in block order.
|
|
758
|
+
NOTE: NOT concatenated into a single array — callers must call
|
|
759
|
+
``numpy.concatenate()`` on the result themselves if a single array is needed.
|
|
760
|
+
"""
|
|
761
|
+
flame_func_dict = {
|
|
762
|
+
'midflame_ws': 'get_mid_flame_ws',
|
|
763
|
+
'flame_length': 'get_flame_length',
|
|
764
|
+
'flame_height': 'get_flame_height',
|
|
765
|
+
'flame_tilt': 'get_flame_tilt',
|
|
766
|
+
'flame_residence': 'get_flame_residence_time',
|
|
767
|
+
'flame_depth': 'get_flame_depth'
|
|
768
|
+
}
|
|
769
|
+
# Get the function object from the global scope
|
|
770
|
+
function_to_run = globals().get(flame_func_dict.get(flame_function))
|
|
771
|
+
|
|
772
|
+
# Verify the function request
|
|
773
|
+
if function_to_run is None:
|
|
774
|
+
raise ValueError(f'Function for {flame_function} does not exist.'
|
|
775
|
+
f'The options are: {list(flame_func_dict.keys())}')
|
|
776
|
+
|
|
777
|
+
# Extract array datasets from kwargs
|
|
778
|
+
array_kwargs = {key: val for key, val in kwargs.items() if isinstance(val, ndarray)}
|
|
779
|
+
array_list = list(array_kwargs.values())
|
|
780
|
+
|
|
781
|
+
# Verify there is at least one input array
|
|
782
|
+
if len(array_list) == 0:
|
|
783
|
+
raise ValueError('Unable to use the multiprocessing function. There are no arrays in the kwargs.')
|
|
784
|
+
|
|
785
|
+
# If more than one array, verify they are all the same shape
|
|
786
|
+
if len(array_list) > 1:
|
|
787
|
+
shapes = {arr.shape for arr in array_list}
|
|
788
|
+
if len(shapes) > 1:
|
|
789
|
+
raise ValueError(f'All arrays must have the same dimensions. '
|
|
790
|
+
f'The following range of dimensions exists: {shapes}')
|
|
791
|
+
|
|
792
|
+
# Verify num_processors is greater than 1
|
|
793
|
+
if num_processors < 2:
|
|
794
|
+
num_processors = 2
|
|
795
|
+
warnings.warn('Multiprocessing requires at least two cores.\n'
|
|
796
|
+
'Defaulting num_processors to 2 for this run',
|
|
797
|
+
UserWarning,
|
|
798
|
+
stacklevel=2)
|
|
799
|
+
|
|
800
|
+
# Verify block size
|
|
801
|
+
if block_size is None:
|
|
802
|
+
block_size = _estimate_optimal_block_size(array_shape=array_list[0].shape,
|
|
803
|
+
num_processors=num_processors)
|
|
804
|
+
|
|
805
|
+
# Split input arrays into blocks and track their positions
|
|
806
|
+
array_blocks = []
|
|
807
|
+
block_positions = None # Will hold the block positions from the first array
|
|
808
|
+
|
|
809
|
+
for array in array_list:
|
|
810
|
+
blocks, positions = _gen_blocks(array=array, block_size=block_size, stride=block_size)
|
|
811
|
+
array_blocks.append(blocks)
|
|
812
|
+
if block_positions is None:
|
|
813
|
+
block_positions = positions
|
|
814
|
+
|
|
815
|
+
# Generate final input_block list for multiprocessing
|
|
816
|
+
input_blocks = []
|
|
817
|
+
num_blocks = len(array_blocks[0]) # Number of blocks should be the same for all arrays
|
|
818
|
+
|
|
819
|
+
for idx in range(num_blocks):
|
|
820
|
+
block_set = [array_blocks[i][idx] for i in range(len(array_blocks))]
|
|
821
|
+
row = {key: None for key in kwargs.keys()}
|
|
822
|
+
|
|
823
|
+
# Assign blocks to the correct indices
|
|
824
|
+
for i, block in zip(array_kwargs.keys(), block_set):
|
|
825
|
+
row[i] = block
|
|
826
|
+
|
|
827
|
+
# Assign non-array inputs
|
|
828
|
+
for key, value in kwargs.items():
|
|
829
|
+
if key not in array_kwargs:
|
|
830
|
+
row[key] = value
|
|
831
|
+
|
|
832
|
+
input_blocks.append((row, block_positions[idx])) # Attach the position to each block
|
|
833
|
+
|
|
834
|
+
# Run the multiprocessing with starmap_async
|
|
835
|
+
# Uses module-level _multiprocessing_worker so it can be pickled by multiprocessing.Pool
|
|
836
|
+
fn_name = flame_func_dict[flame_function]
|
|
837
|
+
with mp.Pool(processes=num_processors) as pool:
|
|
838
|
+
async_result = pool.starmap_async(
|
|
839
|
+
_multiprocessing_worker,
|
|
840
|
+
[(fn_name, block[0]) for block in input_blocks]
|
|
841
|
+
)
|
|
842
|
+
|
|
843
|
+
# Retrieve the results asynchronously
|
|
844
|
+
results = async_result.get()
|
|
845
|
+
|
|
846
|
+
return results
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: flame-components
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Compute flame characteristics (length, height, tilt, residence time, depth, and mid-flame wind speed) for surface and crown fires
|
|
5
|
+
Project-URL: Homepage, https://github.com/gagreene/flame_components
|
|
6
|
+
Project-URL: Source, https://github.com/gagreene/flame_components
|
|
7
|
+
Project-URL: Issue Tracker, https://github.com/gagreene/flame_components/issues
|
|
8
|
+
Project-URL: Release Notes, https://github.com/gagreene/flame_components/releases
|
|
9
|
+
Project-URL: Documentation, https://github.com/gagreene/flame_components#readme
|
|
10
|
+
Author: Gregory A. Greene
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: fire behavior,flame,pyrology,wildfire
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Requires-Dist: numpy>=1.23.2
|
|
26
|
+
Provides-Extra: test
|
|
27
|
+
Requires-Dist: pytest>=7.0; extra == 'test'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# Flame Components
|
|
32
|
+
|
|
33
|
+
This repository provides several functions for calculating various flame characteristics such as mid-flame wind speed, flame length, flame height, flame tilt, flame residence time, and flame depth. It also includes utility functions for multiprocessing these calculations across blocks of data, which can be useful for high-performance fire modeling.
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
|
|
37
|
+
- **Mid-Flame Wind Speed Calculation** (`get_mid_flame_ws`): Calculates mid-flame wind speed based on parameters such as wind speed, canopy cover, and canopy height.
|
|
38
|
+
- **Flame Length Estimation** (`get_flame_length`): Estimates flame length using different published models.
|
|
39
|
+
- **Flame Height Calculation** (`get_flame_height`): Calculates flame height based on flame length and model-specific parameters.
|
|
40
|
+
- **Flame Tilt Angle Calculation** (`get_flame_tilt`): Calculates the angle of flame tilt relative to vertical.
|
|
41
|
+
- **Flame Residence Time** (`get_flame_residence_time`): Computes flame residence time based on rate of spread, fuel consumption, and wind speed.
|
|
42
|
+
- **Flame Depth Calculation** (`get_flame_depth`): Calculates flame depth using flame residence time and rate of spread.
|
|
43
|
+
- **Array Multiprocessing** (`flame_component_array_multiprocessing`): Enables multiprocessing of flame component calculations across blocks of data, making large-scale processing efficient.
|
|
44
|
+
|
|
45
|
+
## Requirements
|
|
46
|
+
|
|
47
|
+
- Python 3.11+
|
|
48
|
+
- **Libraries**: `numpy`
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install flame-components
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Distribution name vs. import name:** the package is published to PyPI as
|
|
57
|
+
`flame-components` (hyphen, used with `pip install`), but imported in Python as
|
|
58
|
+
`flame_components` (underscore, a valid identifier):
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
import flame_components
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Development
|
|
65
|
+
|
|
66
|
+
This project uses [uv](https://docs.astral.sh/uv/) for dependency management and
|
|
67
|
+
packaging.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
uv sync # create .venv and install runtime + dev dependencies
|
|
71
|
+
uv run pytest tests/ -v # run the test suite
|
|
72
|
+
uv build # build the wheel and sdist into dist/
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Usage
|
|
76
|
+
|
|
77
|
+
### Key Functions
|
|
78
|
+
|
|
79
|
+
- **`get_mid_flame_ws`**: Calculates mid-flame wind speed.
|
|
80
|
+
- **`get_flame_length`**: Estimates flame length based on specified models.
|
|
81
|
+
- **`get_flame_height`**: Calculates flame height for a given flame length.
|
|
82
|
+
- **`get_flame_tilt`**: Computes flame tilt angle using various models.
|
|
83
|
+
- **`get_flame_residence_time`**: Estimates flame residence time for a given rate of spread.
|
|
84
|
+
- **`get_flame_depth`**: Computes flame depth from flame residence time and rate of spread.
|
|
85
|
+
|
|
86
|
+
### Example
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from flame_components import get_mid_flame_ws, get_flame_length
|
|
90
|
+
|
|
91
|
+
# Example calculation for mid-flame wind speed
|
|
92
|
+
mid_flame_ws = get_mid_flame_ws(
|
|
93
|
+
wind_speed=15,
|
|
94
|
+
canopy_cover=50,
|
|
95
|
+
canopy_ht=10,
|
|
96
|
+
canopy_baseht=2,
|
|
97
|
+
units='SI'
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# Example calculation for flame length
|
|
101
|
+
flame_length = get_flame_length(
|
|
102
|
+
model='Byram_HEAD',
|
|
103
|
+
fire_intensity=500
|
|
104
|
+
)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Array Multiprocessing Example
|
|
108
|
+
|
|
109
|
+
To perform calculations across blocks of data using multiple processors:
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
import numpy as np
|
|
113
|
+
from flame_components import flame_component_array_multiprocessing
|
|
114
|
+
|
|
115
|
+
wind_speed = np.array([10.0, 15.0, 20.0, 25.0, 30.0, 35.0])
|
|
116
|
+
canopy_cover = np.array([40, 50, 60, 40, 50, 60])
|
|
117
|
+
canopy_ht = np.array([8.0, 10.0, 12.0, 8.0, 10.0, 12.0])
|
|
118
|
+
canopy_baseht = np.array([2.0, 2.0, 3.0, 2.0, 2.0, 3.0])
|
|
119
|
+
|
|
120
|
+
# Returns a list of per-block result arrays, one per worker, in block order --
|
|
121
|
+
# concatenate them yourself if you need a single array back.
|
|
122
|
+
blocks = flame_component_array_multiprocessing(
|
|
123
|
+
flame_function='midflame_ws',
|
|
124
|
+
num_processors=2,
|
|
125
|
+
wind_speed=wind_speed,
|
|
126
|
+
canopy_cover=canopy_cover,
|
|
127
|
+
canopy_ht=canopy_ht,
|
|
128
|
+
canopy_baseht=canopy_baseht,
|
|
129
|
+
units='SI'
|
|
130
|
+
)
|
|
131
|
+
mid_flame_ws = np.concatenate(blocks)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`kwargs` passed to `flame_component_array_multiprocessing` must match the parameter names
|
|
135
|
+
of the target function (here, `get_mid_flame_ws`'s `wind_speed`/`canopy_cover`/`canopy_ht`/
|
|
136
|
+
`canopy_baseht`/`units`). See the API Reference below for `flame_function`'s valid values
|
|
137
|
+
and each target function's required parameters.
|
|
138
|
+
|
|
139
|
+
## API Reference
|
|
140
|
+
|
|
141
|
+
All functions accept `int`/`float` scalars or `numpy.ndarray` (NaN cells are masked and
|
|
142
|
+
propagate as NaN in the output). Passing at least one array returns an array; all-scalar
|
|
143
|
+
input returns a Python `float`. Every function raises `TypeError` for a wrong input type
|
|
144
|
+
and `ValueError` for an invalid string option (e.g. an unknown `model` or `units`) or a
|
|
145
|
+
missing model-specific required parameter.
|
|
146
|
+
|
|
147
|
+
#### `get_mid_flame_ws(wind_speed, canopy_cover, canopy_ht, canopy_baseht, units='SI')`
|
|
148
|
+
Mid-flame wind speed (m/s) under a canopy — Albini & Baughman (1979).
|
|
149
|
+
- `units`: `'SI'` (10-m wind in km/h, heights in m) or `'IMP'` (20-ft wind in mi/h, heights in ft).
|
|
150
|
+
- `canopy_ht == 0` is substituted with a 0.5 m equivalent and raises `UserWarning`.
|
|
151
|
+
- Output is always m/s regardless of input units.
|
|
152
|
+
|
|
153
|
+
#### `get_flame_length(model, fire_intensity, flame_depth=None, params_only=False)`
|
|
154
|
+
Flame length (m) from head fire intensity (kW/m), or the raw model coefficients if
|
|
155
|
+
`params_only=True`. `model` is one of 29 published models (see `model_dict` in
|
|
156
|
+
`src/flame_components/core.py` for the full list and per-model citation); `flame_depth`
|
|
157
|
+
is required only for `model='Finney_HEAD'`.
|
|
158
|
+
|
|
159
|
+
#### `get_flame_height(model, flame_length, fire_type=None, fire_intensity=None, midflame_ws=None, flame_tilt=None, slope_angle=None, slope_units=None)`
|
|
160
|
+
Flame height (m). `model='Nelson'` requires `fire_type` (`1`/`'surface'`, `2`/`'passive
|
|
161
|
+
crown'`, `3`/`'active crown'`), `fire_intensity`, and `midflame_ws`. `model='Finney'`
|
|
162
|
+
requires `flame_tilt`, `slope_angle`, and `slope_units` (`'degrees'` or `'percent'`).
|
|
163
|
+
|
|
164
|
+
#### `get_flame_tilt(model, flame_length=None, flame_height=None, slope_angle=None, slope_units=None, wind_speed=None, wind_speed_units=None, canopy_ht=None)`
|
|
165
|
+
Flame tilt angle from vertical (degrees). `model='Standard'` (flat ground) requires
|
|
166
|
+
`flame_length`/`flame_height`. `model='Finney'` (sloped ground) additionally requires
|
|
167
|
+
`slope_angle`/`slope_units`. `model='Butler'` (crown fires only) requires `wind_speed`,
|
|
168
|
+
`wind_speed_units` (`'kph'`/`'mps'`/`'mph'`), and `canopy_ht` (must be `> 0`, or raises
|
|
169
|
+
`ValueError`).
|
|
170
|
+
|
|
171
|
+
#### `get_flame_residence_time(ros, fuel_consumption, midflame_ws, units)`
|
|
172
|
+
Flame residence time — Nelson & Adkins (1988). `ros` must always be in m/min; `units`
|
|
173
|
+
(`'sec'` or `'min'`) controls the output unit only, not the expected input unit.
|
|
174
|
+
|
|
175
|
+
#### `get_flame_depth(ros, res_time)`
|
|
176
|
+
Flame depth (m) — Fons et al. (1963). `ros` in m/min, `res_time` in minutes.
|
|
177
|
+
|
|
178
|
+
#### `flame_component_array_multiprocessing(flame_function, num_processors=2, block_size=None, **kwargs)`
|
|
179
|
+
Splits array inputs into blocks and runs one of the six functions above across multiple
|
|
180
|
+
processes. `flame_function` is one of `'midflame_ws'`, `'flame_length'`, `'flame_height'`,
|
|
181
|
+
`'flame_tilt'`, `'flame_residence'`, `'flame_depth'`. `kwargs` must match the target
|
|
182
|
+
function's parameter names, with at least one `numpy.ndarray` value (all arrays must share
|
|
183
|
+
the same shape). `num_processors < 2` is coerced to `2` with a `UserWarning`. Returns a
|
|
184
|
+
**list of per-block result arrays, not a single concatenated array** — call
|
|
185
|
+
`numpy.concatenate()` on the result yourself if you need one.
|
|
186
|
+
|
|
187
|
+
See `docs/CODEBASE.md` for internal architecture and implementation-level gotchas, and
|
|
188
|
+
`docs/TEST_SUITE_DESCRIPTION.md` for the full test-suite catalog.
|
|
189
|
+
|
|
190
|
+
## Scientific References
|
|
191
|
+
|
|
192
|
+
The equations implemented here are drawn from the published fire-behavior literature.
|
|
193
|
+
Citations below are as referenced in each function's docstring in
|
|
194
|
+
`src/flame_components/core.py`; consult the original publications for full bibliographic
|
|
195
|
+
detail (journal, volume, DOI) before citing this package's underlying science formally.
|
|
196
|
+
|
|
197
|
+
- **`get_mid_flame_ws`**: Albini, F.A. & Baughman, R.G. (1979).
|
|
198
|
+
- **`get_flame_length`**: 29 models catalogued in Finney, M.A. & Grumstrup, T.P. (2023);
|
|
199
|
+
each model's original source (Byram, Fons, Nelson, Anderson, Fernandes, Butler, and
|
|
200
|
+
others) is cited inline next to its coefficients in `core.py`'s `model_dict`.
|
|
201
|
+
- **`get_flame_height`**: Nelson, R.M. & Adkins, C.W. (1986) (`model='Nelson'`), or
|
|
202
|
+
Finney, M.A. & Martin, S.W. (1992) (`model='Finney'`).
|
|
203
|
+
- **`get_flame_tilt`**: Standard geometry (`model='Standard'`), Finney, M.A. & Martin, S.W.
|
|
204
|
+
(1992) (`model='Finney'`), Butler, B.W. et al. (2004) (`model='Butler'`).
|
|
205
|
+
- **`get_flame_residence_time`**: Nelson, R.M. & Adkins, C.W. (1988).
|
|
206
|
+
- **`get_flame_depth`**: Fons, W.L. et al. (1963).
|
|
207
|
+
|
|
208
|
+
If you use this package in published research, please cite both the package itself (see
|
|
209
|
+
`CITATION.cff`) and the original publication(s) for the specific model(s) you used.
|
|
210
|
+
|
|
211
|
+
## Support and Issue Reporting
|
|
212
|
+
|
|
213
|
+
Please open a [GitHub issue](https://github.com/gagreene/flame_components/issues) for
|
|
214
|
+
bugs, questions, or feature requests. To reproduce a numerical discrepancy quickly,
|
|
215
|
+
please include:
|
|
216
|
+
|
|
217
|
+
- the installed `flame-components` version (`flame_components.__version__`) and Python/
|
|
218
|
+
numpy versions;
|
|
219
|
+
- the exact function call, including whether inputs were scalars or arrays;
|
|
220
|
+
- the expected result and the actual result you got.
|
|
221
|
+
|
|
222
|
+
## Contributing
|
|
223
|
+
|
|
224
|
+
Contributions are welcome. If you have ideas for new features or improvements, please submit a pull request or open an issue.
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
This project is licensed under the MIT License. See the
|
|
229
|
+
[LICENSE](https://github.com/gagreene/flame_components/blob/master/LICENSE) file for details.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
flame_components/__init__.py,sha256=Yf_oVWjRcGCEnjgGOg_4d_QcRbZjVKfVyBd6uv_8mcU,872
|
|
2
|
+
flame_components/core.py,sha256=TP-K3WclQ7f0iFlrrRnYDO-DHEgjfmI78an35TR6QgQ,41325
|
|
3
|
+
flame_components-0.1.1.dist-info/METADATA,sha256=xIRFjPbzg1Bl-UKjJWMNK3fnYZ6yEchPPq70bSVRfBM,10810
|
|
4
|
+
flame_components-0.1.1.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
5
|
+
flame_components-0.1.1.dist-info/licenses/LICENSE,sha256=KRiPngJ0ypglHjM7nEaH33EWokboiGWQ8T7pAq0p0kg,1071
|
|
6
|
+
flame_components-0.1.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Gregory Greene
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|