diff --git a/hub/city_model_structure/building.py b/hub/city_model_structure/building.py index b3d45617..a5650013 100644 --- a/hub/city_model_structure/building.py +++ b/hub/city_model_structure/building.py @@ -262,8 +262,8 @@ class Building(CityObject): @property def usages(self) -> Union[None, list]: """ - Get building function - :return: None or str + Get building usages, if none, assume useage is function + :return: None or list of functions """ if self._usages is None and self._function is not None: self._usages = [{'usage': self._function, 'ratio': 1 }] @@ -604,19 +604,6 @@ class Building(CityObject): """ 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 def energy_systems(self) -> Union[None, List[EnergySystem]]: """ diff --git a/hub/imports/usage/comnet_usage_parameters.py b/hub/imports/usage/comnet_usage_parameters.py index adf65aed..343bd3df 100644 --- a/hub/imports/usage/comnet_usage_parameters.py +++ b/hub/imports/usage/comnet_usage_parameters.py @@ -78,7 +78,12 @@ class ComnetUsageParameters: 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 ' '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 for j, usage_type in enumerate(usages): usage = Usage() @@ -90,6 +95,7 @@ class ComnetUsageParameters: internal_zone_usages.append(usage) internal_zone.usages = internal_zone_usages + @staticmethod def _search_archetypes(comnet_catalog, usage_name): comnet_archetypes = comnet_catalog.entries('archetypes').usages @@ -268,7 +274,7 @@ class ComnetUsageParameters: nrcan_catalog = ConstructionCatalogFactory('nrcan').catalog 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] construction_archetype = None @@ -281,7 +287,7 @@ class ComnetUsageParameters: construction_archetype = building_archetype average_storey_height = building_archetype.average_storey_height 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, building.function, building.year_of_construction, climate_zone) diff --git a/hub/imports/usage/nrcan_usage_parameters.py b/hub/imports/usage/nrcan_usage_parameters.py index f9cf5e63..a6825bbc 100644 --- a/hub/imports/usage/nrcan_usage_parameters.py +++ b/hub/imports/usage/nrcan_usage_parameters.py @@ -86,8 +86,12 @@ class NrcanUsageParameters: 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 ' 'ground', building.name, building.function, building.year_of_construction) - storeys_above_ground = self.average_storey_height_calculator(self._city, building) - continue + 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 for j, usage_type in enumerate(usages): usage = Usage() @@ -224,7 +228,7 @@ class NrcanUsageParameters: nrcan_catalog = ConstructionCatalogFactory('nrcan').catalog 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] construction_archetype = None @@ -237,7 +241,7 @@ class NrcanUsageParameters: construction_archetype = building_archetype average_storey_height = building_archetype.average_storey_height 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, building.function, building.year_of_construction, climate_zone)