Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2de8869dd3
|
@ -21,7 +21,7 @@ class Surface:
|
||||||
self._swr = swr
|
self._swr = swr
|
||||||
self._remove_last = remove_last
|
self._remove_last = remove_last
|
||||||
self._is_projected = is_projected
|
self._is_projected = is_projected
|
||||||
self._geometry = GeometryHelper()
|
self._geometry_helper = GeometryHelper()
|
||||||
self._polygon = None
|
self._polygon = None
|
||||||
self._ground_polygon = None
|
self._ground_polygon = None
|
||||||
self._area = None
|
self._area = None
|
||||||
|
@ -309,7 +309,7 @@ class Surface:
|
||||||
"""
|
"""
|
||||||
if self.type != 'Wall' or surface.type != 'Wall':
|
if self.type != 'Wall' or surface.type != 'Wall':
|
||||||
return
|
return
|
||||||
if self._geometry.is_almost_same_surface(self, surface):
|
if self._geometry_helper.is_almost_same_surface(self, surface):
|
||||||
intersection_area = self.intersect(surface).area
|
intersection_area = self.intersect(surface).area
|
||||||
self.add_shared(surface, intersection_area)
|
self.add_shared(surface, intersection_area)
|
||||||
surface.add_shared(self, intersection_area)
|
surface.add_shared(self, intersection_area)
|
||||||
|
|
|
@ -156,7 +156,7 @@ class ThermalOpening:
|
||||||
@property
|
@property
|
||||||
def overall_u_value(self):
|
def overall_u_value(self):
|
||||||
"""
|
"""
|
||||||
Get thermal opening overall u value
|
Get thermal opening overall u value in W/m2K
|
||||||
:return: float
|
:return: float
|
||||||
"""
|
"""
|
||||||
return self._overall_u_value
|
return self._overall_u_value
|
||||||
|
@ -164,7 +164,7 @@ class ThermalOpening:
|
||||||
@overall_u_value.setter
|
@overall_u_value.setter
|
||||||
def overall_u_value(self, value):
|
def overall_u_value(self, value):
|
||||||
"""
|
"""
|
||||||
Get thermal opening overall u value
|
Get thermal opening overall u value in W/m2K
|
||||||
:param value: float
|
:param value: float
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -85,7 +85,7 @@ class ThermalZone:
|
||||||
@property
|
@property
|
||||||
def additional_thermal_bridge_u_value(self):
|
def additional_thermal_bridge_u_value(self):
|
||||||
"""
|
"""
|
||||||
Get thermal zone additional thermal bridge u value
|
Get thermal zone additional thermal bridge u value W/m2K
|
||||||
:return: float
|
:return: float
|
||||||
"""
|
"""
|
||||||
return self._additional_thermal_bridge_u_value
|
return self._additional_thermal_bridge_u_value
|
||||||
|
@ -93,7 +93,7 @@ class ThermalZone:
|
||||||
@additional_thermal_bridge_u_value.setter
|
@additional_thermal_bridge_u_value.setter
|
||||||
def additional_thermal_bridge_u_value(self, value):
|
def additional_thermal_bridge_u_value(self, value):
|
||||||
"""
|
"""
|
||||||
Set thermal zone additional thermal bridge u value
|
Set thermal zone additional thermal bridge u value W/m2K
|
||||||
:param value: float
|
:param value: float
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -35,7 +35,7 @@ class UsBasePhysicsParameters:
|
||||||
archetype = self._search_archetype(building_type,
|
archetype = self._search_archetype(building_type,
|
||||||
UsToLibraryTypes.yoc_to_standard(city_object.year_of_construction),
|
UsToLibraryTypes.yoc_to_standard(city_object.year_of_construction),
|
||||||
self._climate_zone)
|
self._climate_zone)
|
||||||
# ToDo:remove this in the future
|
# ToDo: remove this in the future
|
||||||
# ToDo: Raise WrongArchetype if not all the surface types are defined for the given city_object
|
# ToDo: Raise WrongArchetype if not all the surface types are defined for the given city_object
|
||||||
if archetype is None:
|
if archetype is None:
|
||||||
print(building_type, UsToLibraryTypes.yoc_to_standard(city_object.year_of_construction),
|
print(building_type, UsToLibraryTypes.yoc_to_standard(city_object.year_of_construction),
|
||||||
|
|
|
@ -4,9 +4,9 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||||
"""
|
"""
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from geometry.geometry_factory import GeometryFactory
|
from geometry.geometry_factory import GeometryFactory
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
class TestGeometryFactory(TestCase):
|
class TestGeometryFactory(TestCase):
|
||||||
|
@ -21,13 +21,9 @@ class TestGeometryFactory(TestCase):
|
||||||
self._city_gml = None
|
self._city_gml = None
|
||||||
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
|
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
|
||||||
|
|
||||||
def get_citygml(self):
|
def _get_citygml(self):
|
||||||
"""
|
|
||||||
Retrieve the test city gml
|
|
||||||
:return: City
|
|
||||||
"""
|
|
||||||
if self._city_gml is None:
|
if self._city_gml is None:
|
||||||
file_path = (self._example_path / '2050 bp_2buildings.gml').resolve()
|
file_path = (self._example_path / 'buildings.gml').resolve()
|
||||||
self._city_gml = GeometryFactory('citygml', file_path).city
|
self._city_gml = GeometryFactory('citygml', file_path).city
|
||||||
self.assertIsNotNone(self._city_gml, 'city is none')
|
self.assertIsNotNone(self._city_gml, 'city is none')
|
||||||
return self._city_gml
|
return self._city_gml
|
||||||
|
@ -37,7 +33,7 @@ class TestGeometryFactory(TestCase):
|
||||||
Test the City parsing
|
Test the City parsing
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
city = self.get_citygml()
|
city = self._get_citygml()
|
||||||
self.assertIsNotNone(city.city_objects, 'city_objects is none')
|
self.assertIsNotNone(city.city_objects, 'city_objects is none')
|
||||||
for city_object in city.city_objects:
|
for city_object in city.city_objects:
|
||||||
self.assertIsNotNone(city.city_object(city_object.name), 'city_object return none')
|
self.assertIsNotNone(city.city_object(city_object.name), 'city_object return none')
|
||||||
|
@ -52,7 +48,7 @@ class TestGeometryFactory(TestCase):
|
||||||
Test city objects in the city
|
Test city objects in the city
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
city = self.get_citygml()
|
city = self._get_citygml()
|
||||||
for city_object in city.city_objects:
|
for city_object in city.city_objects:
|
||||||
self.assertIsNotNone(city_object.name, 'city_object name is none')
|
self.assertIsNotNone(city_object.name, 'city_object name is none')
|
||||||
self.assertIsNotNone(city_object.lod, 'city_object lod is none')
|
self.assertIsNotNone(city_object.lod, 'city_object lod is none')
|
||||||
|
@ -80,7 +76,7 @@ class TestGeometryFactory(TestCase):
|
||||||
Test surfaces in city objects
|
Test surfaces in city objects
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
city = self.get_citygml()
|
city = self._get_citygml()
|
||||||
for city_object in city.city_objects:
|
for city_object in city.city_objects:
|
||||||
for surface in city_object.surfaces:
|
for surface in city_object.surfaces:
|
||||||
self.assertIsNotNone(surface.name, 'surface name is none')
|
self.assertIsNotNone(surface.name, 'surface name is none')
|
||||||
|
@ -111,7 +107,7 @@ class TestGeometryFactory(TestCase):
|
||||||
Test thermal zones in city objects
|
Test thermal zones in city objects
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
city = self.get_citygml()
|
city = self._get_citygml()
|
||||||
for city_object in city.city_objects:
|
for city_object in city.city_objects:
|
||||||
for thermal_zone in city_object.thermal_zones:
|
for thermal_zone in city_object.thermal_zones:
|
||||||
self.assertIsNotNone(thermal_zone.surfaces, 'thermal_zone surfaces is none')
|
self.assertIsNotNone(thermal_zone.surfaces, 'thermal_zone surfaces is none')
|
||||||
|
@ -137,7 +133,7 @@ class TestGeometryFactory(TestCase):
|
||||||
Test thermal boundaries in thermal zones
|
Test thermal boundaries in thermal zones
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
city = self.get_citygml()
|
city = self._get_citygml()
|
||||||
for city_object in city.city_objects:
|
for city_object in city.city_objects:
|
||||||
for thermal_zone in city_object.thermal_zones:
|
for thermal_zone in city_object.thermal_zones:
|
||||||
for thermal_boundary in thermal_zone.bounded:
|
for thermal_boundary in thermal_zone.bounded:
|
||||||
|
@ -167,7 +163,7 @@ class TestGeometryFactory(TestCase):
|
||||||
Test thermal openings in thermal zones
|
Test thermal openings in thermal zones
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
city = self.get_citygml()
|
city = self._get_citygml()
|
||||||
for city_object in city.city_objects:
|
for city_object in city.city_objects:
|
||||||
for thermal_zone in city_object.thermal_zones:
|
for thermal_zone in city_object.thermal_zones:
|
||||||
for thermal_boundary in thermal_zone.bounded:
|
for thermal_boundary in thermal_zone.bounded:
|
||||||
|
|
|
@ -13,26 +13,34 @@ class TestPhysicsFactory(TestCase):
|
||||||
"""
|
"""
|
||||||
TestPhysicsFactory TestCase
|
TestPhysicsFactory TestCase
|
||||||
"""
|
"""
|
||||||
def setup(self) -> None:
|
def setUp(self) -> None:
|
||||||
|
"""
|
||||||
|
Configure test environment
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
self._city_gml = None
|
self._city_gml = None
|
||||||
self._nyc_with_physics = None
|
self._nyc_with_physics = None
|
||||||
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
|
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
|
||||||
|
|
||||||
def get_citygml(self):
|
def _get_citygml(self):
|
||||||
if self._city_gml is None:
|
if self._city_gml is None:
|
||||||
file_path = (self._example_path / 'buildings.gml').resolve()
|
file_path = (self._example_path / 'buildings.gml').resolve()
|
||||||
self._city_gml = GeometryFactory('citygml', file_path).city
|
self._city_gml = GeometryFactory('citygml', file_path).city
|
||||||
self.assertIsNotNone(self._city_gml, 'city is none')
|
self.assertIsNotNone(self._city_gml, 'city is none')
|
||||||
return self._city_gml
|
return self._city_gml
|
||||||
|
|
||||||
def get_city_with_physics(self):
|
def _get_city_with_physics(self):
|
||||||
if self._nyc_with_physics is None:
|
if self._nyc_with_physics is None:
|
||||||
self._nyc_with_physics = self.get_citygml()
|
self._nyc_with_physics = self._get_citygml()
|
||||||
PhysicsFactory('us_new_york_city', self._nyc_with_physics, base_path=self._example_path)
|
PhysicsFactory('us_new_york_city', self._nyc_with_physics, base_path=self._example_path)
|
||||||
return self._nyc_with_physics
|
return self._nyc_with_physics
|
||||||
|
|
||||||
def test_city_with_physics(self):
|
def test_city_with_physics(self):
|
||||||
city = self.get_city_with_physics()
|
"""
|
||||||
|
Enrich the city with the physic information and verify ot
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
city = self._get_city_with_physics()
|
||||||
for city_object in city.city_objects:
|
for city_object in city.city_objects:
|
||||||
self.assertIsNotNone(city_object.average_storey_height, 'average_storey_height is none')
|
self.assertIsNotNone(city_object.average_storey_height, 'average_storey_height is none')
|
||||||
self.assertIsNotNone(city_object.storeys_above_ground, 'storeys_above_ground is none')
|
self.assertIsNotNone(city_object.storeys_above_ground, 'storeys_above_ground is none')
|
||||||
|
|
|
@ -8,22 +8,29 @@ from usage.usage_feeders.us_new_york_city_usage_parameters import UsNewYorkCityU
|
||||||
|
|
||||||
|
|
||||||
class UsageFactory:
|
class UsageFactory:
|
||||||
|
"""
|
||||||
|
UsageFactory class
|
||||||
|
"""
|
||||||
def __init__(self, handler, city):
|
def __init__(self, handler, city):
|
||||||
self._handler = handler.lower().replace(' ', '_')
|
self._handler = '_' + handler.lower().replace(' ', '_')
|
||||||
self._city = city
|
self._city = city
|
||||||
self.factory()
|
self.factory()
|
||||||
|
|
||||||
def us_new_york_city(self):
|
def _us_new_york_city(self):
|
||||||
UsNewYorkCityUsageParameters(self._city)
|
UsNewYorkCityUsageParameters(self._city)
|
||||||
|
|
||||||
def ca(self):
|
def _ca(self):
|
||||||
raise Exception('Not implemented')
|
raise Exception('Not implemented')
|
||||||
|
|
||||||
def de(self):
|
def _de(self):
|
||||||
DeUsageParameters(self._city)
|
DeUsageParameters(self._city)
|
||||||
|
|
||||||
def es(self):
|
def _es(self):
|
||||||
raise Exception('Not implemented')
|
raise Exception('Not implemented')
|
||||||
|
|
||||||
def factory(self):
|
def factory(self):
|
||||||
|
"""
|
||||||
|
Enrich the city with the usage information
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
getattr(self, self._handler, lambda: None)()
|
getattr(self, self._handler, lambda: None)()
|
||||||
|
|
|
@ -3,12 +3,15 @@ DeUsageParameters model the usage properties for a German building
|
||||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||||
"""
|
"""
|
||||||
import xmltodict
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import xmltodict
|
||||||
from usage.usage_feeders.helpers.us_function_to_usage import UsFunctionToUsage
|
from usage.usage_feeders.helpers.us_function_to_usage import UsFunctionToUsage
|
||||||
|
|
||||||
|
|
||||||
class DeUsageParameters:
|
class DeUsageParameters:
|
||||||
|
"""
|
||||||
|
DeUsageParameters
|
||||||
|
"""
|
||||||
def __init__(self, city_objects):
|
def __init__(self, city_objects):
|
||||||
self._city_objects = city_objects
|
self._city_objects = city_objects
|
||||||
|
|
||||||
|
@ -17,4 +20,4 @@ class DeUsageParameters:
|
||||||
with open(path) as xml:
|
with open(path) as xml:
|
||||||
self._library = xmltodict.parse(xml.read())
|
self._library = xmltodict.parse(xml.read())
|
||||||
for city_object in city_objects:
|
for city_object in city_objects:
|
||||||
UsFunctionToUsage.function_to_usage(city_object.function)
|
UsFunctionToUsage.usage(city_object.function)
|
||||||
|
|
|
@ -3,13 +3,16 @@ UsBaseUsageParameters base class to model the usage properties for a building in
|
||||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||||
"""
|
"""
|
||||||
import xmltodict
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import xmltodict
|
||||||
from city_model_structure.usage_zone import UsageZone
|
from city_model_structure.usage_zone import UsageZone
|
||||||
from city_model_structure.internal_gains import InternalGains
|
from city_model_structure.internal_gains import InternalGains
|
||||||
|
|
||||||
|
|
||||||
class UsBaseUsageParameters:
|
class UsBaseUsageParameters:
|
||||||
|
"""
|
||||||
|
UsBaseUsageParameters class
|
||||||
|
"""
|
||||||
def __init__(self, city, function_to_usage):
|
def __init__(self, city, function_to_usage):
|
||||||
self._city = city
|
self._city = city
|
||||||
# ToDo: this is using the german library as a temporary approach, need to use/define a library for US
|
# ToDo: this is using the german library as a temporary approach, need to use/define a library for US
|
||||||
|
@ -17,7 +20,7 @@ class UsBaseUsageParameters:
|
||||||
with open(path) as xml:
|
with open(path) as xml:
|
||||||
self._library = xmltodict.parse(xml.read(), force_list='zoneUsageVariant')
|
self._library = xmltodict.parse(xml.read(), force_list='zoneUsageVariant')
|
||||||
for city_object in self._city.city_objects:
|
for city_object in self._city.city_objects:
|
||||||
#ToDo: Right now is just one usage zone but will be multiple in the future
|
# ToDo: Right now is just one usage zone but will be multiple in the future
|
||||||
usage_zone = UsageZone()
|
usage_zone = UsageZone()
|
||||||
usage_zone.usage = function_to_usage(city_object.function)
|
usage_zone.usage = function_to_usage(city_object.function)
|
||||||
for zone_usage_type in self._library['buildingUsageLibrary']['zoneUsageType']:
|
for zone_usage_type in self._library['buildingUsageLibrary']['zoneUsageType']:
|
||||||
|
@ -31,14 +34,12 @@ class UsBaseUsageParameters:
|
||||||
city_object.usage_zone = [usage_zone]
|
city_object.usage_zone = [usage_zone]
|
||||||
break
|
break
|
||||||
continue
|
continue
|
||||||
else:
|
city_object.usage_zones = [UsBaseUsageParameters._parse_zone_usage_type(zone_usage_type, usage_zone)]
|
||||||
city_object.usage_zones = [UsBaseUsageParameters._parse_zone_usage_type(zone_usage_type, usage_zone)]
|
break
|
||||||
break
|
|
||||||
if city_object.usage_zones is None:
|
if city_object.usage_zones is None:
|
||||||
print(city_object.function)
|
print(city_object.function)
|
||||||
raise Exception('Usage not found for building function')
|
raise Exception('Usage not found for building function')
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_zone_usage_type(zone_usage_type, usage_zone):
|
def _parse_zone_usage_type(zone_usage_type, usage_zone):
|
||||||
usage_zone.hours_day = zone_usage_type['occupancy']['usageHoursPerDay']
|
usage_zone.hours_day = zone_usage_type['occupancy']['usageHoursPerDay']
|
||||||
|
|
|
@ -8,6 +8,9 @@ from usage.usage_feeders.helpers.us_pluto_to_usage import UsPlutoToUsage as Pu
|
||||||
|
|
||||||
|
|
||||||
class UsNewYorkCityUsageParameters(UsBaseUsageParameters):
|
class UsNewYorkCityUsageParameters(UsBaseUsageParameters):
|
||||||
|
"""
|
||||||
|
UsNewYorkCityUsageParameters class
|
||||||
|
"""
|
||||||
def __init__(self, city):
|
def __init__(self, city):
|
||||||
self._city = city
|
self._city = city
|
||||||
super().__init__(self._city, Pu.usage)
|
super().__init__(self._city, Pu.usage)
|
||||||
|
|
|
@ -8,5 +8,8 @@ from usage.usage_feeders.helpers.us_function_to_usage import UsFunctionToUsage
|
||||||
|
|
||||||
|
|
||||||
class UsUsageParameters(UsBaseUsageParameters):
|
class UsUsageParameters(UsBaseUsageParameters):
|
||||||
|
"""
|
||||||
|
UsUsageParameters class
|
||||||
|
"""
|
||||||
def __init__(self, city):
|
def __init__(self, city):
|
||||||
super().__init__(city, UsFunctionToUsage.usage)
|
super().__init__(city, UsFunctionToUsage.usage)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user