|
1
|
|
|
""" |
|
2
|
|
|
SPDX-FileCopyrightText: Patrik Schönfeldt |
|
3
|
|
|
SPDX-FileCopyrightText: DLR e.V. |
|
4
|
|
|
|
|
5
|
|
|
SPDX-License-Identifier: MIT |
|
6
|
|
|
""" |
|
7
|
|
|
|
|
8
|
|
|
from pathlib import Path |
|
9
|
|
|
|
|
10
|
|
|
import demandlib |
|
11
|
|
|
import pandas as pd |
|
12
|
|
|
import numpy as np |
|
13
|
|
|
from urllib.request import urlretrieve |
|
14
|
|
|
from workalendar.europe import Germany |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
def prepare_input_data(): |
|
18
|
|
|
url_temperature = ( |
|
19
|
|
|
"https://oemof.org/wp-content/uploads/2025/12/temperature.csv" |
|
20
|
|
|
) |
|
21
|
|
|
url_energy = "https://oemof.org/wp-content/uploads/2025/12/energy.csv" |
|
22
|
|
|
|
|
23
|
|
|
print( |
|
24
|
|
|
"Data is licensed from M. Schlemminger, T. Ohrdes, E. Schneider," |
|
25
|
|
|
" and M. Knoop. Under Creative Commons Attribution 4.0 International" |
|
26
|
|
|
" License. It is also available at doi: 10.5281/zenodo.5642902." |
|
27
|
|
|
" (We use single family home 26 plus the south-facing PV" |
|
28
|
|
|
" from that dataset.)" |
|
29
|
|
|
) |
|
30
|
|
|
|
|
31
|
|
|
file_path = Path(__file__).parent |
|
32
|
|
|
|
|
33
|
|
|
temperature_file = Path(file_path, "temperature.csv") |
|
34
|
|
|
if not temperature_file.exists(): |
|
35
|
|
|
urlretrieve(url_temperature, temperature_file) |
|
36
|
|
|
df_temperature = pd.read_csv( |
|
37
|
|
|
temperature_file, |
|
38
|
|
|
index_col="Unix Epoch", |
|
39
|
|
|
) |
|
40
|
|
|
timedelta = np.empty(len(df_temperature)) |
|
41
|
|
|
timedelta[:-1] = ( |
|
42
|
|
|
df_temperature.index[1:] - df_temperature.index[:-1] |
|
43
|
|
|
) / 3600 |
|
44
|
|
|
timedelta[-1] = np.nan |
|
45
|
|
|
|
|
46
|
|
|
df_temperature.index = pd.to_datetime( |
|
47
|
|
|
df_temperature.index, |
|
48
|
|
|
unit="s", |
|
49
|
|
|
utc=True, |
|
50
|
|
|
) |
|
51
|
|
|
|
|
52
|
|
|
building_area = 120 # m² (from publication) |
|
53
|
|
|
specific_heat_demand = 60 # kWh/m²/a (educated guess) |
|
54
|
|
|
holidays = dict(Germany().holidays(2019)) |
|
55
|
|
|
|
|
56
|
|
|
# We estimate the heat demand from the ambient temperature using demandlib. |
|
57
|
|
|
# This returns energy per time step in units of kWh. |
|
58
|
|
|
df_temperature["heat demand (kWh)"] = demandlib.bdew.HeatBuilding( |
|
59
|
|
|
df_temperature.index, |
|
60
|
|
|
holidays=holidays, |
|
61
|
|
|
temperature=df_temperature["Air Temperature (°C)"], |
|
62
|
|
|
shlp_type="EFH", |
|
63
|
|
|
building_class=1, |
|
64
|
|
|
wind_class=1, |
|
65
|
|
|
annual_heat_demand=building_area * specific_heat_demand, |
|
66
|
|
|
name="EFH", |
|
67
|
|
|
).get_bdew_profile() |
|
68
|
|
|
|
|
69
|
|
|
df_temperature["heat demand (W)"] = ( |
|
70
|
|
|
df_temperature["heat demand (kWh)"] * 1e3 / timedelta |
|
71
|
|
|
) |
|
72
|
|
|
|
|
73
|
|
|
energy_file = Path(file_path, "energy.csv") |
|
74
|
|
|
if not energy_file.exists(): |
|
75
|
|
|
urlretrieve(url_energy, energy_file) |
|
76
|
|
|
df_engergy = pd.read_csv( |
|
77
|
|
|
energy_file, |
|
78
|
|
|
index_col=0, |
|
79
|
|
|
) |
|
80
|
|
|
df_engergy.index = pd.to_datetime( |
|
81
|
|
|
df_engergy.index, |
|
82
|
|
|
unit="s", |
|
83
|
|
|
utc=True, |
|
84
|
|
|
) |
|
85
|
|
|
|
|
86
|
|
|
print(df_engergy) |
|
87
|
|
|
print(df_temperature) |
|
88
|
|
|
|
|
89
|
|
|
|
|
90
|
|
|
if __name__ == "__main__": |
|
91
|
|
|
prepare_input_data() |
|
92
|
|
|
|