2023-03-23 13:31:36 -04:00
|
|
|
from pathlib import Path
|
|
|
|
import pandas as pd
|
|
|
|
import hub.helpers.constants as cte
|
|
|
|
|
|
|
|
|
|
|
|
class Results:
|
|
|
|
def __init__(self, city, path):
|
|
|
|
self._city = city
|
|
|
|
self._path = path
|
|
|
|
|
|
|
|
def print(self):
|
|
|
|
print_results = None
|
|
|
|
file = 'city name: ' + self._city.name + '\n'
|
|
|
|
for building in self._city.buildings:
|
2023-03-23 13:49:41 -04:00
|
|
|
heating_results = building.heating[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} heating Wh'})
|
|
|
|
cooling_results = building.cooling[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} cooling Wh'})
|
|
|
|
lighting_results = building.lighting_electrical_demand[cte.MONTH]\
|
|
|
|
.rename(columns={cte.INSEL_MEB: f'{building.name} lighting electrical demand Wh'})
|
|
|
|
appliances_results = building.appliances_electrical_demand[cte.MONTH]\
|
|
|
|
.rename(columns={cte.INSEL_MEB: f'{building.name} appliances electrical demand Wh'})
|
|
|
|
dhw_results = building.domestic_hot_water_heat_demand[cte.MONTH]\
|
|
|
|
.rename(columns={cte.INSEL_MEB: f'{building.name} domestic hot water demand Wh'})
|
2023-03-23 13:31:36 -04:00
|
|
|
if print_results is None:
|
|
|
|
print_results = heating_results
|
|
|
|
else:
|
|
|
|
print_results = pd.concat([print_results, heating_results], axis='columns')
|
2023-03-23 13:49:41 -04:00
|
|
|
print_results = pd.concat([print_results,
|
|
|
|
cooling_results,
|
|
|
|
lighting_results,
|
|
|
|
appliances_results,
|
|
|
|
dhw_results], axis='columns')
|
2023-03-23 13:31:36 -04:00
|
|
|
file += '\n'
|
|
|
|
file += 'name: ' + building.name + '\n'
|
|
|
|
file += 'year of construction: ' + str(building.year_of_construction) + '\n'
|
|
|
|
file += 'function: ' + building.function + '\n'
|
|
|
|
file += 'floor area: ' + str(building.floor_area) + '\n'
|
|
|
|
file += 'storeys: ' + str(int(building.eave_height / building.average_storey_height)) + '\n'
|
|
|
|
file += 'heated_volume: ' + str(0.85 * building.volume) + '\n'
|
|
|
|
file += 'volume: ' + str(building.volume) + '\n'
|
|
|
|
|
|
|
|
full_path_results = Path(self._path / 'demand.csv').resolve()
|
|
|
|
print_results.to_csv(full_path_results)
|
|
|
|
full_path_metadata = Path(self._path / 'metadata.csv').resolve()
|
|
|
|
with open(full_path_metadata, 'w') as metadata_file:
|
|
|
|
metadata_file.write(file)
|