Skip to content

Commit 331ed06

Browse files
committed
Improve weights
1 parent da3f29f commit 331ed06

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

flixopt/flow_system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__(
7676
If None, the first time increment of time_series is used.
7777
This is needed to calculate previous durations (for example consecutive_on_hours).
7878
If you use an array, take care that its long enough to cover all previous values!
79-
weights: The weights of each year and scenario. If None, all have the same weight (normalized to 1). Its recommended to scale the weights to sum up to 1.
79+
weights: The weights of each year and scenario. If None, all scenarios have the same weight, while the years have the weight of their represented year (all normalized to 1). Its recommended to scale the weights to sum up to 1.
8080
"""
8181
self.timesteps = self._validate_timesteps(timesteps)
8282
self.timesteps_extra = self._create_timesteps_with_extra(timesteps, hours_of_last_timestep)

flixopt/structure.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ def get_coords(
178178
def weights(self) -> Union[int, xr.DataArray]:
179179
"""Returns the scenario weights of the FlowSystem. If None, return weights that are normalized to 1 (one)"""
180180
if self.flow_system.weights is None:
181-
weights = self.flow_system.fit_to_model_coords('weights', 1, dims=['year', 'scenario'])
181+
weights = self.flow_system.fit_to_model_coords(
182+
'weights', self.flow_system.years_per_year, dims=['year', 'scenario']
183+
)
182184

183185
return weights / weights.sum()
184186

0 commit comments

Comments
 (0)