diff --git a/input_profile_processor/input_profile_processor.py b/input_profile_processor/input_profile_processor.py index 639d6379417850181afb6b4cee90e75c48c9e786..e4f96db7e8aada0beab15d1518ffaeda76db77ea 100644 --- a/input_profile_processor/input_profile_processor.py +++ b/input_profile_processor/input_profile_processor.py @@ -29,10 +29,11 @@ from Tooling.input_profile_processor.calc_irradiance import generate_g_t_series from Tooling.modifier import Modifier from datetime import datetime, timedelta +import numpy as np import pandas as pd def process_input_profiles(input_profile_dict, t_start, dynamic): - d_step_min = min(dynamic.step_size(index) for index in dynamic.time_steps()) + d_step_min = np.min(dynamic.step_lengths()) / 3600.0 # 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 @@ -50,7 +51,7 @@ 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(index) for index in dynamic.time_steps())), input_profile.index[-1], freq = str(d_step_min) + 'H'), inplace = True) + input_profile.drop(pd.date_range(t_start + pd.Timedelta(hours = np.sum(dynamic.step_lengths()) / 3600.0), input_profile.index[-1], freq = str(d_step_min) + 'H'), inplace = True) if len(input_profile) != dynamic.number_of_steps(): index = 0 @@ -75,7 +76,10 @@ def process_input_profiles(input_profile_dict, t_start, dynamic): input_profile = input_profile.squeeze() input_profile.set_axis(list(range(dynamic.number_of_steps())), inplace = True) - input_profiles[input_profile_name] = Profile(input_profile, dynamic) + if isinstance(input_profile, pd.Series): + input_profiles[input_profile_name] = Profile(input_profile.values, dynamic) + else: + input_profiles[input_profile_name] = Profile(input_profile, dynamic) return input_profiles def resample_profile(name, profile, t_start, dynamic, d_step_min, t_last): @@ -100,7 +104,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(index) for index in dynamic.time_steps()) - 1) + t_last = t_start + pd.Timedelta(hours = np.sum(dynamic.step_lengths()[:-1]) / 3600.0) profile = pd.read_csv(file, index_col = 0) try: file_start = pd.to_datetime(profile.index[0], format = '%d-%m-%Y %H:%M:%S') @@ -156,7 +160,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(index) for index in list(dynamic.time_steps())[:-1])) + t_last = t_start + pd.Timedelta(hours = np.sum(dynamic.step_lengths()[:-1]) / 3600.0) years = range(t_start.year, t_last.year + 1) if profile_type == 'electricity_demand':