Merge remote-tracking branch 'origin/master'

This commit is contained in:
pilar 2020-06-11 17:30:56 -04:00
commit 2de8869dd3
11 changed files with 59 additions and 38 deletions

View File

@ -21,7 +21,7 @@ class Surface:
self._swr = swr
self._remove_last = remove_last
self._is_projected = is_projected
self._geometry = GeometryHelper()
self._geometry_helper = GeometryHelper()
self._polygon = None
self._ground_polygon = None
self._area = None
@ -309,7 +309,7 @@ class Surface:
"""
if self.type != 'Wall' or surface.type != 'Wall':
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
self.add_shared(surface, intersection_area)
surface.add_shared(self, intersection_area)

View File

@ -156,7 +156,7 @@ class ThermalOpening:
@property
def overall_u_value(self):
"""
Get thermal opening overall u value
Get thermal opening overall u value in W/m2K
:return: float
"""
return self._overall_u_value
@ -164,7 +164,7 @@ class ThermalOpening:
@overall_u_value.setter
def overall_u_value(self, value):
"""
Get thermal opening overall u value
Get thermal opening overall u value in W/m2K
:param value: float
:return: None
"""

View File

@ -85,7 +85,7 @@ class ThermalZone:
@property
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 self._additional_thermal_bridge_u_value
@ -93,7 +93,7 @@ class ThermalZone:
@additional_thermal_bridge_u_value.setter
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
:return: None
"""

View File

@ -35,7 +35,7 @@ class UsBasePhysicsParameters:
archetype = self._search_archetype(building_type,
UsToLibraryTypes.yoc_to_standard(city_object.year_of_construction),
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
if archetype is None:
print(building_type, UsToLibraryTypes.yoc_to_standard(city_object.year_of_construction),

View File

@ -4,9 +4,9 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
from unittest import TestCase
import os
from pathlib import Path
from geometry.geometry_factory import GeometryFactory
import os
class TestGeometryFactory(TestCase):
@ -21,13 +21,9 @@ class TestGeometryFactory(TestCase):
self._city_gml = None
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
def get_citygml(self):
"""
Retrieve the test city gml
:return: City
"""
def _get_citygml(self):
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.assertIsNotNone(self._city_gml, 'city is none')
return self._city_gml
@ -37,7 +33,7 @@ class TestGeometryFactory(TestCase):
Test the City parsing
:return: None
"""
city = self.get_citygml()
city = self._get_citygml()
self.assertIsNotNone(city.city_objects, 'city_objects is none')
for city_object in city.city_objects:
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
:return: None
"""
city = self.get_citygml()
city = self._get_citygml()
for city_object in city.city_objects:
self.assertIsNotNone(city_object.name, 'city_object name is none')
self.assertIsNotNone(city_object.lod, 'city_object lod is none')
@ -80,7 +76,7 @@ class TestGeometryFactory(TestCase):
Test surfaces in city objects
:return: None
"""
city = self.get_citygml()
city = self._get_citygml()
for city_object in city.city_objects:
for surface in city_object.surfaces:
self.assertIsNotNone(surface.name, 'surface name is none')
@ -111,7 +107,7 @@ class TestGeometryFactory(TestCase):
Test thermal zones in city objects
:return: None
"""
city = self.get_citygml()
city = self._get_citygml()
for city_object in city.city_objects:
for thermal_zone in city_object.thermal_zones:
self.assertIsNotNone(thermal_zone.surfaces, 'thermal_zone surfaces is none')
@ -137,7 +133,7 @@ class TestGeometryFactory(TestCase):
Test thermal boundaries in thermal zones
:return: None
"""
city = self.get_citygml()
city = self._get_citygml()
for city_object in city.city_objects:
for thermal_zone in city_object.thermal_zones:
for thermal_boundary in thermal_zone.bounded:
@ -167,7 +163,7 @@ class TestGeometryFactory(TestCase):
Test thermal openings in thermal zones
:return: None
"""
city = self.get_citygml()
city = self._get_citygml()
for city_object in city.city_objects:
for thermal_zone in city_object.thermal_zones:
for thermal_boundary in thermal_zone.bounded:

View File

@ -13,26 +13,34 @@ class TestPhysicsFactory(TestCase):
"""
TestPhysicsFactory TestCase
"""
def setup(self) -> None:
def setUp(self) -> None:
"""
Configure test environment
:return:
"""
self._city_gml = None
self._nyc_with_physics = None
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
def get_citygml(self):
def _get_citygml(self):
if self._city_gml is None:
file_path = (self._example_path / 'buildings.gml').resolve()
self._city_gml = GeometryFactory('citygml', file_path).city
self.assertIsNotNone(self._city_gml, 'city is none')
return self._city_gml
def get_city_with_physics(self):
def _get_city_with_physics(self):
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)
return self._nyc_with_physics
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:
self.assertIsNotNone(city_object.average_storey_height, 'average_storey_height is none')
self.assertIsNotNone(city_object.storeys_above_ground, 'storeys_above_ground is none')

View File

@ -8,22 +8,29 @@ from usage.usage_feeders.us_new_york_city_usage_parameters import UsNewYorkCityU
class UsageFactory:
"""
UsageFactory class
"""
def __init__(self, handler, city):
self._handler = handler.lower().replace(' ', '_')
self._handler = '_' + handler.lower().replace(' ', '_')
self._city = city
self.factory()
def us_new_york_city(self):
def _us_new_york_city(self):
UsNewYorkCityUsageParameters(self._city)
def ca(self):
def _ca(self):
raise Exception('Not implemented')
def de(self):
def _de(self):
DeUsageParameters(self._city)
def es(self):
def _es(self):
raise Exception('Not implemented')
def factory(self):
"""
Enrich the city with the usage information
:return: None
"""
getattr(self, self._handler, lambda: None)()

View File

@ -3,12 +3,15 @@ DeUsageParameters model the usage properties for a German building
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
import xmltodict
from pathlib import Path
import xmltodict
from usage.usage_feeders.helpers.us_function_to_usage import UsFunctionToUsage
class DeUsageParameters:
"""
DeUsageParameters
"""
def __init__(self, city_objects):
self._city_objects = city_objects
@ -17,4 +20,4 @@ class DeUsageParameters:
with open(path) as xml:
self._library = xmltodict.parse(xml.read())
for city_object in city_objects:
UsFunctionToUsage.function_to_usage(city_object.function)
UsFunctionToUsage.usage(city_object.function)

View File

@ -3,13 +3,16 @@ UsBaseUsageParameters base class to model the usage properties for a building in
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
import xmltodict
from pathlib import Path
import xmltodict
from city_model_structure.usage_zone import UsageZone
from city_model_structure.internal_gains import InternalGains
class UsBaseUsageParameters:
"""
UsBaseUsageParameters class
"""
def __init__(self, city, function_to_usage):
self._city = city
# 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:
self._library = xmltodict.parse(xml.read(), force_list='zoneUsageVariant')
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.usage = function_to_usage(city_object.function)
for zone_usage_type in self._library['buildingUsageLibrary']['zoneUsageType']:
@ -31,14 +34,12 @@ class UsBaseUsageParameters:
city_object.usage_zone = [usage_zone]
break
continue
else:
city_object.usage_zones = [UsBaseUsageParameters._parse_zone_usage_type(zone_usage_type, usage_zone)]
break
if city_object.usage_zones is None:
print(city_object.function)
raise Exception('Usage not found for building function')
@staticmethod
def _parse_zone_usage_type(zone_usage_type, usage_zone):
usage_zone.hours_day = zone_usage_type['occupancy']['usageHoursPerDay']

View File

@ -8,6 +8,9 @@ from usage.usage_feeders.helpers.us_pluto_to_usage import UsPlutoToUsage as Pu
class UsNewYorkCityUsageParameters(UsBaseUsageParameters):
"""
UsNewYorkCityUsageParameters class
"""
def __init__(self, city):
self._city = city
super().__init__(self._city, Pu.usage)

View File

@ -8,5 +8,8 @@ from usage.usage_feeders.helpers.us_function_to_usage import UsFunctionToUsage
class UsUsageParameters(UsBaseUsageParameters):
"""
UsUsageParameters class
"""
def __init__(self, city):
super().__init__(city, UsFunctionToUsage.usage)