Added logging

This commit is contained in:
Peter Yefi 2023-01-10 12:03:27 -05:00
parent 2d301853d6
commit 3dc74371f4
3 changed files with 14 additions and 1 deletions

View File

@ -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()

View File

@ -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

View File

@ -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