forked from s_ranjbar/city_retrofit
Modified city merge function in city
This commit is contained in:
parent
c3f4c27811
commit
a06eced6f4
|
@ -29,6 +29,7 @@ from hub.helpers.geometry_helper import GeometryHelper
|
|||
from hub.helpers.location import Location
|
||||
from hub.city_model_structure.energy_system import EnergySystem
|
||||
from hub.city_model_structure.lca_material import LcaMaterial
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class City:
|
||||
|
@ -447,8 +448,25 @@ class City:
|
|||
|
||||
def merge(self, city) -> City:
|
||||
_merge_city = self.copy
|
||||
selected_city_object = None
|
||||
# set initial minimum radiation to a higher number
|
||||
min_radiation = 1000000
|
||||
for city_object in city.city_objects:
|
||||
_merge_city.add_city_object(city_object)
|
||||
if city_object.type == 'building':
|
||||
building_radiation = 0
|
||||
for surface in city_object.surfaces:
|
||||
radiation = surface.global_irradiance
|
||||
if "yearly" in radiation:
|
||||
building_radiation += radiation["yearly"].iloc[0]
|
||||
elif "monthly" in radiation and "yearly" not in radiation:
|
||||
radiation["yearly"] = pd.DataFrame({radiation["monthly"].sum()})
|
||||
building_radiation += radiation["yearly"].iloc[0]
|
||||
if building_radiation < min_radiation:
|
||||
min_radiation = building_radiation
|
||||
selected_city_object = city_object
|
||||
# merge the city object with the minimum radiation
|
||||
if selected_city_object is not None:
|
||||
_merge_city.add_city_object(selected_city_object)
|
||||
return _merge_city
|
||||
|
||||
@property
|
||||
|
|
|
@ -51,4 +51,4 @@ class DBFactory:
|
|||
:param city_id: city id or None
|
||||
:param city_object_id: city object id or None
|
||||
"""
|
||||
self._simulation_results.insert(name, values,city_id, city_object_id)
|
||||
self._simulation_results.insert(name, values, city_id, city_object_id)
|
||||
|
|
Loading…
Reference in New Issue
Block a user