Skip to content

Support for data indexed over PeriodPartitions - #58

Open
JulStraus wants to merge 9 commits into
mainfrom
fix/partition_profile
Open

JulStraus wants to merge 9 commits into
mainfrom
fix/partition_profile

Conversation

@JulStraus

Copy link
Copy Markdown
Member

This PR closes #55.

TimeStruct v0.9.12 introduced PeriodPartitions, which are used, e.g., by the PeriodDemandSink of EnergyModelsFlex (PartitionProfile fields and the variables demand_sink_*[n, pd]). The GUI crashed on such models. This PR adds support for visualizing partition-indexed data, both from a JuMP.Model and from CSV files.

The implementation is tested through incorporating a PeriodDemandSink to the case7 test set. However, I think we should rework the test set. Currently, the location of the individual required files is spread over the examples and the test set, even if, e.g., examples/utils.jl is only required in the test set and not the examples.

Important

I plan to run through the documentation and docstrings in a different PR after this one. This is the reason why I have not yet increased the version number yet.

Main changes

  • Partition time axis. A new Partition option in the time menu plots data indexed over PeriodPartitions (JuMP variables and PartitionProfile fields). It is only offered for elements that have such data; the standard axes are unchanged.
  • Partitions are determined per element. Partitions differ between elements and are not TimePeriods, so they are extracted from the variable itself or built from the element. The new function EnergyModelsGUI.period_partitions(element, 𝒯) by default uses the field period_duration. Packages whose elements follow another convention can add a method for their type; without it, a warning names the element and the method to provide, and the element's partition data is skipped instead of raising an error.
  • CSV results. save_results writes partition indices in a pd column (it previously threw a MethodError). As the partition labels are not unique across elements, the CSV reader rebuilds them per element through period_partitions, so the hook above also governs reading results from files.

Also included

  • Bugfix: re-applying stored axis limits of plots of constant data crashed Makie because the limits degenerate in Float32 precision.
  • Descriptive names for AbstractPeriodDemandSink/StratPeriodDemandSink and the demand_sink_* variables.

The PR was created with with Claude Code as can be seen from the individual commits. All commits were however reviewed by myself to avoid any potential problems in the code structure.

JulStraus and others added 9 commits October 7, 2026 09:57
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JulStraus
JulStraus requested a review from dqpinel October 7, 2026 12:20
@JulStraus JulStraus added the bug Something isn't working label Oct 7, 2026
@JulStraus
JulStraus requested a review from Zetison October 7, 2026 12:20

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PeriodPartition breaks EMGUI

1 participant