diff --git a/city_model_structure/city.py b/city_model_structure/city.py index bb9b8a7b..cf3e78b0 100644 --- a/city_model_structure/city.py +++ b/city_model_structure/city.py @@ -50,6 +50,7 @@ class City: self._parts_consisting_buildings = None self._city_objects_clusters = None self._city_objects = None + self._energy_systems = None self._fuels = None @property @@ -200,6 +201,10 @@ class City: if self._subway_entrances is None: self._subway_entrances = [] self._subway_entrances.append(new_city_object) + elif new_city_object.type == 'energy_system': + if self._energy_systems is None: + self._energy_systems = [] + self._energy_systems.append(new_city_object) else: raise NotImplementedError(new_city_object.type) @@ -341,6 +346,14 @@ class City: """ return self._parts_consisting_buildings + @property + def energy_systems(self) -> Union[List[EnergySystem], None]: + """ + Get energy systems belonging to the city + :return: None or [EnergySystem] + """ + return self._energy_systems + @property def city_objects_clusters(self) -> Union[List[CityObjectsCluster], None]: """ diff --git a/helpers/yearly_from_daily_schedules.py b/helpers/yearly_from_daily_schedules.py index c7c3bac5..9c8431c9 100644 --- a/helpers/yearly_from_daily_schedules.py +++ b/helpers/yearly_from_daily_schedules.py @@ -32,7 +32,7 @@ class YearlyFromDailySchedules: values = [] for month in range(1, 13): - for day in range(1, cal.monthlen(self._year, month)+1): + for day in range(1, cal._monthlen(self._year, month)+1): week_day = cal.weekday(self._year, month, day) values.extend(weekly_schedules[week_day]) yearly_schedule.type = self._daily_schedules[0].type diff --git a/imports/geometry/obj.py b/imports/geometry/obj.py index 5c7fdd5b..6349921b 100644 --- a/imports/geometry/obj.py +++ b/imports/geometry/obj.py @@ -21,8 +21,8 @@ class Obj: with open(path, 'r') as file: self._scene = trimesh.exchange.load.load(file, file_type='obj', force='scene') self._corners = self._scene.bounds_corners - _bound_corner_min = [] - _bound_corner_max = [] + _bound_corner_min = None + _bound_corner_max = None for corner in self._corners: if _bound_corner_min is None: _bound_corner_min = corner diff --git a/unittests/test_exports.py b/unittests/test_exports.py index 5b25b4e1..b4c38be1 100644 --- a/unittests/test_exports.py +++ b/unittests/test_exports.py @@ -45,7 +45,7 @@ class TestExports(TestCase): else: file_path = (self._example_path / 'one_building_in_kelowna.gml').resolve() self._complete_city = self._get_citygml(file_path) - ConstructionFactory('ca', self._complete_city).enrich() + ConstructionFactory('nrel', self._complete_city).enrich() UsageFactory('ca', self._complete_city).enrich() SchedulesFactory('comnet', self._complete_city).enrich() cli = 'C:\\Users\\Pilar\\PycharmProjects\\monthlyenergybalance\\tests_data\\weather\\inseldb_Summerland.cli' diff --git a/unittests/test_usage_factory.py b/unittests/test_usage_factory.py index 82c692a1..e3c6b7ba 100644 --- a/unittests/test_usage_factory.py +++ b/unittests/test_usage_factory.py @@ -8,6 +8,7 @@ from unittest import TestCase from imports.geometry_factory import GeometryFactory from imports.usage_factory import UsageFactory +from imports.construction_factory import ConstructionFactory from imports.geometry.helpers.geometry_helper import GeometryHelper @@ -38,7 +39,7 @@ class TestUsageFactory(TestCase): city = self._get_citygml(file) for building in city.buildings: building.function = GeometryHelper.pluto_to_function[building.function] - + ConstructionFactory('nrel', city).enrich() UsageFactory('hft', city).enrich() for building in city.buildings: self.assertIsNot(len(building.usage_zones), 0, 'no building usage_zones defined') @@ -61,7 +62,7 @@ class TestUsageFactory(TestCase): # case 2: CA file = 'one_building_in_kelowna.gml' city = self._get_citygml(file) - + ConstructionFactory('nrel', city).enrich() UsageFactory('ca', city).enrich() for building in city.buildings: self.assertIsNot(len(building.usage_zones), 0, 'no building usage_zones defined')