Skip to content

fix: using inactive generators in global carrier constraint#1450

Merged
lkstrp merged 6 commits intoPyPSA:masterfrom
lkstrp:fix-1449
Dec 2, 2025
Merged

fix: using inactive generators in global carrier constraint#1450
lkstrp merged 6 commits intoPyPSA:masterfrom
lkstrp:fix-1449

Conversation

@lkstrp
Copy link
Copy Markdown
Member

@lkstrp lkstrp commented Nov 25, 2025

Closes #1449

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in docs.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes docs/release-notes.md of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

Copy link
Copy Markdown
Contributor

@FabianHofmann FabianHofmann left a comment

Choose a reason for hiding this comment

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

We are not fully there yet. The stores are missing in the filtering. also the investment periods are not considered in the filtering process. For multi-invest problems this will now only filter based on the static active columns. I would push provide a small fix for that, if you agree?

- Add filter_active() supporting DataFrame and Index filtering
- Support single/multiple investment periods for multi-invest
- Simplify global_constraints.py using new method
- Fix missing active filtering for stores in primary_energy_limit
@lkstrp
Copy link
Copy Markdown
Member Author

lkstrp commented Dec 1, 2025

Thanks for adding @FabianHofmann ! You are right, it's also cleaner to add a dedicated method for it.

I would just further move it around. We now have c.filter_active, c.get_active_assets and c.get_activity_mask, which is quite confusing. We can probably deprecatec.get_activity_mask and move it to using c.da.active instead. But c.filter_active and c.get_active_assets are very similar, and if you don't pass data which isn't clean method functionality anyway, you would retrieve the nearly same results (index vs sliced df). What about just renaming to filter_by_active_assets next to get_active_assets and maybe removing the default self.static for data? Alternatively, we could also fully move it to to a helper in common.py a la filter_by_active_assets(c, your_df).

@FabianHofmann
Copy link
Copy Markdown
Contributor

sure thing! you are right about the three parallel methods (forgot about get_activity_mask).

What about just renaming to filter_by_active_assets next to get_active_assets and maybe removing the default self.static for data?

I like that, will do that

FabianHofmann and others added 4 commits December 1, 2025 18:13
- Rename method to better distinguish from get_active_assets
- Make data parameter required (remove self.static default)
- Update all usages in global_constraints.py
@lkstrp lkstrp enabled auto-merge (squash) December 2, 2025 08:57
@lkstrp lkstrp disabled auto-merge December 2, 2025 12:54
@lkstrp lkstrp merged commit 7460437 into PyPSA:master Dec 2, 2025
20 of 21 checks passed
a-buntjer pushed a commit to a-buntjer/PyPSA that referenced this pull request Dec 4, 2025
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.

Non-active generator with carrier and global carrier constraint causes error

2 participants