From 5b99d3b190e3c9b9ea7aa6c213cf10fe9b83ad57 Mon Sep 17 00:00:00 2001 From: home-imac Date: Thu, 17 Nov 2022 17:28:24 -0500 Subject: [PATCH 1/5] ignore __pycache__ --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c1c7f0df..5cb348dd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /data/energy_systems/heat_pumps/*.csv /data/energy_systems/heat_pumps/*.insel .DS_Store +**/__pycache__/ From c24ad62081bf060532fa26b13c83dddbcaf62186 Mon Sep 17 00:00:00 2001 From: home-imac Date: Fri, 18 Nov 2022 15:36:03 -0500 Subject: [PATCH 2/5] fixed importer and geometr factory issue --- imports/geometry/gpandas.py | 8 ++++---- imports/geometry_factory.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/imports/geometry/gpandas.py b/imports/geometry/gpandas.py index 5edbe0c6..d716c8cf 100644 --- a/imports/geometry/gpandas.py +++ b/imports/geometry/gpandas.py @@ -58,10 +58,10 @@ class GPandas: if self._city is None: self._city = City(self._lower_corner, self._upper_corner, self._srs_name) for scene_index, bldg in self._scene.iterrows(): - geom = bldg.geom - polygon = ShapelyPoly(geom['coordinates'][0]) - height = float(bldg['height_mean']) - building_mesh = trimesh.creation.extrude_polygon(polygon, height) + geometry = bldg.geometry + # polygon = ShapelyPoly(geometry['coordinates'][0]) + height = float(bldg['height']) + building_mesh = trimesh.creation.extrude_polygon(geometry, height) trimesh.repair.fill_holes(building_mesh) trimesh.repair.fix_winding(building_mesh) year_of_construction = int(bldg['year_built']) diff --git a/imports/geometry_factory.py b/imports/geometry_factory.py index e9daa30b..eec1e130 100644 --- a/imports/geometry_factory.py +++ b/imports/geometry_factory.py @@ -17,7 +17,7 @@ class GeometryFactory: """ GeometryFactory class """ - def __init__(self, file_type, path, data_frame=None): + def __init__(self, file_type, path=None, data_frame=None): self._file_type = '_' + file_type.lower() self._path = path self._data_frame = data_frame @@ -46,6 +46,7 @@ class GeometryFactory: """ if self._data_frame is None: self._data_frame = geopandas.read_file(self._path) + print( self._data_frame ) return GPandas(self._data_frame).city @property From ac9b51b8b96386e473b00df280b73ec51aa11210 Mon Sep 17 00:00:00 2001 From: Pilar Date: Mon, 21 Nov 2022 11:31:30 -0500 Subject: [PATCH 3/5] Temporary fixed in geopandas importer --- imports/geometry_factory.py | 2 +- unittests/test_geometry_factory.py | 2 +- unittests/tests_data/sample.geojson | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imports/geometry_factory.py b/imports/geometry_factory.py index eec1e130..51683847 100644 --- a/imports/geometry_factory.py +++ b/imports/geometry_factory.py @@ -17,7 +17,7 @@ class GeometryFactory: """ GeometryFactory class """ - def __init__(self, file_type, path=None, data_frame=None): + def __init__(self, file_type, path, data_frame=None): self._file_type = '_' + file_type.lower() self._path = path self._data_frame = data_frame diff --git a/unittests/test_geometry_factory.py b/unittests/test_geometry_factory.py index a35c1d86..dc6381d5 100644 --- a/unittests/test_geometry_factory.py +++ b/unittests/test_geometry_factory.py @@ -36,7 +36,7 @@ class TestGeometryFactory(TestCase): def _get_geojson(self, file): file_path = (self._example_path / file).resolve() - self._city = GeometryFactory('gpandas', file_path).city_debug + self._city = GeometryFactory('gpandas', path=file_path).city self.assertIsNotNone(self._city, 'city is none') return self._city diff --git a/unittests/tests_data/sample.geojson b/unittests/tests_data/sample.geojson index 254542b3..3b1f2eca 100644 --- a/unittests/tests_data/sample.geojson +++ b/unittests/tests_data/sample.geojson @@ -10,7 +10,7 @@ }, "properties": { "geom": {"type": "Polygon", "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:EPSG::4326"}}, "coordinates": [[[3849322.0855625975, 6060583.24800576], [3849326.3956304314, 6060584.796717078], [3849327.0180495544, 6060583.089519385], [3849333.725799462, 6060585.837955164], [3849328.71788522, 6060598.03498192], [3849317.850609142, 6060593.57976506], [3849322.0855625975, 6060583.24800576]]]}, - "height_mean": 13.0790429485, + "height": 13.0790429485, "year_built": 2000 } } From 6be5325f75102b1e435076c72c68aa2bc37f9a53 Mon Sep 17 00:00:00 2001 From: guille Date: Mon, 21 Nov 2022 13:53:58 -0500 Subject: [PATCH 4/5] Correct unit tests due latest changes in gpandas handler. Partial rollback of some changes --- MACOS_INSTALL.md | 2 +- WINDOWS_INSTALL.md | 2 +- catalog_factories/greenery_catalog_factory.py | 2 +- exports/formats/obj.py | 2 +- imports/geometry/gpandas.py | 7 ++++--- imports/geometry_factory.py | 3 +-- unittests/test_city_merge.py | 2 +- unittests/test_construction_factory.py | 2 +- unittests/test_doe_idf.py | 2 +- unittests/test_energy_systems_air_source_hp.py | 2 +- unittests/test_energy_systems_water_to_water_hp.py | 2 +- unittests/test_enrichement.py | 2 +- unittests/test_exports.py | 2 +- unittests/test_geometry_factory.py | 8 ++++---- unittests/test_greenery_catalog.py | 2 +- unittests/test_greenery_in_idf.py | 4 ++-- unittests/test_life_cycle_assessment_factory.py | 8 ++++---- unittests/test_schedules_factory.py | 2 +- unittests/test_usage_factory.py | 2 +- 19 files changed, 29 insertions(+), 29 deletions(-) diff --git a/MACOS_INSTALL.md b/MACOS_INSTALL.md index 1432ac1e..caccd92e 100644 --- a/MACOS_INSTALL.md +++ b/MACOS_INSTALL.md @@ -164,7 +164,7 @@ When all the dependencies are satisfied, you are all set to start importing your Add the following code to your main.py from imports.geometry_factory import GeometryFactory -city = GeometryFactory('citygml', 'myfile.gml').city +city = GeometryFactory('citygml', path='myfile.gml').city Always remember to push your own project changes as the last thing you do before ending your working day! First, commit your changes by clicking on the green check in the top-right corner of Pycharm. Add a comment diff --git a/WINDOWS_INSTALL.md b/WINDOWS_INSTALL.md index d38e41ec..548497f5 100644 --- a/WINDOWS_INSTALL.md +++ b/WINDOWS_INSTALL.md @@ -237,7 +237,7 @@ Add the following code to your main.py from imports.geometry_factory import GeometryFactory -city = GeometryFactory('citygml', 'myfile.gml').city +city = GeometryFactory('citygml', path='myfile.gml').city ``` 9. Always remember to push your own project changes as the last thing you do before ending your working day! diff --git a/catalog_factories/greenery_catalog_factory.py b/catalog_factories/greenery_catalog_factory.py index f9284750..08864c41 100644 --- a/catalog_factories/greenery_catalog_factory.py +++ b/catalog_factories/greenery_catalog_factory.py @@ -12,7 +12,7 @@ Catalog = TypeVar('Catalog') class GreeneryCatalogFactory: """ - GeometryFactory class + GreeneryCatalogFactory class """ def __init__(self, file_type, base_path=None): if base_path is None: diff --git a/exports/formats/obj.py b/exports/formats/obj.py index bf1bee2b..f7237005 100644 --- a/exports/formats/obj.py +++ b/exports/formats/obj.py @@ -26,7 +26,7 @@ class Obj(Triangular): file_name_out = self._city.name + '_ground.' + self._triangular_format file_path_in = (Path(self._path).resolve() / file_name_in).resolve() file_path_out = (Path(self._path).resolve() / file_name_out).resolve() - scene = GeometryFactory('obj', file_path_in).scene + scene = GeometryFactory('obj', path=file_path_in).scene scene.rezero() obj_file = trimesh.exchange.obj.export_obj(scene) with open(file_path_out, 'w') as file: diff --git a/imports/geometry/gpandas.py b/imports/geometry/gpandas.py index d716c8cf..12fa4c95 100644 --- a/imports/geometry/gpandas.py +++ b/imports/geometry/gpandas.py @@ -40,6 +40,7 @@ class GPandas: self._scene = dataframe self._scene = self._scene.to_crs(self._srs_name) min_x, min_y, max_x, max_y = self._scene.total_bounds + print(min_x) self._lower_corner = [min_x, min_y, 0] self._upper_corner = [max_x, max_y, 0] @@ -58,10 +59,10 @@ class GPandas: if self._city is None: self._city = City(self._lower_corner, self._upper_corner, self._srs_name) for scene_index, bldg in self._scene.iterrows(): - geometry = bldg.geometry - # polygon = ShapelyPoly(geometry['coordinates'][0]) + geometry = bldg.geom + polygon = ShapelyPoly(geometry['coordinates'][0]) height = float(bldg['height']) - building_mesh = trimesh.creation.extrude_polygon(geometry, height) + building_mesh = trimesh.creation.extrude_polygon(polygon, height) trimesh.repair.fill_holes(building_mesh) trimesh.repair.fix_winding(building_mesh) year_of_construction = int(bldg['year_built']) diff --git a/imports/geometry_factory.py b/imports/geometry_factory.py index 51683847..22b8df8b 100644 --- a/imports/geometry_factory.py +++ b/imports/geometry_factory.py @@ -17,7 +17,7 @@ class GeometryFactory: """ GeometryFactory class """ - def __init__(self, file_type, path, data_frame=None): + def __init__(self, file_type, path=None, data_frame=None): self._file_type = '_' + file_type.lower() self._path = path self._data_frame = data_frame @@ -46,7 +46,6 @@ class GeometryFactory: """ if self._data_frame is None: self._data_frame = geopandas.read_file(self._path) - print( self._data_frame ) return GPandas(self._data_frame).city @property diff --git a/unittests/test_city_merge.py b/unittests/test_city_merge.py index e1ecaac9..3e087fa0 100644 --- a/unittests/test_city_merge.py +++ b/unittests/test_city_merge.py @@ -23,7 +23,7 @@ class TestCityMerge(TestCase): def _get_citygml(self, file): file_path = (self._example_path / file).resolve() - city = GeometryFactory('citygml', file_path).city + city = GeometryFactory('citygml', path=file_path).city self.assertIsNotNone(city, 'city is none') return city diff --git a/unittests/test_construction_factory.py b/unittests/test_construction_factory.py index 6ca15a2c..e6c6dd50 100644 --- a/unittests/test_construction_factory.py +++ b/unittests/test_construction_factory.py @@ -26,7 +26,7 @@ class TestConstructionFactory(TestCase): def _get_citygml(self, file): file_path = (self._example_path / file).resolve() - self._city = GeometryFactory('citygml', file_path).city + self._city = GeometryFactory('citygml', path=file_path).city self.assertIsNotNone(self._city, 'city is none') return self._city diff --git a/unittests/test_doe_idf.py b/unittests/test_doe_idf.py index b7eddcf7..0afb40b9 100644 --- a/unittests/test_doe_idf.py +++ b/unittests/test_doe_idf.py @@ -27,7 +27,7 @@ class TestBuildings(TestCase): def test_doe_idf(self): city_file = "../unittests/tests_data/one_building_in_kelowna.gml" output_path = Path('../unittests/tests_outputs/').resolve() - city = GeometryFactory('citygml', city_file).city + city = GeometryFactory('citygml', path=city_file).city for building in city.buildings: building.year_of_construction = 2006 ConstructionFactory('nrel', city).enrich() diff --git a/unittests/test_energy_systems_air_source_hp.py b/unittests/test_energy_systems_air_source_hp.py index 6f4edad8..ef06a648 100644 --- a/unittests/test_energy_systems_air_source_hp.py +++ b/unittests/test_energy_systems_air_source_hp.py @@ -25,7 +25,7 @@ class TestEnergySystemsFactory(TestCase): """ city_file = "../unittests/tests_data/C40_Final.gml" self._output_path = "../unittests/tests_data/as_user_output.csv" - self._city = GeometryFactory('citygml', city_file).city + self._city = GeometryFactory('citygml', path=city_file).city EnergySystemsFactory('air source hp', self._city).enrich() def test_air_source_heat_pump_import(self): diff --git a/unittests/test_energy_systems_water_to_water_hp.py b/unittests/test_energy_systems_water_to_water_hp.py index 889f9127..a455834a 100644 --- a/unittests/test_energy_systems_water_to_water_hp.py +++ b/unittests/test_energy_systems_water_to_water_hp.py @@ -26,7 +26,7 @@ class TestEnergySystemsFactory(TestCase): """ city_file = "../unittests/tests_data/C40_Final.gml" self._output_path = "../unittests/tests_data/w2w_user_output.csv" - self._city = GeometryFactory('citygml', city_file).city + self._city = GeometryFactory('citygml', path=city_file).city EnergySystemsFactory('water to water hp', self._city).enrich() def test_water_to_water_heat_pump_import(self): diff --git a/unittests/test_enrichement.py b/unittests/test_enrichement.py index 6ace72d4..4d8ac187 100644 --- a/unittests/test_enrichement.py +++ b/unittests/test_enrichement.py @@ -27,7 +27,7 @@ class TestGeometryFactory(TestCase): def _get_citygml(self, file): file_path = (self._example_path / file).resolve() - self._city = GeometryFactory('citygml', file_path).city + self._city = GeometryFactory('citygml', path=file_path).city self.assertIsNotNone(self._city, 'city is none') return self._city diff --git a/unittests/test_exports.py b/unittests/test_exports.py index 75dc96f0..c33fa715 100644 --- a/unittests/test_exports.py +++ b/unittests/test_exports.py @@ -34,7 +34,7 @@ class TestExports(TestCase): def _get_citygml(self, file): file_path = (self._example_path / file).resolve() - self._city = GeometryFactory('citygml', file_path).city + self._city = GeometryFactory('citygml', path=file_path).city self.assertIsNotNone(self._city, 'city is none') return self._city diff --git a/unittests/test_geometry_factory.py b/unittests/test_geometry_factory.py index dc6381d5..580fd207 100644 --- a/unittests/test_geometry_factory.py +++ b/unittests/test_geometry_factory.py @@ -30,7 +30,7 @@ class TestGeometryFactory(TestCase): def _get_citygml(self, file): file_path = (self._example_path / file).resolve() - self._city = GeometryFactory('citygml', file_path).city + self._city = GeometryFactory('citygml', path=file_path).city self.assertIsNotNone(self._city, 'city is none') return self._city @@ -43,13 +43,13 @@ class TestGeometryFactory(TestCase): def _get_obj(self, file): # todo: solve the incongruities between city and city_debug file_path = (self._example_path / file).resolve() - self._city = GeometryFactory('obj', file_path).city + self._city = GeometryFactory('obj', path=file_path).city self.assertIsNotNone(self._city, 'city is none') return self._city def _get_rhino(self, file): file_path = (self._example_path / file).resolve() - self._city = GeometryFactory('rhino', file_path).city + self._city = GeometryFactory('rhino', path=file_path).city self.assertIsNotNone(self._city, 'city is none') return self._city @@ -178,7 +178,7 @@ class TestGeometryFactory(TestCase): """ file_path = (self._example_path / 'subway.osm').resolve() - city = GeometryFactory('osm_subway', file_path).city + city = GeometryFactory('osm_subway', path=file_path).city self.assertIsNotNone(city, 'subway entrances is none') self.assertEqual(len(city.city_objects), 20, 'Wrong number of subway entrances') diff --git a/unittests/test_greenery_catalog.py b/unittests/test_greenery_catalog.py index 7959b127..efcde06e 100644 --- a/unittests/test_greenery_catalog.py +++ b/unittests/test_greenery_catalog.py @@ -1,5 +1,5 @@ """ -TestGeometryFactory test and validate the city model structure geometric parameters +Test greenery factory test and validate the greenery construction SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca diff --git a/unittests/test_greenery_in_idf.py b/unittests/test_greenery_in_idf.py index 216ea390..fe251329 100644 --- a/unittests/test_greenery_in_idf.py +++ b/unittests/test_greenery_in_idf.py @@ -27,7 +27,7 @@ class GreeneryInIdf(TestCase): city_file = "../unittests/tests_data/one_building_in_kelowna.gml" output_path = Path('../unittests/tests_outputs/').resolve() - city = GeometryFactory('citygml', city_file).city + city = GeometryFactory('citygml', path=city_file).city for building in city.buildings: building.year_of_construction = 2006 ConstructionFactory('nrel', city).enrich() @@ -80,7 +80,7 @@ class GreeneryInIdf(TestCase): print('With greenery') print(f'heating: {heating} MWh/yr, cooling: {cooling} MWh/yr') - city = GeometryFactory('citygml', city_file).city + city = GeometryFactory('citygml', path=city_file).city for building in city.buildings: building.year_of_construction = 2006 ConstructionFactory('nrel', city).enrich() diff --git a/unittests/test_life_cycle_assessment_factory.py b/unittests/test_life_cycle_assessment_factory.py index 43ba7feb..ef00cd79 100644 --- a/unittests/test_life_cycle_assessment_factory.py +++ b/unittests/test_life_cycle_assessment_factory.py @@ -24,28 +24,28 @@ class TestLifeCycleAssessment(TestCase): def test_fuel(self): city_file = "../unittests/tests_data/C40_Final.gml" - city = GeometryFactory('citygml', city_file).city + city = GeometryFactory('citygml', path=city_file).city LifeCycleAssessment('fuel', city).enrich() for fuel in city.fuels: self.assertTrue(len(city.fuels) > 0) def test_vehicle(self): city_file = "../unittests/tests_data/C40_Final.gml" - city = GeometryFactory('citygml', city_file).city + city = GeometryFactory('citygml', path=city_file).city LifeCycleAssessment('vehicle', city).enrich() for vehicle in city.vehicles: self.assertTrue(len(city.vehicles) > 0) def test_machine(self): city_file = "../unittests/tests_data/C40_Final.gml" - city = GeometryFactory('citygml', city_file).city + city = GeometryFactory('citygml', path=city_file).city LifeCycleAssessment('machine', city).enrich() for machine in city.machines: self.assertTrue(len(city.machines) > 0) def test_material(self): city_file = "../unittests/tests_data/C40_Final.gml" - city = GeometryFactory('citygml', city_file).city + city = GeometryFactory('citygml', path=city_file).city LifeCycleAssessment('material', city).enrich() for material in city.lca_materials: self.assertTrue(len(city.lca_materials) > 0) diff --git a/unittests/test_schedules_factory.py b/unittests/test_schedules_factory.py index 85a3c45d..3d7f5180 100644 --- a/unittests/test_schedules_factory.py +++ b/unittests/test_schedules_factory.py @@ -28,7 +28,7 @@ class TestSchedulesFactory(TestCase): def _get_citygml(self, file): file_path = (self._example_path / file).resolve() - _city = GeometryFactory('citygml', file_path).city + _city = GeometryFactory('citygml', path=file_path).city for building in _city.buildings: building.year_of_construction = 2006 ConstructionFactory('nrel', _city).enrich() diff --git a/unittests/test_usage_factory.py b/unittests/test_usage_factory.py index 15138579..f4feb04c 100644 --- a/unittests/test_usage_factory.py +++ b/unittests/test_usage_factory.py @@ -26,7 +26,7 @@ class TestUsageFactory(TestCase): def _get_citygml(self, file): file_path = (self._example_path / file).resolve() - self._city = GeometryFactory('citygml', file_path).city + self._city = GeometryFactory('citygml', path=file_path).city self.assertIsNotNone(self._city, 'city is none') return self._city From cfa424121351d16115b5dbbba0d69d8bb0dfb722 Mon Sep 17 00:00:00 2001 From: guille Date: Mon, 21 Nov 2022 14:00:12 -0500 Subject: [PATCH 5/5] rollback quick fix --- imports/construction/us_physics_parameters.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/imports/construction/us_physics_parameters.py b/imports/construction/us_physics_parameters.py index 657164bf..2baa6749 100644 --- a/imports/construction/us_physics_parameters.py +++ b/imports/construction/us_physics_parameters.py @@ -74,9 +74,7 @@ class UsPhysicsParameters(NrelPhysicsInterface): if (str(function) == str(building_archetype.function)) and \ (climate_zone == str(building_archetype.climate_zone)): return building_archetype - # Todo: line below is added by Milad as a quick fix for when archetypes search is not found - return building_archetype - # return None + return None @staticmethod def _search_construction_in_archetype(archetype, construction_type):