-
Notifications
You must be signed in to change notification settings - Fork 50
Add bilateralization tool (project/newpathways-trade) #438
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for the work here! In order to merge the following are needed, and addressing these things first will help reviewers focus more squarely on the added contents and functionality.
Many members of the team have experience doing each of these steps and can help by checking work, pair programming, or joining in to do the changes directly, so please reach out on Slack or otherwise. |
ebeeb3c to
6a19239
Compare
43eb325 to
a62b990
Compare
1) prepare_edit to generate edit files 2) bare_to_scenario to generate dictionary 3) load_and_solve to update scenario and optionally solve
Update formatting to pass mypy/ruff and allow testing
This removes the NEWPATHWAYS project version of documentation (same content)
Load and solve is now tested Debug to load_and_solve.py (add "_") Add encoding to prepare_edit.py
341cdcb to
6e0b817
Compare
Increase coverage to GEM and MariTeam imports
|
@khaeru Patch coverage is 51%; however, the scripts that are not covered in testing are those that derive input data based on private data sources. I would of course welcome any input on whether/how to increase this coverage. |
|
Dear Jun, thanks for opening this! I will really try to use it later on steel intermediate products and bring feedback here. Just very quickly on test coverage. I see if these three main functions are "tested", then basically all small functions there will be covered. Then it will be useful to separate the scenario identifier from the config list and allow a This also makes it easier for other colleagues to call this function in other workflows. |
Should be in separate GEM folder
message_ix_models/data/bilateralize/node_lists/R12_node_list.yaml
Outdated
Show resolved
Hide resolved
Thanks @yiyi1991 for this. load_and_solve loads a base scenario (identified in the configuration), clones it, and then applies the bilateralization parameters. So this note makes me think that perhaps I should break this further into:
I can implement this if this makes sense to you |
|
Every Python module should have an |
I agree with breaking it into several steps. I was just trying to emphasize that it is better NOT to process a scenario as an identifier string hidden in the config, but as a scenario object. When other colleagues use it, they usually have one scenario object in their workflow (your option 2 style, as they should prepare a cloned scenario ready to add bilateralization by themselves), and pass it to your step three function, together with the other necessary inputs to get the bilateralization there. |
|
TODO: Update data references to IEA:
|
Set scenario to a message_ix.Scenario for direct bialteralization in load_and_clone Otherwise function uses start model/scenario from config.yaml There is also option to name specific start model/scenario
I've added these options in the latest commit: 177cb8d |
Added in e989681 |
|
I see that with recent commits the new docs page now appears in the preview build! 🥳 |
Overview
The merged code allows users to represent trade bilaterally for specified commodities. By default, the tool bilateralizes existing fuel trade (e.g., oil_exp).
The bilateralization tool,
bilateralize, is generalized for any traded commodity, whether that is a fuel (e.g., LNG), or a material (e.g., steel). It also explicitly represents bilateral trade “flows”, or how a fuel/commodity is transported from exporter to importer. These flow technologies are user defined and flexible; the most common are pipelines (e.g., gas pipelines), maritime shipping (e.g., LNG tanker), and transmission lines.See https://github.com/iiasa/message-ix-models/blob/project/newpathways-trade/doc/api/tools-bilateralize.rst for more details on implementation.
How to review
Note: All scripts are additions (no existing scripts are amended). Therefore, I would request reviewing code directly rather than individual commits (of which there are >200).
These review steps are also outlined in https://github.com/iiasa/message-ix-models/blob/project/newpathways-trade/message_ix_models/tools/bilateralize/workflow.py
prepare_edit_files()should produce untracked files in commodity-specific directories indata/bilateralize/edit_filesand also transfer required parameter files todata/bilateralize/bare_filesbare_to_scenario()should produce a dictionary of required parameter updates for bilateralization for all specified trade commodities inconfig.yaml.load_and_solve()should be able to be used to update SSP base scenariosPR checklist