hub/imports/weather_factory.py

46 lines
1.5 KiB
Python
Raw Normal View History

2020-10-28 13:42:58 -04:00
"""
WeatherFactory retrieve the specific weather module for the given source format
SPDX - License - Identifier: LGPL - 3.0 - or -later
2021-04-13 15:09:13 -04:00
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
2020-10-28 13:42:58 -04:00
"""
from pathlib import Path
from imports.weather.xls_weather_parameters import XlsWeatherParameters
from imports.weather.epw_weather_parameters import EpwWeatherParameters
2020-10-28 13:42:58 -04:00
class WeatherFactory:
"""
WeatherFactory class
"""
2021-04-13 15:09:13 -04:00
def __init__(self, handler, city, base_path=Path(Path(__file__).parent.parent / 'data/weather'), file_name=None):
2020-10-28 13:42:58 -04:00
self._handler = '_' + handler.lower().replace(' ', '_')
self._city = city
self._base_path = base_path
2021-04-13 15:09:13 -04:00
self._file_name = file_name
2020-10-28 13:42:58 -04:00
2021-04-13 15:09:13 -04:00
def _tmy3(self):
2020-10-28 13:42:58 -04:00
raise Exception('Not implemented')
2021-04-13 15:09:13 -04:00
def _tm2(self):
# Meteonorm (https://meteonorm.com/en/product/typical-years)
raise Exception('Not implemented')
def _epw(self):
# EnergyPlus Weather
# to download files: https://energyplus.net/weather
# description of the format: https://energyplus.net/sites/default/files/pdfs_v8.3.0/AuxiliaryPrograms.pdf
_path = Path(self._base_path / 'epw').resolve()
EpwWeatherParameters(self._city, _path, self._file_name)
def _xls(self):
name = 'ISO_52016_1_BESTEST_ClimData_2016.08.24'
XlsWeatherParameters(self._city, self._base_path, name)
def enrich(self):
2020-10-28 13:42:58 -04:00
"""
Enrich the city with the usage information
2020-10-28 13:42:58 -04:00
:return: None
"""
getattr(self, self._handler, lambda: None)()