Add optional CH4 effects#19
Open
irm-codebase wants to merge 2 commits into
Open
Conversation
Author
There was a problem hiding this comment.
Pull request overview
Adds configurability for methane (CH4) prospective characterization by introducing selectable indirect-effects treatments, and updates validation tests to compare against Watanabe SI reference tables more directly.
Changes:
- Introduce
indirect_effectsmodes for CH4 AGWP (e.g.,"none","no_carbon_cycle","all") and thread the option through prospective CH4 RF + top-levelcharacterize(...)for relevant metrics. - Refactor prospective
characterize_ch4to reuse a centralized cumulative AGWP helper (_agwp_ch4_cumulative). - Strengthen/expand pGWP100 tests for CH4 across years and scenarios, and add a monotonicity check across modes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
dynamic_characterization/prospective/agwp.py |
Adds CH4 indirect-effects modes and a shared cumulative AGWP implementation used by CH4. |
dynamic_characterization/prospective/radiative_forcing.py |
Exposes indirect_effects in prospective CH4 forcing and delegates to AGWP helper. |
dynamic_characterization/dynamic_characterization.py |
Adds indirect_effects parameter to the public API and forwards it where supported. |
tests/test_prospective.py |
Updates CH4 pGWP100 tests to match SI tables across scenarios/years; adds monotonicity test for CH4 modes. |
Comments suppressed due to low confidence (1)
dynamic_characterization/prospective/radiative_forcing.py:25
load_irf_ch4andload_re_ch4are imported but no longer used after switchingcharacterize_ch4to_agwp_ch4_cumulative. With flake8 enabled, this will raise an unused-import error; remove these imports (and any other now-unused CH4-specific constants/imports in this module).
from dynamic_characterization.prospective.agwp import _agwp_ch4_cumulative
from dynamic_characterization.prospective.config import get_scenario
from dynamic_characterization.prospective.data_loader import (
load_irf_ch4,
load_irf_co2,
load_irf_n2o,
load_re_ch4,
load_re_co2,
load_re_n2o,
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+91
to
96
| indirect_effects : str | ||
| Indirect effect treatment. One of: | ||
| - all: all indirect effects. Matches Watanabe et al. Default. | ||
| - no_carbon_cyle: all indirect effects except carbon cycle feedbacks. | ||
| - none: only direct effects of the gasae. | ||
|
|
| CH4_INDIRECT_EFFECTS_FACTOR = 1.43 | ||
|
|
||
| # Our AGWP implementation of CH4 can calculate both DIRECT and INDIRECT radiative forcing. | ||
| # Our AGWP implementation of NO2 calculates DIRECT radiative forcing only. |
| indirect_effects : str | ||
| Treatment of indirect CH4 effects. One of: | ||
| - all: all indirect effects. Matches Watanabe et al. (2026). Default. | ||
| - no_carbon_cyle: all indirect effects except carbon cycle feedbacks. |
Comment on lines
+161
to
+163
| c1[t] = temp_s[t] * 11.06 * 0.6368 + c1_prev * np.exp(-1 / 2.376) | ||
| c2[t] = temp_s[t] * 11.06 * 0.3322 + c1_prev * np.exp(-1 / 30.14) | ||
| c3[t] = temp_s[t] * 11.06 * 0.031 + c1_prev * np.exp(-1 / 490.1) |
| step: int, | ||
| time_varying_re: bool, | ||
| ) -> float: | ||
| """Configuration-aware radiate efficiency getter.""" |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Fixes #18 and #5
This is my attempt to add more flexibility in how CH4 is treated.
Namely:
Other extra goodies:
For disclosure:
_agwp_ch4_cumulative). I've triple checked things, so it should be clean. However, the SI Code n.4 section full of 'magic values'. I'm trusting Watanabe's implementation, but it'd be ideal if these were converted to global constants with more useful names.