From 51f6edbd315cf1cc5b5e1aee5b5707b01b352559 Mon Sep 17 00:00:00 2001 From: pilar Date: Tue, 15 Dec 2020 12:15:04 -0500 Subject: [PATCH 1/3] demo_schedules is now called comnet_archetypes.xlsx --- .../{demo_schedules.xlsx => comnet_archetypes.xlsx} | Bin .../occupancy_feeders/demo_occupancy_parameters.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename data/occupancy/{demo_schedules.xlsx => comnet_archetypes.xlsx} (100%) diff --git a/data/occupancy/demo_schedules.xlsx b/data/occupancy/comnet_archetypes.xlsx similarity index 100% rename from data/occupancy/demo_schedules.xlsx rename to data/occupancy/comnet_archetypes.xlsx diff --git a/factories/occupancy_feeders/demo_occupancy_parameters.py b/factories/occupancy_feeders/demo_occupancy_parameters.py index 56155e32..48543848 100644 --- a/factories/occupancy_feeders/demo_occupancy_parameters.py +++ b/factories/occupancy_feeders/demo_occupancy_parameters.py @@ -13,7 +13,7 @@ class DemoOccupancyParameters: def __init__(self, city, base_path): self._city = city - self._demo_schedules_path = base_path / 'demo_schedules.xlsx' + self._demo_schedules_path = base_path / 'comnet_archetypes.xlsx' xls = pd.ExcelFile(self._demo_schedules_path) # todo: review for more than one usage_zones per building for building in city.buildings: From 4a7dda045dc54d75b546b4f7b9365d10a6396e93 Mon Sep 17 00:00:00 2001 From: pilar Date: Tue, 15 Dec 2020 14:57:46 -0500 Subject: [PATCH 2/3] occupancy to schedules --- factories/occupancy_factory.py | 14 +++++++------- ...{occupancy_helper.py => schedules_helper.py} | 16 ++++++++-------- ...cupancy_parameters.py => usage_schedules.py} | 17 ++++++++--------- ...geometry_factory.py => schedules_factory.py} | 0 tests/test_geometry_factory.py | 2 +- tests/test_idf.py | 6 +++--- tests/test_occupancy_factory.py | 14 +++++++------- tests/test_physics_factory.py | 2 +- tests/test_usage_factory.py | 2 +- tests/test_weather_factory.py | 2 +- 10 files changed, 37 insertions(+), 38 deletions(-) rename factories/occupancy_feeders/helpers/{occupancy_helper.py => schedules_helper.py} (61%) rename factories/occupancy_feeders/{demo_occupancy_parameters.py => usage_schedules.py} (65%) rename factories/{geometry_factory.py => schedules_factory.py} (100%) diff --git a/factories/occupancy_factory.py b/factories/occupancy_factory.py index bfa0cb3c..8fa7a5dc 100644 --- a/factories/occupancy_factory.py +++ b/factories/occupancy_factory.py @@ -1,16 +1,16 @@ """ -PhysicsFactory retrieve the specific physics module for the given region +SchedulesFactory retrieve the specific schedules module for the given standard SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ from pathlib import Path -from factories.occupancy_feeders.demo_occupancy_parameters import DemoOccupancyParameters +from factories.occupancy_feeders.usage_schedules import ComnetSchedules -class OccupancyFactory: +class SchedulesFactory: """ - PhysicsFactor class + SchedulesFactor class """ def __init__(self, handler, city, base_path=Path(Path(__file__).parent.parent / 'data/occupancy')): self._handler = '_' + handler.lower().replace(' ', '_') @@ -18,12 +18,12 @@ class OccupancyFactory: self._base_path = base_path self.factory() - def _demo(self): - DemoOccupancyParameters(self._city, self._base_path) + def _comnet(self): + ComnetSchedules(self._city, self._base_path) def factory(self): """ - Enrich the city with the physics information + Enrich the city with the schedules information :return: None """ getattr(self, self._handler, lambda: None)() diff --git a/factories/occupancy_feeders/helpers/occupancy_helper.py b/factories/occupancy_feeders/helpers/schedules_helper.py similarity index 61% rename from factories/occupancy_feeders/helpers/occupancy_helper.py rename to factories/occupancy_feeders/helpers/schedules_helper.py index 3a42f575..1013b531 100644 --- a/factories/occupancy_feeders/helpers/occupancy_helper.py +++ b/factories/occupancy_feeders/helpers/schedules_helper.py @@ -1,12 +1,12 @@ """ -Geometry helper +Schedules helper SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ -class OccupancyHelper: - occupancy_pluto_function = { +class SchedulesHelper: + comnet_pluto_function = { 'C1': 'C-12 Residential', 'C5': 'C-12 Residential', 'D3': 'C-12 Residential', @@ -17,18 +17,18 @@ class OccupancyHelper: 'U0': 'C-10 Warehouse', 'W4': 'C-9 School', } - occupancy_function = { + comnet_function = { 'residential': 'C-12 Residential' } @staticmethod - def pluto_occupancy_function(building_pluto_function): + def comnet_pluto_schedules_function(building_pluto_function): """ - Get nrel function from the given pluto function + Get Comnet function from the given pluto function :param building_pluto_function: str :return: str """ try: - return OccupancyHelper.occupancy_pluto_function[building_pluto_function] + return SchedulesHelper.comnet_pluto_function[building_pluto_function] except KeyError: - return OccupancyHelper.occupancy_function[building_pluto_function] + return SchedulesHelper.comnet_function[building_pluto_function] diff --git a/factories/occupancy_feeders/demo_occupancy_parameters.py b/factories/occupancy_feeders/usage_schedules.py similarity index 65% rename from factories/occupancy_feeders/demo_occupancy_parameters.py rename to factories/occupancy_feeders/usage_schedules.py index 48543848..40a35de6 100644 --- a/factories/occupancy_feeders/demo_occupancy_parameters.py +++ b/factories/occupancy_feeders/usage_schedules.py @@ -1,25 +1,24 @@ """ -PhysicsFactory retrieve the specific physics module for the given region +Schedules retrieve the specific usage schedules module for the given standard SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca contributors Pilar Monsalvete pilar_monsalvete@yahoo.es """ import pandas as pd -from factories.occupancy_feeders.helpers.occupancy_helper import OccupancyHelper -from enum import Enum +from factories.occupancy_feeders.helpers.schedules_helper import SchedulesHelper -class DemoOccupancyParameters: +class ComnetSchedules: def __init__(self, city, base_path): self._city = city - self._demo_schedules_path = base_path / 'comnet_archetypes.xlsx' - xls = pd.ExcelFile(self._demo_schedules_path) + self._comnet_schedules_path = base_path / 'comnet_archetypes.xlsx' + xls = pd.ExcelFile(self._comnet_schedules_path) # todo: review for more than one usage_zones per building for building in city.buildings: schedules = dict() - occupancy = pd.read_excel(xls, sheet_name=OccupancyHelper.pluto_occupancy_function(building.function), - skiprows=[0, 1, 2, 3], nrows=39, usecols="A:AA") + usage_schedules = pd.read_excel(xls, sheet_name=SchedulesHelper.comnet_pluto_schedules_function(building.function), + skiprows=[0, 1, 2, 3], nrows=39, usecols="A:AA") # todo: should we save the data type? How? number_of_schedule_types = 13 schedules_per_schedule_type = 3 @@ -29,7 +28,7 @@ class DemoOccupancyParameters: columns_names = [] name = '' for schedule_day in range(0, schedules_per_schedule_type): - row_cells = occupancy.iloc[schedules_per_schedule_type*schedule_types + schedule_day] + row_cells = usage_schedules.iloc[schedules_per_schedule_type*schedule_types + schedule_day] if schedule_day == day_types['week_day']: name = row_cells[0] columns_names.append(row_cells[2]) diff --git a/factories/geometry_factory.py b/factories/schedules_factory.py similarity index 100% rename from factories/geometry_factory.py rename to factories/schedules_factory.py diff --git a/tests/test_geometry_factory.py b/tests/test_geometry_factory.py index b73ea27a..b0a08a78 100644 --- a/tests/test_geometry_factory.py +++ b/tests/test_geometry_factory.py @@ -8,7 +8,7 @@ from pathlib import Path from unittest import TestCase from city_model_structure.city import City -from factories.geometry_factory import GeometryFactory +from factories.schedules_factory import GeometryFactory class TestGeometryFactory(TestCase): diff --git a/tests/test_idf.py b/tests/test_idf.py index 6cf40006..124005e5 100644 --- a/tests/test_idf.py +++ b/tests/test_idf.py @@ -5,10 +5,10 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc """ from pathlib import Path from unittest import TestCase -from factories.geometry_factory import GeometryFactory +from factories.schedules_factory import GeometryFactory from factories.physics_factory import PhysicsFactory from factories.usage_factory import UsageFactory -from factories.occupancy_factory import OccupancyFactory +from factories.occupancy_factory import SchedulesFactory from helpers.idf_helper import IdfHelper import os import glob @@ -35,7 +35,7 @@ class TestIdf(TestCase): PhysicsFactory('us_new_york', self._city_gml) UsageFactory('us_new_york', self._city_gml) UsageFactory('us_new_york', self._city_gml) - OccupancyFactory('demo', self._city_gml) + SchedulesFactory('demo', self._city_gml) return self._city_gml def test_idf_blocks(self): diff --git a/tests/test_occupancy_factory.py b/tests/test_occupancy_factory.py index 28f4d97b..dfdb91f1 100644 --- a/tests/test_occupancy_factory.py +++ b/tests/test_occupancy_factory.py @@ -6,11 +6,9 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc from pathlib import Path from unittest import TestCase -from factories.geometry_factory import GeometryFactory +from factories.schedules_factory import GeometryFactory from factories.usage_factory import UsageFactory -from factories.occupancy_factory import OccupancyFactory -from city_model_structure.attributes.lighting import Lighting -from city_model_structure.attributes.domestic_hot_water import DomesticHotWater +from factories.occupancy_factory import SchedulesFactory class TestOccupancyFactory(TestCase): @@ -30,7 +28,8 @@ class TestOccupancyFactory(TestCase): def _handler(self): if self._city_gml_with_usage.name == 'New York': handler = '{0}_{1}' - return handler.format(self._city_gml_with_usage.country_code, self._city_gml_with_usage.name.lower().replace(' ', '_')) + return handler.format(self._city_gml_with_usage.country_code, + self._city_gml_with_usage.name.lower().replace(' ', '_')) return self._city_gml_with_usage.country_code def _get_citygml_with_usage(self): @@ -42,9 +41,10 @@ class TestOccupancyFactory(TestCase): self.assertIsNotNone(self._city_gml_with_usage, 'city with usage is none') return self._city_gml_with_usage - def test_demo(self): + def test_comnet_archetypes(self): city = self._get_citygml_with_usage() - OccupancyFactory('demo', city) + occupancy_handler = 'comnet' + SchedulesFactory(occupancy_handler, city) for building in city.buildings: for usage_zone in building.usage_zones: self.assertTrue(usage_zone.schedules) diff --git a/tests/test_physics_factory.py b/tests/test_physics_factory.py index 024223ef..a5b7d38b 100644 --- a/tests/test_physics_factory.py +++ b/tests/test_physics_factory.py @@ -6,7 +6,7 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc from pathlib import Path from unittest import TestCase -from factories.geometry_factory import GeometryFactory +from factories.schedules_factory import GeometryFactory from factories.physics_factory import PhysicsFactory diff --git a/tests/test_usage_factory.py b/tests/test_usage_factory.py index bb9b582c..94fc2041 100644 --- a/tests/test_usage_factory.py +++ b/tests/test_usage_factory.py @@ -6,7 +6,7 @@ Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es from pathlib import Path from unittest import TestCase -from factories.geometry_factory import GeometryFactory +from factories.schedules_factory import GeometryFactory from factories.usage_factory import UsageFactory diff --git a/tests/test_weather_factory.py b/tests/test_weather_factory.py index c07f8179..555444eb 100644 --- a/tests/test_weather_factory.py +++ b/tests/test_weather_factory.py @@ -7,7 +7,7 @@ from pathlib import Path from unittest import TestCase import numpy as np -from factories.geometry_factory import GeometryFactory +from factories.schedules_factory import GeometryFactory from factories.weather_factory import WeatherFactory From 74659b8a069843604c850bb8e2cd6c483006d729 Mon Sep 17 00:00:00 2001 From: pilar Date: Tue, 15 Dec 2020 15:15:40 -0500 Subject: [PATCH 3/3] occupancy to schedules --- factories/geometry_factory.py | 50 +++++++++++++++++ factories/occupancy_factory.py | 29 ---------- factories/schedules_factory.py | 55 ++++++------------- tests/test_geometry_factory.py | 2 +- tests/test_idf.py | 4 +- tests/test_physics_factory.py | 2 +- ...y_factory.py => test_schedules_factory.py} | 11 ++-- tests/test_usage_factory.py | 2 +- tests/test_weather_factory.py | 2 +- 9 files changed, 79 insertions(+), 78 deletions(-) create mode 100644 factories/geometry_factory.py delete mode 100644 factories/occupancy_factory.py rename tests/{test_occupancy_factory.py => test_schedules_factory.py} (83%) diff --git a/factories/geometry_factory.py b/factories/geometry_factory.py new file mode 100644 index 00000000..a8df48a3 --- /dev/null +++ b/factories/geometry_factory.py @@ -0,0 +1,50 @@ +""" +GeometryFactory retrieve the specific geometric module to load the given format +SPDX - License - Identifier: LGPL - 3.0 - or -later +Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca +""" +from city_model_structure.city import City +from city_model_structure.city_object import CityObject +from factories.geometry_feeders.city_gml import CityGml +from factories.geometry_feeders.osm_subway import OsmSubway + + +class GeometryFactory: + """ + GeometryFactory class + """ + def __init__(self, file_type, path): + self._file_type = '_' + file_type.lower() + self._path = path + + @property + def _citygml(self): + return CityGml(self._path).city + + @property + def _geojson(self): + raise Exception('Not implemented') + + @property + def _bim(self): + raise Exception('Not implemented') + + @property + def city(self) -> City: + """ + Load the city model structure from a geometry source + :return: City + """ + return getattr(self, self._file_type, lambda: None) + + @property + def _osm_subway(self): + return OsmSubway(self._path).subway_entrances + + @property + def features(self) -> [CityObject]: + """ + Load the city model structure from a geometry source + :return: [CityObject] + """ + return getattr(self, self._file_type, lambda: None) diff --git a/factories/occupancy_factory.py b/factories/occupancy_factory.py deleted file mode 100644 index 8fa7a5dc..00000000 --- a/factories/occupancy_factory.py +++ /dev/null @@ -1,29 +0,0 @@ -""" -SchedulesFactory retrieve the specific schedules module for the given standard -SPDX - License - Identifier: LGPL - 3.0 - or -later -Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca -""" - -from pathlib import Path -from factories.occupancy_feeders.usage_schedules import ComnetSchedules - - -class SchedulesFactory: - """ - SchedulesFactor class - """ - def __init__(self, handler, city, base_path=Path(Path(__file__).parent.parent / 'data/occupancy')): - self._handler = '_' + handler.lower().replace(' ', '_') - self._city = city - self._base_path = base_path - self.factory() - - def _comnet(self): - ComnetSchedules(self._city, self._base_path) - - def factory(self): - """ - Enrich the city with the schedules information - :return: None - """ - getattr(self, self._handler, lambda: None)() diff --git a/factories/schedules_factory.py b/factories/schedules_factory.py index a8df48a3..8fa7a5dc 100644 --- a/factories/schedules_factory.py +++ b/factories/schedules_factory.py @@ -1,50 +1,29 @@ """ -GeometryFactory retrieve the specific geometric module to load the given format +SchedulesFactory retrieve the specific schedules module for the given standard SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ -from city_model_structure.city import City -from city_model_structure.city_object import CityObject -from factories.geometry_feeders.city_gml import CityGml -from factories.geometry_feeders.osm_subway import OsmSubway + +from pathlib import Path +from factories.occupancy_feeders.usage_schedules import ComnetSchedules -class GeometryFactory: +class SchedulesFactory: """ - GeometryFactory class + SchedulesFactor class """ - def __init__(self, file_type, path): - self._file_type = '_' + file_type.lower() - self._path = path + def __init__(self, handler, city, base_path=Path(Path(__file__).parent.parent / 'data/occupancy')): + self._handler = '_' + handler.lower().replace(' ', '_') + self._city = city + self._base_path = base_path + self.factory() - @property - def _citygml(self): - return CityGml(self._path).city + def _comnet(self): + ComnetSchedules(self._city, self._base_path) - @property - def _geojson(self): - raise Exception('Not implemented') - - @property - def _bim(self): - raise Exception('Not implemented') - - @property - def city(self) -> City: + def factory(self): """ - Load the city model structure from a geometry source - :return: City + Enrich the city with the schedules information + :return: None """ - return getattr(self, self._file_type, lambda: None) - - @property - def _osm_subway(self): - return OsmSubway(self._path).subway_entrances - - @property - def features(self) -> [CityObject]: - """ - Load the city model structure from a geometry source - :return: [CityObject] - """ - return getattr(self, self._file_type, lambda: None) + getattr(self, self._handler, lambda: None)() diff --git a/tests/test_geometry_factory.py b/tests/test_geometry_factory.py index b0a08a78..b73ea27a 100644 --- a/tests/test_geometry_factory.py +++ b/tests/test_geometry_factory.py @@ -8,7 +8,7 @@ from pathlib import Path from unittest import TestCase from city_model_structure.city import City -from factories.schedules_factory import GeometryFactory +from factories.geometry_factory import GeometryFactory class TestGeometryFactory(TestCase): diff --git a/tests/test_idf.py b/tests/test_idf.py index 124005e5..c644b44d 100644 --- a/tests/test_idf.py +++ b/tests/test_idf.py @@ -5,10 +5,10 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc """ from pathlib import Path from unittest import TestCase -from factories.schedules_factory import GeometryFactory +from factories.geometry_factory import GeometryFactory from factories.physics_factory import PhysicsFactory from factories.usage_factory import UsageFactory -from factories.occupancy_factory import SchedulesFactory +from factories.schedules_factory import SchedulesFactory from helpers.idf_helper import IdfHelper import os import glob diff --git a/tests/test_physics_factory.py b/tests/test_physics_factory.py index a5b7d38b..024223ef 100644 --- a/tests/test_physics_factory.py +++ b/tests/test_physics_factory.py @@ -6,7 +6,7 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc from pathlib import Path from unittest import TestCase -from factories.schedules_factory import GeometryFactory +from factories.geometry_factory import GeometryFactory from factories.physics_factory import PhysicsFactory diff --git a/tests/test_occupancy_factory.py b/tests/test_schedules_factory.py similarity index 83% rename from tests/test_occupancy_factory.py rename to tests/test_schedules_factory.py index dfdb91f1..4ab3f46a 100644 --- a/tests/test_occupancy_factory.py +++ b/tests/test_schedules_factory.py @@ -1,19 +1,20 @@ """ -TestOccupancyFactory test and validate the city model structure occupancy parameters +TestSchedulesFactory test and validate the city model structure schedules SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca +Contributors Pilar Monsalvete pilar_monsalvete@yahoo.es """ from pathlib import Path from unittest import TestCase -from factories.schedules_factory import GeometryFactory +from factories.geometry_factory import GeometryFactory from factories.usage_factory import UsageFactory -from factories.occupancy_factory import SchedulesFactory +from factories.schedules_factory import SchedulesFactory -class TestOccupancyFactory(TestCase): +class TestSchedulesFactory(TestCase): """ - TestOccupancyFactory TestCase + TestSchedulesFactory TestCase """ def setUp(self) -> None: diff --git a/tests/test_usage_factory.py b/tests/test_usage_factory.py index 94fc2041..bb9b582c 100644 --- a/tests/test_usage_factory.py +++ b/tests/test_usage_factory.py @@ -6,7 +6,7 @@ Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es from pathlib import Path from unittest import TestCase -from factories.schedules_factory import GeometryFactory +from factories.geometry_factory import GeometryFactory from factories.usage_factory import UsageFactory diff --git a/tests/test_weather_factory.py b/tests/test_weather_factory.py index 555444eb..c07f8179 100644 --- a/tests/test_weather_factory.py +++ b/tests/test_weather_factory.py @@ -7,7 +7,7 @@ from pathlib import Path from unittest import TestCase import numpy as np -from factories.schedules_factory import GeometryFactory +from factories.geometry_factory import GeometryFactory from factories.weather_factory import WeatherFactory