Skip to content

Fix handling of inactive storage components in constraints/variables#1442

Merged
lkstrp merged 5 commits intomasterfrom
fix-activity-mask
Nov 17, 2025
Merged

Fix handling of inactive storage components in constraints/variables#1442
lkstrp merged 5 commits intomasterfrom
fix-activity-mask

Conversation

@Irieo
Copy link
Copy Markdown
Contributor

@Irieo Irieo commented Nov 17, 2025

Closes #1440

Changes proposed in this Pull Request

This PR fixes two problems related to active/inactive attr handling. First was connected to xarray alignment error when some storage components have active=False due to unfiltered data arrays being combined with filtered variables. Second was connected to spillage variable fail when all StorageUnits are inactive due to empty array issue.

Thanks @SpamAndEgg for spotting these.

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.

@Irieo Irieo requested a review from lkstrp November 17, 2025 15:01
@lkstrp lkstrp merged commit 1586423 into master Nov 17, 2025
21 of 22 checks passed
@lkstrp lkstrp deleted the fix-activity-mask branch November 17, 2025 16:20
a-buntjer pushed a commit to a-buntjer/PyPSA that referenced this pull request Nov 27, 2025
Merged changes from PyPSA v1.0.3 and v1.0.4 including:
- Fix busmap clustering for multilinks (PyPSA#1441)
- Fix handling of inactive storage components (PyPSA#1442)
- Fix masking of nan constraints in kvl (PyPSA#1438)
- Fix snapshot selection for operational in multi period (PyPSA#1437)
- Fix ramping-/rolling horizon logic (PyPSA#1428)
- CI improvements and dependency updates

Resolved conflicts in pypsa/optimization/constraints.py:
- Used upstream's c.active_assets approach (cleaner, already handles MultiIndex)
- Preserved our stochastic Store constraint fix (transpose for dimension alignment)
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 StorageUnit causes bug when writing constraints

2 participants