Skip to content

Comments

Refactor demand share module#631

Merged
tsmbland merged 13 commits intomainfrom
demand_share
Jan 17, 2025
Merged

Refactor demand share module#631
tsmbland merged 13 commits intomainfrom
demand_share

Conversation

@tsmbland
Copy link
Collaborator

@tsmbland tsmbland commented Jan 16, 2025

This is a refactor the the demand_share module which I think makes the code more readable and leaves less room for bugs. It also removes legacy code to do with the "forecast" feature, as we now only have the current year and investment year.

Main changes:

Most functions in this module were previously taking "year" and "forecast" as arguments, along with a market object that should cover this time period. We're getting rid of the forecast feature, so the forecast year is essentially always the investment year. We can then simplify this the code by extracting the year range from the market object: the first year is the current year, and the second year is the investment year.

As a result, there is less need for interpolation in some places as the market object always covers the appropriate years. This is good, as I think we should rely on interpolation sparingly (as this is essentially making up data), and be super explicit when we do need to interpolate.

There are also checks in place to ensure that object dimensions are as expected:

  • technology parameters should be for a single year (no "year" dimension)
  • market objects should (usually) cover two years: current year and investment year
  • same (usually) for capacity data

I've moved decommissioning_demand to the demand_share module as this seems like a more sensible place for it to belong

I've updated the tests, but they're still a mess to be honest and could do with a complete rewrite

In working through this I spotted a bug which I've market with a TODO - I'll fix this in a separate PR as I wanted this PR to be a pure refactor (not changing any results)

@tsmbland tsmbland marked this pull request as ready for review January 16, 2025 18:42
@tsmbland tsmbland merged commit 4eca5f7 into main Jan 17, 2025
14 checks passed
@tsmbland tsmbland deleted the demand_share branch January 17, 2025 10:10
@tsmbland tsmbland mentioned this pull request Jan 17, 2025
8 tasks
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.

1 participant