Skip to content

Commit 62e0ce8

Browse files
committed
1. Rolling horizon notebook (08b-rolling-horizon.ipynb): Fixed arithmetic in cells 7 and 8 to reflect correct 1h resolution (336 timesteps, 96 per 4-day segment)
2. dataset_plot_accessor.py: Moved import numpy as np from inline (line 756) to module level imports 3. statistics_accessor.py: Added clarifying comment for the +100 offset strategy used for secondary y-axes
1 parent bfe3624 commit 62e0ce8

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

docs/notebooks/08b-rolling-horizon.ipynb

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@
111111
"The `optimize.rolling_horizon()` method divides the time horizon into segments that are solved sequentially:\n",
112112
"\n",
113113
"```\n",
114-
"Full horizon: |---------- 1344 timesteps (14 days) ----------|\n",
114+
"Full horizon: |---------- 336 timesteps (14 days) ----------|\n",
115115
" \n",
116-
"Segment 1: |==== 192 (2 days) ====|-- overlap --|\n",
117-
"Segment 2: |==== 192 (2 days) ====|-- overlap --|\n",
118-
"Segment 3: |==== 192 (2 days) ====|-- overlap --|\n",
116+
"Segment 1: |==== 96 (4 days) ====|-- overlap --|\n",
117+
"Segment 2: |==== 96 (4 days) ====|-- overlap --|\n",
118+
"Segment 3: |==== 96 (4 days) ====|-- overlap --|\n",
119119
"... \n",
120120
"```\n",
121121
"\n",
@@ -137,7 +137,7 @@
137137
"fs_rolling.name = 'Rolling Horizon'\n",
138138
"segments = fs_rolling.optimize.rolling_horizon(\n",
139139
" solver,\n",
140-
" horizon=96, # 2-day segments (192 timesteps at 15-min resolution)\n",
140+
" horizon=96, # 4-day segments (96 timesteps at 1h resolution)\n",
141141
" overlap=24, # 1-day lookahead\n",
142142
")\n",
143143
"time_rolling = timeit.default_timer() - start\n",
@@ -372,6 +372,18 @@
372372
"display_name": "Python 3 (ipykernel)",
373373
"language": "python",
374374
"name": "python3"
375+
},
376+
"language_info": {
377+
"codemirror_mode": {
378+
"name": "ipython",
379+
"version": 3
380+
},
381+
"file_extension": ".py",
382+
"mimetype": "text/x-python",
383+
"name": "python",
384+
"nbconvert_exporter": "python",
385+
"pygments_lexer": "ipython3",
386+
"version": "3.11.11"
375387
}
376388
},
377389
"nbformat": 4,

flixopt/dataset_plot_accessor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import warnings
66
from typing import Any, Literal
77

8+
import numpy as np
89
import pandas as pd
910
import plotly.express as px
1011
import plotly.graph_objects as go
@@ -753,8 +754,6 @@ def to_duration_curve(self, *, normalize: bool = True) -> xr.Dataset:
753754
Example:
754755
>>> ds.fxstats.to_duration_curve().fxplot.line(title='Duration Curve')
755756
"""
756-
import numpy as np
757-
758757
if 'time' not in self._ds.dims:
759758
raise ValueError("Duration curve requires a 'time' dimension.")
760759

flixopt/statistics_accessor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,6 +2104,7 @@ def storage(
21042104
primary_yaxes = [key for key in fig.layout if key.startswith('yaxis')]
21052105

21062106
# For each primary y-axis, create a secondary y-axis
2107+
# Use +100 offset to ensure secondary axes don't conflict with plotly's auto-generated axis numbers
21072108
for i, primary_key in enumerate(sorted(primary_yaxes, key=lambda x: int(x[5:]) if x[5:] else 0)):
21082109
primary_num = primary_key[5:] if primary_key[5:] else '1'
21092110
secondary_num = int(primary_num) + 100

0 commit comments

Comments
 (0)