""" monthly_to_hourly_demand module SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es """ import pandas as pd import helpers.constants as cte class MonthlyToHourlyDemand: """ MonthlyToHourlyDemand class """ def __init__(self, building): self._hourly_heating = pd.DataFrame() self._hourly_cooling = pd.DataFrame() self._building = building @property def hourly_heating(self): """ hourly distribution of the monthly heating of a building :return: [hourly_heating] """ # todo: this method and the insel model have to be reviewed for more than one thermal zone external_temp = self._building.hourly_external_temperature # todo: review index depending on how the schedules are defined, either 8760 or 24 hours period = 'day' for usage_zone in self._building.usage_zones: temp_set = usage_zone.heating_setpoint temp_back = usage_zone.heating_setback occupancy = usage_zone.occupancy.occupant_schedule(period) # todo: heating_schedule is still missing heating_schedule = usage_zone.heating_schedule_month self._hourly_heating = pd.DataFrame(columns=['monthly to hourly']) i = 0 for month in range(0, 12): temp_grad_month = 0 for day in cte.days_of_month[month]: external_temp_med = 0 for hour in range(0, 24): external_temp_med += external_temp[i]/24 for hour in range(0, 24): if external_temp_med < temp_set[i] & heating_schedule[month] == 1: if occupancy[hour] == 1: temp_grad_day = temp_set[i] - external_temp[i] else: temp_grad_day = temp_back[i] - external_temp[i] else: temp_grad_day = 0 temp_grad_month += temp_grad_day self._hourly_heating.append(self._building.monthly_heating(month)*temp_grad_day/temp_grad_month) i += 1 return self._hourly_heating @property def hourly_cooling(self) -> NotImplementedError: raise NotImplementedError