forked from s_ranjbar/city_retrofit
occupancy to schedules
This commit is contained in:
parent
51f6edbd31
commit
4a7dda045d
|
@ -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)()
|
||||
|
|
|
@ -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]
|
|
@ -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])
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user