diff --git a/city_model_structure/attributes/surface.py b/city_model_structure/attributes/surface.py index de206820..8686d208 100644 --- a/city_model_structure/attributes/surface.py +++ b/city_model_structure/attributes/surface.py @@ -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]: """ diff --git a/factories/weather_feeders/helpers/weather.py b/factories/weather_feeders/helpers/weather.py index 9ee068fc..ed4cf6d4 100644 --- a/factories/weather_feeders/helpers/weather.py +++ b/factories/weather_feeders/helpers/weather.py @@ -1,5 +1,4 @@ import math -import pandas as pd import helpers.constants as cte diff --git a/tests/test_weather_factory.py b/tests/test_weather_factory.py index b0117599..84f7c554 100644 --- a/tests/test_weather_factory.py +++ b/tests/test_weather_factory.py @@ -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')