flame-components 0.1.1__tar.gz → 0.2.0__tar.gz

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.
Files changed (63) hide show
  1. {flame_components-0.1.1 → flame_components-0.2.0}/PKG-INFO +110 -61
  2. {flame_components-0.1.1 → flame_components-0.2.0}/README.md +93 -45
  3. {flame_components-0.1.1 → flame_components-0.2.0}/pyproject.toml +11 -13
  4. flame_components-0.2.0/rust/Cargo.lock +390 -0
  5. flame_components-0.2.0/rust/Cargo.toml +14 -0
  6. flame_components-0.2.0/rust/crates/flame-components/Cargo.toml +25 -0
  7. flame_components-0.2.0/rust/crates/flame-components/LICENSE +21 -0
  8. flame_components-0.2.0/rust/crates/flame-components/README.md +62 -0
  9. flame_components-0.2.0/rust/crates/flame-components/build.rs +13 -0
  10. flame_components-0.2.0/rust/crates/flame-components/src/array.rs +101 -0
  11. flame_components-0.2.0/rust/crates/flame-components/src/cell.rs +214 -0
  12. flame_components-0.2.0/rust/crates/flame-components/src/depth.rs +85 -0
  13. flame_components-0.2.0/rust/crates/flame-components/src/extended.rs +312 -0
  14. flame_components-0.2.0/rust/crates/flame-components/src/height.rs +321 -0
  15. flame_components-0.2.0/rust/crates/flame-components/src/length.rs +210 -0
  16. flame_components-0.2.0/rust/crates/flame-components/src/lib.rs +91 -0
  17. flame_components-0.2.0/rust/crates/flame-components/src/precision.rs +318 -0
  18. flame_components-0.2.0/rust/crates/flame-components/src/residence.rs +88 -0
  19. flame_components-0.2.0/rust/crates/flame-components/src/tilt.rs +395 -0
  20. flame_components-0.2.0/rust/crates/flame-components/src/wide.c +152 -0
  21. flame_components-0.2.0/rust/crates/flame-components/src/wide.rs +154 -0
  22. flame_components-0.2.0/rust/crates/flame-components/src/wind.rs +327 -0
  23. flame_components-0.2.0/rust/crates/flame-components/tests/depth_residence.rs +114 -0
  24. flame_components-0.2.0/rust/crates/flame-components/tests/extended.rs +126 -0
  25. flame_components-0.2.0/rust/crates/flame-components/tests/precision.rs +125 -0
  26. flame_components-0.2.0/rust/crates/flame-components/tests/wide.rs +94 -0
  27. flame_components-0.2.0/rust/crates/flame-components-py/Cargo.toml +18 -0
  28. flame_components-0.2.0/rust/crates/flame-components-py/src/errors.rs +111 -0
  29. flame_components-0.2.0/rust/crates/flame-components-py/src/extended.rs +293 -0
  30. flame_components-0.2.0/rust/crates/flame-components-py/src/lib.rs +488 -0
  31. {flame_components-0.1.1 → flame_components-0.2.0}/src/flame_components/__init__.py +11 -12
  32. flame_components-0.2.0/src/flame_components/_backend.py +41 -0
  33. flame_components-0.2.0/src/flame_components/_blocks.py +59 -0
  34. flame_components-0.2.0/src/flame_components/_equations.py +193 -0
  35. flame_components-0.2.0/src/flame_components/_native_bridge.py +183 -0
  36. flame_components-0.2.0/src/flame_components/_precision.py +237 -0
  37. flame_components-0.2.0/src/flame_components/_utils.py +95 -0
  38. flame_components-0.2.0/src/flame_components/core.py +351 -0
  39. flame_components-0.1.1/.github/workflows/release.yml +0 -118
  40. flame_components-0.1.1/.github/workflows/tests.yml +0 -101
  41. flame_components-0.1.1/.gitignore +0 -70
  42. flame_components-0.1.1/CITATION.cff +0 -12
  43. flame_components-0.1.1/docs/CODEBASE.md +0 -159
  44. flame_components-0.1.1/docs/RELEASING.md +0 -73
  45. flame_components-0.1.1/docs/TEST_SUITE_DESCRIPTION.md +0 -257
  46. flame_components-0.1.1/scripts/smoke_test.py +0 -79
  47. flame_components-0.1.1/src/flame_components/core.py +0 -846
  48. flame_components-0.1.1/tests/__init__.py +0 -0
  49. flame_components-0.1.1/tests/integration/__init__.py +0 -0
  50. flame_components-0.1.1/tests/integration/test_flame_pipeline.py +0 -145
  51. flame_components-0.1.1/tests/regression/__init__.py +0 -0
  52. flame_components-0.1.1/tests/regression/test_gotchas.py +0 -107
  53. flame_components-0.1.1/tests/unit/__init__.py +0 -0
  54. flame_components-0.1.1/tests/unit/test_flame_component_array_multiprocessing.py +0 -88
  55. flame_components-0.1.1/tests/unit/test_get_flame_depth.py +0 -62
  56. flame_components-0.1.1/tests/unit/test_get_flame_height.py +0 -193
  57. flame_components-0.1.1/tests/unit/test_get_flame_length.py +0 -101
  58. flame_components-0.1.1/tests/unit/test_get_flame_residence_time.py +0 -89
  59. flame_components-0.1.1/tests/unit/test_get_flame_tilt.py +0 -160
  60. flame_components-0.1.1/tests/unit/test_get_mid_flame_ws.py +0 -128
  61. flame_components-0.1.1/tests/unit/test_public_api.py +0 -19
  62. flame_components-0.1.1/uv.lock +0 -232
  63. {flame_components-0.1.1 → flame_components-0.2.0}/LICENSE +0 -0
@@ -1,31 +1,31 @@
1
- Metadata-Version: 2.5
1
+ Metadata-Version: 2.4
2
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
3
+ Version: 0.2.0
14
4
  Classifier: Development Status :: 4 - Beta
15
5
  Classifier: Intended Audience :: Science/Research
16
- Classifier: Operating System :: OS Independent
17
6
  Classifier: Programming Language :: Python :: 3
18
7
  Classifier: Programming Language :: Python :: 3 :: Only
19
8
  Classifier: Programming Language :: Python :: 3.11
20
9
  Classifier: Programming Language :: Python :: 3.12
21
10
  Classifier: Programming Language :: Python :: 3.13
22
11
  Classifier: Programming Language :: Python :: 3.14
12
+ Classifier: Operating System :: OS Independent
23
13
  Classifier: Topic :: Scientific/Engineering
24
- Requires-Python: >=3.11
25
14
  Requires-Dist: numpy>=1.23.2
15
+ Requires-Dist: pytest>=7.0 ; extra == 'test'
26
16
  Provides-Extra: test
27
- Requires-Dist: pytest>=7.0; extra == 'test'
28
- Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Summary: Compute flame characteristics (length, height, tilt, residence time, depth, and mid-flame wind speed) for surface and crown fires
19
+ Keywords: wildfire,fire behavior,flame,pyrology
20
+ Author: Gregory A. Greene
21
+ License-Expression: MIT
22
+ Requires-Python: >=3.11
23
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
24
+ Project-URL: Documentation, https://github.com/gagreene/flame_components/tree/v0.2.0#readme
25
+ Project-URL: Homepage, https://github.com/gagreene/flame_components
26
+ Project-URL: Issue Tracker, https://github.com/gagreene/flame_components/issues
27
+ Project-URL: Release Notes, https://github.com/gagreene/flame_components/releases/tag/v0.2.0
28
+ Project-URL: Source, https://github.com/gagreene/flame_components/tree/v0.2.0
29
29
 
30
30
 
31
31
  # Flame Components
@@ -44,8 +44,8 @@ This repository provides several functions for calculating various flame charact
44
44
 
45
45
  ## Requirements
46
46
 
47
- - Python 3.11+
48
- - **Libraries**: `numpy`
47
+ - Python 3.11 or later
48
+ - NumPy 1.23.2 or later
49
49
 
50
50
  ## Installation
51
51
 
@@ -53,6 +53,10 @@ This repository provides several functions for calculating various flame charact
53
53
  pip install flame-components
54
54
  ```
55
55
 
56
+ Wheels cover CPython 3.11?3.14 on Linux x86-64 and ARM64 (glibc 2.17 or later),
57
+ Windows x86-64, and macOS Intel and Apple Silicon. Building from the source distribution requires Rust
58
+ 1.78 or later and a C compiler.
59
+
56
60
  **Distribution name vs. import name:** the package is published to PyPI as
57
61
  `flame-components` (hyphen, used with `pip install`), but imported in Python as
58
62
  `flame_components` (underscore, a valid identifier):
@@ -64,14 +68,37 @@ import flame_components
64
68
  ## Development
65
69
 
66
70
  This project uses [uv](https://docs.astral.sh/uv/) for dependency management and
67
- packaging.
71
+ packaging. Development installs build the native extension and require Rust
72
+ and a C compiler.
68
73
 
69
74
  ```bash
70
75
  uv sync # create .venv and install runtime + dev dependencies
71
- uv run pytest tests/ -v # run the test suite
76
+ uv run pytest tests/ -v --calculation-backend=python
77
+ uv run pytest tests/ -v --calculation-backend=rust
72
78
  uv build # build the wheel and sdist into dist/
73
79
  ```
74
80
 
81
+ ## Rust library
82
+
83
+ The [standalone Rust crate](https://github.com/gagreene/flame_components/blob/v0.2.0/rust/crates/flame-components/README.md) provides
84
+ scalar and array APIs for all six calculations. Rust 1.78 or later can build
85
+ and test it without a Python environment.
86
+
87
+ ```text
88
+ cargo test --locked --manifest-path rust/Cargo.toml
89
+ ```
90
+
91
+ ## Standalone command line
92
+
93
+ Build the executable with `cargo build --release --locked --manifest-path
94
+ rust/Cargo.toml -p flame-components-cli`. For example,
95
+ `flame-components flame-depth --ros 3 --res-time 2` prints `6`.
96
+ The CLI accepts scalar flags and scalar JSON from a file or standard input.
97
+ The [release downloads](https://github.com/gagreene/flame_components/releases/tag/v0.2.0)
98
+ include standalone executables for Linux x86-64 and ARM64, Windows x86-64,
99
+ and macOS Intel and Apple Silicon.
100
+ [CLI reference](https://github.com/gagreene/flame_components/blob/v0.2.0/rust/crates/flame-components-cli/README.md)
101
+
75
102
  ## Usage
76
103
 
77
104
  ### Key Functions
@@ -112,23 +139,24 @@ To perform calculations across blocks of data using multiple processors:
112
139
  import numpy as np
113
140
  from flame_components import flame_component_array_multiprocessing
114
141
 
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)
142
+ if __name__ == '__main__':
143
+ wind_speed = np.array([10.0, 15.0, 20.0, 25.0, 30.0, 35.0])
144
+ canopy_cover = np.array([40, 50, 60, 40, 50, 60])
145
+ canopy_ht = np.array([8.0, 10.0, 12.0, 8.0, 10.0, 12.0])
146
+ canopy_baseht = np.array([2.0, 2.0, 3.0, 2.0, 2.0, 3.0])
147
+
148
+ # Six rows form three blocks of two rows, processed by up to two workers.
149
+ blocks = flame_component_array_multiprocessing(
150
+ flame_function='midflame_ws',
151
+ num_processors=2,
152
+ block_size=2,
153
+ wind_speed=wind_speed,
154
+ canopy_cover=canopy_cover,
155
+ canopy_ht=canopy_ht,
156
+ canopy_baseht=canopy_baseht,
157
+ units='SI'
158
+ )
159
+ mid_flame_ws = np.concatenate(blocks)
132
160
  ```
133
161
 
134
162
  `kwargs` passed to `flame_component_array_multiprocessing` must match the parameter names
@@ -138,54 +166,73 @@ and each target function's required parameters.
138
166
 
139
167
  ## API Reference
140
168
 
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')`
169
+ The calculation functions accept real scalars or real numeric NumPy arrays. Input NaNs
170
+ and masked values propagate as NaN in the output. Passing at least one array returns
171
+ an array. All-scalar inputs produce a NumPy scalar. Invalid types raise `TypeError`.
172
+ Invalid options such as an unknown model and missing model-specific parameters raise
173
+ `ValueError`.
174
+
175
+ Every calculation and the multiprocessing helper accepts a keyword-only
176
+ `backend` argument. The default `backend="auto"` selects Rust when the compiled
177
+ extension is installed and uses NumPy when it is absent. An error loading an
178
+ installed extension propagates to the caller. Use `backend="python"` or
179
+ `backend="rust"` to select an engine explicitly. Rust supports extended NumPy
180
+ `longdouble` inputs when the extension and NumPy use the same native format.
181
+ On Intel macOS, both backends compute powers in binary64 and keep the
182
+ `longdouble` result dtype.
183
+
184
+ Automatic selection also uses NumPy when `numpy.seterr` or `numpy.errstate`
185
+ requests an exception, callback, log, or printed error. The NumPy backend
186
+ suppresses incidental arithmetic warnings. The package reports
187
+ `UserWarning` for conditions such as zero canopy height and a processor count
188
+ below two.
189
+
190
+ #### `get_mid_flame_ws(wind_speed, canopy_cover, canopy_ht, canopy_baseht, units='SI', *, backend="auto")`
148
191
  Mid-flame wind speed (m/s) under a canopy — Albini & Baughman (1979).
149
192
  - `units`: `'SI'` (10-m wind in km/h, heights in m) or `'IMP'` (20-ft wind in mi/h, heights in ft).
150
193
  - `canopy_ht == 0` is substituted with a 0.5 m equivalent and raises `UserWarning`.
151
194
  - Output is always m/s regardless of input units.
152
195
 
153
- #### `get_flame_length(model, fire_intensity, flame_depth=None, params_only=False)`
196
+ #### `get_flame_length(model, fire_intensity, flame_depth=None, params_only=False, *, backend="auto")`
154
197
  Flame length (m) from head fire intensity (kW/m), or the raw model coefficients if
155
198
  `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'`.
199
+ `src/flame_components/_equations.py` for the full list and per-model citation); `flame_depth`
200
+ is required only for `model='Finney_HEAD'`. The legacy name `'Barbon_iNOWIND'` selects
201
+ the same model as `'Barbon_NOWIND'`.
158
202
 
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)`
203
+ #### `get_flame_height(model, flame_length, fire_type=None, fire_intensity=None, midflame_ws=None, flame_tilt=None, slope_angle=None, slope_units=None, *, backend="auto")`
160
204
  Flame height (m). `model='Nelson'` requires `fire_type` (`1`/`'surface'`, `2`/`'passive
161
205
  crown'`, `3`/`'active crown'`), `fire_intensity`, and `midflame_ws`. `model='Finney'`
162
206
  requires `flame_tilt`, `slope_angle`, and `slope_units` (`'degrees'` or `'percent'`).
163
207
 
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)`
208
+ #### `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, *, backend="auto")`
165
209
  Flame tilt angle from vertical (degrees). `model='Standard'` (flat ground) requires
166
210
  `flame_length`/`flame_height`. `model='Finney'` (sloped ground) additionally requires
167
211
  `slope_angle`/`slope_units`. `model='Butler'` (crown fires only) requires `wind_speed`,
168
212
  `wind_speed_units` (`'kph'`/`'mps'`/`'mph'`), and `canopy_ht` (must be `> 0`, or raises
169
213
  `ValueError`).
170
214
 
171
- #### `get_flame_residence_time(ros, fuel_consumption, midflame_ws, units)`
215
+ #### `get_flame_residence_time(ros, fuel_consumption, midflame_ws, units, *, backend="auto")`
172
216
  Flame residence time — Nelson & Adkins (1988). `ros` must always be in m/min; `units`
173
217
  (`'sec'` or `'min'`) controls the output unit only, not the expected input unit.
174
218
 
175
- #### `get_flame_depth(ros, res_time)`
176
- Flame depth (m) — Fons et al. (1963). `ros` in m/min, `res_time` in minutes.
219
+ #### `get_flame_depth(ros, res_time, *, backend="auto")`
220
+ Flame depth (m) — Fons et al. (1963). `ros` in m/min, `res_time` in minutes. The
221
+ multiplication follows NumPy dtype rules. Fixed-width integer products can wrap before
222
+ negative results are clamped to zero. Use a dtype wide enough for the expected product.
177
223
 
178
- #### `flame_component_array_multiprocessing(flame_function, num_processors=2, block_size=None, **kwargs)`
224
+ #### `flame_component_array_multiprocessing(flame_function, num_processors=2, block_size=None, *, backend="auto", **kwargs)`
179
225
  Splits array inputs into blocks and runs one of the six functions above across multiple
180
226
  processes. `flame_function` is one of `'midflame_ws'`, `'flame_length'`, `'flame_height'`,
181
227
  `'flame_tilt'`, `'flame_residence'`, `'flame_depth'`. `kwargs` must match the target
182
228
  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.
229
+ the same shape and have at least one row). `num_processors < 2` is coerced to `2` with a
230
+ `UserWarning`. The dispatcher returns one result per block in input order, including any
231
+ final partial block. Use `numpy.concatenate()` to join numeric result arrays.
232
+ `params_only=True` for flame length returns a coefficient tuple for each block.
186
233
 
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.
234
+ See the [architecture guide](https://github.com/gagreene/flame_components/blob/v0.2.0/docs/CODEBASE.md)
235
+ and the [test suite guide](https://github.com/gagreene/flame_components/blob/v0.2.0/docs/TEST_SUITE_DESCRIPTION.md).
189
236
 
190
237
  ## Scientific References
191
238
 
@@ -197,7 +244,8 @@ detail (journal, volume, DOI) before citing this package's underlying science fo
197
244
  - **`get_mid_flame_ws`**: Albini, F.A. & Baughman, R.G. (1979).
198
245
  - **`get_flame_length`**: 29 models catalogued in Finney, M.A. & Grumstrup, T.P. (2023);
199
246
  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`.
247
+ others) is cited next to its coefficients in the
248
+ [Python reference table](https://github.com/gagreene/flame_components/blob/v0.2.0/src/flame_components/_equations.py).
201
249
  - **`get_flame_height`**: Nelson, R.M. & Adkins, C.W. (1986) (`model='Nelson'`), or
202
250
  Finney, M.A. & Martin, S.W. (1992) (`model='Finney'`).
203
251
  - **`get_flame_tilt`**: Standard geometry (`model='Standard'`), Finney, M.A. & Martin, S.W.
@@ -206,7 +254,7 @@ detail (journal, volume, DOI) before citing this package's underlying science fo
206
254
  - **`get_flame_depth`**: Fons, W.L. et al. (1963).
207
255
 
208
256
  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.
257
+ [CITATION.cff](https://github.com/gagreene/flame_components/blob/v0.2.0/CITATION.cff)) and the original publication(s) for the specific model(s) you used.
210
258
 
211
259
  ## Support and Issue Reporting
212
260
 
@@ -226,4 +274,5 @@ Contributions are welcome. If you have ideas for new features or improvements, p
226
274
  ## License
227
275
 
228
276
  This project is licensed under the MIT License. See the
229
- [LICENSE](https://github.com/gagreene/flame_components/blob/master/LICENSE) file for details.
277
+ [LICENSE](https://github.com/gagreene/flame_components/blob/v0.2.0/LICENSE) file for details.
278
+
@@ -15,8 +15,8 @@ This repository provides several functions for calculating various flame charact
15
15
 
16
16
  ## Requirements
17
17
 
18
- - Python 3.11+
19
- - **Libraries**: `numpy`
18
+ - Python 3.11 or later
19
+ - NumPy 1.23.2 or later
20
20
 
21
21
  ## Installation
22
22
 
@@ -24,6 +24,10 @@ This repository provides several functions for calculating various flame charact
24
24
  pip install flame-components
25
25
  ```
26
26
 
27
+ Wheels cover CPython 3.11?3.14 on Linux x86-64 and ARM64 (glibc 2.17 or later),
28
+ Windows x86-64, and macOS Intel and Apple Silicon. Building from the source distribution requires Rust
29
+ 1.78 or later and a C compiler.
30
+
27
31
  **Distribution name vs. import name:** the package is published to PyPI as
28
32
  `flame-components` (hyphen, used with `pip install`), but imported in Python as
29
33
  `flame_components` (underscore, a valid identifier):
@@ -35,14 +39,37 @@ import flame_components
35
39
  ## Development
36
40
 
37
41
  This project uses [uv](https://docs.astral.sh/uv/) for dependency management and
38
- packaging.
42
+ packaging. Development installs build the native extension and require Rust
43
+ and a C compiler.
39
44
 
40
45
  ```bash
41
46
  uv sync # create .venv and install runtime + dev dependencies
42
- uv run pytest tests/ -v # run the test suite
47
+ uv run pytest tests/ -v --calculation-backend=python
48
+ uv run pytest tests/ -v --calculation-backend=rust
43
49
  uv build # build the wheel and sdist into dist/
44
50
  ```
45
51
 
52
+ ## Rust library
53
+
54
+ The [standalone Rust crate](https://github.com/gagreene/flame_components/blob/v0.2.0/rust/crates/flame-components/README.md) provides
55
+ scalar and array APIs for all six calculations. Rust 1.78 or later can build
56
+ and test it without a Python environment.
57
+
58
+ ```text
59
+ cargo test --locked --manifest-path rust/Cargo.toml
60
+ ```
61
+
62
+ ## Standalone command line
63
+
64
+ Build the executable with `cargo build --release --locked --manifest-path
65
+ rust/Cargo.toml -p flame-components-cli`. For example,
66
+ `flame-components flame-depth --ros 3 --res-time 2` prints `6`.
67
+ The CLI accepts scalar flags and scalar JSON from a file or standard input.
68
+ The [release downloads](https://github.com/gagreene/flame_components/releases/tag/v0.2.0)
69
+ include standalone executables for Linux x86-64 and ARM64, Windows x86-64,
70
+ and macOS Intel and Apple Silicon.
71
+ [CLI reference](https://github.com/gagreene/flame_components/blob/v0.2.0/rust/crates/flame-components-cli/README.md)
72
+
46
73
  ## Usage
47
74
 
48
75
  ### Key Functions
@@ -83,23 +110,24 @@ To perform calculations across blocks of data using multiple processors:
83
110
  import numpy as np
84
111
  from flame_components import flame_component_array_multiprocessing
85
112
 
86
- wind_speed = np.array([10.0, 15.0, 20.0, 25.0, 30.0, 35.0])
87
- canopy_cover = np.array([40, 50, 60, 40, 50, 60])
88
- canopy_ht = np.array([8.0, 10.0, 12.0, 8.0, 10.0, 12.0])
89
- canopy_baseht = np.array([2.0, 2.0, 3.0, 2.0, 2.0, 3.0])
90
-
91
- # Returns a list of per-block result arrays, one per worker, in block order --
92
- # concatenate them yourself if you need a single array back.
93
- blocks = flame_component_array_multiprocessing(
94
- flame_function='midflame_ws',
95
- num_processors=2,
96
- wind_speed=wind_speed,
97
- canopy_cover=canopy_cover,
98
- canopy_ht=canopy_ht,
99
- canopy_baseht=canopy_baseht,
100
- units='SI'
101
- )
102
- mid_flame_ws = np.concatenate(blocks)
113
+ if __name__ == '__main__':
114
+ wind_speed = np.array([10.0, 15.0, 20.0, 25.0, 30.0, 35.0])
115
+ canopy_cover = np.array([40, 50, 60, 40, 50, 60])
116
+ canopy_ht = np.array([8.0, 10.0, 12.0, 8.0, 10.0, 12.0])
117
+ canopy_baseht = np.array([2.0, 2.0, 3.0, 2.0, 2.0, 3.0])
118
+
119
+ # Six rows form three blocks of two rows, processed by up to two workers.
120
+ blocks = flame_component_array_multiprocessing(
121
+ flame_function='midflame_ws',
122
+ num_processors=2,
123
+ block_size=2,
124
+ wind_speed=wind_speed,
125
+ canopy_cover=canopy_cover,
126
+ canopy_ht=canopy_ht,
127
+ canopy_baseht=canopy_baseht,
128
+ units='SI'
129
+ )
130
+ mid_flame_ws = np.concatenate(blocks)
103
131
  ```
104
132
 
105
133
  `kwargs` passed to `flame_component_array_multiprocessing` must match the parameter names
@@ -109,54 +137,73 @@ and each target function's required parameters.
109
137
 
110
138
  ## API Reference
111
139
 
112
- All functions accept `int`/`float` scalars or `numpy.ndarray` (NaN cells are masked and
113
- propagate as NaN in the output). Passing at least one array returns an array; all-scalar
114
- input returns a Python `float`. Every function raises `TypeError` for a wrong input type
115
- and `ValueError` for an invalid string option (e.g. an unknown `model` or `units`) or a
116
- missing model-specific required parameter.
117
-
118
- #### `get_mid_flame_ws(wind_speed, canopy_cover, canopy_ht, canopy_baseht, units='SI')`
140
+ The calculation functions accept real scalars or real numeric NumPy arrays. Input NaNs
141
+ and masked values propagate as NaN in the output. Passing at least one array returns
142
+ an array. All-scalar inputs produce a NumPy scalar. Invalid types raise `TypeError`.
143
+ Invalid options such as an unknown model and missing model-specific parameters raise
144
+ `ValueError`.
145
+
146
+ Every calculation and the multiprocessing helper accepts a keyword-only
147
+ `backend` argument. The default `backend="auto"` selects Rust when the compiled
148
+ extension is installed and uses NumPy when it is absent. An error loading an
149
+ installed extension propagates to the caller. Use `backend="python"` or
150
+ `backend="rust"` to select an engine explicitly. Rust supports extended NumPy
151
+ `longdouble` inputs when the extension and NumPy use the same native format.
152
+ On Intel macOS, both backends compute powers in binary64 and keep the
153
+ `longdouble` result dtype.
154
+
155
+ Automatic selection also uses NumPy when `numpy.seterr` or `numpy.errstate`
156
+ requests an exception, callback, log, or printed error. The NumPy backend
157
+ suppresses incidental arithmetic warnings. The package reports
158
+ `UserWarning` for conditions such as zero canopy height and a processor count
159
+ below two.
160
+
161
+ #### `get_mid_flame_ws(wind_speed, canopy_cover, canopy_ht, canopy_baseht, units='SI', *, backend="auto")`
119
162
  Mid-flame wind speed (m/s) under a canopy — Albini & Baughman (1979).
120
163
  - `units`: `'SI'` (10-m wind in km/h, heights in m) or `'IMP'` (20-ft wind in mi/h, heights in ft).
121
164
  - `canopy_ht == 0` is substituted with a 0.5 m equivalent and raises `UserWarning`.
122
165
  - Output is always m/s regardless of input units.
123
166
 
124
- #### `get_flame_length(model, fire_intensity, flame_depth=None, params_only=False)`
167
+ #### `get_flame_length(model, fire_intensity, flame_depth=None, params_only=False, *, backend="auto")`
125
168
  Flame length (m) from head fire intensity (kW/m), or the raw model coefficients if
126
169
  `params_only=True`. `model` is one of 29 published models (see `model_dict` in
127
- `src/flame_components/core.py` for the full list and per-model citation); `flame_depth`
128
- is required only for `model='Finney_HEAD'`.
170
+ `src/flame_components/_equations.py` for the full list and per-model citation); `flame_depth`
171
+ is required only for `model='Finney_HEAD'`. The legacy name `'Barbon_iNOWIND'` selects
172
+ the same model as `'Barbon_NOWIND'`.
129
173
 
130
- #### `get_flame_height(model, flame_length, fire_type=None, fire_intensity=None, midflame_ws=None, flame_tilt=None, slope_angle=None, slope_units=None)`
174
+ #### `get_flame_height(model, flame_length, fire_type=None, fire_intensity=None, midflame_ws=None, flame_tilt=None, slope_angle=None, slope_units=None, *, backend="auto")`
131
175
  Flame height (m). `model='Nelson'` requires `fire_type` (`1`/`'surface'`, `2`/`'passive
132
176
  crown'`, `3`/`'active crown'`), `fire_intensity`, and `midflame_ws`. `model='Finney'`
133
177
  requires `flame_tilt`, `slope_angle`, and `slope_units` (`'degrees'` or `'percent'`).
134
178
 
135
- #### `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)`
179
+ #### `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, *, backend="auto")`
136
180
  Flame tilt angle from vertical (degrees). `model='Standard'` (flat ground) requires
137
181
  `flame_length`/`flame_height`. `model='Finney'` (sloped ground) additionally requires
138
182
  `slope_angle`/`slope_units`. `model='Butler'` (crown fires only) requires `wind_speed`,
139
183
  `wind_speed_units` (`'kph'`/`'mps'`/`'mph'`), and `canopy_ht` (must be `> 0`, or raises
140
184
  `ValueError`).
141
185
 
142
- #### `get_flame_residence_time(ros, fuel_consumption, midflame_ws, units)`
186
+ #### `get_flame_residence_time(ros, fuel_consumption, midflame_ws, units, *, backend="auto")`
143
187
  Flame residence time — Nelson & Adkins (1988). `ros` must always be in m/min; `units`
144
188
  (`'sec'` or `'min'`) controls the output unit only, not the expected input unit.
145
189
 
146
- #### `get_flame_depth(ros, res_time)`
147
- Flame depth (m) — Fons et al. (1963). `ros` in m/min, `res_time` in minutes.
190
+ #### `get_flame_depth(ros, res_time, *, backend="auto")`
191
+ Flame depth (m) — Fons et al. (1963). `ros` in m/min, `res_time` in minutes. The
192
+ multiplication follows NumPy dtype rules. Fixed-width integer products can wrap before
193
+ negative results are clamped to zero. Use a dtype wide enough for the expected product.
148
194
 
149
- #### `flame_component_array_multiprocessing(flame_function, num_processors=2, block_size=None, **kwargs)`
195
+ #### `flame_component_array_multiprocessing(flame_function, num_processors=2, block_size=None, *, backend="auto", **kwargs)`
150
196
  Splits array inputs into blocks and runs one of the six functions above across multiple
151
197
  processes. `flame_function` is one of `'midflame_ws'`, `'flame_length'`, `'flame_height'`,
152
198
  `'flame_tilt'`, `'flame_residence'`, `'flame_depth'`. `kwargs` must match the target
153
199
  function's parameter names, with at least one `numpy.ndarray` value (all arrays must share
154
- the same shape). `num_processors < 2` is coerced to `2` with a `UserWarning`. Returns a
155
- **list of per-block result arrays, not a single concatenated array** — call
156
- `numpy.concatenate()` on the result yourself if you need one.
200
+ the same shape and have at least one row). `num_processors < 2` is coerced to `2` with a
201
+ `UserWarning`. The dispatcher returns one result per block in input order, including any
202
+ final partial block. Use `numpy.concatenate()` to join numeric result arrays.
203
+ `params_only=True` for flame length returns a coefficient tuple for each block.
157
204
 
158
- See `docs/CODEBASE.md` for internal architecture and implementation-level gotchas, and
159
- `docs/TEST_SUITE_DESCRIPTION.md` for the full test-suite catalog.
205
+ See the [architecture guide](https://github.com/gagreene/flame_components/blob/v0.2.0/docs/CODEBASE.md)
206
+ and the [test suite guide](https://github.com/gagreene/flame_components/blob/v0.2.0/docs/TEST_SUITE_DESCRIPTION.md).
160
207
 
161
208
  ## Scientific References
162
209
 
@@ -168,7 +215,8 @@ detail (journal, volume, DOI) before citing this package's underlying science fo
168
215
  - **`get_mid_flame_ws`**: Albini, F.A. & Baughman, R.G. (1979).
169
216
  - **`get_flame_length`**: 29 models catalogued in Finney, M.A. & Grumstrup, T.P. (2023);
170
217
  each model's original source (Byram, Fons, Nelson, Anderson, Fernandes, Butler, and
171
- others) is cited inline next to its coefficients in `core.py`'s `model_dict`.
218
+ others) is cited next to its coefficients in the
219
+ [Python reference table](https://github.com/gagreene/flame_components/blob/v0.2.0/src/flame_components/_equations.py).
172
220
  - **`get_flame_height`**: Nelson, R.M. & Adkins, C.W. (1986) (`model='Nelson'`), or
173
221
  Finney, M.A. & Martin, S.W. (1992) (`model='Finney'`).
174
222
  - **`get_flame_tilt`**: Standard geometry (`model='Standard'`), Finney, M.A. & Martin, S.W.
@@ -177,7 +225,7 @@ detail (journal, volume, DOI) before citing this package's underlying science fo
177
225
  - **`get_flame_depth`**: Fons, W.L. et al. (1963).
178
226
 
179
227
  If you use this package in published research, please cite both the package itself (see
180
- `CITATION.cff`) and the original publication(s) for the specific model(s) you used.
228
+ [CITATION.cff](https://github.com/gagreene/flame_components/blob/v0.2.0/CITATION.cff)) and the original publication(s) for the specific model(s) you used.
181
229
 
182
230
  ## Support and Issue Reporting
183
231
 
@@ -197,4 +245,4 @@ Contributions are welcome. If you have ideas for new features or improvements, p
197
245
  ## License
198
246
 
199
247
  This project is licensed under the MIT License. See the
200
- [LICENSE](https://github.com/gagreene/flame_components/blob/master/LICENSE) file for details.
248
+ [LICENSE](https://github.com/gagreene/flame_components/blob/v0.2.0/LICENSE) file for details.
@@ -1,6 +1,6 @@
1
1
  [build-system]
2
- requires = ["hatchling", "hatch-vcs"]
3
- build-backend = "hatchling.build"
2
+ requires = ["maturin>=1.9.6,<2"]
3
+ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "flame-components"
@@ -32,10 +32,10 @@ classifiers = [
32
32
 
33
33
  [project.urls]
34
34
  Homepage = "https://github.com/gagreene/flame_components"
35
- Source = "https://github.com/gagreene/flame_components"
35
+ Source = "https://github.com/gagreene/flame_components/tree/v0.2.0"
36
36
  "Issue Tracker" = "https://github.com/gagreene/flame_components/issues"
37
- "Release Notes" = "https://github.com/gagreene/flame_components/releases"
38
- Documentation = "https://github.com/gagreene/flame_components#readme"
37
+ "Release Notes" = "https://github.com/gagreene/flame_components/releases/tag/v0.2.0"
38
+ Documentation = "https://github.com/gagreene/flame_components/tree/v0.2.0#readme"
39
39
 
40
40
  [project.optional-dependencies]
41
41
  test = ["pytest>=7.0"]
@@ -43,14 +43,12 @@ test = ["pytest>=7.0"]
43
43
  [dependency-groups]
44
44
  dev = ["pytest>=7.0"]
45
45
 
46
- [tool.hatch.version]
47
- source = "vcs"
48
-
49
- [tool.hatch.build.targets.wheel]
50
- packages = ["src/flame_components"]
51
-
52
- [tool.hatch.build.targets.sdist]
53
- exclude = ["archive"]
46
+ [tool.maturin]
47
+ manifest-path = "rust/crates/flame-components-py/Cargo.toml"
48
+ module-name = "flame_components._native"
49
+ python-source = "src"
50
+ features = ["pyo3/extension-module"]
51
+ locked = true
54
52
 
55
53
  [tool.pytest.ini_options]
56
54
  testpaths = ["tests"]