flame-components 0.1.1__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.
- flame_components-0.1.1/.github/workflows/release.yml +118 -0
- flame_components-0.1.1/.github/workflows/tests.yml +101 -0
- flame_components-0.1.1/.gitignore +70 -0
- flame_components-0.1.1/CITATION.cff +12 -0
- flame_components-0.1.1/LICENSE +21 -0
- flame_components-0.1.1/PKG-INFO +229 -0
- flame_components-0.1.1/README.md +200 -0
- flame_components-0.1.1/docs/CODEBASE.md +159 -0
- flame_components-0.1.1/docs/RELEASING.md +73 -0
- flame_components-0.1.1/docs/TEST_SUITE_DESCRIPTION.md +257 -0
- flame_components-0.1.1/pyproject.toml +57 -0
- flame_components-0.1.1/scripts/smoke_test.py +79 -0
- flame_components-0.1.1/src/flame_components/__init__.py +34 -0
- flame_components-0.1.1/src/flame_components/core.py +846 -0
- flame_components-0.1.1/tests/__init__.py +0 -0
- flame_components-0.1.1/tests/integration/__init__.py +0 -0
- flame_components-0.1.1/tests/integration/test_flame_pipeline.py +145 -0
- flame_components-0.1.1/tests/regression/__init__.py +0 -0
- flame_components-0.1.1/tests/regression/test_gotchas.py +107 -0
- flame_components-0.1.1/tests/unit/__init__.py +0 -0
- flame_components-0.1.1/tests/unit/test_flame_component_array_multiprocessing.py +88 -0
- flame_components-0.1.1/tests/unit/test_get_flame_depth.py +62 -0
- flame_components-0.1.1/tests/unit/test_get_flame_height.py +193 -0
- flame_components-0.1.1/tests/unit/test_get_flame_length.py +101 -0
- flame_components-0.1.1/tests/unit/test_get_flame_residence_time.py +89 -0
- flame_components-0.1.1/tests/unit/test_get_flame_tilt.py +160 -0
- flame_components-0.1.1/tests/unit/test_get_mid_flame_ws.py +128 -0
- flame_components-0.1.1/tests/unit/test_public_api.py +19 -0
- flame_components-0.1.1/uv.lock +232 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
# Runs only for a deliberate, human-published GitHub Release -- never on a bare tag push.
|
|
4
|
+
# Mark the Release as "pre-release" (e.g. a v0.1.1rc1 tag) to publish to TestPyPI, or as a
|
|
5
|
+
# full release (e.g. v0.1.1) to publish to PyPI. See docs/RELEASING.md.
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
name: Build, validate, and smoke-test distributions
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
timeout-minutes: 15
|
|
15
|
+
permissions:
|
|
16
|
+
contents: write # needed to attach dist/ files to the GitHub Release
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout
|
|
19
|
+
uses: actions/checkout@v7
|
|
20
|
+
with:
|
|
21
|
+
fetch-depth: 0 # full history + tags, required for hatch-vcs to derive the version
|
|
22
|
+
|
|
23
|
+
- name: Set up uv
|
|
24
|
+
uses: astral-sh/setup-uv@v10.0.1
|
|
25
|
+
with:
|
|
26
|
+
enable-cache: true
|
|
27
|
+
|
|
28
|
+
- name: Install Python
|
|
29
|
+
run: uv python install 3.12
|
|
30
|
+
|
|
31
|
+
- name: Install project (extras + dev group)
|
|
32
|
+
run: uv sync --all-extras --dev
|
|
33
|
+
|
|
34
|
+
- name: Run full test suite
|
|
35
|
+
run: uv run pytest tests/ -v --tb=long
|
|
36
|
+
|
|
37
|
+
- name: Build distributions
|
|
38
|
+
run: uv build --no-sources
|
|
39
|
+
|
|
40
|
+
- name: Verify the built version matches the release tag
|
|
41
|
+
# hatch-vcs derives the version from git tags -- assert it actually did, rather
|
|
42
|
+
# than trusting it silently. Guards against any stale-build/cache scenario
|
|
43
|
+
# producing a dev-version wheel that would otherwise get published as if it were
|
|
44
|
+
# the tagged release.
|
|
45
|
+
run: |
|
|
46
|
+
expected="${GITHUB_REF_NAME#v}"
|
|
47
|
+
actual="$(uv run python -c 'import flame_components as fc; print(fc.__version__)')"
|
|
48
|
+
echo "expected (from tag): $expected"
|
|
49
|
+
echo "actual (from built package): $actual"
|
|
50
|
+
if [ "$expected" != "$actual" ]; then
|
|
51
|
+
echo "::error::Built version '$actual' does not match release tag '$GITHUB_REF_NAME' (expected '$expected')"
|
|
52
|
+
exit 1
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
- name: Validate distributions
|
|
56
|
+
run: uvx twine check dist/*
|
|
57
|
+
|
|
58
|
+
- name: Install the built wheel into a fresh environment and smoke-test it
|
|
59
|
+
run: |
|
|
60
|
+
uv venv /tmp/smoke-wheel
|
|
61
|
+
uv pip install --python /tmp/smoke-wheel/bin/python dist/*.whl
|
|
62
|
+
/tmp/smoke-wheel/bin/python scripts/smoke_test.py
|
|
63
|
+
|
|
64
|
+
- name: Upload distributions as a workflow artifact
|
|
65
|
+
uses: actions/upload-artifact@v7
|
|
66
|
+
with:
|
|
67
|
+
name: dist
|
|
68
|
+
path: dist/
|
|
69
|
+
if-no-files-found: error
|
|
70
|
+
|
|
71
|
+
- name: Attach distributions to the GitHub Release
|
|
72
|
+
env:
|
|
73
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
74
|
+
run: gh release upload "${{ github.event.release.tag_name }}" dist/* --clobber
|
|
75
|
+
|
|
76
|
+
publish-testpypi:
|
|
77
|
+
name: Publish to TestPyPI
|
|
78
|
+
needs: build
|
|
79
|
+
if: github.event.release.prerelease == true
|
|
80
|
+
runs-on: ubuntu-latest
|
|
81
|
+
timeout-minutes: 10
|
|
82
|
+
environment:
|
|
83
|
+
name: testpypi
|
|
84
|
+
url: https://test.pypi.org/project/flame-components/
|
|
85
|
+
permissions:
|
|
86
|
+
id-token: write # required for Trusted Publishing; granted only to this job
|
|
87
|
+
steps:
|
|
88
|
+
- name: Download distributions
|
|
89
|
+
uses: actions/download-artifact@v7
|
|
90
|
+
with:
|
|
91
|
+
name: dist
|
|
92
|
+
path: dist/
|
|
93
|
+
|
|
94
|
+
- name: Publish to TestPyPI
|
|
95
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
96
|
+
with:
|
|
97
|
+
repository-url: https://test.pypi.org/legacy/
|
|
98
|
+
|
|
99
|
+
publish-pypi:
|
|
100
|
+
name: Publish to PyPI
|
|
101
|
+
needs: build
|
|
102
|
+
if: github.event.release.prerelease == false
|
|
103
|
+
runs-on: ubuntu-latest
|
|
104
|
+
timeout-minutes: 10
|
|
105
|
+
environment:
|
|
106
|
+
name: pypi
|
|
107
|
+
url: https://pypi.org/project/flame-components/
|
|
108
|
+
permissions:
|
|
109
|
+
id-token: write # required for Trusted Publishing; granted only to this job
|
|
110
|
+
steps:
|
|
111
|
+
- name: Download distributions
|
|
112
|
+
uses: actions/download-artifact@v7
|
|
113
|
+
with:
|
|
114
|
+
name: dist
|
|
115
|
+
path: dist/
|
|
116
|
+
|
|
117
|
+
- name: Publish to PyPI
|
|
118
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [master]
|
|
6
|
+
push:
|
|
7
|
+
branches: [master]
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: tests-${{ github.head_ref || github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
name: pytest (${{ matrix.os }}, py${{ matrix.python-version }})
|
|
16
|
+
runs-on: ${{ matrix.os }}
|
|
17
|
+
timeout-minutes: 15
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
os: [ubuntu-latest]
|
|
22
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
23
|
+
include:
|
|
24
|
+
# Windows leg: package exposes multiprocessing behavior and its main downstream
|
|
25
|
+
# project (FuelAnalyst) is developed on Windows -- one representative version is
|
|
26
|
+
# enough here, the Linux matrix above already covers the full Python range.
|
|
27
|
+
- os: windows-latest
|
|
28
|
+
python-version: "3.12"
|
|
29
|
+
# macOS leg: no OS-specific code, but previously untested and the
|
|
30
|
+
# "Operating System :: OS Independent" classifier was an unverified claim.
|
|
31
|
+
# macOS defaults to the "spawn" multiprocessing start method (like Windows,
|
|
32
|
+
# unlike Linux's "fork"), so this also exercises that path on another platform.
|
|
33
|
+
- os: macos-latest
|
|
34
|
+
python-version: "3.12"
|
|
35
|
+
# These jobs also serve as the "latest NumPy" check: uv resolves the newest
|
|
36
|
+
# compatible NumPy per Python version by default (no pin below), so an upcoming
|
|
37
|
+
# NumPy release that breaks compatibility shows up here without a separate job.
|
|
38
|
+
|
|
39
|
+
steps:
|
|
40
|
+
- name: Checkout
|
|
41
|
+
uses: actions/checkout@v7
|
|
42
|
+
with:
|
|
43
|
+
fetch-depth: 0 # full history + tags, required for hatch-vcs to derive the version
|
|
44
|
+
|
|
45
|
+
- name: Set up uv
|
|
46
|
+
uses: astral-sh/setup-uv@v10.0.1
|
|
47
|
+
with:
|
|
48
|
+
enable-cache: true
|
|
49
|
+
cache-dependency-glob: |
|
|
50
|
+
uv.lock
|
|
51
|
+
pyproject.toml
|
|
52
|
+
|
|
53
|
+
- name: Install Python ${{ matrix.python-version }}
|
|
54
|
+
run: uv python install ${{ matrix.python-version }}
|
|
55
|
+
|
|
56
|
+
- name: Install project (extras + dev group)
|
|
57
|
+
run: uv sync --python ${{ matrix.python-version }} --all-extras --dev
|
|
58
|
+
|
|
59
|
+
- name: Run pytest (warnings as errors)
|
|
60
|
+
run: uv run pytest tests/ -v --tb=long -W error
|
|
61
|
+
|
|
62
|
+
- name: Run package smoke test
|
|
63
|
+
run: uv run python scripts/smoke_test.py
|
|
64
|
+
|
|
65
|
+
minimum-dependency:
|
|
66
|
+
name: pytest (Python 3.11, NumPy 1.23.2 minimum)
|
|
67
|
+
runs-on: ubuntu-latest
|
|
68
|
+
timeout-minutes: 15
|
|
69
|
+
|
|
70
|
+
steps:
|
|
71
|
+
- name: Checkout
|
|
72
|
+
uses: actions/checkout@v7
|
|
73
|
+
with:
|
|
74
|
+
fetch-depth: 0
|
|
75
|
+
|
|
76
|
+
- name: Set up uv
|
|
77
|
+
uses: astral-sh/setup-uv@v10.0.1
|
|
78
|
+
with:
|
|
79
|
+
enable-cache: true
|
|
80
|
+
|
|
81
|
+
- name: Install Python 3.11
|
|
82
|
+
run: uv python install 3.11
|
|
83
|
+
|
|
84
|
+
- name: Create test environment
|
|
85
|
+
run: uv venv --python 3.11
|
|
86
|
+
|
|
87
|
+
- name: Install minimum NumPy and test dependencies
|
|
88
|
+
run: uv pip install -e ".[test]" "numpy==1.23.2"
|
|
89
|
+
|
|
90
|
+
- name: Verify dependency version
|
|
91
|
+
run: |
|
|
92
|
+
uv run --no-sync python -c "
|
|
93
|
+
import numpy
|
|
94
|
+
assert numpy.__version__ == '1.23.2', numpy.__version__
|
|
95
|
+
"
|
|
96
|
+
|
|
97
|
+
- name: Run full test suite
|
|
98
|
+
run: uv run --no-sync pytest tests/ -v --tb=long
|
|
99
|
+
|
|
100
|
+
- name: Run package smoke test
|
|
101
|
+
run: uv run --no-sync python scripts/smoke_test.py
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Python bytecode and caches
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
downloads/
|
|
10
|
+
eggs/
|
|
11
|
+
.eggs/
|
|
12
|
+
lib/
|
|
13
|
+
lib64/
|
|
14
|
+
parts/
|
|
15
|
+
sdist/
|
|
16
|
+
share/python-wheels/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg
|
|
20
|
+
*.egg-info/
|
|
21
|
+
.installed.cfg
|
|
22
|
+
MANIFEST
|
|
23
|
+
pip-wheel-metadata/
|
|
24
|
+
|
|
25
|
+
# Virtual environments
|
|
26
|
+
.venv/
|
|
27
|
+
venv/
|
|
28
|
+
env/
|
|
29
|
+
ENV/
|
|
30
|
+
env.bak/
|
|
31
|
+
venv.bak/
|
|
32
|
+
|
|
33
|
+
# Tool caches and reports
|
|
34
|
+
.claude/
|
|
35
|
+
.mypy_cache/
|
|
36
|
+
.pytest_cache/
|
|
37
|
+
.ruff_cache/
|
|
38
|
+
.pyre/
|
|
39
|
+
.hypothesis/
|
|
40
|
+
.tox/
|
|
41
|
+
.nox/
|
|
42
|
+
.coverage
|
|
43
|
+
.coverage.*
|
|
44
|
+
coverage.xml
|
|
45
|
+
htmlcov/
|
|
46
|
+
*.cover
|
|
47
|
+
*.py,cover
|
|
48
|
+
|
|
49
|
+
# Notebooks and local databases
|
|
50
|
+
.ipynb_checkpoints/
|
|
51
|
+
*.sqlite3
|
|
52
|
+
|
|
53
|
+
# Logs and runtime artifacts
|
|
54
|
+
*.log
|
|
55
|
+
*.pid
|
|
56
|
+
*.pid.lock
|
|
57
|
+
*.seed
|
|
58
|
+
|
|
59
|
+
# IDEs and editors
|
|
60
|
+
.idea/
|
|
61
|
+
.vscode/
|
|
62
|
+
*.iml
|
|
63
|
+
|
|
64
|
+
# OS-generated files
|
|
65
|
+
.DS_Store
|
|
66
|
+
Thumbs.db
|
|
67
|
+
Desktop.ini
|
|
68
|
+
|
|
69
|
+
# Planning docs -- local reference only, not part of the public-facing repo
|
|
70
|
+
docs/*-plan.md
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: >-
|
|
3
|
+
If you use this software, please cite it using the metadata below,
|
|
4
|
+
and cite the original publication(s) for the specific fire-behavior
|
|
5
|
+
model(s) you used (see README.md's "Scientific References" section).
|
|
6
|
+
title: Flame Components
|
|
7
|
+
authors:
|
|
8
|
+
- family-names: Greene
|
|
9
|
+
given-names: Gregory A.
|
|
10
|
+
type: software
|
|
11
|
+
repository-code: "https://github.com/gagreene/flame_components"
|
|
12
|
+
license: MIT
|
|
@@ -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.
|
|
@@ -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.
|