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 capacity additions and retirements to statistics #760

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

coroa
Copy link
Member

@coroa coroa commented Oct 19, 2023

Adds a new when argument to only optimal_capacity add the moment, which allows switching from selecting power plants, which are "active" in a given investment period to only show them at their "build_year" or at their "retirement" year.

Not super happy with the names so fishing for suggestions and also comments on which other variables would benefit from such a scope.

@coroa coroa changed the base branch from fix-globalconstraints-primaryenergylimit to master October 19, 2023 14:18
@coroa coroa requested a review from lisazeyen October 19, 2023 14:18
df = pd.concat(per_period, axis=1)
elif when in ("build_year", "retirement") and groupby_kwargs is not None:
# TODO uses 9999 as the sentinel value for after modelling period
investment_periods = pd.Index(np.r_[n.investment_periods, 9999])
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe to make it clear just add one line

SENTINEL_YEAR = 9999
investment_periods = pd.Index(np.r_[n.investment_periods, SENTINEL_YEAR])

period = investment_periods[0 if when == "build_year" else -1]
else:
year = n.df(c)["build_year"]
if when == "retirement":
Copy link
Contributor

Choose a reason for hiding this comment

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

we should add to the description that retirement is the first year the asset is not operating anymore

if when == "retirement":
year += n.df(c)["lifetime"]

period = investment_periods[
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't tested it but is it necessary to define the period or can we just groupby year?

per_period[p] = df[n.get_active_assets(c, p).loc[df.index]]
df = pd.concat(per_period, axis=1)

if isinstance(n.snapshots, pd.MultiIndex):
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this functionality is also useful for running myopic code where you don't have a multi-index snapshot but still the information about build year and lifetime

@lisazeyen
Copy link
Contributor

Great! I only have some minor comments. I can't come up with better names, sorry! I think they one suggested are fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants