Skip to content

Commit d3db2bb

Browse files
authored
Merge pull request #83 from oemof/fix/vdi-leap-year
Fix leap year handling in VDI
2 parents e143ec4 + 07b57ec commit d3db2bb

3 files changed

Lines changed: 21 additions & 10 deletions

File tree

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ New features
99

1010
Bug fixes
1111
#########
12+
* Fix leap year handling in VDI 4655 profiles
1213

1314
Other changes
1415
#############

src/demandlib/vdi/regions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def _load_profile_factors(self, tl):
343343
# Create a table for every minute of the year
344344
minute_table = pd.DataFrame(
345345
index=pd.date_range(
346-
f"1/1/{self._year}", periods=525600, freq="Min"
346+
f"1/1/{self._year}", periods=self.hoy * 60, freq="Min"
347347
)
348348
)
349349

tests/test_vdi4655.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,25 @@ def test_resample_rule(self, example_houses):
105105
# Quarter-hourly data should have 4 times as many entries
106106
assert len(load_curves_quarter) == len(load_curves_hourly) * 4
107107

108-
def test_leap_year(self):
109-
"""Test handling of leap years."""
110-
# region_leap = Region(2020, try_region=4) # Leap year
111-
region_normal = Region(
112-
2017, Climate().from_try_data(4)
113-
) # Non-leap year
114-
115-
# assert region_leap.hoy == 8784 # Hours in leap year
116-
assert region_normal.hoy == 8760 # Hours in normal year
108+
def test_leap_year(self, example_houses, example_holidays):
109+
"""Test generation of load curves for leap year."""
110+
climate = Climate().from_try_data(4)
111+
climate.temperature = pd.concat(
112+
[climate.temperature, climate.temperature.iloc[[-1]]]
113+
)
114+
climate.cloud_coverage = pd.concat(
115+
[climate.cloud_coverage, climate.cloud_coverage.iloc[[-1]]]
116+
)
117+
118+
region = Region(
119+
2024,
120+
climate=climate,
121+
houses=example_houses,
122+
holidays=example_holidays,
123+
resample_rule="1h",
124+
)
125+
load_curves = region.get_load_curve_houses()
126+
assert len(load_curves) == 8784 # 366 days * 24 hours
117127

118128
def test_temperature_limits(self, example_houses):
119129
"""Test custom temperature limits."""

0 commit comments

Comments
 (0)