From 78d47195cfd18645b85e1e9c14da50c84ce539cb Mon Sep 17 00:00:00 2001 From: "christoph.von.oy" <christoph.von.oy@rwth-aachen.de> Date: Thu, 15 Jun 2023 11:34:52 +0200 Subject: [PATCH] Made t_step and t_horizon be interpreted correctly Fixed focus-framework#44 --- input_profile_processor/calc_irradiance.py | 40 ++----------------- .../input_profile_processor.py | 2 +- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/input_profile_processor/calc_irradiance.py b/input_profile_processor/calc_irradiance.py index e127c03..4e8fd9e 100644 --- a/input_profile_processor/calc_irradiance.py +++ b/input_profile_processor/calc_irradiance.py @@ -26,27 +26,7 @@ import numpy as np import pandas as pd from datetime import timedelta - -def set_dates(t_start, t_horizon, t_step): - """ - The method XYZ adds ... - :param - XYZ: - :returns - XYZ - """ - - time_steps = [] - for t in pd.date_range(pd.Timestamp(t_start), pd.Timestamp(t_start) + - timedelta(hours=t_horizon) - - timedelta(hours=t_step), - freq=str(t_step) + 'H'): - time_steps.append(t) - return time_steps - - -def calc_total_irradiance(irradiance, timer, beta, psi_f, phi, lambda_st, lambda_1, alpha_albedo=0.2, reflection=1, - refraction_index=2): +def calc_total_irradiance(irradiance, timer, beta, psi_f, phi, lambda_st, lambda_1, alpha_albedo=0.2, reflection=1, refraction_index=2): """ check value: alpha_albedo: ground reflectivity Reflection = 1? @@ -138,22 +118,10 @@ def calc_total_irradiance(irradiance, timer, beta, psi_f, phi, lambda_st, lambda g_total = g_diffuse + g_reflected + g_beam return g_total - def generate_g_t_series(irradiance, beta, psi_f, phi, lambda_st, lambda_1, t_start, t_horizon, t_step): - """ - The method XYZ adds ... - :param - XYZ: - :returns - XYZ - """ - - T = set_dates(t_start, t_horizon, t_step) + T = list(pd.date_range(pd.Timestamp(t_start), pd.Timestamp(t_start) + timedelta(hours=t_horizon * t_step - t_step), freq=str(t_step) + 'H')) g_total_lst = [] - - for itr in range(len(T)): - timer = T[itr] - g_total = calc_total_irradiance(irradiance.loc[timer], timer, beta, psi_f, phi, lambda_st, lambda_1) - g_total_lst.append(g_total) + for t in T: + g_total_lst.append(calc_total_irradiance(irradiance.loc[t], t, beta, psi_f, phi, lambda_st, lambda_1)) return pd.Series(data=g_total_lst, index=T) diff --git a/input_profile_processor/input_profile_processor.py b/input_profile_processor/input_profile_processor.py index 66ad5b8..2735774 100644 --- a/input_profile_processor/input_profile_processor.py +++ b/input_profile_processor/input_profile_processor.py @@ -63,7 +63,7 @@ def process_input_profiles(input_profile_dict, t_start, t_horizon, t_step): def generate_profile(profile_type, parameters, input_profiles, t_start, t_horizon, t_step): - t_last = t_start + pd.Timedelta(hours = (t_horizon - 1) * t_step) + t_last = t_start + pd.Timedelta(hours = t_horizon * t_step - t_step) years = range(t_start.year, t_last.year + 1) if profile_type == 'elec_demand': -- GitLab