-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
* 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
There was a problem hiding this 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.
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
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 ayear
argument, and some changes dotted through the code to pass around this year argument. Due to the way that thesave_multiple_outputs
is reused multiple times I also had to add**kwargs
to lots of functions taht don't useyear
, so they don't complain about being passedyear
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