Add logger messages to all sys.out
This commit is contained in:
parent
725e7a098f
commit
63b91c4d67
|
@ -6,6 +6,7 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
import hub.helpers.constants as cte
|
import hub.helpers.constants as cte
|
||||||
|
from hub.hub_logger import logger
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,3 +130,5 @@ class UsageHelper:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
sys.stderr.write('Error: Comnet keyword not found. An update of the Comnet files might have been '
|
sys.stderr.write('Error: Comnet keyword not found. An update of the Comnet files might have been '
|
||||||
'done changing the keywords.\n')
|
'done changing the keywords.\n')
|
||||||
|
logger.error('Error: Comnet keyword not found. An update of the Comnet files might have been '
|
||||||
|
'done changing the keywords.\n')
|
||||||
|
|
|
@ -264,8 +264,8 @@ class Polygon:
|
||||||
return mesh
|
return mesh
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logger.error(f'Not able to triangulate polygon\n')
|
|
||||||
sys.stderr.write(f'Not able to triangulate polygon\n')
|
sys.stderr.write(f'Not able to triangulate polygon\n')
|
||||||
|
logger.error(f'Not able to triangulate polygon\n')
|
||||||
_vertices = [[0, 0, 0], [0, 0, 1], [0, 1, 0]]
|
_vertices = [[0, 0, 0], [0, 0, 1], [0, 1, 0]]
|
||||||
_faces = [[0, 1, 2]]
|
_faces = [[0, 1, 2]]
|
||||||
return Trimesh(vertices=_vertices, faces=_faces)
|
return Trimesh(vertices=_vertices, faces=_faces)
|
||||||
|
@ -293,6 +293,7 @@ class Polygon:
|
||||||
"""
|
"""
|
||||||
if np.linalg.norm(vec_1) == 0 or np.linalg.norm(vec_2) == 0:
|
if np.linalg.norm(vec_1) == 0 or np.linalg.norm(vec_2) == 0:
|
||||||
sys.stderr.write("Warning: impossible to calculate angle between planes' normal. Return 0\n")
|
sys.stderr.write("Warning: impossible to calculate angle between planes' normal. Return 0\n")
|
||||||
|
logger.error("Warning: impossible to calculate angle between planes' normal. Return 0\n")
|
||||||
return 0
|
return 0
|
||||||
cosine = np.dot(vec_1, vec_2) / np.linalg.norm(vec_1) / np.linalg.norm(vec_2)
|
cosine = np.dot(vec_1, vec_2) / np.linalg.norm(vec_1) / np.linalg.norm(vec_2)
|
||||||
if cosine > 1 and cosine - 1 < 1e-5:
|
if cosine > 1 and cosine - 1 < 1e-5:
|
||||||
|
|
|
@ -12,6 +12,7 @@ import math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from trimesh import Trimesh
|
from trimesh import Trimesh
|
||||||
from hub.helpers.configuration_helper import ConfigurationHelper
|
from hub.helpers.configuration_helper import ConfigurationHelper
|
||||||
|
from hub.hub_logger import logger
|
||||||
|
|
||||||
|
|
||||||
class Polyhedron:
|
class Polyhedron:
|
||||||
|
@ -116,6 +117,7 @@ class Polyhedron:
|
||||||
for face in self.faces:
|
for face in self.faces:
|
||||||
if len(face) != 3:
|
if len(face) != 3:
|
||||||
sys.stderr.write('Not able to generate trimesh\n')
|
sys.stderr.write('Not able to generate trimesh\n')
|
||||||
|
logger.error('Not able to generate trimesh\n')
|
||||||
return None
|
return None
|
||||||
self._trimesh = Trimesh(vertices=self.vertices, faces=self.faces)
|
self._trimesh = Trimesh(vertices=self.vertices, faces=self.faces)
|
||||||
return self._trimesh
|
return self._trimesh
|
||||||
|
|
|
@ -71,8 +71,8 @@ class Building(CityObject):
|
||||||
elif surface.type == cte.INTERIOR_SLAB:
|
elif surface.type == cte.INTERIOR_SLAB:
|
||||||
self._interior_slabs.append(surface)
|
self._interior_slabs.append(surface)
|
||||||
else:
|
else:
|
||||||
logger.error(f'Building {self.name} [alias {self.alias}] has an unexpected surface type {surface.type}.\n')
|
|
||||||
sys.stderr.write(f'Building {self.name} [alias {self.alias}] has an unexpected surface type {surface.type}.\n')
|
sys.stderr.write(f'Building {self.name} [alias {self.alias}] has an unexpected surface type {surface.type}.\n')
|
||||||
|
logger.error(f'Building {self.name} [alias {self.alias}] has an unexpected surface type {surface.type}.\n')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def shell(self) -> Polyhedron:
|
def shell(self) -> Polyhedron:
|
||||||
|
|
|
@ -16,6 +16,7 @@ import pyproj
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
from pyproj import Transformer
|
from pyproj import Transformer
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from hub.hub_logger import logger
|
||||||
from hub.city_model_structure.building import Building
|
from hub.city_model_structure.building import Building
|
||||||
from hub.city_model_structure.city_object import CityObject
|
from hub.city_model_structure.city_object import CityObject
|
||||||
from hub.city_model_structure.city_objects_cluster import CityObjectsCluster
|
from hub.city_model_structure.city_objects_cluster import CityObjectsCluster
|
||||||
|
@ -87,6 +88,8 @@ class City:
|
||||||
except pyproj.exceptions.CRSError:
|
except pyproj.exceptions.CRSError:
|
||||||
sys.stderr.write('Invalid projection reference system, please check the input data. '
|
sys.stderr.write('Invalid projection reference system, please check the input data. '
|
||||||
'(e.g. in CityGML files: srs_name)\n')
|
'(e.g. in CityGML files: srs_name)\n')
|
||||||
|
logger.error('Invalid projection reference system, please check the input data. '
|
||||||
|
'(e.g. in CityGML files: srs_name)\n')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
transformer = Transformer.from_crs(input_reference, gps)
|
transformer = Transformer.from_crs(input_reference, gps)
|
||||||
coordinates = transformer.transform(self.lower_corner[0], self.lower_corner[1])
|
coordinates = transformer.transform(self.lower_corner[0], self.lower_corner[1])
|
||||||
|
@ -230,6 +233,7 @@ class City:
|
||||||
raise NotImplementedError(city_object.type)
|
raise NotImplementedError(city_object.type)
|
||||||
if self._buildings is None or self._buildings == []:
|
if self._buildings is None or self._buildings == []:
|
||||||
sys.stderr.write('Warning: impossible to remove city_object, the city is empty\n')
|
sys.stderr.write('Warning: impossible to remove city_object, the city is empty\n')
|
||||||
|
logger.error('Warning: impossible to remove city_object, the city is empty\n')
|
||||||
else:
|
else:
|
||||||
if city_object in self._buildings:
|
if city_object in self._buildings:
|
||||||
self._buildings.remove(city_object)
|
self._buildings.remove(city_object)
|
||||||
|
|
|
@ -10,6 +10,7 @@ import numpy as np
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from hub.helpers import constants as cte
|
from hub.helpers import constants as cte
|
||||||
|
from hub.hub_logger import logger
|
||||||
from hub.city_model_structure.attributes.polygon import Polygon
|
from hub.city_model_structure.attributes.polygon import Polygon
|
||||||
from hub.city_model_structure.attributes.point import Point
|
from hub.city_model_structure.attributes.point import Point
|
||||||
from hub.city_model_structure.building_demand.storey import Storey
|
from hub.city_model_structure.building_demand.storey import Storey
|
||||||
|
@ -17,6 +18,7 @@ from hub.city_model_structure.building_demand.surface import Surface
|
||||||
from hub.city_model_structure.building_demand.thermal_zone import ThermalZone
|
from hub.city_model_structure.building_demand.thermal_zone import ThermalZone
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class StoreysGeneration:
|
class StoreysGeneration:
|
||||||
"""
|
"""
|
||||||
StoreysGeneration
|
StoreysGeneration
|
||||||
|
@ -134,6 +136,8 @@ class StoreysGeneration:
|
||||||
if storeys_above_ground is None or storeys_above_ground <= 0:
|
if storeys_above_ground is None or storeys_above_ground <= 0:
|
||||||
sys.stderr.write('Warning: not enough information to divide building into storeys, '
|
sys.stderr.write('Warning: not enough information to divide building into storeys, '
|
||||||
'either number of storeys or average storey height must be provided.\n')
|
'either number of storeys or average storey height must be provided.\n')
|
||||||
|
logger.error('Warning: not enough information to divide building into storeys, '
|
||||||
|
'either number of storeys or average storey height must be provided.\n')
|
||||||
return 0, 0
|
return 0, 0
|
||||||
number_of_storeys = int(storeys_above_ground)
|
number_of_storeys = int(storeys_above_ground)
|
||||||
height = eave_height / number_of_storeys
|
height = eave_height / number_of_storeys
|
||||||
|
|
|
@ -7,7 +7,9 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
import math
|
import math
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
import hub.helpers.constants as cte
|
import hub.helpers.constants as cte
|
||||||
|
from hub.hub_logger import logger
|
||||||
from hub.catalog_factories.construction_catalog_factory import ConstructionCatalogFactory
|
from hub.catalog_factories.construction_catalog_factory import ConstructionCatalogFactory
|
||||||
from hub.city_model_structure.building_demand.layer import Layer
|
from hub.city_model_structure.building_demand.layer import Layer
|
||||||
from hub.city_model_structure.building_demand.material import Material
|
from hub.city_model_structure.building_demand.material import Material
|
||||||
|
@ -40,6 +42,10 @@ class NrcanPhysicsParameters:
|
||||||
sys.stderr.write(f'Building {building.name} has unknown construction archetype for building function: '
|
sys.stderr.write(f'Building {building.name} has unknown construction archetype for building function: '
|
||||||
f'{building.function}, building year of construction: {building.year_of_construction} '
|
f'{building.function}, building year of construction: {building.year_of_construction} '
|
||||||
f'and climate zone {self._climate_zone}\n')
|
f'and climate zone {self._climate_zone}\n')
|
||||||
|
logger.error(f'Building {building.name} has unknown construction archetype for building function: '
|
||||||
|
f'{building.function}, building year of construction: {building.year_of_construction} '
|
||||||
|
f'and climate zone {self._climate_zone}\n')
|
||||||
|
|
||||||
return
|
return
|
||||||
# if building has no thermal zones defined from geometry, and the building will be divided in storeys,
|
# if building has no thermal zones defined from geometry, and the building will be divided in storeys,
|
||||||
# one thermal zone per storey is assigned
|
# one thermal zone per storey is assigned
|
||||||
|
|
|
@ -39,12 +39,12 @@ class NrelPhysicsParameters:
|
||||||
archetype = self._search_archetype(nrel_catalog, function, building.year_of_construction,
|
archetype = self._search_archetype(nrel_catalog, function, building.year_of_construction,
|
||||||
self._climate_zone)
|
self._climate_zone)
|
||||||
except KeyError:
|
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} '
|
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 building year of construction: {building.year_of_construction} '
|
||||||
f'and climate zone reference norm {self._climate_zone}\n')
|
f'and climate zone reference norm {self._climate_zone}\n')
|
||||||
|
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')
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import sys
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
import hub.helpers.constants as cte
|
import hub.helpers.constants as cte
|
||||||
|
from hub.hub_logger import logger
|
||||||
from hub.helpers.dictionaries import Dictionaries
|
from hub.helpers.dictionaries import Dictionaries
|
||||||
from hub.city_model_structure.building_demand.usage import Usage
|
from hub.city_model_structure.building_demand.usage import Usage
|
||||||
from hub.city_model_structure.building_demand.lighting import Lighting
|
from hub.city_model_structure.building_demand.lighting import Lighting
|
||||||
|
@ -42,6 +43,8 @@ class ComnetUsageParameters:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
sys.stderr.write(f'Building {building.name} has unknown usage archetype for building function:'
|
sys.stderr.write(f'Building {building.name} has unknown usage archetype for building function:'
|
||||||
f' {building.function}')
|
f' {building.function}')
|
||||||
|
logger.error(f'Building {building.name} has unknown usage archetype for building function:'
|
||||||
|
f' {building.function}')
|
||||||
return
|
return
|
||||||
|
|
||||||
for internal_zone in building.internal_zones:
|
for internal_zone in building.internal_zones:
|
||||||
|
|
|
@ -8,6 +8,7 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import hub.helpers.constants as cte
|
import hub.helpers.constants as cte
|
||||||
|
from hub.hub_logger import logger
|
||||||
from hub.helpers.dictionaries import Dictionaries
|
from hub.helpers.dictionaries import Dictionaries
|
||||||
from hub.city_model_structure.building_demand.usage import Usage
|
from hub.city_model_structure.building_demand.usage import Usage
|
||||||
from hub.city_model_structure.building_demand.lighting import Lighting
|
from hub.city_model_structure.building_demand.lighting import Lighting
|
||||||
|
@ -41,6 +42,8 @@ class NrcanUsageParameters:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
sys.stderr.write(f'Building {building.name} has unknown usage archetype for building function:'
|
sys.stderr.write(f'Building {building.name} has unknown usage archetype for building function:'
|
||||||
f' {building.function}')
|
f' {building.function}')
|
||||||
|
logger.error(f'Building {building.name} has unknown usage archetype for building function:'
|
||||||
|
f' {building.function}')
|
||||||
return
|
return
|
||||||
|
|
||||||
usage_name = Dictionaries().hub_usage_to_comnet_usage[building.function]
|
usage_name = Dictionaries().hub_usage_to_comnet_usage[building.function]
|
||||||
|
@ -49,6 +52,8 @@ class NrcanUsageParameters:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
sys.stderr.write(f'Building {building.name} has unknown usage archetype for building function:'
|
sys.stderr.write(f'Building {building.name} has unknown usage archetype for building function:'
|
||||||
f' {building.function}')
|
f' {building.function}')
|
||||||
|
logger.error(f'Building {building.name} has unknown usage archetype for building function:'
|
||||||
|
f' {building.function}')
|
||||||
return
|
return
|
||||||
|
|
||||||
for internal_zone in building.internal_zones:
|
for internal_zone in building.internal_zones:
|
||||||
|
|
|
@ -9,6 +9,7 @@ import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import hub.helpers.constants as cte
|
import hub.helpers.constants as cte
|
||||||
|
from hub.hub_logger import logger
|
||||||
|
|
||||||
|
|
||||||
class DatWeatherParameters:
|
class DatWeatherParameters:
|
||||||
|
@ -29,6 +30,7 @@ class DatWeatherParameters:
|
||||||
names=['hour', 'global_horiz', 'temperature', 'diffuse', 'beam', 'empty'])
|
names=['hour', 'global_horiz', 'temperature', 'diffuse', 'beam', 'empty'])
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
sys.stderr.write(f'Error: weather file {self._path} not found\n')
|
sys.stderr.write(f'Error: weather file {self._path} not found\n')
|
||||||
|
logger.error(f'Error: weather file {self._path} not found\n')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
|
|
|
@ -9,6 +9,7 @@ import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import hub.helpers.constants as cte
|
import hub.helpers.constants as cte
|
||||||
|
from hub.hub_logger import logger
|
||||||
from hub.imports.weather.helpers.weather import Weather as wh
|
from hub.imports.weather.helpers.weather import Weather as wh
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +45,8 @@ class EpwWeatherParameters:
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
sys.stderr.write(f'Error: weather file {self._path} not found. Please download it from '
|
sys.stderr.write(f'Error: weather file {self._path} not found. Please download it from '
|
||||||
f'https://energyplus.net/weather and place it in folder data\\weather\\epw\n')
|
f'https://energyplus.net/weather and place it in folder data\\weather\\epw\n')
|
||||||
|
logger.error(f'Error: weather file {self._path} not found. Please download it from '
|
||||||
|
f'https://energyplus.net/weather and place it in folder data\\weather\\epw\n')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -71,6 +74,7 @@ class EpwWeatherParameters:
|
||||||
'liquid_precipitation_quality_hr'])
|
'liquid_precipitation_quality_hr'])
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
sys.stderr.write(f'Error: wrong formatting of weather file {self._path}\n')
|
sys.stderr.write(f'Error: wrong formatting of weather file {self._path}\n')
|
||||||
|
logger.error(f'Error: wrong formatting of weather file {self._path}\n')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
|
@ -80,6 +84,7 @@ class EpwWeatherParameters:
|
||||||
number_invalid_records = new_value[new_value.epw == 99.9].count().epw
|
number_invalid_records = new_value[new_value.epw == 99.9].count().epw
|
||||||
if number_invalid_records > 0:
|
if number_invalid_records > 0:
|
||||||
sys.stderr.write(f'Warning: {self._path} invalid records (value of 99.9) in dry bulb temperature\n')
|
sys.stderr.write(f'Warning: {self._path} invalid records (value of 99.9) in dry bulb temperature\n')
|
||||||
|
logger.error(f'Warning: {self._path} invalid records (value of 99.9) in dry bulb temperature\n')
|
||||||
if cte.HOUR not in building.external_temperature:
|
if cte.HOUR not in building.external_temperature:
|
||||||
building.external_temperature[cte.HOUR] = new_value
|
building.external_temperature[cte.HOUR] = new_value
|
||||||
else:
|
else:
|
||||||
|
@ -89,6 +94,7 @@ class EpwWeatherParameters:
|
||||||
number_invalid_records = new_value[new_value.epw == 9999].count().epw
|
number_invalid_records = new_value[new_value.epw == 9999].count().epw
|
||||||
if number_invalid_records > 0:
|
if number_invalid_records > 0:
|
||||||
sys.stderr.write(f'Warning: {self._path} invalid records (value of 9999) in global horizontal radiation\n')
|
sys.stderr.write(f'Warning: {self._path} invalid records (value of 9999) in global horizontal radiation\n')
|
||||||
|
logger.error(f'Warning: {self._path} invalid records (value of 9999) in global horizontal radiation\n')
|
||||||
if cte.HOUR not in building.global_horizontal:
|
if cte.HOUR not in building.global_horizontal:
|
||||||
building.global_horizontal[cte.HOUR] = new_value
|
building.global_horizontal[cte.HOUR] = new_value
|
||||||
else:
|
else:
|
||||||
|
@ -98,6 +104,7 @@ class EpwWeatherParameters:
|
||||||
number_invalid_records = new_value[new_value.epw == 9999].count().epw
|
number_invalid_records = new_value[new_value.epw == 9999].count().epw
|
||||||
if number_invalid_records > 0:
|
if number_invalid_records > 0:
|
||||||
sys.stderr.write(f'Warning: {self._path} invalid records (value of 9999) in diffuse horizontal radiation\n')
|
sys.stderr.write(f'Warning: {self._path} invalid records (value of 9999) in diffuse horizontal radiation\n')
|
||||||
|
logger.error(f'Warning: {self._path} invalid records (value of 9999) in diffuse horizontal radiation\n')
|
||||||
if cte.HOUR not in building.diffuse:
|
if cte.HOUR not in building.diffuse:
|
||||||
building.diffuse[cte.HOUR] = new_value
|
building.diffuse[cte.HOUR] = new_value
|
||||||
else:
|
else:
|
||||||
|
@ -107,6 +114,7 @@ class EpwWeatherParameters:
|
||||||
number_invalid_records = new_value[new_value.epw == 9999].count().epw
|
number_invalid_records = new_value[new_value.epw == 9999].count().epw
|
||||||
if number_invalid_records > 0:
|
if number_invalid_records > 0:
|
||||||
sys.stderr.write(f'Warning: {self._path} invalid records (value of 9999) in direct horizontal radiation\n')
|
sys.stderr.write(f'Warning: {self._path} invalid records (value of 9999) in direct horizontal radiation\n')
|
||||||
|
logger.error(f'Warning: {self._path} invalid records (value of 9999) in direct horizontal radiation\n')
|
||||||
if cte.HOUR not in building.beam:
|
if cte.HOUR not in building.beam:
|
||||||
building.beam[cte.HOUR] = new_value
|
building.beam[cte.HOUR] = new_value
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -10,6 +10,7 @@ import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import hub.helpers.constants as cte
|
import hub.helpers.constants as cte
|
||||||
|
from hub.hub_logger import logger
|
||||||
|
|
||||||
|
|
||||||
class XlsWeatherParameters:
|
class XlsWeatherParameters:
|
||||||
|
@ -32,6 +33,7 @@ class XlsWeatherParameters:
|
||||||
'void', 'global_horiz', 'wind_velocity', 'humidity'])
|
'void', 'global_horiz', 'wind_velocity', 'humidity'])
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
sys.stderr.write(f'Error reading weather file {self._path}\n')
|
sys.stderr.write(f'Error reading weather file {self._path}\n')
|
||||||
|
logger.error(f'Error reading weather file {self._path}\n')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user