mirror of
https://rs-loy-gitlab.concordia.ca/PMAU/DynamicBuildingSimulation.git
synced 2024-12-23 05:25:42 -05:00
35 lines
1.5 KiB
Python
35 lines
1.5 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, full_path_weather):
|
|
self._full_path_weather = full_path_weather
|
|
if self._full_path_weather is not None:
|
|
# TODO: catch error if file does not exist
|
|
self._weather_values = pd.read_csv(self._full_path_weather, sep='\s+', header=None,
|
|
names=['hour', 'global_horiz', 'temperature', 'diffuse', 'beam', 'empty'])
|
|
self._weather_values = pd.concat([mv.MonthlyValues().month_hour, self._weather_values], axis=1)
|
|
|
|
@property
|
|
def weather_temperatures(self):
|
|
temperatures_hourly = self._weather_values[['month', 'temperature']]
|
|
sky_temperature = self.calculate_sky_temperature(temperatures_hourly)
|
|
temperatures_hourly = pd.concat([temperatures_hourly, sky_temperature], axis=1)
|
|
return temperatures_hourly
|
|
|
|
@staticmethod
|
|
def calculate_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.celsius2kelvin), 1.5) \
|
|
+ 0.32 * (temperature + cte.celsius2kelvin) - cte.celsius2kelvin
|
|
values.append(value)
|
|
return pd.DataFrame(values, columns=['sky temperature'])
|