base classes for lod at city level
This commit is contained in:
parent
de2a319727
commit
5dc471dd2a
|
@ -20,8 +20,8 @@ class Building(CityObject):
|
||||||
"""
|
"""
|
||||||
Building(CityObject) class
|
Building(CityObject) class
|
||||||
"""
|
"""
|
||||||
def __init__(self, name, lod, surfaces, year_of_construction, function, city_lower_corner, terrains=None):
|
def __init__(self, name, surfaces, year_of_construction, function, city_lower_corner, terrains=None):
|
||||||
super().__init__(name, lod, surfaces, city_lower_corner)
|
super().__init__(name, surfaces, city_lower_corner)
|
||||||
self._households = None
|
self._households = None
|
||||||
self._basement_heated = None
|
self._basement_heated = None
|
||||||
self._attic_heated = None
|
self._attic_heated = None
|
||||||
|
|
|
@ -17,8 +17,8 @@ class BusSystem(CityObject):
|
||||||
"""
|
"""
|
||||||
BusSystem(CityObject) class
|
BusSystem(CityObject) class
|
||||||
"""
|
"""
|
||||||
def __init__(self, name, lod, surfaces, city_lower_corner):
|
def __init__(self, name, surfaces, city_lower_corner):
|
||||||
super().__init__(name, lod, surfaces, city_lower_corner)
|
super().__init__(name, surfaces, city_lower_corner)
|
||||||
self._bus_routes = None
|
self._bus_routes = None
|
||||||
self._bus_network = None
|
self._bus_network = None
|
||||||
self._buses = None
|
self._buses = None
|
||||||
|
|
|
@ -21,6 +21,7 @@ from city_model_structure.city_objects_cluster import CityObjectsCluster
|
||||||
from city_model_structure.buildings_cluster import BuildingsCluster
|
from city_model_structure.buildings_cluster import BuildingsCluster
|
||||||
from city_model_structure.fuel import Fuel
|
from city_model_structure.fuel import Fuel
|
||||||
from city_model_structure.iot.station import Station
|
from city_model_structure.iot.station import Station
|
||||||
|
from city_model_structure.level_of_detail import LevelOfDetail
|
||||||
from city_model_structure.machine import Machine
|
from city_model_structure.machine import Machine
|
||||||
from city_model_structure.parts_consisting_building import PartsConsistingBuilding
|
from city_model_structure.parts_consisting_building import PartsConsistingBuilding
|
||||||
from city_model_structure.subway_entrance import SubwayEntrance
|
from city_model_structure.subway_entrance import SubwayEntrance
|
||||||
|
@ -59,6 +60,7 @@ class City:
|
||||||
self._machines = None
|
self._machines = None
|
||||||
self._stations = []
|
self._stations = []
|
||||||
self._lca_materials = None
|
self._lca_materials = None
|
||||||
|
self._level_of_detail = LevelOfDetail()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fuels(self) -> [Fuel]:
|
def fuels(self) -> [Fuel]:
|
||||||
|
@ -287,7 +289,6 @@ class City:
|
||||||
selected_region_upper_corner = [center[0] + radius, center[1] + radius, center[2] + radius]
|
selected_region_upper_corner = [center[0] + radius, center[1] + radius, center[2] + radius]
|
||||||
selected_region_city = City(selected_region_lower_corner, selected_region_upper_corner, srs_name=self.srs_name)
|
selected_region_city = City(selected_region_lower_corner, selected_region_upper_corner, srs_name=self.srs_name)
|
||||||
selected_region_city.climate_file = self.climate_file
|
selected_region_city.climate_file = self.climate_file
|
||||||
# selected_region_city.climate_reference_city = self.climate_reference_city
|
|
||||||
for city_object in self.city_objects:
|
for city_object in self.city_objects:
|
||||||
location = city_object.centroid
|
location = city_object.centroid
|
||||||
if location is not None:
|
if location is not None:
|
||||||
|
@ -426,9 +427,9 @@ class City:
|
||||||
"""
|
"""
|
||||||
self._lca_materials = value
|
self._lca_materials = value
|
||||||
|
|
||||||
def lca_material(self, lca_id) -> LcaMaterial:
|
def lca_material(self, lca_id) -> Union[LcaMaterial, None]:
|
||||||
"""
|
"""
|
||||||
Get the lca materiol matching the given Id
|
Get the lca material matching the given Id
|
||||||
:return: LcaMaterial or None
|
:return: LcaMaterial or None
|
||||||
"""
|
"""
|
||||||
for lca_material in self.lca_materials:
|
for lca_material in self.lca_materials:
|
||||||
|
@ -448,3 +449,7 @@ class City:
|
||||||
for city_object in city.city_objects:
|
for city_object in city.city_objects:
|
||||||
_merge_city.add_city_object(city_object)
|
_merge_city.add_city_object(city_object)
|
||||||
return _merge_city
|
return _merge_city
|
||||||
|
|
||||||
|
@property
|
||||||
|
def level_of_detail(self):
|
||||||
|
return self._level_of_detail
|
||||||
|
|
|
@ -18,9 +18,8 @@ class CityObject:
|
||||||
"""
|
"""
|
||||||
class CityObject
|
class CityObject
|
||||||
"""
|
"""
|
||||||
def __init__(self, name, lod, surfaces, city_lower_corner):
|
def __init__(self, name, surfaces, city_lower_corner):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._lod = lod
|
|
||||||
self._surfaces = surfaces
|
self._surfaces = surfaces
|
||||||
self._city_lower_corner = city_lower_corner
|
self._city_lower_corner = city_lower_corner
|
||||||
self._type = None
|
self._type = None
|
||||||
|
@ -45,15 +44,6 @@ class CityObject:
|
||||||
"""
|
"""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def lod(self) -> int:
|
|
||||||
"""
|
|
||||||
Get city object level of detail 1, 2, 3 or 4
|
|
||||||
:return: int
|
|
||||||
"""
|
|
||||||
lod = int(math.log(self._lod, 2) + 1)
|
|
||||||
return lod
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self) -> str:
|
def type(self) -> str:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -16,8 +16,8 @@ class EnergySystem(CityObject):
|
||||||
EnergySystem(CityObject) class
|
EnergySystem(CityObject) class
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, lod, surfaces, city_lower_corner):
|
def __init__(self, name, surfaces, city_lower_corner):
|
||||||
super().__init__(name, lod, surfaces, city_lower_corner)
|
super().__init__(name, surfaces, city_lower_corner)
|
||||||
self._air_source_hp = None
|
self._air_source_hp = None
|
||||||
self._water_to_water_hp = None
|
self._water_to_water_hp = None
|
||||||
self._type = 'energy_system'
|
self._type = 'energy_system'
|
||||||
|
|
57
city_model_structure/level_of_detail.py
Normal file
57
city_model_structure/level_of_detail.py
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
"""
|
||||||
|
Level of detail module
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2022 Concordia CERC group
|
||||||
|
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||||
|
"""
|
||||||
|
|
||||||
|
class LevelOfDetail:
|
||||||
|
"""
|
||||||
|
Level of detail for the city class
|
||||||
|
"""
|
||||||
|
def __init__(self):
|
||||||
|
self._geometry = None
|
||||||
|
self._construction = None
|
||||||
|
self._usage = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def geometry(self):
|
||||||
|
"""
|
||||||
|
Get the city minimal geometry level of detail
|
||||||
|
"""
|
||||||
|
return self._geometry
|
||||||
|
|
||||||
|
@geometry.setter
|
||||||
|
def geometry(self, value):
|
||||||
|
"""
|
||||||
|
Set the city minimal geometry level of detail
|
||||||
|
"""
|
||||||
|
self._geometry = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def construction(self):
|
||||||
|
"""
|
||||||
|
Get the city minimal construction level of detail
|
||||||
|
"""
|
||||||
|
return self._construction
|
||||||
|
|
||||||
|
@construction.setter
|
||||||
|
def construction(self, value):
|
||||||
|
"""
|
||||||
|
Set the city minimal construction level of detail
|
||||||
|
"""
|
||||||
|
self._construction = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def usage(self):
|
||||||
|
"""
|
||||||
|
Get the city minimal usage level of detail
|
||||||
|
"""
|
||||||
|
return self._usage
|
||||||
|
|
||||||
|
@usage.setter
|
||||||
|
def usage(self, value):
|
||||||
|
"""
|
||||||
|
Set the city minimal usage level of detail
|
||||||
|
"""
|
||||||
|
self._usage = value
|
|
@ -100,8 +100,8 @@ class TestExports(TestCase):
|
||||||
building.year_of_construction = 2006
|
building.year_of_construction = 2006
|
||||||
if building.function is None:
|
if building.function is None:
|
||||||
building.function = 'large office'
|
building.function = 'large office'
|
||||||
building.attic_heated = False
|
building.attic_heated = 0
|
||||||
building.basement_heated = False
|
building.basement_heated = 0
|
||||||
ConstructionFactory('nrel', city).enrich()
|
ConstructionFactory('nrel', city).enrich()
|
||||||
UsageFactory('comnet', city).enrich()
|
UsageFactory('comnet', city).enrich()
|
||||||
|
|
||||||
|
@ -141,9 +141,8 @@ class TestExports(TestCase):
|
||||||
self.assertIsNotNone(usage_zone.days_year, f'usage zone {usage_zone.usage} days_year is none')
|
self.assertIsNotNone(usage_zone.days_year, f'usage zone {usage_zone.usage} days_year is none')
|
||||||
self.assertIsNotNone(usage_zone.mechanical_air_change, f'usage zone {usage_zone.usage} '
|
self.assertIsNotNone(usage_zone.mechanical_air_change, f'usage zone {usage_zone.usage} '
|
||||||
f'mechanical_air_change is none')
|
f'mechanical_air_change is none')
|
||||||
|
|
||||||
# export files
|
# export files
|
||||||
try:
|
try:
|
||||||
EnergyBuildingsExportsFactory('insel_monthly_energy_balance', city, self._output_path).export_debug()
|
EnergyBuildingsExportsFactory('insel_monthly_energy_balance', city, self._output_path).export()
|
||||||
except Exception:
|
except Exception:
|
||||||
self.fail("Insel MonthlyEnergyBalance ExportsFactory raised ExceptionType unexpectedly!")
|
self.fail("Insel MonthlyEnergyBalance ExportsFactory raised ExceptionType unexpectedly!")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user