city_retrofit/imports/weather_factory.py
2021-08-26 13:27:43 -04:00

39 lines
1.3 KiB
Python

"""
WeatherFactory retrieve the specific weather module for the given source format
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from pathlib import Path
from imports.weather.xls_weather_parameters import XlsWeatherParameters
from imports.weather.epw_weather_parameters import EpwWeatherParameters
class WeatherFactory:
"""
WeatherFactory class
"""
def __init__(self, handler, city, base_path=Path(Path(__file__).parent.parent / 'data/weather'), file_name=None):
self._handler = '_' + handler.lower().replace(' ', '_')
self._city = city
self._base_path = base_path
self._file_name = file_name
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()
return EpwWeatherParameters(self._city, _path, self._file_name)
def _xls(self):
name = 'ISO_52016_1_BESTEST_ClimData_2016.08.24'
return XlsWeatherParameters(self._city, self._base_path, name)
def enrich(self):
"""
Enrich the city with the usage information
:return: None
"""
getattr(self, self._handler, lambda: None)()