From 3dc74371f4d21294eed7c7232dd7c2dff25a8338 Mon Sep 17 00:00:00 2001 From: Peter Yefi Date: Tue, 10 Jan 2023 12:03:27 -0500 Subject: [PATCH] Added logging --- exports/energy_systems/heat_pump_export.py | 5 ++++- helpers/enrich_city.py | 4 ++++ imports/construction/us_physics_parameters.py | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/exports/energy_systems/heat_pump_export.py b/exports/energy_systems/heat_pump_export.py index a7e9e1df..6deb5c0e 100644 --- a/exports/energy_systems/heat_pump_export.py +++ b/exports/energy_systems/heat_pump_export.py @@ -9,6 +9,7 @@ from typing import List, Union, Dict import yaml from string import Template import pandas as pd +from hub_logger import logger class HeatPumpExport: @@ -56,13 +57,15 @@ class HeatPumpExport: insel_file_handler.write(insel_template) # Now run insel self._delete_existing_output_files() - os.system('/usr/local/bin/insel {}'.format(insel_file)) + logger.info(f'Running Insel with user input: {user_input} and coefficients {capacity_coeff}') + os.system('insel {}'.format(insel_file)) # Writer headers to csv output files generated by insel self._write_insel_output_headers() # User output return self._get_user_out_put() except IOError as err: print("I/O exception: {}".format(err)) + logger.error(f'An I/O error occurred while running insel: {err}') finally: insel_file_handler.close() insel_template_handler.close() diff --git a/helpers/enrich_city.py b/helpers/enrich_city.py index 7e0f47cf..f4a5e25b 100644 --- a/helpers/enrich_city.py +++ b/helpers/enrich_city.py @@ -8,6 +8,7 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca from imports.construction_factory import ConstructionFactory from imports.usage_factory import UsageFactory from imports.schedules_factory import SchedulesFactory +from hub_logger import logger class EnrichCity: @@ -36,6 +37,7 @@ class EnrichCity: if self._enriched_city is None: self._errors = [] print('original:', len(self._city.buildings)) + logger.info(f'Building length prior to enrichment: {len(self._city.buildings)}') if not pickle_construction: if construction_format is not None: self._enriched_city = self._construction(construction_format) @@ -83,6 +85,7 @@ class EnrichCity: self._enriched_city = self._city return self._enriched_city print('enriched with usage:', len(self._city.buildings)) + logger.info(f'City enriched with usage: {len(self._city.buildings)}') return self._city def _schedules(self, schedules_format): @@ -101,4 +104,5 @@ class EnrichCity: self._enriched_city = self._city return self._enriched_city print('enriched with occupancy:', len(self._city.buildings)) + logger.info(f'City enriched with occupancy: {len(self._city.buildings)}') return self._city diff --git a/imports/construction/us_physics_parameters.py b/imports/construction/us_physics_parameters.py index 3ace0850..5be4a58d 100644 --- a/imports/construction/us_physics_parameters.py +++ b/imports/construction/us_physics_parameters.py @@ -12,6 +12,7 @@ from catalog_factories.construction_catalog_factory import ConstructionCatalogFa from city_model_structure.building_demand.layer import Layer from city_model_structure.building_demand.material import Material from imports.construction.helpers.construction_helper import ConstructionHelper +from hub_logger import logger class UsPhysicsParameters(NrelPhysicsInterface): @@ -35,9 +36,14 @@ class UsPhysicsParameters(NrelPhysicsInterface): try: archetype = self._search_archetype(building.function, building.year_of_construction, self._climate_zone) except KeyError: + + logger.error(f'Building {building.name} has unknown archetype for building function: {building.function} ' + f'and building year of construction: {building.year_of_construction} ' + f'and climate zone reference norm {self._climate_zone}\n') sys.stderr.write(f'Building {building.name} has unknown archetype for building function: {building.function} ' f'and building year of construction: {building.year_of_construction} ' f'and climate zone reference norm {self._climate_zone}\n') + return # if building has no thermal zones defined from geometry, one thermal zone per storey is assigned