fixed test_occupancy_factory.py
This commit is contained in:
parent
b2dcec9845
commit
20d9f00e77
|
@ -19,7 +19,6 @@ from city_model_structure.thermal_zone import ThermalZone
|
|||
from city_model_structure.usage_zone import UsageZone
|
||||
from city_model_structure.city_object import CityObject
|
||||
from city_model_structure.building_unit import BuildingUnit
|
||||
from city_model_structure.schedule_value import ScheduleValue
|
||||
|
||||
|
||||
class Building(CityObject):
|
||||
|
@ -43,11 +42,8 @@ class Building(CityObject):
|
|||
self._type = 'building'
|
||||
self._monthly_heating = pd.DataFrame()
|
||||
self._monthly_cooling = pd.DataFrame()
|
||||
self._hourly_heating = []
|
||||
self._hourly_cooling = []
|
||||
self._week_day_schedule = []
|
||||
self._saturday_schedule = []
|
||||
self._sunday_schedule = []
|
||||
self._hourly_heating = pd.DataFrame()
|
||||
self._hourly_cooling = pd.DataFrame()
|
||||
|
||||
# ToDo: Check this for LOD4
|
||||
self._thermal_zones = []
|
||||
|
@ -280,7 +276,7 @@ class Building(CityObject):
|
|||
self._building_units = value
|
||||
|
||||
@property
|
||||
def monthly_heating(self):
|
||||
def monthly_heating(self) -> pd.DataFrame:
|
||||
"""
|
||||
building monthly heating values in Watts-hour
|
||||
:return: DataFrame with 12 values and a header with the source of those
|
||||
|
@ -296,10 +292,10 @@ class Building(CityObject):
|
|||
if self._monthly_heating.empty:
|
||||
self._monthly_heating = value
|
||||
else:
|
||||
self._monthly_heating = pd.concat([self._monthly_heating, value])
|
||||
self._monthly_heating = pd.concat([self._monthly_heating, value], axis=1)
|
||||
|
||||
@property
|
||||
def monthly_cooling(self):
|
||||
def monthly_cooling(self) -> pd.DataFrame:
|
||||
"""
|
||||
building monthly cooling values in Watts-hour
|
||||
:return: DataFrame with 12 values and a header with the source of those
|
||||
|
@ -315,10 +311,10 @@ class Building(CityObject):
|
|||
if self._monthly_cooling.empty:
|
||||
self._monthly_cooling = value
|
||||
else:
|
||||
self._monthly_cooling = pd.concat([self._monthly_cooling, value])
|
||||
self._monthly_cooling = pd.concat([self._monthly_cooling, value], axis=1)
|
||||
|
||||
@property
|
||||
def hourly_heating(self):
|
||||
def hourly_heating(self) -> pd.DataFrame:
|
||||
"""
|
||||
building hourly heating values in Watts-hour
|
||||
:return: DataFrame with 8760 values and a header with the source of those
|
||||
|
@ -331,10 +327,13 @@ class Building(CityObject):
|
|||
building hourly heating values in Watts-hour and a header with the source
|
||||
:param value: DataFrame(heating demand)
|
||||
"""
|
||||
self._hourly_heating.append(value)
|
||||
if self._hourly_heating.empty:
|
||||
self._hourly_heating = value
|
||||
else:
|
||||
self._hourly_heating = pd.concat([self._hourly_heating, value], axis=1)
|
||||
|
||||
@property
|
||||
def hourly_cooling(self):
|
||||
def hourly_cooling(self) -> pd.DataFrame:
|
||||
"""
|
||||
building hourly cooling values in Watts-hour
|
||||
:return: DataFrame with 8760 values and a header with the source of those
|
||||
|
@ -347,52 +346,7 @@ class Building(CityObject):
|
|||
building hourly cooling values in Watts-hour and a header with the source
|
||||
:param value: DataFrame(cooling demand)
|
||||
"""
|
||||
self._hourly_cooling.append(value)
|
||||
|
||||
@property
|
||||
def week_day_schedule(self) -> List[ScheduleValue]:
|
||||
"""
|
||||
Get schedule of weekdays
|
||||
:return: [ScheduleValue]
|
||||
"""
|
||||
return self._week_day_schedule
|
||||
|
||||
@week_day_schedule.setter
|
||||
def week_day_schedule(self, value):
|
||||
"""
|
||||
occupancy schedules of week days
|
||||
:param value: week day schedules
|
||||
"""
|
||||
self._week_day_schedule = value
|
||||
|
||||
@property
|
||||
def saturday_schedule(self) -> List[ScheduleValue]:
|
||||
"""
|
||||
Get schedule of Saturdays
|
||||
:return: [Saturday Schedule_Values]
|
||||
"""
|
||||
return self._saturday_schedule
|
||||
|
||||
@saturday_schedule.setter
|
||||
def saturday_schedule(self, value):
|
||||
"""
|
||||
occupancy schedules of Saturdays
|
||||
:param value: Saturday schedules
|
||||
"""
|
||||
self._saturday_schedule = value
|
||||
|
||||
@property
|
||||
def sunday_schedule(self) -> List[ScheduleValue]:
|
||||
"""
|
||||
Get schedule of Sundays
|
||||
:return: [Sundays Schedule_Values]
|
||||
"""
|
||||
return self._sunday_schedule
|
||||
|
||||
@sunday_schedule.setter
|
||||
def sunday_schedule(self, value):
|
||||
"""
|
||||
occupancy schedules of Sundays
|
||||
:param value: Sunday schedules
|
||||
"""
|
||||
self._sunday_schedule = value
|
||||
if self._hourly_cooling.empty:
|
||||
self._hourly_cooling = value
|
||||
else:
|
||||
self._hourly_cooling = pd.concat([self._hourly_cooling, value], axis=1)
|
||||
|
|
|
@ -4,6 +4,7 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||
"""
|
||||
from typing import List
|
||||
import pandas as pd
|
||||
|
||||
from city_model_structure.internal_gains import InternalGains
|
||||
from helpers.configuration_helper import ConfigurationHelper
|
||||
|
@ -26,6 +27,7 @@ class UsageZone:
|
|||
self._mechanical_air_change = ConfigurationHelper().min_air_change
|
||||
|
||||
self._occupancy = None
|
||||
self._schedules = None
|
||||
|
||||
@property
|
||||
def internal_gains(self) -> List[InternalGains]:
|
||||
|
@ -178,3 +180,19 @@ class UsageZone:
|
|||
:param values: [Occupancy]
|
||||
"""
|
||||
self._occupancy = values
|
||||
|
||||
@property
|
||||
def schedules(self):
|
||||
"""
|
||||
Get schedule of Sundays
|
||||
:return: [Sundays Schedule_Values]
|
||||
"""
|
||||
return self._schedules
|
||||
|
||||
@schedules.setter
|
||||
def schedules(self, value):
|
||||
"""
|
||||
occupancy schedules of Sundays
|
||||
:param value: Sunday schedules
|
||||
"""
|
||||
self._schedules = value
|
||||
|
|
|
@ -13,6 +13,7 @@ class DemoOccupancyParameters:
|
|||
self._city = city
|
||||
self._demo_schedules_path = base_path / 'demo_schedules.xlsx'
|
||||
xls = pd.ExcelFile(self._demo_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),
|
||||
|
@ -26,4 +27,4 @@ class DemoOccupancyParameters:
|
|||
data1 = row[1:]
|
||||
data = pd.concat([data, data1], axis=1)
|
||||
schedules[name] = data
|
||||
print(schedules)
|
||||
building.usage_zones[0].schedules = schedules
|
||||
|
|
|
@ -8,6 +8,7 @@ from pathlib import Path
|
|||
from unittest import TestCase
|
||||
|
||||
from geometry.geometry_factory import GeometryFactory
|
||||
from usage.usage_factory import UsageFactory
|
||||
from occupancy.occupancy_factory import OccupancyFactory
|
||||
|
||||
|
||||
|
@ -21,21 +22,27 @@ class TestOccupancyFactory(TestCase):
|
|||
Test setup
|
||||
:return: None
|
||||
"""
|
||||
self._city_gml = None
|
||||
self._city_gml_with_usage = None
|
||||
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
|
||||
|
||||
def _get_citygml(self):
|
||||
if self._city_gml is None:
|
||||
@property
|
||||
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 self._city_gml_with_usage.country_code
|
||||
|
||||
def _get_citygml_with_usage(self):
|
||||
if self._city_gml_with_usage 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
|
||||
self._city_gml_with_usage = GeometryFactory('citygml', file_path).city
|
||||
self.assertIsNotNone(self._city_gml_with_usage, 'city is none')
|
||||
UsageFactory(self._handler, self._city_gml_with_usage)
|
||||
self.assertIsNotNone(self._city_gml_with_usage, 'city with usage is none')
|
||||
return self._city_gml_with_usage
|
||||
|
||||
def test_demo(self):
|
||||
city = self._get_citygml()
|
||||
city = self._get_citygml_with_usage()
|
||||
OccupancyFactory('demo', city)
|
||||
for building in city.buildings:
|
||||
#self.assertTrue(building.week_day_schedule)
|
||||
self.assertTrue(building.saturday_schedule)
|
||||
#self.assertTrue(building.sunday_schedule)
|
||||
|
||||
self.assertTrue(building.usage_zones[0].schedules)
|
||||
|
|
Loading…
Reference in New Issue
Block a user