diff --git a/unittest/test_sra_workflow.py b/unittest/test_sra_workflow.py new file mode 100644 index 0000000..c935066 --- /dev/null +++ b/unittest/test_sra_workflow.py @@ -0,0 +1,69 @@ +""" +TestSRAWorkflow test +SPDX - License - Identifier: LGPL - 3.0 - or -later +Copyright © 2022 Concordia CERC group +Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca +""" + +from pathlib import Path +from unittest import TestCase +import helpers.constants as cte +from imports.geometry_factory import GeometryFactory +from imports.construction_factory import ConstructionFactory +from imports.usage_factory import UsageFactory +from imports.weather_factory import WeatherFactory +from simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm + + +class TestSRAWorkflow(TestCase): + """ + TestSRAWorkflow class + """ + def setUp(self) -> None: + """ + Test setup + :return: None + """ + self._city = None + self._complete_city = None + self._example_path = (Path(__file__).parent / 'tests_data').resolve() + self._output_path = (Path(__file__).parent / 'tests_outputs').resolve() + + def _get_citygml(self, file): + file_path = (self._example_path / file).resolve() + self._city = GeometryFactory('citygml', path=file_path).city + self.assertIsNotNone(self._city, 'city is none') + return self._city + + @staticmethod + def _enrich_city(city, weather_file, weather_format, construction_format, usage_format): + WeatherFactory(weather_format, city, file_name=weather_file).enrich() + + for building in city.buildings: + building.year_of_construction = 2006 + if building.function is None: + building.function = cte.LARGE_OFFICE + + ConstructionFactory(construction_format, city).enrich() + UsageFactory(usage_format, city).enrich() + + def test_workflow(self): + path = Path(__file__).parent.parent + + gml_file = 'one_building_in_kelowna.gml' + city = self._get_citygml(gml_file) + + climate_reference_city = 'Montreal' + weather_file = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw' + weather_format = 'epw' + construction_format = 'nrel' + usage_format = 'comnet' + city.climate_reference_city = climate_reference_city + city.climate_file = (path / 'tmp' / f'{climate_reference_city}.cli').resolve() + + self._enrich_city(city, weather_file, weather_format, construction_format, usage_format) + sra = SimplifiedRadiosityAlgorithm(city, path, weather_file) + sra.call_sra(weather_format, keep_files=True) + sra.set_irradiance_surfaces(city) + sra.set_irradiance_surfaces(city, mode=1) + diff --git a/unittest/tests_data/one_building_in_kelowna.gml b/unittest/tests_data/one_building_in_kelowna.gml new file mode 100644 index 0000000..a13a1fe --- /dev/null +++ b/unittest/tests_data/one_building_in_kelowna.gml @@ -0,0 +1,409 @@ + + + + +326011.03601000085 5526048.416990001 -1.6000000000058208 +329466.6600299999 5529018.72205 9.80000000000291 + + + + + +291 + + +m2 + +residential +1996 +5.3 +1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +329231.5010599997 5528270.404139999 4.311470000000554 329229.15295 5528271.14002 3.8000000000029104 329229.30395000055 5528269.304020001 3.8000000000029104 329231.5010599997 5528270.404139999 4.311470000000554 + + + + + + + + + + + + + + + + +329248.8121399991 5528267.658840001 4.925719999999274 329254.11205999926 5528262.99903 3.8000000000029104 329253.52796000056 5528272.956 3.8000000000029104 329248.8121399991 5528267.658840001 4.925719999999274 + + + + + + + + + + + + + + + + +329246.16602000035 5528272.533020001 0 329246.16602000035 5528272.533020001 3.8000000000029104 329253.52796000056 5528272.956 3.8000000000029104 329253.52796000056 5528272.956 0 329246.16602000035 5528272.533020001 0 + + + + + + + + + + + + + + + + +329241.7199700009 5528276.307010001 0 329241.7199700009 5528276.307010001 3.8000000000029104 329246.16602000035 5528272.533020001 3.8000000000029104 329246.16602000035 5528272.533020001 0 329241.7199700009 5528276.307010001 0 + + + + + + + + + + + + + + + + +329237.9890100006 5528272.159 0 329237.9890100006 5528272.159 3.8000000000029104 329241.7199700009 5528276.307010001 3.8000000000029104 329241.7199700009 5528276.307010001 0 329237.9890100006 5528272.159 0 + + + + + + + + + + + + + + + + +329233.3360600006 5528276.213989999 0 329233.3360600006 5528276.213989999 3.8000000000029104 329237.9890100006 5528272.159 3.8000000000029104 329237.9890100006 5528272.159 0 329233.3360600006 5528276.213989999 0 + + + + + + + + + + + + + + + + +329229.15295 5528271.14002 0 329229.15295 5528271.14002 3.8000000000029104 329233.3360600006 5528276.213989999 3.8000000000029104 329233.3360600006 5528276.213989999 0 329229.15295 5528271.14002 0 + + + + + + + + + + + + + + + + +329229.30395000055 5528269.304020001 0 329229.30395000055 5528269.304020001 3.8000000000029104 329229.15295 5528271.14002 3.8000000000029104 329229.15295 5528271.14002 0 329229.30395000055 5528269.304020001 0 + + + + + + + + + + + + + + + + +329242.40003000014 5528257.71503 0 329242.40003000014 5528257.71503 3.8000000000029104 329229.30395000055 5528269.304020001 3.8000000000029104 329229.30395000055 5528269.304020001 0 329242.40003000014 5528257.71503 0 + + + + + + + + + + + + + + + + +329247.3289800007 5528262.52503 0 329247.3289800007 5528262.52503 3.8000000000029104 329242.40003000014 5528257.71503 3.8000000000029104 329242.40003000014 5528257.71503 0 329247.3289800007 5528262.52503 0 + + + + + + + + + + + + + + + + +329254.11205999926 5528262.99903 0 329254.11205999926 5528262.99903 3.8000000000029104 329247.3289800007 5528262.52503 3.8000000000029104 329247.3289800007 5528262.52503 0 329254.11205999926 5528262.99903 0 + + + + + + + + + + + + + + + + +329253.52796000056 5528272.956 0 329253.52796000056 5528272.956 3.8000000000029104 329254.11205999926 5528262.99903 3.8000000000029104 329254.11205999926 5528262.99903 0 329253.52796000056 5528272.956 0 + + + + + + + + + + + + + + + + +329253.52796000056 5528272.956 0 329254.11205999926 5528262.99903 0 329247.3289800007 5528262.52503 0 329242.40003000014 5528257.71503 0 329229.30395000055 5528269.304020001 0 329229.15295 5528271.14002 0 329233.3360600006 5528276.213989999 0 329237.9890100006 5528272.159 0 329241.7199700009 5528276.307010001 0 329246.16602000035 5528272.533020001 0 329253.52796000056 5528272.956 0 + + + + + + + + + + + + + + + + +329246.16602000035 5528272.533020001 3.8000000000029104 329244.33748999983 5528267.074109999 4.999100000000908 329245.1323099993 5528267.42457 4.930840000000899 329248.8121399991 5528267.658840001 4.925719999999274 329253.52796000056 5528272.956 3.8000000000029104 329246.16602000035 5528272.533020001 3.8000000000029104 + + + + + + + + + + + + + + + + +329241.7199700009 5528276.307010001 3.8000000000029104 329242.3462899998 5528267.00502 5.30000000000291 329244.33748999983 5528267.074109999 4.999100000000908 329246.16602000035 5528272.533020001 3.8000000000029104 329241.7199700009 5528276.307010001 3.8000000000029104 + + + + + + + + + + + + + + + + +329237.9890100006 5528272.159 3.8000000000029104 329238.32637000084 5528266.609999999 4.6887600000045495 329242.1777599994 5528266.829500001 5.298219999996945 329242.3462899998 5528267.00502 5.30000000000291 329241.7199700009 5528276.307010001 3.8000000000029104 329237.9890100006 5528272.159 3.8000000000029104 + + + + + + + + + + + + + + + + +329233.3360600006 5528276.213989999 3.8000000000029104 329233.80010999925 5528270.5848900005 4.683640000002924 329238.32637000084 5528266.609999999 4.6887600000045495 329237.9890100006 5528272.159 3.8000000000029104 329233.3360600006 5528276.213989999 3.8000000000029104 + + + + + + + + + + + + + + + + +329229.15295 5528271.14002 3.8000000000029104 329231.5010599997 5528270.404139999 4.311470000000554 329233.80010999925 5528270.5848900005 4.683640000002924 329233.3360600006 5528276.213989999 3.8000000000029104 329229.15295 5528271.14002 3.8000000000029104 + + + + + + + + + + + + + + + + +329242.40003000014 5528257.71503 3.8000000000029104 329242.1777599994 5528266.829500001 5.298219999996945 329238.32637000084 5528266.609999999 4.6887600000045495 329233.80010999925 5528270.5848900005 4.683640000002924 329231.5010599997 5528270.404139999 4.311470000000554 329229.30395000055 5528269.304020001 3.8000000000029104 329242.40003000014 5528257.71503 3.8000000000029104 + + + + + + + + + + + + + + + + +329247.3289800007 5528262.52503 3.8000000000029104 329245.1323099993 5528267.42457 4.930840000000899 329244.33748999983 5528267.074109999 4.999100000000908 329242.3462899998 5528267.00502 5.30000000000291 329242.1777599994 5528266.829500001 5.298219999996945 329242.40003000014 5528257.71503 3.8000000000029104 329247.3289800007 5528262.52503 3.8000000000029104 + + + + + + + + + + + + + + + + +329254.11205999926 5528262.99903 3.8000000000029104 329248.8121399991 5528267.658840001 4.925719999999274 329245.1323099993 5528267.42457 4.930840000000899 329247.3289800007 5528262.52503 3.8000000000029104 329254.11205999926 5528262.99903 3.8000000000029104 + + + + + + + + + + +