From db1d2362c8e109ab75ee77933c46c7d97568b4c2 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Fri, 9 Jun 2023 13:12:00 -0400 Subject: [PATCH 1/2] bug in idf.py and added uuid to building_name in geojson importer --- hub/exports/building_energy/idf.py | 40 +++++++++++++----------------- hub/imports/geometry/geojson.py | 4 ++- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/hub/exports/building_energy/idf.py b/hub/exports/building_energy/idf.py index 9cca4301..a8a465b8 100644 --- a/hub/exports/building_energy/idf.py +++ b/hub/exports/building_energy/idf.py @@ -446,31 +446,24 @@ class Idf: ) def _add_infiltration(self, thermal_zone, zone_name): - - for zone in self._idf.idfobjects["ZONE"]: - if zone.Name == f'{zone_name}_infiltration': - return - schedule = f'Infiltration schedules {thermal_zone.usage_name}' - self._idf.newidfobject(self._INFILTRATION, - Name=f'{zone_name}_infiltration', - Zone_or_ZoneList_Name=zone_name, - Schedule_Name=schedule, - Design_Flow_Rate_Calculation_Method='AirChanges/Hour', - Air_Changes_per_Hour=thermal_zone.infiltration_rate_system_off - ) + schedule = f'Infiltration schedules {thermal_zone.usage_name}' + self._idf.newidfobject(self._INFILTRATION, + Name=f'{zone_name}_infiltration', + Zone_or_ZoneList_Name=zone_name, + Schedule_Name=schedule, + Design_Flow_Rate_Calculation_Method='AirChanges/Hour', + Air_Changes_per_Hour=thermal_zone.infiltration_rate_system_off + ) def _add_ventilation(self, thermal_zone, zone_name): - for zone in self._idf.idfobjects["ZONE"]: - if zone.Name == f'{zone_name}_ventilation': - return - schedule = f'Ventilation schedules {thermal_zone.usage_name}' - self._idf.newidfobject(self._VENTILATION, - Name=f'{zone_name}_ventilation', - Zone_or_ZoneList_Name=zone_name, - Schedule_Name=schedule, - Design_Flow_Rate_Calculation_Method='AirChanges/Hour', - Air_Changes_per_Hour=thermal_zone.mechanical_air_change - ) + schedule = f'Ventilation schedules {thermal_zone.usage_name}' + self._idf.newidfobject(self._VENTILATION, + Name=f'{zone_name}_ventilation', + Zone_or_ZoneList_Name=zone_name, + Schedule_Name=schedule, + Design_Flow_Rate_Calculation_Method='AirChanges/Hour', + Air_Changes_per_Hour=thermal_zone.mechanical_air_change + ) def _add_dhw(self, thermal_zone, zone_name): peak_flow_rate = thermal_zone.domestic_hot_water.peak_flow * thermal_zone.total_floor_area @@ -514,6 +507,7 @@ class Idf: self._rename_building(self._city.name) self._lod = self._city.level_of_detail.geometry for building in self._city.buildings: + print('building name', building.name) for internal_zone in building.internal_zones: if internal_zone.thermal_zones is None: continue diff --git a/hub/imports/geometry/geojson.py b/hub/imports/geometry/geojson.py index 10bd0e72..a66ab7cf 100644 --- a/hub/imports/geometry/geojson.py +++ b/hub/imports/geometry/geojson.py @@ -5,6 +5,7 @@ Copyright © 2022 Concordia CERC group Project Coder Guillermo Gutierrez Guillermo.GutierrezMorote@concordia.ca """ +import uuid import json import numpy as np @@ -126,10 +127,11 @@ class Geojson: if function in self._function_to_hub: function = self._function_to_hub[function] geometry = feature['geometry'] - building_name = '' building_aliases = [] if 'id' in feature: building_name = feature['id'] + else: + building_name = uuid.uuid4() if self._aliases_field is not None: for alias_field in self._aliases_field: From 5dcead4e5d471a96a576f398f1bd0f0975c48a14 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Fri, 9 Jun 2023 13:36:21 -0400 Subject: [PATCH 2/2] bug in function reading, expecting str and getting int --- hub/imports/geometry/geojson.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hub/imports/geometry/geojson.py b/hub/imports/geometry/geojson.py index a66ab7cf..29b8551e 100644 --- a/hub/imports/geometry/geojson.py +++ b/hub/imports/geometry/geojson.py @@ -121,7 +121,7 @@ class Geojson: year_of_construction = int(feature['properties'][self._year_of_construction_field]) function = None if self._function_field is not None: - function = feature['properties'][self._function_field] + function = str(feature['properties'][self._function_field]) if self._function_to_hub is not None: # use the transformation dictionary to retrieve the proper function if function in self._function_to_hub: