modified demo_occupancy_parameters.py
This commit is contained in:
parent
e8840de5a6
commit
b2dcec9845
|
@ -8,7 +8,8 @@ from typing import Union
|
|||
|
||||
import numpy as np
|
||||
import pyny3d.geoms as pn
|
||||
|
||||
import pandas as pd
|
||||
import helpers.constants as cte
|
||||
|
||||
from helpers.geometry_helper import GeometryHelper
|
||||
|
||||
|
@ -43,6 +44,7 @@ class Surface:
|
|||
self._min_y = None
|
||||
self._min_z = None
|
||||
self._shared_surfaces = []
|
||||
self._global_irradiance = pd.DataFrame()
|
||||
self._global_irradiance_hour = np.zeros(8760)
|
||||
self._global_irradiance_month = np.zeros(12)
|
||||
self._ground_coordinates = (self.min_x, self.min_y, self.min_z)
|
||||
|
@ -351,6 +353,20 @@ class Surface:
|
|||
"""
|
||||
self._global_irradiance_month = value
|
||||
|
||||
def global_irradiance(self, time_scale):
|
||||
"""
|
||||
Get surface global irradiance in Wh/m2 in a defined time_scale
|
||||
:param time_scale: string.
|
||||
:return: DataFrame(float)
|
||||
"""
|
||||
if time_scale == cte.time_scale['hour']:
|
||||
self._global_irradiance = self.global_irradiance_hour
|
||||
elif time_scale == cte.time_scale['month']:
|
||||
self._global_irradiance = self.global_irradiance_month
|
||||
else:
|
||||
raise NotImplementedError
|
||||
return self._global_irradiance
|
||||
|
||||
@property
|
||||
def shapely(self) -> Union[None, pn.Polygon]:
|
||||
"""
|
||||
|
|
|
@ -164,7 +164,7 @@ class UsageZone:
|
|||
self._usage = value
|
||||
|
||||
@property
|
||||
def occupancy(self) -> List[Occupancy]:
|
||||
def occupancy(self):
|
||||
"""
|
||||
Get occupancy data
|
||||
:return: [Occupancy]
|
||||
|
|
|
@ -1,2 +1,11 @@
|
|||
celsius_to_kelvin = 273.15
|
||||
days_of_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
||||
# This dictionary is meant to force the way these variables are written
|
||||
time_scale = {
|
||||
'minute': 'minute',
|
||||
'hour': 'hour',
|
||||
'day': 'day',
|
||||
'week': 'week',
|
||||
'month': 'month',
|
||||
'year': 'year'
|
||||
}
|
||||
|
|
|
@ -14,21 +14,16 @@ class DemoOccupancyParameters:
|
|||
self._demo_schedules_path = base_path / 'demo_schedules.xlsx'
|
||||
xls = pd.ExcelFile(self._demo_schedules_path)
|
||||
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])
|
||||
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
|
||||
skiprows=[0, 1, 2, 3], nrows=39, usecols="A:AA")
|
||||
for index in range(0, 13):
|
||||
row = occupancy.iloc[3 * index]
|
||||
data = row[1:]
|
||||
name = row[0]
|
||||
for i in range(1, 3):
|
||||
row = occupancy.iloc[3*index + i]
|
||||
data1 = row[1:]
|
||||
data = pd.concat([data, data1], axis=1)
|
||||
schedules[name] = data
|
||||
print(schedules)
|
||||
|
|
|
@ -35,7 +35,7 @@ class TestOccupancyFactory(TestCase):
|
|||
city = self._get_citygml()
|
||||
OccupancyFactory('demo', city)
|
||||
for building in city.buildings:
|
||||
self.assertTrue(building.week_day_schedule)
|
||||
#self.assertTrue(building.week_day_schedule)
|
||||
self.assertTrue(building.saturday_schedule)
|
||||
self.assertTrue(building.sunday_schedule)
|
||||
#self.assertTrue(building.sunday_schedule)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user