From 35667ab0832ade2ffc250c51776afd191e32ab61 Mon Sep 17 00:00:00 2001 From: Guille Date: Wed, 14 Apr 2021 10:22:29 -0400 Subject: [PATCH] Correct errors in simplified radiosity algorithm export --- city_model_structure/attributes/surface.py | 9 +++++++-- exports/formats/simplified_radiosity_algorithm.py | 13 ++++++------- requirements.txt | 5 ++++- tests/test_exports.py | 5 +++-- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/city_model_structure/attributes/surface.py b/city_model_structure/attributes/surface.py index 5be1f94d..168b8eb8 100644 --- a/city_model_structure/attributes/surface.py +++ b/city_model_structure/attributes/surface.py @@ -19,6 +19,7 @@ class Surface: self._type = surface_type self._swr = swr self._name = None + self._id = None self._azimuth = None self._inclination = None self._area_above_ground = None @@ -39,7 +40,7 @@ class Surface: :return: str """ if self._name is None: - self._name = uuid.uuid4() + self._name = str(uuid.uuid4()) return self._name @property @@ -48,7 +49,11 @@ class Surface: Surface id :return str """ - return str(self.name)[:8] + if self._id is None: + self._id = self.name.replace('-', '').replace('a', '').replace('b', '').replace('c', '').replace('d', '') + self._id = self._id.replace('e', '').replace('f', '') + print(self._id) + return self._id @property def swr(self): diff --git a/exports/formats/simplified_radiosity_algorithm.py b/exports/formats/simplified_radiosity_algorithm.py index 4d38ad07..562e3348 100644 --- a/exports/formats/simplified_radiosity_algorithm.py +++ b/exports/formats/simplified_radiosity_algorithm.py @@ -41,19 +41,18 @@ class SimplifiedRadiosityAlgorithm: '@ShortWaveReflectance': f'{surface.swr}' } for point_index, point in enumerate(surface.perimeter_polygon.points): - # todo: check corrected points point = self._correct_point(point) surface_dict[f'V{point_index}'] = { '@x': f'{point[0]}', '@y': f'{point[1]}', '@z': f'{point[2]}' } - if surface.type == 'Wall': - walls.append(surface_dict) - elif surface.type == 'Roof': - roofs.append(surface_dict) - else: - floors.append(surface_dict) + if surface.type == 'Wall': + walls.append(surface_dict) + elif surface.type == 'Roof': + roofs.append(surface_dict) + else: + floors.append(surface_dict) building_dict['Wall'] = walls building_dict['Roof'] = roofs building_dict['Floor'] = floors diff --git a/requirements.txt b/requirements.txt index 638c0a1d..53fd1d8f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,7 @@ esoreader~=1.2.3 geomeppy~=0.11.8 open3d~=0.12.0 pathlib~=1.0.1 -PyWavefront~=1.3.3 \ No newline at end of file +PyWavefront~=1.3.3 +xlrd~=2.0.1 +openpyxl~=3.0.7 +networkx~=2.5.1 \ No newline at end of file diff --git a/tests/test_exports.py b/tests/test_exports.py index 3052befb..d2762fbc 100644 --- a/tests/test_exports.py +++ b/tests/test_exports.py @@ -38,9 +38,10 @@ class TestExports(TestCase): cli = 'C:\\Users\\Pilar\\PycharmProjects\\monthlyenergybalance\\tests_data\\weather\\inseldb_Summerland.cli' self._city_gml.climate_file = Path(cli) self._city_gml.climate_reference_city = 'Summerland' + dummy_measures = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] for building in self._city_gml.buildings: - building.heating['month'] = pd.DataFrame({'INSEL': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}) - building.cooling['month'] = pd.DataFrame({'INSEL': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}) + building.heating['month'] = pd.DataFrame({'INSEL': dummy_measures}) + building.cooling['month'] = pd.DataFrame({'INSEL': dummy_measures}) building.heating['year'] = pd.DataFrame({'INSEL': [0.0]}) building.cooling['year'] = pd.DataFrame({'INSEL': [0.0]}) return self._city_gml