monthly_energy_balance/populate.py

64 lines
2.3 KiB
Python

"""
Populate city
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
"""
from imports.physics_factory import PhysicsFactory
from imports.usage_factory import UsageFactory
from city_model_structure.city import City
class Populate:
def __init__(self, city):
self._city = city
self._populated_city = None
self._errors = []
@property
def handler(self):
if self._city.name == 'New York':
handler = '{0}_{1}'
return handler.format(self._city.country_code, self._city.name.lower().replace(' ', '_'))
return self._city.country_code
@property
def errors(self):
return self._errors
@property
def populated_city(self):
if self._populated_city is None:
self._errors = []
# Step 2.1: Thermal parameters
tmp_city = City(self._city.lower_corner, self._city.upper_corner, self._city.srs_name)
# todo: just for Rabeehs case!!
#PhysicsFactory(self.handler, self._city)
PhysicsFactory('ca', self._city).enrich()
print('original:', len(self._city.buildings))
for building in self._city.buildings:
# infiltration_rate_system_off is a mandatory parameter.
# If it is not returned, extract the building from the calculation list
if building.thermal_zones[0].infiltration_rate_system_off is not None:
tmp_city.add_city_object(building)
if tmp_city.buildings is None:
self._populated_city = tmp_city
return self._populated_city
# Step 2.2: Usage parameters
print('physics:', len(tmp_city.buildings))
# todo: just for Rabeehs case!!
#UsageFactory(self.handler, tmp_city)
UsageFactory('ca', tmp_city).enrich()
self._populated_city = City(self._city.lower_corner, self._city.upper_corner, self._city.srs_name)
for building in tmp_city.buildings:
# heating_setpoint is a mandatory parameter.
# If it is not returned, extract the building from the calculation list
if len(building.usage_zones) > 0:
self._populated_city.add_city_object(building)
if self._populated_city.buildings is None:
self._errors.append('no archetype found per usage')
print('usage:', len(tmp_city.buildings))
return self._populated_city