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

Fix in input profile processor

parent 143e7268
No related branches found
No related tags found
No related merge requests found
...@@ -68,11 +68,20 @@ def resample_profile(name, profile, t_start, t_horizon, t_step, t_last): ...@@ -68,11 +68,20 @@ def resample_profile(name, profile, t_start, t_horizon, t_step, t_last):
print(f'For input profile {name} {len(missing_indices)} {"values are" if len(missing_indices) > 1 else "value is"} extrapolated to the beginning of the profile!') print(f'For input profile {name} {len(missing_indices)} {"values are" if len(missing_indices) > 1 else "value is"} extrapolated to the beginning of the profile!')
profile = pd.concat([pd.DataFrame([profile.iloc[0]], index = missing_indices), profile]) profile = pd.concat([pd.DataFrame([profile.iloc[0]], index = missing_indices), profile])
if profile.index[-1] < t_last: if profile.index[-1] < t_last:
missing_indices = pd.date_range(profile.index[-1] ++ timedelta(hours = t_step), t_last, freq = str(t_step) + 'H') missing_indices = pd.date_range(profile.index[-1] + timedelta(hours = t_step), t_last, freq = str(t_step) + 'H')
print(f'For input profile {name} {len(missing_indices)} {"values are" if len(missing_indices) > 1 else "value is"} extrapolated to the end of the profile!') print(f'For input profile {name} {len(missing_indices)} {"values are" if len(missing_indices) > 1 else "value is"} extrapolated to the end of the profile!')
profile = pd.concat([profile, pd.DataFrame([profile.iloc[-1]], index = missing_indices)]) profile = pd.concat([profile, pd.DataFrame([profile.iloc[-1]], index = missing_indices)])
return profile return profile
def expand_profile_to_year(profile, year, t_step):
if datetime(year, 1, 1, 0) < profile.index[0]:
missing_indices = pd.date_range(datetime(year, 1, 1, 0), profile.index[0] - timedelta(hours = t_step), freq = str(t_step) + 'H')
profile = pd.concat([pd.DataFrame([profile.iloc[0]], index =missing_indices), profile])
if profile.index[-1] < datetime(year + 1, 1, 1, 0) - timedelta(hours = t_step):
missing_indices = pd.date_range(profile.index[-1] + timedelta(hours = t_step), datetime(year + 1, 1, 1, 0) - timedelta(hours = t_step), freq = str(t_step) + 'H')
profile = pd.concat([profile, pd.DataFrame([profile.iloc[-1]], index = missing_indices)])
return profile
def load_profile(name, file, t_start, t_horizon, t_step): def load_profile(name, file, t_start, t_horizon, t_step):
t_last = t_start + pd.Timedelta(hours = t_horizon * t_step - t_step) t_last = t_start + pd.Timedelta(hours = t_horizon * t_step - t_step)
profile = pd.read_csv(file, index_col = 0) profile = pd.read_csv(file, index_col = 0)
...@@ -149,6 +158,11 @@ def generate_profile(name, profile_type, parameters, input_profiles, t_start, t_ ...@@ -149,6 +158,11 @@ def generate_profile(name, profile_type, parameters, input_profiles, t_start, t_
# Fixme: non-residential building only have building_class = 0 # Fixme: non-residential building only have building_class = 0
# residential building could varies from 1 to 11 # residential building could varies from 1 to 11
# same problem for hot water demand. # same problem for hot water demand.
# temporary fix
if len(input_profiles[parameters['temperature']][1]) < len(demand_df.index):
temp = list(input_profiles[parameters['temperature']])
temp[1] = expand_profile_to_year(input_profiles[parameters['temperature']][1], year, t_step)
input_profiles[parameters['temperature']] = tuple(temp)
year_profile = ThermalDemand(demand_df.index, year_profile = ThermalDemand(demand_df.index,
shlp_type='EFH', shlp_type='EFH',
temperature=input_profiles[parameters['temperature']][1], temperature=input_profiles[parameters['temperature']][1],
...@@ -166,6 +180,11 @@ def generate_profile(name, profile_type, parameters, input_profiles, t_start, t_ ...@@ -166,6 +180,11 @@ def generate_profile(name, profile_type, parameters, input_profiles, t_start, t_
demand_df = pd.DataFrame(index=pd.date_range(datetime(year, 1, 1, 0), demand_df = pd.DataFrame(index=pd.date_range(datetime(year, 1, 1, 0),
periods=8760 / t_step, periods=8760 / t_step,
freq=str(t_step) + 'H')) freq=str(t_step) + 'H'))
# temporary fix
if len(input_profiles[parameters['temperature']][1]) < len(demand_df.index):
temp = list(input_profiles[parameters['temperature']])
temp[1] = expand_profile_to_year(input_profiles[parameters['temperature']][1], year, t_step)
input_profiles[parameters['temperature']] = tuple(temp)
year_profile = ThermalDemand(demand_df.index, year_profile = ThermalDemand(demand_df.index,
shlp_type='EFH', shlp_type='EFH',
temperature=input_profiles[parameters['temperature']][1], temperature=input_profiles[parameters['temperature']][1],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment