From 4a7dda045dc54d75b546b4f7b9365d10a6396e93 Mon Sep 17 00:00:00 2001 From: pilar Date: Tue, 15 Dec 2020 14:57:46 -0500 Subject: [PATCH] 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