Improve documentation and error handling
This commit is contained in:
parent
66dbda5525
commit
44e6820ce6
@ -262,8 +262,8 @@ class Building(CityObject):
|
|||||||
@property
|
@property
|
||||||
def usages(self) -> Union[None, list]:
|
def usages(self) -> Union[None, list]:
|
||||||
"""
|
"""
|
||||||
Get building function
|
Get building usages, if none, assume useage is function
|
||||||
:return: None or str
|
:return: None or list of functions
|
||||||
"""
|
"""
|
||||||
if self._usages is None and self._function is not None:
|
if self._usages is None and self._function is not None:
|
||||||
self._usages = [{'usage': self._function, 'ratio': 1 }]
|
self._usages = [{'usage': self._function, 'ratio': 1 }]
|
||||||
@ -604,19 +604,6 @@ class Building(CityObject):
|
|||||||
"""
|
"""
|
||||||
self._city = value
|
self._city = value
|
||||||
|
|
||||||
@property
|
|
||||||
def usages_percentage(self):
|
|
||||||
"""
|
|
||||||
Get the usages and percentages for the building
|
|
||||||
"""
|
|
||||||
_usage = ''
|
|
||||||
for internal_zone in self.internal_zones:
|
|
||||||
if internal_zone.usages is None:
|
|
||||||
continue
|
|
||||||
for usage in internal_zone.usages:
|
|
||||||
_usage = f'{_usage}{usage.name}_{usage.percentage} '
|
|
||||||
return _usage.rstrip()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def energy_systems(self) -> Union[None, List[EnergySystem]]:
|
def energy_systems(self) -> Union[None, List[EnergySystem]]:
|
||||||
"""
|
"""
|
||||||
|
@ -78,7 +78,12 @@ class ComnetUsageParameters:
|
|||||||
logging.error('Building %s no number of storeys assigned, ACH cannot be calculated for usage %s. '
|
logging.error('Building %s no number of storeys assigned, ACH cannot be calculated for usage %s. '
|
||||||
'NRCAN construction data for the year %s is used to calculated number of storeys above '
|
'NRCAN construction data for the year %s is used to calculated number of storeys above '
|
||||||
'ground', building.name, usages, building.year_of_construction)
|
'ground', building.name, usages, building.year_of_construction)
|
||||||
storeys_above_ground = self.average_storey_height_calculator(self._city, building)
|
try:
|
||||||
|
storeys_above_ground = self.average_storey_height_calculator(self._city, building)
|
||||||
|
except ValueError as e:
|
||||||
|
logging.error(e)
|
||||||
|
continue
|
||||||
|
|
||||||
volume_per_area = building.volume / building.floor_area / storeys_above_ground
|
volume_per_area = building.volume / building.floor_area / storeys_above_ground
|
||||||
for j, usage_type in enumerate(usages):
|
for j, usage_type in enumerate(usages):
|
||||||
usage = Usage()
|
usage = Usage()
|
||||||
@ -90,6 +95,7 @@ class ComnetUsageParameters:
|
|||||||
internal_zone_usages.append(usage)
|
internal_zone_usages.append(usage)
|
||||||
|
|
||||||
internal_zone.usages = internal_zone_usages
|
internal_zone.usages = internal_zone_usages
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _search_archetypes(comnet_catalog, usage_name):
|
def _search_archetypes(comnet_catalog, usage_name):
|
||||||
comnet_archetypes = comnet_catalog.entries('archetypes').usages
|
comnet_archetypes = comnet_catalog.entries('archetypes').usages
|
||||||
@ -268,7 +274,7 @@ class ComnetUsageParameters:
|
|||||||
nrcan_catalog = ConstructionCatalogFactory('nrcan').catalog
|
nrcan_catalog = ConstructionCatalogFactory('nrcan').catalog
|
||||||
|
|
||||||
if building.function not in Dictionaries().hub_function_to_nrcan_construction_function:
|
if building.function not in Dictionaries().hub_function_to_nrcan_construction_function:
|
||||||
logging.error('Building %s has an unknown building function %s', building.name, building.function)
|
raise ValueError('Building %s has an unknown building function %s', building.name, building.function)
|
||||||
|
|
||||||
function = Dictionaries().hub_function_to_nrcan_construction_function[building.function]
|
function = Dictionaries().hub_function_to_nrcan_construction_function[building.function]
|
||||||
construction_archetype = None
|
construction_archetype = None
|
||||||
@ -281,7 +287,7 @@ class ComnetUsageParameters:
|
|||||||
construction_archetype = building_archetype
|
construction_archetype = building_archetype
|
||||||
average_storey_height = building_archetype.average_storey_height
|
average_storey_height = building_archetype.average_storey_height
|
||||||
if construction_archetype is None:
|
if construction_archetype is None:
|
||||||
logging.error('Building %s has unknown construction archetype for building function: %s '
|
raise ValueError('Building %s has unknown construction archetype for building function: %s '
|
||||||
'[%s], building year of construction: %s and climate zone %s', building.name, function,
|
'[%s], building year of construction: %s and climate zone %s', building.name, function,
|
||||||
building.function, building.year_of_construction, climate_zone)
|
building.function, building.year_of_construction, climate_zone)
|
||||||
|
|
||||||
|
@ -86,8 +86,12 @@ class NrcanUsageParameters:
|
|||||||
logging.error('Building %s no number of storeys assigned, ACH cannot be calculated for function %s. '
|
logging.error('Building %s no number of storeys assigned, ACH cannot be calculated for function %s. '
|
||||||
'NRCAN construction data for the year %s is used to calculated number of storeys above '
|
'NRCAN construction data for the year %s is used to calculated number of storeys above '
|
||||||
'ground', building.name, building.function, building.year_of_construction)
|
'ground', building.name, building.function, building.year_of_construction)
|
||||||
storeys_above_ground = self.average_storey_height_calculator(self._city, building)
|
try:
|
||||||
continue
|
storeys_above_ground = self.average_storey_height_calculator(self._city, building)
|
||||||
|
except ValueError as e:
|
||||||
|
logging.error(e)
|
||||||
|
continue
|
||||||
|
|
||||||
volume_per_area = building.volume / building.floor_area / storeys_above_ground
|
volume_per_area = building.volume / building.floor_area / storeys_above_ground
|
||||||
for j, usage_type in enumerate(usages):
|
for j, usage_type in enumerate(usages):
|
||||||
usage = Usage()
|
usage = Usage()
|
||||||
@ -224,7 +228,7 @@ class NrcanUsageParameters:
|
|||||||
nrcan_catalog = ConstructionCatalogFactory('nrcan').catalog
|
nrcan_catalog = ConstructionCatalogFactory('nrcan').catalog
|
||||||
|
|
||||||
if building.function not in Dictionaries().hub_function_to_nrcan_construction_function:
|
if building.function not in Dictionaries().hub_function_to_nrcan_construction_function:
|
||||||
logging.error('Building %s has an unknown building function %s', building.name, building.function)
|
raise ValueError('Building %s has an unknown building function %s', building.name, building.function)
|
||||||
|
|
||||||
function = Dictionaries().hub_function_to_nrcan_construction_function[building.function]
|
function = Dictionaries().hub_function_to_nrcan_construction_function[building.function]
|
||||||
construction_archetype = None
|
construction_archetype = None
|
||||||
@ -237,7 +241,7 @@ class NrcanUsageParameters:
|
|||||||
construction_archetype = building_archetype
|
construction_archetype = building_archetype
|
||||||
average_storey_height = building_archetype.average_storey_height
|
average_storey_height = building_archetype.average_storey_height
|
||||||
if construction_archetype is None:
|
if construction_archetype is None:
|
||||||
logging.error('Building %s has unknown construction archetype for building function: %s '
|
raise ValueError('Building %s has unknown construction archetype for building function: %s '
|
||||||
'[%s], building year of construction: %s and climate zone %s', building.name, function,
|
'[%s], building year of construction: %s and climate zone %s', building.name, function,
|
||||||
building.function, building.year_of_construction, climate_zone)
|
building.function, building.year_of_construction, climate_zone)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user