From 51fc72b921c6e5fc59a911fdf25a2c213f61d4d5 Mon Sep 17 00:00:00 2001 From: Pilar Date: Mon, 12 Jul 2021 04:32:10 -0400 Subject: [PATCH] two bugs solved befor students workshop --- main.py | 5 +++-- populate.py | 63 ----------------------------------------------------- 2 files changed, 3 insertions(+), 65 deletions(-) delete mode 100644 populate.py diff --git a/main.py b/main.py index dc1e774..0b15b13 100644 --- a/main.py +++ b/main.py @@ -12,12 +12,13 @@ import pandas as pd import datetime from helpers import monthly_values as mv -from populate import Populate from simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm from imports.geometry_factory import GeometryFactory from imports.weather_factory import WeatherFactory from city_model_structure.city import City from monthly_demand_calculation import MonthlyDemandCalculation +from helpers.enrich_city import EnrichCity + parser = ArgumentParser(description='Monthly energy balance workflow v0.1.') required = parser.add_argument_group('required arguments') @@ -65,7 +66,7 @@ populated_step_in_pickle = ast.literal_eval(args.populated_step_in_pickle) if populated_step_in_pickle: populated_city = city else: - populated_city = Populate(city).populated_city + populated_city = EnrichCity(city).enriched_city(construction_format='nrcan', usage_format='hft') pickle_file = Path(str(pickle_file).replace('.pickle', '_populated.pickle')) populated_city.save(pickle_file) if populated_city.buildings is None: diff --git a/populate.py b/populate.py deleted file mode 100644 index 0912621..0000000 --- a/populate.py +++ /dev/null @@ -1,63 +0,0 @@ -""" -Populate city -SPDX - License - Identifier: LGPL - 3.0 - or -later -Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es -""" - -from imports.construction_factory import ConstructionFactory -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) - ConstructionFactory('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