32 lines
1.3 KiB
Python
32 lines
1.3 KiB
Python
import math
|
|
import pandas as pd
|
|
import helpers.constants as cte
|
|
from helpers import monthly_values as mv
|
|
|
|
|
|
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
|
|
def sky_temperature(ambient_temperature):
|
|
# Swinbank - Fuentes sky model approximation(1963) based on cloudiness statistics(32 %) in United States
|
|
# ambient temperatures( in °C)
|
|
# sky temperatures( in °C)
|
|
_ambient_temperature = ambient_temperature[['temperature']].to_numpy()
|
|
values = []
|
|
for temperature in _ambient_temperature:
|
|
value = 0.037536 * math.pow((temperature + cte.celsius_to_kelvin), 1.5) \
|
|
+ 0.32 * (temperature + cte.celsius_to_kelvin) - cte.celsius_to_kelvin
|
|
values.append(value)
|
|
return pd.DataFrame(values, columns=['sky temperature'])
|