diff --git a/input_profile_processor/input_profile_processor.py b/input_profile_processor/input_profile_processor.py index 7647cb1dc1ac4d3ea2b343676c7503b5db655e72..4b18450fad7b04675df8c58c02d7a70686861fe2 100644 --- a/input_profile_processor/input_profile_processor.py +++ b/input_profile_processor/input_profile_processor.py @@ -66,11 +66,20 @@ def resample_profile(name, profile, t_start, t_horizon, t_step, t_last): if t_start < profile.index[0]: missing_indices = pd.date_range(t_start, profile.index[0] - timedelta(hours = t_step), 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 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: - 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!') - 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 + +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): @@ -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 # residential building could varies from 1 to 11 # 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, shlp_type='EFH', temperature=input_profiles[parameters['temperature']][1], @@ -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), periods=8760 / t_step, 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, shlp_type='EFH', temperature=input_profiles[parameters['temperature']][1],