-
Notifications
You must be signed in to change notification settings - Fork 50
Add reporting of resource extraction to IAMC structure #451
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
Conversation
fe9ecf8 to
1da9a4b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #451 +/- ##
=======================================
- Coverage 76.2% 75.0% -1.3%
=======================================
Files 278 278
Lines 23552 22751 -801
=======================================
- Hits 17970 17065 -905
- Misses 5582 5686 +104
🚀 New features to boost your workflow:
|
Ensure that structure keys ("n", "y", etc.) are populated.
Collect general features for converting data to IAMC structure.
- Remove function of same name in .report.extraction(). - Add to .report.defaults().
- {crude,gas}_[12345678] and uranium.
- Add report-only aggregates with these codes as children.
- Used in .report.extraction.
- Adjust test expectations via .test_bare.SET_SIZE.
- Add in .report.defaults() using .report.key.coords.n_glb. - Adjust usage in IAMCConversion.add_tasks().
1da9a4b to
913b3f2
Compare
913b3f2 to
dc81640
Compare
|
Hi @macflo8 @Wegatriespython @Tyler-lc @junukitashepard @yiyi1991 —another PR following on our discussion on Monday. There, we discussed the idea of transferring some of the genno-based reporting of quantities like Final Energy or GDP that Florian had developed for the materials variant, into the general-purpose message_ix_models.report module. We talked about the strategy of tackling 'simpler' cases (such as GDP) first, to gain familiarity and identify what tools/utilities are still needed. For the same reasons, I tried here to do one of the smaller/simpler functions: message-ix-models/message_ix_models/report/legacy/default_tables.py Lines 411 to 442 in ccb9393
Most of the changes on the branch are adjustments/housekeeping/improved utilities/improved docs, in order to make the one function linked in the PR branch as simple and clean as possible. I hope that this, in turn, will make it just as simple to report other quantities. Please ask any questions by comments on the PR, on particular lines of the diff, or in Slack—I will try to add to the docs until the answers are all in there. |
|
Thank you so much Paul! I was able to run This is a good example to follow (e.g., for adding one variable category, and for adding building-related variables reporting). Please feel free to merge this PR. This is not the best place but let me list two things I immediately sensed difficulties if we want to reproduce more complex power/material reporting under the same framework. The first byproduct issue becomes ok after I took a scecond look. message-ix-models/message_ix_models/model/material/report/reporting.py Lines 1709 to 1712 in dc81640
When dealing with Final Energy variables, after retrieving all in flows by df = rep.get("in:nl-t-ya-m-c-l") with the explicit naming flow\|level\|commodity\|tech\|mode, we filtered them by level final (as only energy commodities use that level). Then the byproduct gases need to be excluded or even treated as negative energy input in specific scopes (e.g., bf_gas are generated by blast furnace but mostly immediately used by basic oxygen furnace, similarly those coke oven gas, but they should be counted under emission accounting.). But we can work with an, e.g., excluding_comm list to the key c right?
The second one is level-specific variable assignment. message-ix-models/message_ix_models/data/material/reporting/fe.yaml Lines 373 to 389 in dc81640
To handle this the material reporting simply uses pandas groupby after genno. After 10 minutes digging, I think I need additional help to get genno handle that flexibly too. In short, I think as a maintainer I get the idea of what to do with the commodity.yaml. My understanding is, the commodities with the same commodity names in gdx but different levels, they should be treated as different commodities here in this yaml? E.g., the commodity message-ix-models/message_ix_models/data/commodity.yaml Lines 61 to 67 in dc81640
|
|
Thanks @yiyi1991 for the detailed comments! I will note these two points for specific response (maybe in tomorrow's weekly meeting), but in the meantime per:
…could you please give a ✅ so I can do that? |
Per discussion 2025-11-03, this PR gives a proof-of-concept for implementation of one reporting 'table' (measure) using the Reporter class. See in particular the added module
.report.extractionand the function.report.extraction.callback().Some things to observe about the implementation:
c/commoditydimension) are derived from the same files (in this case, commodity.yaml) that describe the model structure.callback()function:Some things to observe about the PR:
.report; a 'flat'/wide arrangement of similar reporting code will make for easier maintenance and readability than 1 or a few files with >1000 lines..report.config._default_callbacks.This ensures it is called every time
prepare_reporter()is called (unless user code deliberately removes it)..report.util.NOT_IMPLEMENTED_{IAMC,MEASURE}and the expectation of.test_report.test_compare()are adjusted to reflect the additions.Future PRs could make similar changes.
How to review
PR checklist