Merge remote-tracking branch 'origin/master'
# Conflicts: # helpers/idf_helper.py
This commit is contained in:
commit
cd3ee05c52
|
@ -42,8 +42,8 @@ class Building(CityObject):
|
|||
self._type = 'building'
|
||||
self._monthly_heating = pd.DataFrame()
|
||||
self._monthly_cooling = pd.DataFrame()
|
||||
self._hourly_heating = pd.DataFrame()
|
||||
self._hourly_cooling = pd.DataFrame()
|
||||
self._hourly_heating = []
|
||||
self._hourly_cooling = []
|
||||
self._week_day_schedule = []
|
||||
self._saturday_schedule = []
|
||||
self._sunday_schedule = []
|
||||
|
@ -279,7 +279,7 @@ class Building(CityObject):
|
|||
self._building_units = value
|
||||
|
||||
@property
|
||||
def monthly_heating(self) -> pd.DataFrame:
|
||||
def monthly_heating(self):
|
||||
"""
|
||||
building monthly heating values in Watts-hour
|
||||
:return: DataFrame with 12 values and a header with the source of those
|
||||
|
@ -292,10 +292,13 @@ class Building(CityObject):
|
|||
building monthly heating values in Watts-hour and a header with the source
|
||||
:param value: DataFrame(heating demand)
|
||||
"""
|
||||
self._monthly_heating.append(value)
|
||||
if self._monthly_heating.empty:
|
||||
self._monthly_heating = value
|
||||
else:
|
||||
self._monthly_heating = pd.concat([self._monthly_heating, value])
|
||||
|
||||
@property
|
||||
def monthly_cooling(self) -> pd.DataFrame:
|
||||
def monthly_cooling(self):
|
||||
"""
|
||||
building monthly cooling values in Watts-hour
|
||||
:return: DataFrame with 12 values and a header with the source of those
|
||||
|
@ -308,10 +311,13 @@ class Building(CityObject):
|
|||
building monthly cooling values in Watts-hour and a header with the source
|
||||
:param value: DataFrame(cooling demand)
|
||||
"""
|
||||
self._monthly_cooling.append(value)
|
||||
if self._monthly_cooling.empty:
|
||||
self._monthly_cooling = value
|
||||
else:
|
||||
self._monthly_cooling = pd.concat([self._monthly_cooling, value])
|
||||
|
||||
@property
|
||||
def hourly_heating(self) -> pd.DataFrame:
|
||||
def hourly_heating(self):
|
||||
"""
|
||||
building hourly heating values in Watts-hour
|
||||
:return: DataFrame with 8760 values and a header with the source of those
|
||||
|
@ -327,7 +333,7 @@ class Building(CityObject):
|
|||
self._hourly_heating.append(value)
|
||||
|
||||
@property
|
||||
def hourly_cooling(self) -> pd.DataFrame:
|
||||
def hourly_cooling(self):
|
||||
"""
|
||||
building hourly cooling values in Watts-hour
|
||||
:return: DataFrame with 8760 values and a header with the source of those
|
||||
|
|
BIN
data/occupancy/demo_schedules.xlsx
Normal file
BIN
data/occupancy/demo_schedules.xlsx
Normal file
Binary file not shown.
29
occupancy/occupancy_factory.py
Normal file
29
occupancy/occupancy_factory.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
"""
|
||||
PhysicsFactory retrieve the specific physics module for the given region
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from occupancy.occupancy_feeders.demo_occupancy_parameters import DemoOccupancyParameters
|
||||
|
||||
|
||||
class OccupancyFactory:
|
||||
"""
|
||||
PhysicsFactor 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 _demo(self):
|
||||
DemoOccupancyParameters(self._city, self._base_path)
|
||||
|
||||
def factory(self):
|
||||
"""
|
||||
Enrich the city with the physics information
|
||||
:return: None
|
||||
"""
|
||||
getattr(self, self._handler, lambda: None)()
|
34
occupancy/occupancy_feeders/demo_occupancy_parameters.py
Normal file
34
occupancy/occupancy_feeders/demo_occupancy_parameters.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
"""
|
||||
PhysicsFactory retrieve the specific physics module for the given region
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||
"""
|
||||
import pandas as pd
|
||||
from occupancy.occupancy_feeders.helpers.occupancy_helper import OccupancyHelper
|
||||
|
||||
|
||||
class DemoOccupancyParameters:
|
||||
|
||||
def __init__(self, city, base_path):
|
||||
self._city = city
|
||||
self._demo_schedules_path = base_path / 'demo_schedules.xlsx'
|
||||
xls = pd.ExcelFile(self._demo_schedules_path)
|
||||
for building in city.buildings:
|
||||
occupancy = pd.read_excel(xls, sheet_name=OccupancyHelper.pluto_occupancy_function(building.function),
|
||||
skiprows=[0, 1, 2, 3])
|
||||
for index, row in occupancy.iterrows():
|
||||
building.week_day_schedule = [row['1am'], row['2am'], row['3am'], row['4am'], row['5am'], row['6am'],
|
||||
row['7am'], row['8am'], row['9am'], row['10am'], row['11am'], row['12am'],
|
||||
row['1pm'], row['2pm'], row['3pm'], row['4pm'], row['5pm'], row['6pm'],
|
||||
row['7pm'], row['8pm'], row['9pm'], row['10pm'], row['11pm'], row['12pm']]
|
||||
row = occupancy.iloc[index + 1]
|
||||
building.saturday_schedule = [row['1am'], row['2am'], row['3am'], row['4am'], row['5am'], row['6am'],
|
||||
row['7am'], row['8am'], row['9am'], row['10am'], row['11am'], row['12am'],
|
||||
row['1pm'], row['2pm'], row['3pm'], row['4pm'], row['5pm'], row['6pm'],
|
||||
row['7pm'], row['8pm'], row['9pm'], row['10pm'], row['11pm'], row['12pm']]
|
||||
row = occupancy.iloc[index + 2]
|
||||
building.sunday_schedule = [row['1am'], row['2am'], row['3am'], row['4am'], row['5am'], row['6am'],
|
||||
row['7am'], row['8am'], row['9am'], row['10am'], row['11am'], row['12am'],
|
||||
row['1pm'], row['2pm'], row['3pm'], row['4pm'], row['5pm'], row['6pm'],
|
||||
row['7pm'], row['8pm'], row['9pm'], row['10pm'], row['11pm'], row['12pm']]
|
||||
break
|
21
occupancy/occupancy_feeders/helpers/occupancy_helper.py
Normal file
21
occupancy/occupancy_feeders/helpers/occupancy_helper.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
"""
|
||||
Geometry helper
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||
"""
|
||||
|
||||
|
||||
class OccupancyHelper:
|
||||
occupancy_function = {
|
||||
'I1': 'C-2 Health',
|
||||
'C1': 'C-12 Residential'
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def pluto_occupancy_function(building_pluto_function):
|
||||
"""
|
||||
Get nrel function from the given pluto function
|
||||
:param building_pluto_function: str
|
||||
:return: str
|
||||
"""
|
||||
return OccupancyHelper.occupancy_function[building_pluto_function]
|
41
tests/test_occupancy_factory.py
Normal file
41
tests/test_occupancy_factory.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
"""
|
||||
TestOccupancyFactory test and validate the city model structure occupancy parameters
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||
"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
from unittest import TestCase
|
||||
|
||||
from geometry.geometry_factory import GeometryFactory
|
||||
from occupancy.occupancy_factory import OccupancyFactory
|
||||
|
||||
|
||||
class TestOccupancyFactory(TestCase):
|
||||
"""
|
||||
TestOccupancyFactory TestCase
|
||||
"""
|
||||
|
||||
def setUp(self) -> None:
|
||||
"""
|
||||
Test setup
|
||||
:return: None
|
||||
"""
|
||||
self._city_gml = None
|
||||
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
|
||||
|
||||
def _get_citygml(self):
|
||||
if self._city_gml is None:
|
||||
file_path = (self._example_path / 'buildings.gml').resolve()
|
||||
self._city_gml = GeometryFactory('citygml', file_path).city
|
||||
self.assertIsNotNone(self._city_gml, 'city is none')
|
||||
return self._city_gml
|
||||
|
||||
def test_demo(self):
|
||||
city = self._get_citygml()
|
||||
OccupancyFactory('demo', city)
|
||||
for building in city.buildings:
|
||||
self.assertTrue(building.week_day_schedule)
|
||||
self.assertTrue(building.saturday_schedule)
|
||||
self.assertTrue(building.sunday_schedule)
|
||||
|
Loading…
Reference in New Issue
Block a user