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

Profiles use numpy arrays now

parent 18a1cbc8
No related branches found
No related tags found
No related merge requests found
......@@ -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,6 +76,9 @@ 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)
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
......@@ -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':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment