first version of weather factory and related files
This commit is contained in:
parent
b3f8647036
commit
f4ea7686a5
|
@ -50,6 +50,12 @@ class Building(CityObject):
|
||||||
self._m_external_temperature = pd.DataFrame()
|
self._m_external_temperature = pd.DataFrame()
|
||||||
self._h_external_temperature = pd.DataFrame()
|
self._h_external_temperature = pd.DataFrame()
|
||||||
self._external_temperature = pd.DataFrame()
|
self._external_temperature = pd.DataFrame()
|
||||||
|
self._h_global_horizontal = pd.DataFrame()
|
||||||
|
self._global_horizontal = pd.DataFrame()
|
||||||
|
self._h_diffuse = pd.DataFrame()
|
||||||
|
self._diffuse = pd.DataFrame()
|
||||||
|
self._h_beam = pd.DataFrame()
|
||||||
|
self._beam = pd.DataFrame()
|
||||||
|
|
||||||
# ToDo: Check this for LOD4
|
# ToDo: Check this for LOD4
|
||||||
self._thermal_zones = []
|
self._thermal_zones = []
|
||||||
|
@ -425,7 +431,7 @@ class Building(CityObject):
|
||||||
|
|
||||||
def external_temperature(self, time_scale) -> pd.DataFrame:
|
def external_temperature(self, time_scale) -> pd.DataFrame:
|
||||||
"""
|
"""
|
||||||
Get cooling demand in Wh in a defined time_scale
|
Get external temperature surrounding the building in grads Celsius in a defined time_scale
|
||||||
:param time_scale: string.
|
:param time_scale: string.
|
||||||
:return: DataFrame(float)
|
:return: DataFrame(float)
|
||||||
"""
|
"""
|
||||||
|
@ -436,3 +442,97 @@ class Building(CityObject):
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
return self._external_temperature
|
return self._external_temperature
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _hourly_global_horizontal(self) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
global horizontal radiation surrounding the building in W/m2 hourly based
|
||||||
|
:return: DataFrame with 8760 values and a header with the source of those
|
||||||
|
"""
|
||||||
|
return self._h_global_horizontal
|
||||||
|
|
||||||
|
@_hourly_global_horizontal.setter
|
||||||
|
def _hourly_global_horizontal(self, value):
|
||||||
|
"""
|
||||||
|
global horizontal radiation surrounding the building in W/m2 hourly based
|
||||||
|
:param value: DataFrame(external temperature)
|
||||||
|
"""
|
||||||
|
if self._h_global_horizontal.empty:
|
||||||
|
self._h_global_horizontal = value
|
||||||
|
else:
|
||||||
|
self._h_global_horizontal = pd.concat([self._h_global_horizontal, value], axis=1)
|
||||||
|
|
||||||
|
def global_horizontal(self, time_scale) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
Get global horizontal radiation surrounding the building in W/m2 in a defined time_scale
|
||||||
|
:param time_scale: string.
|
||||||
|
:return: DataFrame(float)
|
||||||
|
"""
|
||||||
|
if time_scale == cte.time_scale['hour']:
|
||||||
|
self._global_horizontal = self._hourly_global_horizontal
|
||||||
|
else:
|
||||||
|
raise NotImplementedError
|
||||||
|
return self._global_horizontal
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _hourly_diffuse(self) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
diffuse radiation surrounding the building in W/m2 hourly based
|
||||||
|
:return: DataFrame with 8760 values and a header with the source of those
|
||||||
|
"""
|
||||||
|
return self._h_diffuse
|
||||||
|
|
||||||
|
@_hourly_diffuse.setter
|
||||||
|
def _hourly_diffuse(self, value):
|
||||||
|
"""
|
||||||
|
diffuse radiation surrounding the building in W/m2 hourly based
|
||||||
|
:param value: DataFrame(external temperature)
|
||||||
|
"""
|
||||||
|
if self._h_diffuse.empty:
|
||||||
|
self._h_diffuse = value
|
||||||
|
else:
|
||||||
|
self._h_diffuse = pd.concat([self._h_diffuse, value], axis=1)
|
||||||
|
|
||||||
|
def diffuse(self, time_scale) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
Get diffuse radiation surrounding the building in W/m2 in a defined time_scale
|
||||||
|
:param time_scale: string.
|
||||||
|
:return: DataFrame(float)
|
||||||
|
"""
|
||||||
|
if time_scale == cte.time_scale['hour']:
|
||||||
|
self._diffuse = self._hourly_diffuse
|
||||||
|
else:
|
||||||
|
raise NotImplementedError
|
||||||
|
return self._diffuse
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _hourly_beam(self) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
beam radiation surrounding the building in W/m2 hourly based
|
||||||
|
:return: DataFrame with 8760 values and a header with the source of those
|
||||||
|
"""
|
||||||
|
return self._h_beam
|
||||||
|
|
||||||
|
@_hourly_beam.setter
|
||||||
|
def _hourly_beam(self, value):
|
||||||
|
"""
|
||||||
|
beam radiation surrounding the building in W/m2 hourly based
|
||||||
|
:param value: DataFrame(external temperature)
|
||||||
|
"""
|
||||||
|
if self._h_beam.empty:
|
||||||
|
self._h_beam = value
|
||||||
|
else:
|
||||||
|
self._h_beam = pd.concat([self._h_beam, value], axis=1)
|
||||||
|
|
||||||
|
def beam(self, time_scale) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
Get beam radiation surrounding the building in W/m2 in a defined time_scale
|
||||||
|
:param time_scale: string.
|
||||||
|
:return: DataFrame(float)
|
||||||
|
"""
|
||||||
|
if time_scale == cte.time_scale['hour']:
|
||||||
|
self._beam = self._hourly_beam
|
||||||
|
else:
|
||||||
|
raise NotImplementedError
|
||||||
|
return self._beam
|
||||||
|
|
||||||
|
|
8764
data/weather/inseldb_new_york_city.cli
Normal file
8764
data/weather/inseldb_new_york_city.cli
Normal file
File diff suppressed because it is too large
Load Diff
8760
data/weather/inseldb_new_york_city.dat
Normal file
8760
data/weather/inseldb_new_york_city.dat
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -4,7 +4,7 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
|
Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from factories.weather.weather_feeders.cli_weather_parameters import CliWeatherParameters
|
from pathlib import Path
|
||||||
from factories.weather.weather_feeders.dat_weather_parameters import DatWeatherParameters
|
from factories.weather.weather_feeders.dat_weather_parameters import DatWeatherParameters
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,17 +14,14 @@ class WeatherFactory:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# todo: modify full_path_weather to make it depending on "city"
|
# todo: modify full_path_weather to make it depending on "city"
|
||||||
def __init__(self, handler, city, full_path_weather):
|
def __init__(self, handler, city, base_path=Path(Path(__file__).parent.parent / 'data/weather')):
|
||||||
self._handler = '_' + handler.lower().replace(' ', '_')
|
self._handler = '_' + handler.lower().replace(' ', '_')
|
||||||
self._city = city
|
self._city = city
|
||||||
self._full_path_weather = full_path_weather
|
self._base_path = base_path
|
||||||
self.factory()
|
self.factory()
|
||||||
|
|
||||||
def _cli(self):
|
|
||||||
CliWeatherParameters(self._full_path_weather)
|
|
||||||
|
|
||||||
def _dat(self):
|
def _dat(self):
|
||||||
DatWeatherParameters(self._full_path_weather)
|
DatWeatherParameters(self._city, Path(self._base_path / 'inseldb' + self._handler + '.dat'))
|
||||||
|
|
||||||
def _tmy(self):
|
def _tmy(self):
|
||||||
raise Exception('Not implemented')
|
raise Exception('Not implemented')
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
"""
|
|
||||||
CliWeatherParameters class to extract weather parameters from a defined region in .cli format
|
|
||||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
||||||
Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
class CliWeatherParameters:
|
|
||||||
"""
|
|
||||||
CliWeatherParameters class
|
|
||||||
"""
|
|
||||||
def __init__(self, full_path_weather):
|
|
||||||
self._full_path_weather = full_path_weather
|
|
|
@ -11,14 +11,19 @@ class DatWeatherParameters:
|
||||||
"""
|
"""
|
||||||
DatWeatherParameters class
|
DatWeatherParameters class
|
||||||
"""
|
"""
|
||||||
def __init__(self, full_path_weather):
|
def __init__(self, city, path):
|
||||||
self._full_path_weather = full_path_weather
|
self._path = path
|
||||||
self._weather_values = None
|
self._weather_values = None
|
||||||
|
self._city = city
|
||||||
|
|
||||||
def weather_values(self):
|
def weather_values(self):
|
||||||
if self._full_path_weather is not None:
|
# TODO: catch error if file does not exist
|
||||||
# TODO: catch error if file does not exist
|
if self._weather_values is None:
|
||||||
if self._weather_values is None:
|
self._weather_values = pd.read_csv(self._path, sep='\s+', header=None,
|
||||||
self._weather_values = pd.read_csv(self._full_path_weather, sep='\s+', header=None,
|
names=['hour', 'global_horiz', 'temperature', 'diffuse', 'beam', 'empty'])
|
||||||
names=['hour', 'global_horiz', 'temperature', 'diffuse', 'beam', 'empty'])
|
for building in self._city.buildings:
|
||||||
return self._weather_values
|
building._hourly_external_temperature = pd.DataFrame(self._weather_values[['temperature']], columns=['inseldb'])
|
||||||
|
building._hourly_global_horizontal = pd.DataFrame(self._weather_values[['global_horiz']], columns=['inseldb'])
|
||||||
|
building._hourly_diffuse = pd.DataFrame(self._weather_values[['diffuse']], columns=['inseldb'])
|
||||||
|
building._hourly_beam = pd.DataFrame(self._weather_values[['beam']], columns=['inseldb'])
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,9 @@
|
||||||
import math
|
import math
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import helpers.constants as cte
|
import helpers.constants as cte
|
||||||
from helpers import monthly_values as mv
|
|
||||||
|
|
||||||
|
|
||||||
class Weather(object):
|
class Weather(object):
|
||||||
def __init__(self, weather_values):
|
|
||||||
self._weather_values = pd.concat([mv.MonthlyValues().month_hour, weather_values], axis=1)
|
|
||||||
self._temperatures_hourly = None
|
|
||||||
|
|
||||||
@property
|
|
||||||
def external_and_sky_temperatures(self):
|
|
||||||
if self._temperatures_hourly is None:
|
|
||||||
self._temperatures_hourly = self._weather_values[['month', 'temperature']]
|
|
||||||
sky_temperature = self.sky_temperature(self._temperatures_hourly)
|
|
||||||
self._temperatures_hourly = pd.concat([self._temperatures_hourly, sky_temperature], axis=1)
|
|
||||||
return self._temperatures_hourly
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def sky_temperature(ambient_temperature):
|
def sky_temperature(ambient_temperature):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user