occupancy to schedules

This commit is contained in:
pilar 2020-12-15 14:57:46 -05:00
parent 51f6edbd31
commit 4a7dda045d
10 changed files with 37 additions and 38 deletions

View File

@ -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 SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
""" """
from pathlib import Path 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')): def __init__(self, handler, city, base_path=Path(Path(__file__).parent.parent / 'data/occupancy')):
self._handler = '_' + handler.lower().replace(' ', '_') self._handler = '_' + handler.lower().replace(' ', '_')
@ -18,12 +18,12 @@ class OccupancyFactory:
self._base_path = base_path self._base_path = base_path
self.factory() self.factory()
def _demo(self): def _comnet(self):
DemoOccupancyParameters(self._city, self._base_path) ComnetSchedules(self._city, self._base_path)
def factory(self): def factory(self):
""" """
Enrich the city with the physics information Enrich the city with the schedules information
:return: None :return: None
""" """
getattr(self, self._handler, lambda: None)() getattr(self, self._handler, lambda: None)()

View File

@ -1,12 +1,12 @@
""" """
Geometry helper Schedules helper
SPDX - License - Identifier: LGPL - 3.0 - or -later SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
""" """
class OccupancyHelper: class SchedulesHelper:
occupancy_pluto_function = { comnet_pluto_function = {
'C1': 'C-12 Residential', 'C1': 'C-12 Residential',
'C5': 'C-12 Residential', 'C5': 'C-12 Residential',
'D3': 'C-12 Residential', 'D3': 'C-12 Residential',
@ -17,18 +17,18 @@ class OccupancyHelper:
'U0': 'C-10 Warehouse', 'U0': 'C-10 Warehouse',
'W4': 'C-9 School', 'W4': 'C-9 School',
} }
occupancy_function = { comnet_function = {
'residential': 'C-12 Residential' 'residential': 'C-12 Residential'
} }
@staticmethod @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 :param building_pluto_function: str
:return: str :return: str
""" """
try: try:
return OccupancyHelper.occupancy_pluto_function[building_pluto_function] return SchedulesHelper.comnet_pluto_function[building_pluto_function]
except KeyError: except KeyError:
return OccupancyHelper.occupancy_function[building_pluto_function] return SchedulesHelper.comnet_function[building_pluto_function]

View File

@ -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 SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
contributors Pilar Monsalvete pilar_monsalvete@yahoo.es contributors Pilar Monsalvete pilar_monsalvete@yahoo.es
""" """
import pandas as pd import pandas as pd
from factories.occupancy_feeders.helpers.occupancy_helper import OccupancyHelper from factories.occupancy_feeders.helpers.schedules_helper import SchedulesHelper
from enum import Enum
class DemoOccupancyParameters: class ComnetSchedules:
def __init__(self, city, base_path): def __init__(self, city, base_path):
self._city = city self._city = city
self._demo_schedules_path = base_path / 'comnet_archetypes.xlsx' self._comnet_schedules_path = base_path / 'comnet_archetypes.xlsx'
xls = pd.ExcelFile(self._demo_schedules_path) xls = pd.ExcelFile(self._comnet_schedules_path)
# todo: review for more than one usage_zones per building # todo: review for more than one usage_zones per building
for building in city.buildings: for building in city.buildings:
schedules = dict() schedules = dict()
occupancy = pd.read_excel(xls, sheet_name=OccupancyHelper.pluto_occupancy_function(building.function), 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") skiprows=[0, 1, 2, 3], nrows=39, usecols="A:AA")
# todo: should we save the data type? How? # todo: should we save the data type? How?
number_of_schedule_types = 13 number_of_schedule_types = 13
schedules_per_schedule_type = 3 schedules_per_schedule_type = 3
@ -29,7 +28,7 @@ class DemoOccupancyParameters:
columns_names = [] columns_names = []
name = '' name = ''
for schedule_day in range(0, schedules_per_schedule_type): 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']: if schedule_day == day_types['week_day']:
name = row_cells[0] name = row_cells[0]
columns_names.append(row_cells[2]) columns_names.append(row_cells[2])

View File

@ -8,7 +8,7 @@ from pathlib import Path
from unittest import TestCase from unittest import TestCase
from city_model_structure.city import City from city_model_structure.city import City
from factories.geometry_factory import GeometryFactory from factories.schedules_factory import GeometryFactory
class TestGeometryFactory(TestCase): class TestGeometryFactory(TestCase):

View File

@ -5,10 +5,10 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
""" """
from pathlib import Path from pathlib import Path
from unittest import TestCase from unittest import TestCase
from factories.geometry_factory import GeometryFactory from factories.schedules_factory import GeometryFactory
from factories.physics_factory import PhysicsFactory from factories.physics_factory import PhysicsFactory
from factories.usage_factory import UsageFactory from factories.usage_factory import UsageFactory
from factories.occupancy_factory import OccupancyFactory from factories.occupancy_factory import SchedulesFactory
from helpers.idf_helper import IdfHelper from helpers.idf_helper import IdfHelper
import os import os
import glob import glob
@ -35,7 +35,7 @@ class TestIdf(TestCase):
PhysicsFactory('us_new_york', self._city_gml) PhysicsFactory('us_new_york', self._city_gml)
UsageFactory('us_new_york', self._city_gml) UsageFactory('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 return self._city_gml
def test_idf_blocks(self): def test_idf_blocks(self):

View File

@ -6,11 +6,9 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
from pathlib import Path from pathlib import Path
from unittest import TestCase from unittest import TestCase
from factories.geometry_factory import GeometryFactory from factories.schedules_factory import GeometryFactory
from factories.usage_factory import UsageFactory from factories.usage_factory import UsageFactory
from factories.occupancy_factory import OccupancyFactory from factories.occupancy_factory import SchedulesFactory
from city_model_structure.attributes.lighting import Lighting
from city_model_structure.attributes.domestic_hot_water import DomesticHotWater
class TestOccupancyFactory(TestCase): class TestOccupancyFactory(TestCase):
@ -30,7 +28,8 @@ class TestOccupancyFactory(TestCase):
def _handler(self): def _handler(self):
if self._city_gml_with_usage.name == 'New York': if self._city_gml_with_usage.name == 'New York':
handler = '{0}_{1}' 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 return self._city_gml_with_usage.country_code
def _get_citygml_with_usage(self): 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') self.assertIsNotNone(self._city_gml_with_usage, 'city with usage is none')
return self._city_gml_with_usage return self._city_gml_with_usage
def test_demo(self): def test_comnet_archetypes(self):
city = self._get_citygml_with_usage() city = self._get_citygml_with_usage()
OccupancyFactory('demo', city) occupancy_handler = 'comnet'
SchedulesFactory(occupancy_handler, city)
for building in city.buildings: for building in city.buildings:
for usage_zone in building.usage_zones: for usage_zone in building.usage_zones:
self.assertTrue(usage_zone.schedules) self.assertTrue(usage_zone.schedules)

View File

@ -6,7 +6,7 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
from pathlib import Path from pathlib import Path
from unittest import TestCase from unittest import TestCase
from factories.geometry_factory import GeometryFactory from factories.schedules_factory import GeometryFactory
from factories.physics_factory import PhysicsFactory from factories.physics_factory import PhysicsFactory

View File

@ -6,7 +6,7 @@ Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
from pathlib import Path from pathlib import Path
from unittest import TestCase from unittest import TestCase
from factories.geometry_factory import GeometryFactory from factories.schedules_factory import GeometryFactory
from factories.usage_factory import UsageFactory from factories.usage_factory import UsageFactory

View File

@ -7,7 +7,7 @@ from pathlib import Path
from unittest import TestCase from unittest import TestCase
import numpy as np import numpy as np
from factories.geometry_factory import GeometryFactory from factories.schedules_factory import GeometryFactory
from factories.weather_factory import WeatherFactory from factories.weather_factory import WeatherFactory