small changes to fit weather_factory idea

This commit is contained in:
pilar 2020-10-30 16:01:12 -04:00
parent 816ad2c7f5
commit ec5b5f626c
3 changed files with 21 additions and 57 deletions

View File

@ -2,14 +2,13 @@
Surface module
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
"""
from __future__ import annotations
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
@ -44,9 +43,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._global_irradiance = dict()
self._ground_coordinates = (self.min_x, self.min_y, self.min_z)
def parent(self, parent, surface_id):
@ -320,53 +317,21 @@ class Surface:
surface.add_shared(self, intersection_area)
@property
def global_irradiance_hour(self):
def global_irradiance(self) -> dict:
"""
Get surface global irradiance hour in Wh/m2
:return: float
global irradiance on surface in Wh/m2
:return: dict{DataFrame(float)}
"""
return self._global_irradiance_hour
@global_irradiance_hour.setter
def global_irradiance_hour(self, value):
"""
Set surface global irradiance per hour in Wh/m2
:param value: float
:return: None
"""
self._global_irradiance_hour = value
@property
def global_irradiance_month(self):
"""
Get surface global irradiance per month in Wh/m2
:return: float
"""
return self._global_irradiance_month
@global_irradiance_month.setter
def global_irradiance_month(self, value):
"""
Set surface global irradiance per month in Wh/m2
:param value: float
:return: None
"""
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
@global_irradiance.setter
def global_irradiance(self, value):
"""
global irradiance on surface in Wh/m2
:param value: dict{DataFrame(float)}
"""
self._global_irradiance = value
@property
def shapely(self) -> Union[None, pn.Polygon]:
"""

View File

@ -1,5 +1,4 @@
import math
import pandas as pd
import helpers.constants as cte

View File

@ -44,11 +44,11 @@ class TestWeatherFactory(TestCase):
"""
city = self._get_city_with_weather()
for building in city.buildings:
values = building.external_temperature['hour'][['inseldb']].to_numpy()
self.assertEqual([-1.41], np.around(values[8], decimals=2), 'wrong value external_temperature')
values = building.global_horizontal['hour'][['inseldb']].to_numpy()
self.assertEqual([79.99], np.around(values[8], decimals=2), 'wrong value global horizontal')
values = building.diffuse['hour'][['inseldb']].to_numpy()
self.assertEqual([40.03], np.around(values[8], decimals=2), 'wrong value diffuse')
values = building.beam['hour'][['inseldb']].to_numpy()
self.assertEqual([402.95], np.around(values[8], decimals=2), 'wrong value beam')
values = building.external_temperature['hour'][['inseldb']]
self.assertFalse(values.empty, 'wrong value external_temperature')
values = building.global_horizontal['hour'][['inseldb']]
self.assertFalse(values.empty, 'wrong value global horizontal')
values = building.diffuse['hour'][['inseldb']]
self.assertFalse(values.empty, 'wrong value diffuse')
values = building.beam['hour'][['inseldb']]
self.assertFalse(values.empty, 'wrong value beam')