Skip to content
Snippets Groups Projects
Commit 33a33b4b authored by Martin Schnitzler's avatar Martin Schnitzler
Browse files

Properly added remaining profile types for demand generators

parent f0a91a38
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,6 @@ import pandas as pd
# profiles from https://www.bdew.de/energie/standardlastprofile-strom/
class ElectricityDemandGenerator:
def __init__(self):
# load profiles (Hardcoded H0: Haushalt)
# TODO: sort the csv by its index
profiles_df = pd.read_csv(
os.path.join(os.path.dirname(__file__), "selp.csv"), index_col=[0, 1]
......@@ -72,6 +71,7 @@ class ElectricityDemandGenerator:
def generate(self, year, annual_demand, profile_type="H0"):
# year: year to generate the data for in astronomical numbering
# annual_demand: annual electricity demand in kWh
# profile_type: profile type to generate, e.g. H0, G0, etc.
# days in the year, depending on wehter the given year a leap year
......@@ -118,13 +118,13 @@ class ElectricityDemandGenerator:
# profile source P2007/13 https://www.eichsfeldwerke.de/fileadmin/user_upload/Praxisinformation_P2007_13.pdf
class HeatingDemandGenerator:
def __init__(self):
# load factors (Hardcoded D13/DE_HEF03: Deutschland, bundesweit, Einfamilienhaushalt, Ausprägung o)
# load factors
profiles_df = pd.read_csv(
os.path.join(os.path.dirname(__file__), "shlp.csv"), index_col=0
)
hour_factors_df = pd.read_csv(
os.path.join(os.path.dirname(__file__), "shlp_hour_factors.csv"),
index_col=[0, 1],
index_col=[0, 1, 2],
)
self.a = profiles_df["A"]
......@@ -134,6 +134,7 @@ class HeatingDemandGenerator:
self.theta_0 = profiles_df["theta_0"]
#load weekday factors and hour factors into dictionaries indexed by profile
self.weekday_factors = dict()
for profile in profiles_df.index:
......@@ -141,30 +142,32 @@ class HeatingDemandGenerator:
profile, ["F_Mon", "F_Tue", "F_Wed", "F_Thu", "F_Fri", "F_Sat", "F_Sun"]
].values
# self.weekday_factors = profiles_df.loc[
# "D13", ["F_Mon", "F_Tue", "F_Wed", "F_Thu", "F_Fri", "F_Sat", "F_Sun"]
# ].values
#create hour factors dictionary with the different profiles
self.hour_factors = dict()
for profile in hour_factors_df.index.get_level_values(0).unique():
self.hour_factors[profile] = hour_factors_df.loc[profile].values
self.hour_factors[profile] = hour_factors_df.loc[profile].to_dict()
#self.hour_factors = hour_factors_df.loc["D13"].values
def generate(self, year, annual_demand, temperatures, seperate_warm_water=False, profile_type="D13"):
def generate(self, profile_type, year, annual_demand, temperatures, seperate_warm_water=False):
# year: year to generate the data for in astronomical numbering
# annual_demand: annual heating demand in kWh
# temperatures: daily temperatures in °C
# seperate_warm_water: if set to false, the function returns one heating demand profile, if set to true, the function returns two demand profiles, the first is the heating demand withoud the warm water demand and the second is the warm water demand
# profile_type: profile type to generate, e.g. D13, D23, etc.
# seperate_warm_water: if set to false, the function ret^urns one heating demand profile, if set to true, the function returns two demand profiles, the first is the heating demand without the warm water demand and the second is the warm water demand
# days in the year, depending on if the given year is a leap year
#TODO: implement error handling
# days in the year, depending on wehter the given year a leap year
days_in_year = 365 if not calendar.isleap(year) else 366
if len(temperatures) != days_in_year:
raise ValueError(f"Lengh of daily tamperatures has to be {days_in_year}!")
# compute geometric mean of the temperatures
# compute geometric mean of the temperatures to smooth out temperature fluctuations
allocation_temperatures = (
temperatures
+ 0.5 * np.roll(temperatures, 1)
......@@ -183,11 +186,13 @@ class HeatingDemandGenerator:
dtype=float,
)
hour_factors = self.hour_factors[profile_type] if profile_type in self.hour_factors.keys() else self.hour_factors["D13"]
f_h = np.empty((days_in_year,24),dtype=float)
f_h = hour_factors[
(
(allocation_temperatures <= -15.0) * 1
weekdays=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"]
for i, date in enumerate(pd.date_range(datetime.datetime(year, 1, 1), periods=days_in_year)):
weekday = date.weekday()
temperature_range = (((allocation_temperatures <= -15.0) * 1
+ (
(-15.0 < allocation_temperatures)
& (allocation_temperatures <= -10.0)
......@@ -212,8 +217,10 @@ class HeatingDemandGenerator:
* 9
+ (25.0 < allocation_temperatures) * 10
)
- 1
]
- 1)
for j in range(24):
f_h[i, j] = self.hour_factors[profile_type[:-1]][str(j)][(temperature_range[j], weekdays[weekday])]
# compute reference daily demand (kundenwert)
reference_temp = self.b[profile_type] / (np.full(days_in_year, 8.0, dtype=float) - 40.0)
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment