Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ New features

Bug fixes
#########
* Fix leap year handling in VDI 4655 profiles

Other changes
#############
Expand Down
2 changes: 1 addition & 1 deletion src/demandlib/vdi/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def _load_profile_factors(self, tl):
# Create a table for every minute of the year
minute_table = pd.DataFrame(
index=pd.date_range(
f"1/1/{self._year}", periods=525600, freq="Min"
f"1/1/{self._year}", periods=self.hoy * 60, freq="Min"
)
)

Expand Down
28 changes: 19 additions & 9 deletions tests/test_vdi4655.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,25 @@ def test_resample_rule(self, example_houses):
# Quarter-hourly data should have 4 times as many entries
assert len(load_curves_quarter) == len(load_curves_hourly) * 4

def test_leap_year(self):
"""Test handling of leap years."""
# region_leap = Region(2020, try_region=4) # Leap year
region_normal = Region(
2017, Climate().from_try_data(4)
) # Non-leap year

# assert region_leap.hoy == 8784 # Hours in leap year
assert region_normal.hoy == 8760 # Hours in normal year
def test_leap_year(self, example_houses, example_holidays):
"""Test generation of load curves for leap year."""
climate = Climate().from_try_data(4)
climate.temperature = pd.concat(
[climate.temperature, climate.temperature.iloc[[-1]]]
)
climate.cloud_coverage = pd.concat(
[climate.cloud_coverage, climate.cloud_coverage.iloc[[-1]]]
)

region = Region(
2024,
climate=climate,
houses=example_houses,
holidays=example_holidays,
resample_rule="1h",
)
load_curves = region.get_load_curve_houses()
assert len(load_curves) == 8784 # 366 days * 24 hours

def test_temperature_limits(self, example_houses):
"""Test custom temperature limits."""
Expand Down
Loading