diff --git a/hub/catalog_factories/data_models/energy_systems/archetype.py b/hub/catalog_factories/data_models/energy_systems/archetype.py index 7f43c5dc..4834b8cc 100644 --- a/hub/catalog_factories/data_models/energy_systems/archetype.py +++ b/hub/catalog_factories/data_models/energy_systems/archetype.py @@ -50,11 +50,11 @@ class Archetype: _systems = [] for _system in self.systems: _systems.append(_system.to_dictionary()) - content = {'Archetype': {'name': self.name, - 'level of detail': self.lod, - 'systems': _systems - } - } + content = { + 'Archetype': { + 'name': self.name, + 'level of detail': self.lod, + 'systems': _systems + } + } return content - - diff --git a/hub/catalog_factories/energy_systems/montreal_custom_catalog.py b/hub/catalog_factories/energy_systems/montreal_custom_catalog.py index b2df20c2..ee88b19c 100644 --- a/hub/catalog_factories/energy_systems/montreal_custom_catalog.py +++ b/hub/catalog_factories/energy_systems/montreal_custom_catalog.py @@ -30,9 +30,7 @@ class MontrealCustomCatalog(Catalog): 'demand', 'system_id')) self._lod = float(self._archetypes['catalog']['@lod']) - - self._catalog_generation_equipments, self._catalog_storage_equipments = \ - self._load_generation_and_storage_equipments() + self._catalog_generation_equipments, self._catalog_storage_equipments = self._load_generation_and_storage_equipments() self._catalog_distribution_equipments = self._load_distribution_equipments() self._catalog_emission_equipments = self._load_emission_equipments() self._catalog_systems = self._load_systems() @@ -63,6 +61,7 @@ class MontrealCustomCatalog(Catalog): electricity_efficiency = None if 'electrical_efficiency' in equipment: electricity_efficiency = float(equipment['electrical_efficiency']) + # todo: this may be optionals instead? generation_system = GenerationSystem(equipment_id, name, None, @@ -283,4 +282,4 @@ class MontrealCustomCatalog(Catalog): for entry in self._content.emission_equipments: if entry.name.lower() == name.lower(): return entry - raise IndexError(f"{name} doesn't exists in the catalog") \ No newline at end of file + raise IndexError(f"{name} doesn't exists in the catalog") diff --git a/hub/catalog_factories/energy_systems/north_america_energy_system_catalog.py b/hub/catalog_factories/energy_systems/north_america_energy_system_catalog.py index b5702215..77c4287c 100644 --- a/hub/catalog_factories/energy_systems/north_america_energy_system_catalog.py +++ b/hub/catalog_factories/energy_systems/north_america_energy_system_catalog.py @@ -56,7 +56,7 @@ class NorthAmericaEnergySystemCatalog(Catalog): boiler_maximum_heat_output = float(boiler['@maximumHeatOutput']) boiler_minimum_heat_output = float(boiler['@minimumHeatOutput']) boiler_heat_efficiency = float(boiler['@nominalEfficiency']) - + # todo: this may be optionals instead? boiler_component = GenerationSystem(boiler_id, boiler_name, boiler_model_name, @@ -405,15 +405,16 @@ class NorthAmericaEnergySystemCatalog(Catalog): for material in materials: if int(material.id) == int(material_id): _material = material - return _material - + break if _material is None: raise ValueError(f'Material with the id = [{material_id}] not found in catalog ') + return _material @staticmethod def _search_generation_equipment(generation_systems, generation_id): _generation_systems = [] - if type(generation_id) == list: + + if isinstance(generation_id, list): integer_ids = [int(item) for item in generation_id] for generation in generation_systems: if int(generation.id) in integer_ids: diff --git a/hub/city_model_structure/building.py b/hub/city_model_structure/building.py index 94e27fbf..9e6d8c8b 100644 --- a/hub/city_model_structure/building.py +++ b/hub/city_model_structure/building.py @@ -89,7 +89,7 @@ class Building(CityObject): elif surface.type == cte.INTERIOR_SLAB: self._interior_slabs.append(surface) else: - logging.error(f'Building %s [%s] has an unexpected surface type %s.', self.name, self.aliases, surface.type) + logging.error('Building %s [%s] has an unexpected surface type %s.', self.name, self.aliases, surface.type) @property def shell(self) -> Polyhedron: diff --git a/hub/city_model_structure/building_demand/thermal_zone.py b/hub/city_model_structure/building_demand/thermal_zone.py index 386e8c4b..6ea08324 100644 --- a/hub/city_model_structure/building_demand/thermal_zone.py +++ b/hub/city_model_structure/building_demand/thermal_zone.py @@ -578,7 +578,7 @@ class ThermalZone: for i_type, _ in enumerate(_types_reference): _schedules = [] _schedule_type = _types_reference[i_type][1] - for i_schedule, schedule_value in enumerate(_schedule_type): + for _, schedule_value in enumerate(_schedule_type): schedule = Schedule() schedule.type = schedule_value.type schedule.day_types = schedule_value.day_types diff --git a/hub/city_model_structure/energy_systems/electrical_storage_system.py b/hub/city_model_structure/energy_systems/electrical_storage_system.py index 54bf587c..080f86c7 100644 --- a/hub/city_model_structure/energy_systems/electrical_storage_system.py +++ b/hub/city_model_structure/energy_systems/electrical_storage_system.py @@ -13,6 +13,9 @@ from hub.city_model_structure.energy_systems.generic_storage_system import Gener class ElectricalStorageSystem: + """ + Electrical Storage system class + """ def __init__(self): self._model_name = None self._manufacturer = None @@ -150,6 +153,3 @@ class ElectricalStorageSystem: :return: float """ self._self_discharge_rate = value - - - diff --git a/hub/city_model_structure/energy_systems/generic_storage_system.py b/hub/city_model_structure/energy_systems/generic_storage_system.py index 2b7e0bab..3cd46ca9 100644 --- a/hub/city_model_structure/energy_systems/generic_storage_system.py +++ b/hub/city_model_structure/energy_systems/generic_storage_system.py @@ -10,6 +10,9 @@ from __future__ import annotations class GenericStorageSystem: + """ + Generic storage System class + """ def __init__(self): self._storage_type = None self._nominal_capacity = None @@ -62,4 +65,3 @@ class GenericStorageSystem: :return: float """ self._losses_ratio = value - diff --git a/hub/city_model_structure/energy_systems/performance_curve.py b/hub/city_model_structure/energy_systems/performance_curve.py index 4aaaef1f..e7c72287 100644 --- a/hub/city_model_structure/energy_systems/performance_curve.py +++ b/hub/city_model_structure/energy_systems/performance_curve.py @@ -101,5 +101,3 @@ class PerformanceCurves: :return: [coefficients] """ self._coefficients = value - - diff --git a/hub/exports/formats/obj.py b/hub/exports/formats/obj.py index 5faa02d3..0392ec05 100644 --- a/hub/exports/formats/obj.py +++ b/hub/exports/formats/obj.py @@ -4,7 +4,6 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ -import math from pathlib import Path import numpy as np @@ -59,7 +58,6 @@ class Obj: mtl.write("Ks 1.0 1.0 1.0 # Specular color (white)\n") mtl.write("Ns 400.0 # Specular exponent (defines shininess)\n") vertices = {} - normals_index = {} faces = [] vertex_index = 0 normal_index = 0 diff --git a/hub/imports/construction/eilat_physics_parameters.py b/hub/imports/construction/eilat_physics_parameters.py index c09db490..8e078d5a 100644 --- a/hub/imports/construction/eilat_physics_parameters.py +++ b/hub/imports/construction/eilat_physics_parameters.py @@ -32,7 +32,7 @@ class EilatPhysicsParameters: city = self._city eilat_catalog = ConstructionCatalogFactory('eilat').catalog for building in city.buildings: - if building.function not in Dictionaries().hub_function_to_eilat_construction_function.keys(): + if building.function not in Dictionaries().hub_function_to_eilat_construction_function: logging.error('Building %s has an unknown building function %s', building.name, building.function) continue function = Dictionaries().hub_function_to_eilat_construction_function[building.function] diff --git a/hub/imports/construction/nrcan_physics_parameters.py b/hub/imports/construction/nrcan_physics_parameters.py index 8caede23..6d334cac 100644 --- a/hub/imports/construction/nrcan_physics_parameters.py +++ b/hub/imports/construction/nrcan_physics_parameters.py @@ -32,8 +32,8 @@ class NrcanPhysicsParameters: city = self._city nrcan_catalog = ConstructionCatalogFactory('nrcan').catalog for building in city.buildings: - if building.function not in Dictionaries().hub_function_to_nrcan_construction_function.keys(): - logging.error(f'Building %s has an unknown building function %s', building.name, building.function) + if building.function not in Dictionaries().hub_function_to_nrcan_construction_function: + logging.error('Building %s has an unknown building function %s', building.name, building.function) continue function = Dictionaries().hub_function_to_nrcan_construction_function[building.function] try: diff --git a/hub/imports/construction/nrel_physics_parameters.py b/hub/imports/construction/nrel_physics_parameters.py index 6f61102a..b3dc3af4 100644 --- a/hub/imports/construction/nrel_physics_parameters.py +++ b/hub/imports/construction/nrel_physics_parameters.py @@ -105,4 +105,4 @@ class NrelPhysicsParameters: construction.window_g_value = window_archetype.g_value construction.window_overall_u_value = window_archetype.overall_u_value _constructions.append(construction) - thermal_archetype.constructions = _constructions \ No newline at end of file + thermal_archetype.constructions = _constructions diff --git a/hub/imports/energy_systems/north_america_custom_energy_system_parameters.py b/hub/imports/energy_systems/north_america_custom_energy_system_parameters.py index f5360568..d387909f 100644 --- a/hub/imports/energy_systems/north_america_custom_energy_system_parameters.py +++ b/hub/imports/energy_systems/north_america_custom_energy_system_parameters.py @@ -6,21 +6,20 @@ Project Coder Saeed Ranjbar saeed.ranjbar@concordia.ca Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ -import logging import copy +import logging from pandas import DataFrame from hub.catalog_factories.energy_systems_catalog_factory import EnergySystemsCatalogFactory -from hub.city_model_structure.energy_systems.generic_energy_system import GenericEnergySystem -from hub.city_model_structure.energy_systems.generic_generation_system import GenericGenerationSystem -from hub.city_model_structure.energy_systems.energy_system import EnergySystem -from hub.city_model_structure.energy_systems.generation_system import GenerationSystem from hub.city_model_structure.energy_systems.distribution_system import DistributionSystem from hub.city_model_structure.energy_systems.emission_system import EmissionSystem -from hub.helpers.dictionaries import Dictionaries -from hub.city_model_structure.energy_systems.generic_storage_system import GenericStorageSystem +from hub.city_model_structure.energy_systems.energy_system import EnergySystem +from hub.city_model_structure.energy_systems.generation_system import GenerationSystem +from hub.city_model_structure.energy_systems.generic_energy_system import GenericEnergySystem +from hub.city_model_structure.energy_systems.generic_generation_system import GenericGenerationSystem from hub.city_model_structure.energy_systems.thermal_storage_system import ThermalStorageSystem +from hub.helpers.dictionaries import Dictionaries class NorthAmericaCustomEnergySystemParameters: @@ -83,7 +82,7 @@ class NorthAmericaCustomEnergySystemParameters: energy_system = GenericEnergySystem() _hub_demand_types = [] demand_types = system.demand_types - if type(demand_types) == str: + if isinstance(demand_types, str): demand_types = [demand_types] for demand_type in demand_types: _hub_demand_types.append(Dictionaries().north_america_demand_type_to_hub_energy_demand_type[demand_type]) @@ -105,17 +104,17 @@ class NorthAmericaCustomEnergySystemParameters: _generation_system.source_mass_flow = archetype_generation_equipment.source_mass_flow _generation_system.storage = None _generation_system.auxiliary_equipment = None - _generation_system._supply_medium = archetype_generation_equipment.supply_medium - _generation_system._maximum_heat_supply_temperature = archetype_generation_equipment.maximum_heat_supply_temperature - _generation_system._minimum_heat_supply_temperature = archetype_generation_equipment.minimum_heat_supply_temperature - _generation_system._maximum_cooling_supply_temperature = archetype_generation_equipment.maximum_cooling_supply_temperature - _generation_system._minimum_cooling_supply_temperature = archetype_generation_equipment.minimum_cooling_supply_temperature - _generation_system._heat_output_curve = archetype_generation_equipment.heat_output_curve - _generation_system._heat_fuel_consumption_curve = archetype_generation_equipment.heat_fuel_consumption_curve - _generation_system._heat_efficiency_curve = archetype_generation_equipment.heat_efficiency_curve - _generation_system._cooling_output_curve = archetype_generation_equipment.cooling_output_curve - _generation_system._cooling_fuel_consumption_curve = archetype_generation_equipment.cooling_fuel_consumption_curve - _generation_system._cooling_efficiency_curve = archetype_generation_equipment.cooling_efficiency_curve + _generation_system.supply_medium = archetype_generation_equipment.supply_medium + _generation_system.maximum_heat_supply_temperature = archetype_generation_equipment.maximum_heat_supply_temperature + _generation_system.minimum_heat_supply_temperature = archetype_generation_equipment.minimum_heat_supply_temperature + _generation_system.maximum_cooling_supply_temperature = archetype_generation_equipment.maximum_cooling_supply_temperature + _generation_system.minimum_cooling_supply_temperature = archetype_generation_equipment.minimum_cooling_supply_temperature + _generation_system.heat_output_curve = archetype_generation_equipment.heat_output_curve + _generation_system.heat_fuel_consumption_curve = archetype_generation_equipment.heat_fuel_consumption_curve + _generation_system.heat_efficiency_curve = archetype_generation_equipment.heat_efficiency_curve + _generation_system.cooling_output_curve = archetype_generation_equipment.cooling_output_curve + _generation_system.cooling_fuel_consumption_curve = archetype_generation_equipment.cooling_fuel_consumption_curve + _generation_system.cooling_efficiency_curve = archetype_generation_equipment.cooling_efficiency_curve _generation_systems.append(_generation_system) energy_system.generation_systems = _generation_systems diff --git a/hub/imports/results/energy_plus_workflow.py b/hub/imports/results/energy_plus.py similarity index 99% rename from hub/imports/results/energy_plus_workflow.py rename to hub/imports/results/energy_plus.py index 627b3fd7..773aca46 100644 --- a/hub/imports/results/energy_plus_workflow.py +++ b/hub/imports/results/energy_plus.py @@ -6,13 +6,16 @@ Project Coder Saeed Ranjbar saeed.ranjbar@concordia.ca Project collaborator Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ from pathlib import Path -from hub.helpers.monthly_values import MonthlyValues import csv +from hub.helpers.monthly_values import MonthlyValues import hub.helpers.constants as cte -class EnergyPlusWorkflow: +class EnergyPlus: + """ + Energy plus class + """ def __init__(self, city, base_path): self._city = city self._base_path = base_path diff --git a/hub/imports/results_factory.py b/hub/imports/results_factory.py index fac60de3..da33f3af 100644 --- a/hub/imports/results_factory.py +++ b/hub/imports/results_factory.py @@ -10,7 +10,7 @@ from pathlib import Path from hub.helpers.utils import validate_import_export_type from hub.imports.results.insel_monthly_energry_balance import InselMonthlyEnergyBalance from hub.imports.results.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm -from hub.imports.results.energy_plus_workflow import EnergyPlusWorkflow +from hub.imports.results.energy_plus import EnergyPlusWorkflow class ResultFactory: """ diff --git a/hub/persistence/repositories/city_object.py b/hub/persistence/repositories/city_object.py index aa69a0e3..4c8513ec 100644 --- a/hub/persistence/repositories/city_object.py +++ b/hub/persistence/repositories/city_object.py @@ -7,7 +7,7 @@ Project Coder Guille Gutierrez Guillermo.GutierrezMorote@concordia.ca import datetime import logging -from sqlalchemy import select, or_ +from sqlalchemy import select from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.orm import Session