fixed bug not printing results when building not processed

This commit is contained in:
Pilar Monsalvete 2023-05-02 12:39:51 -04:00
parent d78ab8010c
commit adf62d56db

View File

@ -11,22 +11,30 @@ class Results:
def print(self): def print(self):
print_results = None print_results = None
file = 'city name: ' + self._city.name + '\n' file = 'city name: ' + self._city.name + '\n'
array = [None] * 12
for building in self._city.buildings: for building in self._city.buildings:
if cte.MONTH in building.heating.keys(): if cte.MONTH in building.heating.keys():
heating_results = building.heating[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} heating Wh'}) heating_results = building.heating[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} heating Wh'})
else:
heating_results = pd.DataFrame(array, columns=[f'{building.name} heating Wh'])
if cte.MONTH in building.cooling.keys():
cooling_results = building.cooling[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} cooling Wh'}) cooling_results = building.cooling[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} cooling Wh'})
else:
cooling_results = pd.DataFrame(array, columns=[f'{building.name} cooling Wh'])
if cte.MONTH in building.lighting_electrical_demand.keys():
lighting_results = building.lighting_electrical_demand[cte.MONTH]\ lighting_results = building.lighting_electrical_demand[cte.MONTH]\
.rename(columns={cte.INSEL_MEB: f'{building.name} lighting electrical demand Wh'}) .rename(columns={cte.INSEL_MEB: f'{building.name} lighting electrical demand Wh'})
else:
lighting_results = pd.DataFrame(array, columns=[f'{building.name} lighting electrical demand Wh'])
if cte.MONTH in building.appliances_electrical_demand.keys():
appliances_results = building.appliances_electrical_demand[cte.MONTH]\ appliances_results = building.appliances_electrical_demand[cte.MONTH]\
.rename(columns={cte.INSEL_MEB: f'{building.name} appliances electrical demand Wh'}) .rename(columns={cte.INSEL_MEB: f'{building.name} appliances electrical demand Wh'})
else:
appliances_results = pd.DataFrame(array, columns=[f'{building.name} appliances electrical demand Wh'])
if cte.MONTH in building.domestic_hot_water_heat_demand.keys():
dhw_results = building.domestic_hot_water_heat_demand[cte.MONTH]\ dhw_results = building.domestic_hot_water_heat_demand[cte.MONTH]\
.rename(columns={cte.INSEL_MEB: f'{building.name} domestic hot water demand Wh'}) .rename(columns={cte.INSEL_MEB: f'{building.name} domestic hot water demand Wh'})
else: else:
array = [None] * 12
heating_results = pd.DataFrame(array, columns=[f'{building.name} heating Wh'])
cooling_results = pd.DataFrame(array, columns=[f'{building.name} cooling Wh'])
lighting_results = pd.DataFrame(array, columns=[f'{building.name} lighting electrical demand Wh'])
appliances_results = pd.DataFrame(array, columns=[f'{building.name} appliances electrical demand Wh'])
dhw_results = pd.DataFrame(array, columns=[f'{building.name} domestic hot water demand Wh']) dhw_results = pd.DataFrame(array, columns=[f'{building.name} domestic hot water demand Wh'])
if print_results is None: if print_results is None:
print_results = heating_results print_results = heating_results