Skip to content
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

Add variant/module for cooling technologies in tools.costs #222

Merged
merged 11 commits into from
Oct 23, 2024
Merged

Conversation

measrainsey
Copy link
Contributor

@measrainsey measrainsey commented Aug 29, 2024

Add a variant/module to project costs for cooling technologies

This PR adds a new module within tools.costs called cooling. @adrivinca has provided input data for these technologies -- these technologies are currently all mapped to a technology in the energy module (based on the assumption that these cooling technologies are sort of addons that follow the same regional differentiation as their non-addon counterpart). However, the cooling technologies have their own base year reference region costs.

This PR's branch is derived from the costs/reduction-year branch, which has its own PR #227. Once that one is merged, I will rebase.

How to review

For @adrivinca: Verify if the implementation is correct and if the outputs make sense.

For @khaeru and/or @glatterf42 : Read the diff and note that the CI checks all pass.

PR checklist

  • Continuous integration checks all ✅
  • Add or expand tests; coverage checks both ✅
  • Add, expand, or update documentation.
  • Update doc/whatsnew.

@khaeru khaeru added the costs `.tools.costs`/cost data preparation label Aug 29, 2024
@measrainsey measrainsey self-assigned this Aug 29, 2024
@measrainsey measrainsey force-pushed the costs/cooling branch 2 times, most recently from 159089e to 55e2446 Compare September 2, 2024 13:59
@measrainsey measrainsey added the water MESSAGEix-Nexus (water) variant label Sep 2, 2024
@measrainsey measrainsey marked this pull request as ready for review September 2, 2024 14:26
@adrivinca
Copy link
Contributor

adrivinca commented Sep 3, 2024

Thanks @measrainsey for advancing this work!
We tried and it seems it works well for what concerns the cooling techs.

just a note for the general module that could maybe improved with a fix or just notified to developers: One limitation of the fix cost generator is that is does not take into account of the technology lifetime in the vintage-activity years. This way the output dataframe is way larger than actually needed and might take up space. (for example with cooling technologies with 30 years lifetime) the fix_cost df would be five time smaller than the actual one.

I understand that including the lifetime in the process would require adding the information in the initial data, and maybe we don't want it.
Otherwise I would suggest write a note about it and the users one could post-apply some formulas like in message_ix_models.model.water.util.map_yv_ya_lt() and just filter the output

@measrainsey
Copy link
Contributor Author

Thanks @measrainsey for advancing this work! We tried and it seems it works well for what concerns the cooling techs.

just a note for the general module that could maybe improved with a fix or just notified to developers: One limitation of the fix cost generator is that is does not take into account of the technology lifetime in the vintage-activity years. This way the output dataframe is way larger than actually needed and might take up space. (for example with cooling technologies with 30 years lifetime) the fix_cost df would be five time smaller than the actual one.

I understand that including the lifetime in the process would require adding the information in the initial data, and maybe we don't want it. Otherwise I would suggest write a note about it and the users one could post-apply some formulas like in message_ix_models.model.water.util.map_yv_ya_lt() and just filter the output

Sorry I forgot to respond to this comment/review here as Adriano and I had a side conversation about this topic! But I'll put my thoughts here anyways to preserve them on this platform. Additionally, this issue of lifetime was also brought to my attention by Oliver, so I might have to address this at some point.

While my initial thoughts/feelings was to keep technology lifetime outside of this tool so that the tool can remain agnostic to so many inputs/parameters (as perhaps technology lifetimes can vary across scenarios, hypothetically) and as lean as possible, I can see that keeping costs projection for a technology beyond its lifetime can (a) cause confusion and (b) lead to very large output dataframes, like Adriano mentioned.

It seems the best way to make sure lifetimes and vintages are accounted for would be to have the tool call upon the vintage_and_active_years() function from a scenario object. Given that at the moment the costs tool does not interact with MESSAGEix scenario objects at all (this is done by the user post-tool), I would like to leave this issue of lifetimes as a larger TODO on my list and not have it addressed within this PR.

@measrainsey
Copy link
Contributor Author

measrainsey commented Oct 21, 2024

We also have ScenarioInfo.yv_ya. The ScenarioInfo class (and the .water.utils function mentioned by @adrivinca) are specifically for working with data in the absence of (e.g. before the creation of) a concrete Scenario object, so I think this is quite possible. But it's also fine to omit it from this PR and leave a note at an appropriate place in the docs like:

.. note:: The data produced are for all valid combinations of :math:`(y^V, y^A)`—including those that are beyond the `technical_lifetime` of the |t| to which they apply.
   This may produce large data frames.
   If this is problematic, user code **may** filter the data for valid combinations.

Thanks @khaeru for your suggestion. I have created an issue #237 to track progress on this, and for the time being, I have added a note in the documentation:

.. note:: The data produced are for all valid combinations of :math:`(y^V, y^A)`—including those that are beyond the `technical_lifetime` of the |t| to which they apply.
This may produce large data frames, depending on the number of technologies, regions, and scenarios.
At the moment, :mod:`.tools.costs` does not filter out these combinations.
If this is problematic, the user may consider filtering the data for valid combinations of :math:`(y^V, y^A)`.

Copy link
Member

@khaeru khaeru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @glatterf42 was there anything else you were waiting to see here, or can I merge?

@glatterf42
Copy link
Member

Nope, good from my side :)

@measrainsey
Copy link
Contributor Author

Hi all, thanks for approving the PR!

Just a quick note that this branch is based off of the branch in #227, so that PR should probably be approved and merged before this one, I presume?

@glatterf42
Copy link
Member

You could also merge this PR into the branch it originated from. This would increase the size of the other PR, but we could focus on the changes not already reviewed.
However, as far as I can tell, the other PR is already quite close to being merged, so I don't think it hurts to wait before merging this one.

Base automatically changed from costs/reduction-year to main October 23, 2024 06:26
Copy link

codecov bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.5%. Comparing base (2dbdec6) to head (687c4c4).
Report is 13 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #222     +/-   ##
=======================================
- Coverage   75.5%   75.5%   -0.1%     
=======================================
  Files        203     203             
  Lines      15503   15503             
=======================================
- Hits       11707   11706      -1     
- Misses      3796    3797      +1     
Files with missing lines Coverage Δ
message_ix_models/tests/tools/costs/test_decay.py 100.0% <100.0%> (ø)
message_ix_models/tests/tools/costs/test_gdp.py 100.0% <100.0%> (ø)
...ge_ix_models/tests/tools/costs/test_projections.py 100.0% <ø> (ø)
...tests/tools/costs/test_regional_differentiation.py 100.0% <100.0%> (ø)
message_ix_models/tools/costs/config.py 97.2% <100.0%> (ø)
..._ix_models/tools/costs/regional_differentiation.py 97.9% <ø> (ø)

... and 1 file with indirect coverage changes

@khaeru khaeru merged commit b15268e into main Oct 23, 2024
26 checks passed
@khaeru khaeru deleted the costs/cooling branch October 23, 2024 07:58
glatterf42 pushed a commit that referenced this pull request Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
costs `.tools.costs`/cost data preparation water MESSAGEix-Nexus (water) variant
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants