Skip to content
Snippets Groups Projects
Commit e5ccdd9a authored by Christoph von Oy's avatar Christoph von Oy
Browse files

Refactored dynamics

parent 0e393a62
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ from datetime import datetime, timedelta ...@@ -31,7 +31,7 @@ from datetime import datetime, timedelta
import pandas as pd import pandas as pd
def process_input_profiles(input_profile_dict, t_start, dynamic): def process_input_profiles(input_profile_dict, t_start, dynamic):
d_step_min = min(dynamic.step_size_p(position) for position in range(dynamic.number_of_steps())) d_step_min = min(dynamic.step_size(index) for index in dynamic.time_steps())
# This entire process assumes four things: # This entire process assumes four things:
# 1. d_step_min devides a day into an integer amount of steps # 1. d_step_min devides a day into an integer amount of steps
# 2. d_step_min devides the intervall from YYYY.MM.DD 00:00:00 of the day containing t_start to t_start into an integer amount of steps # 2. d_step_min devides the intervall from YYYY.MM.DD 00:00:00 of the day containing t_start to t_start into an integer amount of steps
...@@ -49,15 +49,15 @@ def process_input_profiles(input_profile_dict, t_start, dynamic): ...@@ -49,15 +49,15 @@ def process_input_profiles(input_profile_dict, t_start, dynamic):
for input_profile_name, (input_profile_type, input_profile) in input_profiles.items(): for input_profile_name, (input_profile_type, input_profile) in input_profiles.items():
input_profile.drop(pd.date_range(input_profile.index[0], t_start - timedelta(hours = d_step_min), freq = str(d_step_min) + 'H'), inplace = True) input_profile.drop(pd.date_range(input_profile.index[0], t_start - timedelta(hours = d_step_min), freq = str(d_step_min) + 'H'), inplace = True)
input_profile.drop(pd.date_range(t_start + pd.Timedelta(hours = sum(dynamic.step_size_p(position) for position in range(dynamic.number_of_steps()))), input_profile.index[-1], freq = str(d_step_min) + 'H'), inplace = True) input_profile.drop(pd.date_range(t_start + pd.Timedelta(hours = sum(dynamic.step_size(index) for index in dynamic.time_steps())), input_profile.index[-1], freq = str(d_step_min) + 'H'), inplace = True)
if len(input_profile) != dynamic.number_of_steps(): if len(input_profile) != dynamic.number_of_steps():
index = 0 index = 0
drop = [] drop = []
for position in range(dynamic.number_of_steps()): for index in dynamic.time_steps():
if dynamic.step_size_p(position) != d_step_min: if dynamic.step_size(index) != d_step_min:
number_of_steps = int(dynamic.step_size_p(position) / d_step_min) number_of_steps = int(dynamic.step_size(index) / d_step_min)
input_profile.iloc[index] = sum(d_step_min * input_profile.iloc[index + i] for i in range(number_of_steps)) / dynamic.step_size_p(position) input_profile.iloc[index] = sum(d_step_min * input_profile.iloc[index + i] for i in range(number_of_steps)) / dynamic.step_size(index)
drop.extend(index + i + 1 for i in range(number_of_steps - 1)) drop.extend(index + i + 1 for i in range(number_of_steps - 1))
index += number_of_steps index += number_of_steps
else: else:
...@@ -99,7 +99,7 @@ def expand_profile_to_year(profile, year, t_step): ...@@ -99,7 +99,7 @@ def expand_profile_to_year(profile, year, t_step):
return profile return profile
def load_profile(name, file, t_start, dynamic, d_step_min): def load_profile(name, file, t_start, dynamic, d_step_min):
t_last = t_start + pd.Timedelta(hours = sum(dynamic.step_size_p(position) for position in range(dynamic.number_of_steps() - 1))) t_last = t_start + pd.Timedelta(hours = sum(dynamic.step_size(index) for index in dynamic.time_steps()) - 1)
profile = pd.read_csv(file, index_col = 0) profile = pd.read_csv(file, index_col = 0)
try: try:
file_start = pd.to_datetime(profile.index[0], format = '%d-%m-%Y %H:%M:%S') file_start = pd.to_datetime(profile.index[0], format = '%d-%m-%Y %H:%M:%S')
...@@ -155,7 +155,7 @@ def load_profile(name, file, t_start, dynamic, d_step_min): ...@@ -155,7 +155,7 @@ def load_profile(name, file, t_start, dynamic, d_step_min):
return resample_profile(name, profile, t_start, dynamic, d_step_min, t_last) return resample_profile(name, profile, t_start, dynamic, d_step_min, t_last)
def generate_profile(name, profile_type, parameters, input_profiles, t_start, dynamic, d_step_min): def generate_profile(name, profile_type, parameters, input_profiles, t_start, dynamic, d_step_min):
t_last = t_start + pd.Timedelta(hours = sum(dynamic.step_size_p(position) for position in range(dynamic.number_of_steps() - 1))) t_last = t_start + pd.Timedelta(hours = sum(dynamic.step_size(index) for index in list(dynamic.time_steps())[:-1]))
years = range(t_start.year, t_last.year + 1) years = range(t_start.year, t_last.year + 1)
if profile_type == 'elec_demand': if profile_type == 'elec_demand':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment