From dbda4bae47cced1ebe86122347c89577139bfab9 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Fri, 24 Mar 2023 14:59:27 -0400 Subject: [PATCH] changed print results format --- peak_loads.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/peak_loads.py b/peak_loads.py index 7912275..d3fd4a8 100644 --- a/peak_loads.py +++ b/peak_loads.py @@ -94,25 +94,32 @@ class PeakLoads: self._results[building.name] = {'monthly heating peak load': monthly_heating_loads, 'monthly cooling peak load': monthly_cooling_loads} - print(self._results) self._print_results() def _print_results(self): - print_results = 'Peak loads in W' - for results in self._results: + print_results = f'Building name, monthly heating peak load W,,,,,,,,,,,, monthly cooling peak load W,,,,,,,,,,,' + for building in self._city.buildings: + results = self._results[building.name] print_results += '\n' - print_results += f'{results[0]}, {results[1]}, {results[2]}\n' + print_results += f'{building.name}, ' + for value in results["monthly heating peak load"]: + print_results += f'{value}, ' + for value in results["monthly cooling peak load"]: + print_results += f'{value}, ' file = 'city name: ' + self._city.name + '\n' for building in self._city.buildings: 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.internal_zones[0].area) + '\n' - file += 'storeys: ' + str(building.storeys_above_ground) + '\n' - file += 'heated_volume: ' + str(0.85 * building.volume) + '\n' - file += 'volume: ' + str(building.volume) + '\n' + file += f'name: {building.name}\n' + file += f'year of construction: {building.year_of_construction}\n' + file += f'function: {building.function}\n' + file += f'floor area: {building.floor_area}\n' + if building.average_storey_height is not None and building.eave_height is not None: + file += f'storeys: {int(building.eave_height / building.average_storey_height)}\n' + else: + file += f'storeys: n/a\n' + file += f'heated_volume: {0.85 * building.volume}\n' + file += f'volume: {building.volume}\n' full_path_results = Path(self._path / 'peak_loads.csv').resolve() with open(full_path_results, 'w') as results_file: