From b135a97ad2e7304a235bd7a948e7488939efa71a Mon Sep 17 00:00:00 2001 From: Pilar Date: Tue, 26 Apr 2022 18:30:31 -0400 Subject: [PATCH] Modified workflow to include Sanam's schedules --- data/.gitignore | 1 + .../stochastic_schedules_importer.py | 48 +++++++++++++++++++ imports/customized_imports_factory.py | 28 +++++++++++ scripts/workshop_ep_workflow.py | 22 ++++----- 4 files changed, 88 insertions(+), 11 deletions(-) create mode 100644 data/.gitignore create mode 100644 imports/customized_imports/stochastic_schedules_importer.py create mode 100644 imports/customized_imports_factory.py diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 00000000..b722e9e1 --- /dev/null +++ b/data/.gitignore @@ -0,0 +1 @@ +!.gitignore \ No newline at end of file diff --git a/imports/customized_imports/stochastic_schedules_importer.py b/imports/customized_imports/stochastic_schedules_importer.py new file mode 100644 index 00000000..a71378e4 --- /dev/null +++ b/imports/customized_imports/stochastic_schedules_importer.py @@ -0,0 +1,48 @@ +""" +StochasticSchedulesImporter +SPDX - License - Identifier: LGPL - 3.0 - or -later +Copyright © 2022 Concordia CERC group +Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca +""" + + +import pandas as pd +from city_model_structure.attributes.schedule import Schedule +import helpers.constants as cte + + +class StochasticSchedulesImporter: + """ + StochasticSchedulesImporter class + """ + def __init__(self, city, base_path, buildings=None): + file = 'Occupancy_schedules_EVBuilding.xlsx' + path = str(base_path / file) + if buildings is None: + self._buildings = city.buildings + else: + self._buildings = buildings + self._xls = pd.ExcelFile(path) + + def enrich_buildings(self): + """ + Returns the city with the usage parameters assigned to the buildings + :return: + """ + _daily_schedules = pd.read_excel(self._xls, nrows=261, usecols="A:Y") + year = [] + for day in range(1, 262): + values = _daily_schedules.iloc[day-1][1:].to_numpy() + year.extend(values) + schedule = Schedule() + schedule.values = year + schedule.type = cte.OCCUPANCY + schedule.time_range = cte.YEAR + schedule.time_step = cte.HOUR + schedule.data_type = cte.FRACTION + + for building in self._buildings: + for internal_zone in building.internal_zones: + for thermal_zone in internal_zone.thermal_zones: + occupancy = thermal_zone.occupancy + occupancy.occupancy_schedules = [schedule] diff --git a/imports/customized_imports_factory.py b/imports/customized_imports_factory.py new file mode 100644 index 00000000..a070c095 --- /dev/null +++ b/imports/customized_imports_factory.py @@ -0,0 +1,28 @@ +""" +CustomizedImportsFactory is used to import any information using user customized formats +This factory can only be called after calling the construction factory. +SPDX - License - Identifier: LGPL - 3.0 - or -later +Copyright © 2022 Concordia CERC group +Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca +""" +from pathlib import Path + + +class CustomizedImportsFactory: + """ + CustomizedImportsFactory class + """ + def __init__(self, importer_class, city, base_path=None): + if base_path is None: + base_path = Path('C:/Users/Pilar/Documents/Pycharm_repository/Workshops/ep_workflow/inputs/') + self._importer_class = importer_class + self._city = city + self._base_path = base_path + + def enrich(self): + """ + Returns the class that will enrich the city given + :return: Class + """ + importer = self._importer_class(self._city, self._base_path) + return importer.enrich_buildings() diff --git a/scripts/workshop_ep_workflow.py b/scripts/workshop_ep_workflow.py index 34813d1e..a35b7010 100644 --- a/scripts/workshop_ep_workflow.py +++ b/scripts/workshop_ep_workflow.py @@ -1,22 +1,22 @@ import sys -sys.path.append('/home/guille/Projects/Concordia/libs') +sys.path.append('C:/Users/Pilar/PycharmProjects/libs') + from imports.geometry_factory import GeometryFactory from imports.construction_factory import ConstructionFactory from imports.usage_factory import UsageFactory -from imports.schedules_factory import SchedulesFactory from exports.exports_factory import ExportsFactory +from imports.customized_imports_factory import CustomizedImportsFactory +from imports.customized_imports.stochastic_schedules_importer import StochasticSchedulesImporter as ssi -city = GeometryFactory('citygml', '/home/guille/Documents/Concordia/EP_Workflow/one_building_in_kelowna.gml').city +city = GeometryFactory('citygml', 'C:/Users/Pilar/Documents/Pycharm_repository/Workshops/ep_workflow/' + 'inputs/one_building_in_kelowna.gml').city +for building in city.buildings: + building.year_of_construction = 2006 ConstructionFactory('nrel', city).enrich() UsageFactory('comnet', city).enrich() -SchedulesFactory('comnet', city).enrich() -for building in city.buildings: - for usage in building.usage_zones: - if usage.cooling_setpoint is None: - usage.cooling_setpoint = 22.0 - if usage.heating_setpoint is None: - usage.heating_setpoint = 22.0 +CustomizedImportsFactory(ssi, city).enrich() -_idf = ExportsFactory('idf', city, '/home/guille/Documents/Concordia/EP_Workflow/outputs/').export() +_idf = ExportsFactory('idf', city, + 'C:/Users/Pilar/Documents/Pycharm_repository/Workshops/ep_workflow/outputs/').export_debug() _idf.run()