created epw_weather_parameters.py
This commit is contained in:
parent
a0613201e3
commit
146162165f
|
@ -225,3 +225,43 @@ class City:
|
|||
:return: real
|
||||
"""
|
||||
return self._latitude
|
||||
|
||||
@latitude.setter
|
||||
def latitude(self, value):
|
||||
"""
|
||||
city latitude in degrees
|
||||
:parameter value: real
|
||||
"""
|
||||
self._latitude = value
|
||||
|
||||
@property
|
||||
def longitude(self):
|
||||
"""
|
||||
city longitude in degrees
|
||||
:return: real
|
||||
"""
|
||||
return self._longitude
|
||||
|
||||
@longitude.setter
|
||||
def longitude(self, value):
|
||||
"""
|
||||
city longitude in degrees
|
||||
:parameter value: real
|
||||
"""
|
||||
self._longitude = value
|
||||
|
||||
@property
|
||||
def time_zone(self):
|
||||
"""
|
||||
city time_zone
|
||||
:return: real
|
||||
"""
|
||||
return self._time_zone
|
||||
|
||||
@time_zone.setter
|
||||
def time_zone(self, value):
|
||||
"""
|
||||
city time_zone
|
||||
:parameter value: real
|
||||
"""
|
||||
self._time_zone = value
|
||||
|
|
|
@ -108,7 +108,7 @@ class CityObject:
|
|||
@property
|
||||
def centroid(self):
|
||||
"""
|
||||
City object location
|
||||
City object centroid
|
||||
:return: [x,y,z]
|
||||
"""
|
||||
if self._centroid is None:
|
||||
|
|
|
@ -69,7 +69,7 @@ class ExportsFactory:
|
|||
|
||||
@property
|
||||
def _sra(self):
|
||||
return SimplifiedRadiosityAlgorithm(self._city, (self._path/ f'{self._city.name}_sra.xml'))
|
||||
return SimplifiedRadiosityAlgorithm(self._city, (self._path / f'{self._city.name}_sra.xml'))
|
||||
|
||||
def export(self):
|
||||
"""
|
||||
|
|
|
@ -6,6 +6,7 @@ Copyright © 2020 Project Author Guillermo.GutierrezMorote@concordia.ca
|
|||
from pathlib import Path
|
||||
import xmltodict
|
||||
|
||||
|
||||
class SimplifiedRadiosityAlgorithm:
|
||||
|
||||
def __init__(self, city, file_name, begin_month=1, begin_day=1, end_month=12, end_day=31):
|
||||
|
@ -25,7 +26,6 @@ class SimplifiedRadiosityAlgorithm:
|
|||
return [x, y, z]
|
||||
|
||||
def _export(self):
|
||||
print('export')
|
||||
buildings = []
|
||||
for building_index, building in enumerate(self._city.buildings):
|
||||
building_dict = {
|
||||
|
|
|
@ -4,7 +4,6 @@ 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_feeders.dat_weather_parameters import DatWeatherParameters
|
||||
from imports.weather_feeders.xls_weather_parameters import XlsWeatherParameters
|
||||
from imports.weather_feeders.epw_weather_parameters import EpwWeatherParameters
|
||||
|
||||
|
@ -20,9 +19,6 @@ class WeatherFactory:
|
|||
self._base_path = base_path
|
||||
self._file_name = file_name
|
||||
|
||||
def _dat(self):
|
||||
DatWeatherParameters(self._city, self._base_path)
|
||||
|
||||
def _tmy3(self):
|
||||
raise Exception('Not implemented')
|
||||
|
||||
|
|
|
@ -16,8 +16,7 @@ class DatWeatherParameters:
|
|||
def __init__(self, city, path):
|
||||
self._weather_values = None
|
||||
self._city = city
|
||||
# todo: change it to reference_weather_city_name
|
||||
self._city_name = city.name
|
||||
self._city_name = city.climate_reference_city
|
||||
file_name = 'inseldb_' + self._city_name + '.dat'
|
||||
self._path = Path(path / file_name)
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@ class EpwWeatherParameters:
|
|||
try:
|
||||
file = open(self._path, 'r')
|
||||
line = file.readline().split(',')
|
||||
city_name = line[1]
|
||||
latitude = line[6]
|
||||
longitude = line[7]
|
||||
time_zone = line[8]
|
||||
city.climate_reference_city = line[1]
|
||||
city.latitude = line[6]
|
||||
city.longitude = line[7]
|
||||
city.time_zone = line[8]
|
||||
for i in range(0, 2):
|
||||
line = file.readline().split(',')
|
||||
line = file.readline().split(',')
|
||||
|
@ -45,7 +45,7 @@ class EpwWeatherParameters:
|
|||
|
||||
if self._weather_values is None:
|
||||
try:
|
||||
self._weather_values = pd.read_csv(self._path, header=0, skiprows=8,
|
||||
self._weather_values = pd.read_csv(self._path, header=0, skiprows=7,
|
||||
names=['year', 'month', 'day', 'hour', 'minute',
|
||||
'data_source_and_uncertainty_flags',
|
||||
'dry_bulb_temperature_c', 'dew_point_temperature_c',
|
||||
|
@ -73,7 +73,7 @@ class EpwWeatherParameters:
|
|||
|
||||
for building in self._city.buildings:
|
||||
new_value = pd.DataFrame(self._weather_values[['dry_bulb_temperature_c']].to_numpy(), columns=['epw'])
|
||||
number_invalid_records = new_value[new_value.epw == 99.9].count()['epw']
|
||||
number_invalid_records = new_value[new_value.epw == 99.9].count().epw
|
||||
if number_invalid_records > 0:
|
||||
sys.stderr.write(f'Warning: {self._path} invalid records (value of 99.9) in dry bulb temperature\n')
|
||||
if 'hour' not in building.external_temperature:
|
||||
|
@ -82,7 +82,7 @@ class EpwWeatherParameters:
|
|||
pd.concat([building.external_temperature['hour'], new_value], axis=1)
|
||||
|
||||
new_value = pd.DataFrame(self._weather_values[['global_horizontal_radiation_wh_m2']].to_numpy(), columns=['epw'])
|
||||
number_invalid_records = new_value[new_value.epw == 9999].count()['epw']
|
||||
number_invalid_records = new_value[new_value.epw == 9999].count().epw
|
||||
if number_invalid_records > 0:
|
||||
sys.stderr.write(f'Warning: {self._path} invalid records (value of 9999) in global horizontal radiation\n')
|
||||
if 'hour' not in building.global_horizontal:
|
||||
|
@ -91,7 +91,7 @@ class EpwWeatherParameters:
|
|||
pd.concat([building.global_horizontal['hour'], new_value], axis=1)
|
||||
|
||||
new_value = pd.DataFrame(self._weather_values[['diffuse_horizontal_radiation_wh_m2']].to_numpy(), columns=['epw'])
|
||||
number_invalid_records = new_value[new_value.epw == 9999].count()['epw']
|
||||
number_invalid_records = new_value[new_value.epw == 9999].count().epw
|
||||
if number_invalid_records > 0:
|
||||
sys.stderr.write(f'Warning: {self._path} invalid records (value of 9999) in diffuse horizontal radiation\n')
|
||||
if 'hour' not in building.diffuse:
|
||||
|
@ -100,7 +100,7 @@ class EpwWeatherParameters:
|
|||
pd.concat([building.diffuse['hour'], new_value], axis=1)
|
||||
|
||||
new_value = pd.DataFrame(self._weather_values[['direct_normal_radiation_wh_m2']].to_numpy(), columns=['epw'])
|
||||
number_invalid_records = new_value[new_value.epw == 9999].count()['epw']
|
||||
number_invalid_records = new_value[new_value.epw == 9999].count().epw
|
||||
if number_invalid_records > 0:
|
||||
sys.stderr.write(f'Warning: {self._path} invalid records (value of 9999) in direct horizontal radiation\n')
|
||||
if 'hour' not in building.beam:
|
||||
|
|
|
@ -59,4 +59,4 @@ class TestExports(TestCase):
|
|||
self._export('energy_ade')
|
||||
|
||||
def test_sra_export(self):
|
||||
self._export('sra')
|
||||
self._export('sra')
|
||||
|
|
|
@ -29,19 +29,13 @@ class TestWeatherFactory(TestCase):
|
|||
self.assertIsNotNone(self._city_gml, 'city is none')
|
||||
return self._city_gml
|
||||
|
||||
def _get_city_with_weather(self):
|
||||
if self._city_with_weather is None:
|
||||
file_path = (Path(__file__).parent / 'tests_data' / '20buildings.gml').resolve()
|
||||
self._city_with_weather = self._get_citygml(file_path)
|
||||
WeatherFactory('dat', self._city_with_weather, base_path=self._example_path).enrich()
|
||||
return self._city_with_weather
|
||||
|
||||
def test_city_with_weather(self):
|
||||
"""
|
||||
Enrich the city with the weather information and verify it
|
||||
:return: None
|
||||
"""
|
||||
city = self._get_city_with_weather()
|
||||
file_path = (Path(__file__).parent / 'tests_data' / '20buildings.gml').resolve()
|
||||
city = self._get_citygml(file_path)
|
||||
for building in city.buildings:
|
||||
values = building.external_temperature['hour'][['inseldb']]
|
||||
self.assertFalse(values.empty, 'wrong value external_temperature')
|
||||
|
|
Loading…
Reference in New Issue
Block a user