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

Save outputs for investment year #657

Merged
merged 15 commits into from
Feb 7, 2025
Merged

Save outputs for investment year #657

merged 15 commits into from
Feb 7, 2025

Conversation

tsmbland
Copy link
Collaborator

@tsmbland tsmbland commented Feb 6, 2025

Following on from #641, in this PR we're saving data for the investment year each iteration, rather than the current year. The exception is the first iteration, where we save output data for both years. This way, we get output data for every year of the time framework, without having to simulate an extra year (as was done before #641). As far as the user is concerned nothing has changed compared to before #641 - they're still getting the same data for all the same years, but it will be slightly quicker without the extra time step.

It's still a bit messy and wasteful. Most outputs are calculated for both years, but only saving data for the investment year. For now I think it's fine, but certainly more work still to be done.

I've made some changes to outputs.mca so the functions take a year argument, and some changes dotted through the code to pass around this year argument. Due to the way that the save_multiple_outputs is reused multiple times I also had to add **kwargs to lots of functions taht don't use year, so they don't complain about being passed year against their will. Not very satisfying, but the simplest fix without having to refactor a load of stuff.

Just noticed the cached outputs feature. I've made some changes to keep the tests happy, but it seems like it was broken anyway to begin with (only outputting data for the first year). Not really sure why this exists anyway.

This also fixes #540 which was caused by inconsistency in the year used for various parts of the LCOE/EAC calculations - now fixed as we're passing year to the functions and using this throughout.

Close #540

tsmbland and others added 15 commits February 6, 2025 14:18
* Move broadcast_techs out of quantities module

* Update _inner_split

* Fix trade model

* Fix constraints tests

* Fix demand_share tests

* Fix quantities tests

* Fix trade tests

* Fix adhoc model

* Rename broadcast_techs to broadcast_over_assets

* Better docstring, rename argument

* Delete filter_with_template

* Remove `broadcast_over_assets` from `capacity_in_use`

* Fix trade tests

* Edit TODO

* Remove foresight parameter

* Update settings and documentation

* Temporarily suppress test

* Fix carbon budget framework

* Revert change to settings

* Update settings and documentation

* Revert change to settings

* Update results

* Small changes to fix tests

* Add warning about deprecated parameter

* Clarify log messages

* Better final message
@tsmbland tsmbland marked this pull request as ready for review February 6, 2025 15:28
@tsmbland tsmbland requested a review from dalonsoa February 6, 2025 15:29
Copy link
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

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

There are a lot of years and kwargs floating around, but all in all, the changes seem reasonable. At least the MCA is more explicit on the year we are talking about.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If I remember correctly, the purpose of this was to save intermediate results of the simulation for post-mortem analysis. I believe I was the one setting it up :P , and I think back then it was working fine but, as many things in MUSE, it might have broken along the way and, if no one uses the feature (and there are no thorough tests), no one notice it is broken.

@@ -104,10 +104,10 @@ def _factory(

def save_multiple_outputs(market, *args, year: int | None = None) -> list[Any]:
if year is None:
year = int(market.year.min())
year = int(market.year.max())
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like a radical change, from min to max. Why is it? Is it because min is current year and max is investment year or something like that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, exactly. This is actually never used in the main code as I've made sure year is always passed explicitly. There are just a couple of tests that rely on this, but they weren't super straightforward to change so I've left this in (for now)

@tsmbland tsmbland merged commit 8a19169 into main Feb 7, 2025
14 checks passed
@tsmbland tsmbland deleted the outputs2 branch February 7, 2025 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Wrong year being used for LCOE and EAC outputs
2 participants