diff --git a/input_profile_processor/input_profile_processor.py b/input_profile_processor/input_profile_processor.py index 6d26a6e0b273ac0171e69d85ebf3c180191c9ee2..1eb70e040af43540a9951715b284b83564c83e16 100644 --- a/input_profile_processor/input_profile_processor.py +++ b/input_profile_processor/input_profile_processor.py @@ -31,7 +31,7 @@ from datetime import datetime, timedelta import pandas as pd 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: # 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 @@ -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(): 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(): index = 0 drop = [] - for position in range(dynamic.number_of_steps()): - if dynamic.step_size_p(position) != d_step_min: - number_of_steps = int(dynamic.step_size_p(position) / 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) + for index in dynamic.time_steps(): + if dynamic.step_size(index) != 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(index) drop.extend(index + i + 1 for i in range(number_of_steps - 1)) index += number_of_steps else: @@ -99,7 +99,7 @@ def expand_profile_to_year(profile, year, t_step): return profile 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) try: 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): 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): - 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) if profile_type == 'elec_demand':