-
Notifications
You must be signed in to change notification settings - Fork 100
EPPT-2589: Fire Severity Index: Add a CanadianForestFireWeatherIndex class to IMPROVER #2254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mo-philrelton
merged 7 commits into
metoppv:EPPT_2411_fire_severity_index_workflow_development
from
mo-philrelton:EPPT_2589_canadianforestfireweatherindex
Jan 6, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8c82798
Adding working plugin and tests for CanadianForestFireWeatherIndex
mo-philrelton 571f972
Correcting algorithm referece in the docstring
mo-philrelton 43064f5
Changes from ABC refactor
mo-philrelton 9a3d56a
Adding input/output validation tests for CFFWI
mo-philrelton 07cbe32
Changes from first round review suggestions
mo-philrelton 3ed55cb
Parameterising looped test
mo-philrelton 3f3b083
Docstring changes from review
mo-philrelton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
improver/fire_weather/canadian_forest_fire_weather_index.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| # (C) Crown Copyright, Met Office. All rights reserved. | ||
| # | ||
| # This file is part of 'IMPROVER' and is released under the BSD 3-Clause license. | ||
| # See LICENSE in the root of the repository for full licensing details. | ||
| """Plugin to calculate the Canadian Forest Fire Weather Index (FWI).""" | ||
|
|
||
| import numpy as np | ||
| from iris.cube import Cube | ||
|
|
||
| from improver.fire_weather import FireWeatherIndexBase | ||
|
|
||
|
|
||
| class CanadianForestFireWeatherIndex(FireWeatherIndexBase): | ||
| """ | ||
| Plugin to calculate the Canadian Forest Fire Weather Index (FWI). | ||
|
|
||
| The FWI combines the Initial Spread Index (ISI) and the Build Up Index (BUI) | ||
| to provide a numerical rating of fire intensity. It represents the rate of | ||
| fire spread and the amount of available fuel. | ||
|
|
||
| This process is adapted directly from: | ||
| Equations and FORTRAN Program for the | ||
| Canadian Forest Fire Weather Index System | ||
| (C.E. Van Wagner and T.L. Pickett, 1985). | ||
| Pages 7-8, Equations 28-30. | ||
|
|
||
| Expected input units: | ||
| - Initial Spread Index (ISI): dimensionless | ||
| - Build Up Index (BUI): dimensionless | ||
| """ | ||
|
|
||
| INPUT_CUBE_NAMES = ["initial_spread_index", "build_up_index"] | ||
| OUTPUT_CUBE_NAME = "canadian_forest_fire_weather_index" | ||
|
|
||
| initial_spread_index: Cube | ||
| build_up_index: Cube | ||
|
|
||
| def _calculate(self) -> np.ndarray: | ||
| """Calculate the Fire Weather Index (FWI). | ||
|
|
||
| From Van Wagner and Pickett (1985), Page 8: Steps 4-6 | ||
|
|
||
| Returns: | ||
| The calculated FWI values. | ||
| """ | ||
| # Step 4: Calculate extrapolated Duff Moisture Function | ||
| extrapolated_DMF = self._calculate_extrapolated_duff_moisture_function() | ||
|
|
||
| # Steps 5 & 6: Calculate FWI | ||
| fwi = self._calculate_fwi(extrapolated_DMF) | ||
|
|
||
| return fwi | ||
|
|
||
| def _calculate_fwi(self, extrapolated_DMF) -> np.ndarray: | ||
| """Calculates the Fire Weather Index (FWI) from the Initial Spread Index (ISI) | ||
| and the extrapolated Duff Moisture Function (extrapolated_DMF). | ||
|
|
||
| From Van Wagner and Pickett (1985), Page 7-8: Equations 29-30. | ||
|
|
||
| Returns: | ||
| The calculated FWI values. | ||
| """ | ||
| isi_data = self.initial_spread_index.data | ||
|
|
||
| # Equation 29: Calculate "B-Scale" FWI (intermediate value) | ||
| fwi_Bscale = 0.1 * isi_data * extrapolated_DMF | ||
|
|
||
| # Equations 30a and 30b: Calculate the final "S-Scale" | ||
| # When B > 1, use equation 30a; otherwise use equation 30b | ||
| with np.errstate(divide="ignore", invalid="ignore"): | ||
| fwi_Sscale = 2.72 * (0.434 * np.log(fwi_Bscale)) ** 0.647 | ||
| fwi_30a = np.exp(fwi_Sscale) | ||
|
|
||
| fwi = np.where(fwi_Bscale > 1.0, fwi_30a, fwi_Bscale) | ||
|
|
||
| return fwi | ||
|
|
||
| def _calculate_extrapolated_duff_moisture_function(self) -> np.ndarray: | ||
| """Calculates the extrapolated Duff Moisture Function (extrapolated_DMF) | ||
| from the Build Up Index (BUI). | ||
|
|
||
| From Van Wagner and Pickett (1985), Page 7-8: Equations 28a and 28b. | ||
|
|
||
| Returns: | ||
| The calculated extrapolated_DMF values. | ||
| """ | ||
| bui_data = self.build_up_index.data | ||
|
|
||
| # Calculate extrapolated_DMF using equations 28a and 28b | ||
| extrapolated_DMF_28a = 0.626 * bui_data**0.809 + 2.0 | ||
| extrapolated_DMF_28b = 1000.0 / (25.0 + 108.64 * np.exp(-0.023 * bui_data)) | ||
|
|
||
| # Condition: BUI <= 80 uses equation 28a, BUI > 80 uses equation 28b | ||
| extrapolated_DMF = np.where( | ||
| bui_data <= 80.0, extrapolated_DMF_28a, extrapolated_DMF_28b | ||
| ) | ||
|
|
||
| return extrapolated_DMF | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.