diff --git a/hub/catalog_factories/construction/construction_helper.py b/hub/catalog_factories/construction/construction_helper.py index a9bdaf19..012c30ab 100644 --- a/hub/catalog_factories/construction/construction_helper.py +++ b/hub/catalog_factories/construction/construction_helper.py @@ -1,3 +1,9 @@ +""" +Construction helper module +SPDX - License - Identifier: LGPL - 3.0 - or -later +Copyright © 2022 Concordia CERC group +Project Coder Guille Gutierrez Guillermo.GutierrezMorote@concordia.ca +""" from hub.helpers import constants as cte @@ -34,12 +40,24 @@ class ConstructionHelper: @property def reference_standard_to_construction_period(self): + """ + Get reference standard to construction period dictionary + :return: {} + """ return self._reference_standard_to_construction_period @property def nrel_surfaces_types_to_hub_types(self): + """ + Get reference nrel surface type to hub type dictionary + :return: {} + """ return self._nrel_surfaces_types_to_hub_types @property def nrcan_surfaces_types_to_hub_types(self): + """ + Get reference nrcan surface type to hub type dictionary + :return: {} + """ return self._nrcan_surfaces_types_to_hub_types diff --git a/hub/catalog_factories/construction/nrcan_catalog.py b/hub/catalog_factories/construction/nrcan_catalog.py index 554ac7a0..cb1c3f76 100644 --- a/hub/catalog_factories/construction/nrcan_catalog.py +++ b/hub/catalog_factories/construction/nrcan_catalog.py @@ -18,12 +18,15 @@ from hub.catalog_factories.data_models.construction.layer import Layer class NrcanCatalog(Catalog): + """ + Nrcan catalog class + """ def __init__(self, path): _path_archetypes = Path(path / 'nrcan_archetypes.json').resolve() - _path_constructions = (path / 'nrcan_constructions.json') - with open(_path_archetypes, 'r') as file: + _path_constructions = (path / 'nrcan_constructions.json').resolve() + with open(_path_archetypes, 'r', encoding='utf-8') as file: self._archetypes = json.load(file) - with open(_path_constructions, 'r') as file: + with open(_path_constructions, 'r', encoding='utf-8') as file: self._constructions = json.load(file) self._catalog_windows = self._load_windows() @@ -200,17 +203,15 @@ class NrcanCatalog(Catalog): """ if category is None: return self._content - else: - if category.lower() == 'archetypes': - return self._content.archetypes - elif category.lower() == 'constructions': - return self._content.constructions - elif category.lower() == 'materials': - return self._content.materials - elif category.lower() == 'windows': - return self._content.windows - else: - raise ValueError(f'Unknown category [{category}]') + if category.lower() == 'archetypes': + return self._content.archetypes + if category.lower() == 'constructions': + return self._content.constructions + if category.lower() == 'materials': + return self._content.materials + if category.lower() == 'windows': + return self._content.windows + raise ValueError(f'Unknown category [{category}]') def get_entry(self, name): """ diff --git a/hub/catalog_factories/construction/nrel_catalog.py b/hub/catalog_factories/construction/nrel_catalog.py index c231b5f3..fcfb5a06 100644 --- a/hub/catalog_factories/construction/nrel_catalog.py +++ b/hub/catalog_factories/construction/nrel_catalog.py @@ -5,8 +5,8 @@ Copyright © 2022 Concordia CERC group Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ -import xmltodict from pathlib import Path +import xmltodict from hub.catalog_factories.catalog import Catalog from hub.catalog_factories.data_models.construction.window import Window from hub.catalog_factories.data_models.construction.material import Material @@ -18,12 +18,15 @@ from hub.catalog_factories.construction.construction_helper import ConstructionH class NrelCatalog(Catalog): + """ + Nrel catalog class + """ def __init__(self, path): archetypes_path = str(Path(path / 'us_archetypes.xml').resolve()) constructions_path = str(Path(path / 'us_constructions.xml').resolve()) - with open(constructions_path) as xml: + with open(constructions_path, 'r', encoding='utf-8') as xml: self._constructions = xmltodict.parse(xml.read(), force_list=('material', 'window', 'construction', 'layer')) - with open(archetypes_path) as xml: + with open(archetypes_path, 'r', encoding='utf-8') as xml: self._archetypes = xmltodict.parse(xml.read(), force_list=('archetype', 'construction')) self._catalog_windows = self._load_windows() self._catalog_materials = self._load_materials() @@ -58,9 +61,9 @@ class NrelCatalog(Catalog): thermal_absorptance = float(material['thermal_absorptance']['#text']) visible_absorptance = float(material['visible_absorptance']['#text']) no_mass = False - thermal_resistance = None, - conductivity = None, - density = None, + thermal_resistance = None + conductivity = None + density = None specific_heat = None if 'no_mass' in material and material['no_mass'] == 'true': no_mass = True @@ -201,17 +204,15 @@ class NrelCatalog(Catalog): """ if category is None: return self._content - else: - if category.lower() == 'archetypes': - return self._content.archetypes - elif category.lower() == 'constructions': - return self._content.constructions - elif category.lower() == 'materials': - return self._content.materials - elif category.lower() == 'windows': - return self._content.windows - else: - raise ValueError(f'Unknown category [{category}]') + if category.lower() == 'archetypes': + return self._content.archetypes + if category.lower() == 'constructions': + return self._content.constructions + if category.lower() == 'materials': + return self._content.materials + if category.lower() == 'windows': + return self._content.windows + raise ValueError(f'Unknown category [{category}]') def get_entry(self, name): """ diff --git a/hub/catalog_factories/construction_catalog_factory.py b/hub/catalog_factories/construction_catalog_factory.py index daebce6f..a41e0aed 100644 --- a/hub/catalog_factories/construction_catalog_factory.py +++ b/hub/catalog_factories/construction_catalog_factory.py @@ -4,17 +4,21 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ -import logging from pathlib import Path from typing import TypeVar + +from hub.catalog_factories.construction.nrcan_catalog import NrcanCatalog from hub.catalog_factories.construction.nrel_catalog import NrelCatalog from hub.helpers.utils import validate_import_export_type -from hub.catalog_factories.construction.nrcan_catalog import NrcanCatalog + Catalog = TypeVar('Catalog') class ConstructionCatalogFactory: + """ + Construction catalog factory class + """ def __init__(self, handler, base_path=None): if base_path is None: base_path = Path(Path(__file__).parent.parent / 'data/construction') diff --git a/hub/catalog_factories/cost/montreal_custom_catalog.py b/hub/catalog_factories/cost/montreal_custom_catalog.py index d5021b1b..8dca370c 100644 --- a/hub/catalog_factories/cost/montreal_custom_catalog.py +++ b/hub/catalog_factories/cost/montreal_custom_catalog.py @@ -18,9 +18,12 @@ from hub.catalog_factories.data_models.cost.income import Income class MontrealCustomCatalog(Catalog): + """ + Montreal custom catalog class + """ def __init__(self, path): - path = (path / 'montreal_costs.xml') - with open(path) as xml: + path = (path / 'montreal_costs.xml').resolve() + with open(path, 'r', encoding='utf-8') as xml: self._archetypes = xmltodict.parse(xml.read(), force_list='archetype') # store the full catalog data model in self._content diff --git a/hub/catalog_factories/data_models/construction/archetype.py b/hub/catalog_factories/data_models/construction/archetype.py index d23e57a0..39b2e4ce 100644 --- a/hub/catalog_factories/data_models/construction/archetype.py +++ b/hub/catalog_factories/data_models/construction/archetype.py @@ -9,6 +9,9 @@ from hub.catalog_factories.data_models.construction.construction import Construc class Archetype: + """ + Archetype class + """ def __init__(self, archetype_id, name, function, diff --git a/hub/catalog_factories/data_models/construction/construction.py b/hub/catalog_factories/data_models/construction/construction.py index 0397b56d..c178de7c 100644 --- a/hub/catalog_factories/data_models/construction/construction.py +++ b/hub/catalog_factories/data_models/construction/construction.py @@ -9,6 +9,9 @@ from hub.catalog_factories.data_models.construction.window import Window class Construction: + """ + Construction class + """ def __init__(self, construction_id, construction_type, name, layers, window_ratio=None, window=None): self._id = construction_id self._type = construction_type diff --git a/hub/catalog_factories/data_models/construction/content.py b/hub/catalog_factories/data_models/construction/content.py index 3fa2f596..8fcb4ad1 100644 --- a/hub/catalog_factories/data_models/construction/content.py +++ b/hub/catalog_factories/data_models/construction/content.py @@ -7,6 +7,9 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca class Content: + """ + Content class + """ def __init__(self, archetypes, constructions, materials, windows): self._archetypes = archetypes self._constructions = constructions diff --git a/hub/catalog_factories/data_models/construction/layer.py b/hub/catalog_factories/data_models/construction/layer.py index e8452d79..a55bdde0 100644 --- a/hub/catalog_factories/data_models/construction/layer.py +++ b/hub/catalog_factories/data_models/construction/layer.py @@ -7,6 +7,9 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca class Layer: + """ + Layer class + """ def __init__(self, layer_id, name, material, thickness): self._id = layer_id self._name = name diff --git a/hub/catalog_factories/data_models/construction/material.py b/hub/catalog_factories/data_models/construction/material.py index 34674e0d..5109fe7c 100644 --- a/hub/catalog_factories/data_models/construction/material.py +++ b/hub/catalog_factories/data_models/construction/material.py @@ -7,6 +7,9 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca class Material: + """ + Material class + """ def __init__(self, material_id, name, solar_absorptance, diff --git a/hub/catalog_factories/data_models/construction/window.py b/hub/catalog_factories/data_models/construction/window.py index 200ad22f..96804be4 100644 --- a/hub/catalog_factories/data_models/construction/window.py +++ b/hub/catalog_factories/data_models/construction/window.py @@ -7,6 +7,9 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca class Window: + """ + Window class + """ def __init__(self, window_id, frame_ratio, g_value, overall_u_value, name, window_type=None): self._id = window_id self._frame_ratio = frame_ratio diff --git a/hub/catalog_factories/data_models/cost/archetype.py b/hub/catalog_factories/data_models/cost/archetype.py index 97cabe1a..7749f400 100644 --- a/hub/catalog_factories/data_models/cost/archetype.py +++ b/hub/catalog_factories/data_models/cost/archetype.py @@ -11,6 +11,9 @@ from hub.catalog_factories.data_models.cost.income import Income class Archetype: + """ + Archetype class + """ def __init__(self, lod, function, diff --git a/hub/catalog_factories/data_models/cost/capital_cost.py b/hub/catalog_factories/data_models/cost/capital_cost.py index 94981e42..e68a71d1 100644 --- a/hub/catalog_factories/data_models/cost/capital_cost.py +++ b/hub/catalog_factories/data_models/cost/capital_cost.py @@ -10,6 +10,9 @@ from hub.catalog_factories.data_models.cost.chapter import Chapter class CapitalCost: + """ + Capital cost class + """ def __init__(self, general_chapters, design_allowance, overhead_and_profit): self._general_chapters = general_chapters self._design_allowance = design_allowance diff --git a/hub/catalog_factories/data_models/cost/chapter.py b/hub/catalog_factories/data_models/cost/chapter.py index 2cd7b4e6..a1a35f8d 100644 --- a/hub/catalog_factories/data_models/cost/chapter.py +++ b/hub/catalog_factories/data_models/cost/chapter.py @@ -10,6 +10,9 @@ from hub.catalog_factories.data_models.cost.item_description import ItemDescript class Chapter: + """ + Chapter class + """ def __init__(self, chapter_type, items): self._chapter_type = chapter_type diff --git a/hub/catalog_factories/data_models/cost/content.py b/hub/catalog_factories/data_models/cost/content.py index aa12e2a4..e124acd7 100644 --- a/hub/catalog_factories/data_models/cost/content.py +++ b/hub/catalog_factories/data_models/cost/content.py @@ -8,6 +8,9 @@ Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concord class Content: + """ + Content class + """ def __init__(self, archetypes): self._archetypes = archetypes diff --git a/hub/catalog_factories/data_models/cost/fuel.py b/hub/catalog_factories/data_models/cost/fuel.py index 82b47477..b16fb590 100644 --- a/hub/catalog_factories/data_models/cost/fuel.py +++ b/hub/catalog_factories/data_models/cost/fuel.py @@ -9,6 +9,9 @@ from typing import Union class Fuel: + """ + Fuel class + """ def __init__(self, fuel_type, fixed_monthly=None, fixed_power=None, diff --git a/hub/catalog_factories/data_models/cost/income.py b/hub/catalog_factories/data_models/cost/income.py index 0a8c0442..43c9c71b 100644 --- a/hub/catalog_factories/data_models/cost/income.py +++ b/hub/catalog_factories/data_models/cost/income.py @@ -9,6 +9,9 @@ from typing import Union class Income: + """ + Income class + """ def __init__(self, construction_subsidy=None, hvac_subsidy=None, photovoltaic_subsidy=None, diff --git a/hub/catalog_factories/data_models/cost/item_description.py b/hub/catalog_factories/data_models/cost/item_description.py index 45b24bbb..7f69fb5f 100644 --- a/hub/catalog_factories/data_models/cost/item_description.py +++ b/hub/catalog_factories/data_models/cost/item_description.py @@ -9,6 +9,9 @@ from typing import Union class ItemDescription: + """ + Item description class + """ def __init__(self, item_type, initial_investment=None, initial_investment_unit=None, diff --git a/hub/catalog_factories/data_models/cost/operational_cost.py b/hub/catalog_factories/data_models/cost/operational_cost.py index f7cbcc6f..dd4b4715 100644 --- a/hub/catalog_factories/data_models/cost/operational_cost.py +++ b/hub/catalog_factories/data_models/cost/operational_cost.py @@ -10,6 +10,9 @@ from hub.catalog_factories.data_models.cost.fuel import Fuel class OperationalCost: + """ + Operational cost class + """ def __init__(self, fuels, maintenance_heating, maintenance_cooling, maintenance_pv, co2): self._fuels = fuels self._maintenance_heating = maintenance_heating diff --git a/hub/catalog_factories/data_models/energy_systems/archetype.py b/hub/catalog_factories/data_models/energy_systems/archetype.py index 632fc999..cd3f7c15 100644 --- a/hub/catalog_factories/data_models/energy_systems/archetype.py +++ b/hub/catalog_factories/data_models/energy_systems/archetype.py @@ -11,6 +11,9 @@ from hub.catalog_factories.data_models.energy_systems.system import System class Archetype: + """ + Archetype class + """ def __init__(self, lod, name, systems): self._lod = lod diff --git a/hub/catalog_factories/data_models/energy_systems/content.py b/hub/catalog_factories/data_models/energy_systems/content.py index 7611e1e7..06b6a085 100644 --- a/hub/catalog_factories/data_models/energy_systems/content.py +++ b/hub/catalog_factories/data_models/energy_systems/content.py @@ -7,6 +7,9 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca class Content: + """ + Content class + """ def __init__(self, archetypes, systems, generations, distributions, emissions): self._archetypes = archetypes self._systems = systems diff --git a/hub/catalog_factories/data_models/energy_systems/distribution_system.py b/hub/catalog_factories/data_models/energy_systems/distribution_system.py index 77176eb4..3f22a520 100644 --- a/hub/catalog_factories/data_models/energy_systems/distribution_system.py +++ b/hub/catalog_factories/data_models/energy_systems/distribution_system.py @@ -7,6 +7,9 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca class DistributionSystem: + """ + Distribution system class + """ def __init__(self, system_id, name, system_type, supply_temperature, distribution_consumption_fix_flow, distribution_consumption_variable_flow, heat_losses): diff --git a/hub/catalog_factories/data_models/energy_systems/emission_system.py b/hub/catalog_factories/data_models/energy_systems/emission_system.py index 61f917fc..f869a4a4 100644 --- a/hub/catalog_factories/data_models/energy_systems/emission_system.py +++ b/hub/catalog_factories/data_models/energy_systems/emission_system.py @@ -7,6 +7,9 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca class EmissionSystem: + """ + Emission system class + """ def __init__(self, system_id, name, system_type, parasitic_energy_consumption): self._system_id = system_id diff --git a/hub/catalog_factories/data_models/energy_systems/generation_system.py b/hub/catalog_factories/data_models/energy_systems/generation_system.py index 79665f76..04069a96 100644 --- a/hub/catalog_factories/data_models/energy_systems/generation_system.py +++ b/hub/catalog_factories/data_models/energy_systems/generation_system.py @@ -10,6 +10,9 @@ from typing import Union class GenerationSystem: + """ + Generation system class + """ def __init__(self, system_id, name, system_type, fuel_type, source_types, heat_efficiency, cooling_efficiency, electricity_efficiency, source_temperature, source_mass_flow, storage, auxiliary_equipment): diff --git a/hub/catalog_factories/data_models/energy_systems/system.py b/hub/catalog_factories/data_models/energy_systems/system.py index f03a9725..c4bf0258 100644 --- a/hub/catalog_factories/data_models/energy_systems/system.py +++ b/hub/catalog_factories/data_models/energy_systems/system.py @@ -13,6 +13,9 @@ from hub.catalog_factories.data_models.energy_systems.emission_system import Emi class System: + """ + System class + """ def __init__(self, lod, system_id, diff --git a/hub/catalog_factories/data_models/greenery/content.py b/hub/catalog_factories/data_models/greenery/content.py index 528b54a0..2087e7f7 100644 --- a/hub/catalog_factories/data_models/greenery/content.py +++ b/hub/catalog_factories/data_models/greenery/content.py @@ -7,6 +7,9 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca class Content: + """ + Content class + """ def __init__(self, vegetations, plants, soils): self._vegetations = vegetations self._plants = plants diff --git a/hub/catalog_factories/data_models/greenery/plant.py b/hub/catalog_factories/data_models/greenery/plant.py index 864e447d..ea6bfa95 100644 --- a/hub/catalog_factories/data_models/greenery/plant.py +++ b/hub/catalog_factories/data_models/greenery/plant.py @@ -9,6 +9,9 @@ from hub.catalog_factories.data_models.greenery.soil import Soil as hub_soil class Plant: + """ + Plant class + """ def __init__(self, category, plant): self._name = plant.name self._category = category diff --git a/hub/catalog_factories/data_models/greenery/plant_percentage.py b/hub/catalog_factories/data_models/greenery/plant_percentage.py index 778aea98..8f72846b 100644 --- a/hub/catalog_factories/data_models/greenery/plant_percentage.py +++ b/hub/catalog_factories/data_models/greenery/plant_percentage.py @@ -5,10 +5,13 @@ Copyright © 2022 Concordia CERC group Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ -from hub.catalog_factories.data_models.greenery.plant import Plant as hub_plant +from hub.catalog_factories.data_models.greenery.plant import Plant as HubPlant -class PlantPercentage(hub_plant): +class PlantPercentage(HubPlant): + """ + Plant percentage class + """ def __init__(self, percentage, plant_category, plant): super().__init__(plant_category, plant) diff --git a/hub/catalog_factories/data_models/greenery/soil.py b/hub/catalog_factories/data_models/greenery/soil.py index c6e8266b..099ba03f 100644 --- a/hub/catalog_factories/data_models/greenery/soil.py +++ b/hub/catalog_factories/data_models/greenery/soil.py @@ -7,6 +7,9 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca class Soil: + """ + Soil class + """ def __init__(self, soil): self._name = soil.name self._roughness = soil.roughness @@ -19,7 +22,7 @@ class Soil: self._saturation_volumetric_moisture_content = soil.saturationVolumetricMoistureContent self._residual_volumetric_moisture_content = soil.residualVolumetricMoistureContent self._initial_volumetric_moisture_content = soil.initialVolumetricMoistureContent - + @property def name(self): """ diff --git a/hub/catalog_factories/data_models/greenery/vegetation.py b/hub/catalog_factories/data_models/greenery/vegetation.py index e7a5151b..ec3a9a1c 100644 --- a/hub/catalog_factories/data_models/greenery/vegetation.py +++ b/hub/catalog_factories/data_models/greenery/vegetation.py @@ -9,6 +9,9 @@ from hub.catalog_factories.data_models.greenery.plant_percentage import PlantPer class Vegetation: + """ + Vegetation class + """ def __init__(self, category, vegetation, plant_percentages): self._name = vegetation.name self._category = category diff --git a/hub/catalog_factories/data_models/usages/content.py b/hub/catalog_factories/data_models/usages/content.py index 63fe8797..ffc34a4f 100644 --- a/hub/catalog_factories/data_models/usages/content.py +++ b/hub/catalog_factories/data_models/usages/content.py @@ -8,6 +8,9 @@ from hub.catalog_factories.data_models.usages.usage import Usage class Content: + """ + Content class + """ def __init__(self, usages): self._usages = usages @@ -17,4 +20,3 @@ class Content: Get catalog usages """ return self._usages - diff --git a/hub/catalog_factories/data_models/usages/internal_gain.py b/hub/catalog_factories/data_models/usages/internal_gain.py index f1d8ad7f..447ce80a 100644 --- a/hub/catalog_factories/data_models/usages/internal_gain.py +++ b/hub/catalog_factories/data_models/usages/internal_gain.py @@ -18,5 +18,3 @@ class InternalGain: self._radiative_fraction = radiative_fraction self._latent_fraction = latent_fraction self._schedules = schedules - - diff --git a/hub/catalog_factories/data_models/usages/lighting.py b/hub/catalog_factories/data_models/usages/lighting.py index b7b48c4e..29e8a490 100644 --- a/hub/catalog_factories/data_models/usages/lighting.py +++ b/hub/catalog_factories/data_models/usages/lighting.py @@ -11,6 +11,9 @@ from hub.catalog_factories.data_models.usages.schedule import Schedule class Lighting: + """ + Lighting class + """ def __init__(self, density, convective_fraction, radiative_fraction, latent_fraction, schedules): self._density = density self._convective_fraction = convective_fraction diff --git a/hub/catalog_factories/data_models/usages/usage.py b/hub/catalog_factories/data_models/usages/usage.py index ef80af70..4ed0db2f 100644 --- a/hub/catalog_factories/data_models/usages/usage.py +++ b/hub/catalog_factories/data_models/usages/usage.py @@ -14,6 +14,9 @@ from hub.catalog_factories.data_models.usages.domestic_hot_water import Domestic class Usage: + """ + Usage class + """ def __init__(self, name, hours_day, days_year, diff --git a/hub/catalog_factories/energy_systems/montreal_custom_catalog.py b/hub/catalog_factories/energy_systems/montreal_custom_catalog.py index 0727e3d0..91c8d4e4 100644 --- a/hub/catalog_factories/energy_systems/montreal_custom_catalog.py +++ b/hub/catalog_factories/energy_systems/montreal_custom_catalog.py @@ -1,12 +1,12 @@ """ -Montreal custom energy systems catalog +Montreal custom energy systems catalog module SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ +from ast import literal_eval import xmltodict - from hub.catalog_factories.catalog import Catalog from hub.catalog_factories.data_models.energy_systems.system import System from hub.catalog_factories.data_models.energy_systems.content import Content @@ -17,9 +17,12 @@ from hub.catalog_factories.data_models.energy_systems.archetype import Archetype class MontrealCustomCatalog(Catalog): + """ + Montreal custom energy systems catalog class + """ def __init__(self, path): path = str(path / 'montreal_custom_systems.xml') - with open(path) as xml: + with open(path, 'r', encoding='utf-8') as xml: self._archetypes = xmltodict.parse(xml.read(), force_list=('system', 'system_cluster', 'equipment', 'demand', 'system_id')) @@ -55,7 +58,7 @@ class MontrealCustomCatalog(Catalog): electricity_efficiency = None if 'electrical_efficiency' in equipment: electricity_efficiency = float(equipment['electrical_efficiency']) - storage = eval(equipment['storage'].capitalize()) + storage = literal_eval(equipment['storage'].capitalize()) generation_system = GenerationSystem(equipment_id, name, equipment_type, @@ -211,19 +214,17 @@ class MontrealCustomCatalog(Catalog): """ if category is None: return self._content - else: - if category.lower() == 'archetypes': - return self._content.archetypes - elif category.lower() == 'systems': - return self._content.systems - elif category.lower() == 'generation_equipments': - return self._content.generation_equipments - elif category.lower() == 'distribution_equipments': - return self._content.distribution_equipments - elif category.lower() == 'emission_equipments': - return self._content.emission_equipments - else: - raise ValueError(f'Unknown category [{category}]') + if category.lower() == 'archetypes': + return self._content.archetypes + if category.lower() == 'systems': + return self._content.systems + if category.lower() == 'generation_equipments': + return self._content.generation_equipments + if category.lower() == 'distribution_equipments': + return self._content.distribution_equipments + if category.lower() == 'emission_equipments': + return self._content.emission_equipments + raise ValueError(f'Unknown category [{category}]') def get_entry(self, name): """ diff --git a/hub/catalog_factories/energy_systems_catalog_factory.py b/hub/catalog_factories/energy_systems_catalog_factory.py index b7cf597c..4b59eeda 100644 --- a/hub/catalog_factories/energy_systems_catalog_factory.py +++ b/hub/catalog_factories/energy_systems_catalog_factory.py @@ -4,16 +4,20 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca """ -import logging from pathlib import Path from typing import TypeVar + from hub.catalog_factories.energy_systems.montreal_custom_catalog import MontrealCustomCatalog from hub.helpers.utils import validate_import_export_type + Catalog = TypeVar('Catalog') class EnergySystemsCatalogFactory: + """ + Energy system catalog factory class + """ def __init__(self, handler, base_path=None): if base_path is None: base_path = Path(Path(__file__).parent.parent / 'data/energy_systems') diff --git a/hub/catalog_factories/greenery/greenery_catalog.py b/hub/catalog_factories/greenery/greenery_catalog.py index a7c7f4aa..2ea177ab 100644 --- a/hub/catalog_factories/greenery/greenery_catalog.py +++ b/hub/catalog_factories/greenery/greenery_catalog.py @@ -5,33 +5,36 @@ Copyright © 2022 Concordia CERC group Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ -from pyecore.resources import ResourceSet, URI -from hub.catalog_factories.greenery.ecore_greenery.greenerycatalog import GreeneryCatalog as gc -from hub.catalog_factories.catalog import Catalog from pathlib import Path -from hub.catalog_factories.data_models.greenery.vegetation import Vegetation as libs_vegetation -from hub.catalog_factories.data_models.greenery.plant import Plant as libs_plant -from hub.catalog_factories.data_models.greenery.soil import Soil as libs_soil -from hub.catalog_factories.data_models.greenery.plant_percentage import PlantPercentage as libs_pp +from pyecore.resources import ResourceSet, URI +from hub.catalog_factories.greenery.ecore_greenery.greenerycatalog import GreeneryCatalog as Gc +from hub.catalog_factories.catalog import Catalog +from hub.catalog_factories.data_models.greenery.vegetation import Vegetation as HubVegetation +from hub.catalog_factories.data_models.greenery.plant import Plant as HubPlant +from hub.catalog_factories.data_models.greenery.soil import Soil as HubSoil +from hub.catalog_factories.data_models.greenery.plant_percentage import PlantPercentage as HubPlantPercentage from hub.catalog_factories.data_models.greenery.content import Content as GreeneryContent class GreeneryCatalog(Catalog): + """ + Greenery catalog class + """ def __init__(self, path): - base_path = Path(Path(__file__).parent / 'ecore_greenery' / 'greenerycatalog_no_quantities.ecore') + base_path = Path(Path(__file__).parent / 'ecore_greenery/greenerycatalog_no_quantities.ecore').resolve() resource_set = ResourceSet() data_model = resource_set.get_resource(URI(str(base_path))) data_model_root = data_model.contents[0] resource_set.metamodel_registry[data_model_root.nsURI] = data_model_root resource = resource_set.get_resource(URI(str(path))) - catalog_data: gc = resource.contents[0] + catalog_data: Gc = resource.contents[0] plants = [] for plant_category in catalog_data.plantCategories: name = plant_category.name for plant in plant_category.plants: - plants.append(libs_plant(name, plant)) + plants.append(HubPlant(name, plant)) vegetations = [] for vegetation_category in catalog_data.vegetationCategories: @@ -45,17 +48,19 @@ class GreeneryCatalog(Catalog): if plant.name == plant_percentage.plant.name: plant_category = plant.category break - plant_percentages.append(libs_pp(plant_percentage.percentage, plant_category, plant_percentage.plant)) - vegetations.append(libs_vegetation(name, vegetation, plant_percentages)) + plant_percentages.append( + HubPlantPercentage(plant_percentage.percentage, plant_category, plant_percentage.plant) + ) + vegetations.append(HubVegetation(name, vegetation, plant_percentages)) plants = [] for plant_category in catalog_data.plantCategories: name = plant_category.name for plant in plant_category.plants: - plants.append(libs_plant(name, plant)) + plants.append(HubPlant(name, plant)) soils = [] for soil in catalog_data.soils: - soils.append(libs_soil(soil)) + soils.append(HubSoil(soil)) self._content = GreeneryContent(vegetations, plants, soils) @@ -103,14 +108,15 @@ class GreeneryCatalog(Catalog): raise IndexError(f"{name} doesn't exists in the catalog") def entries(self, category=None): + """ + Get all entries from the greenery catalog optionally filtered by category + """ if category is None: return self._content - else: - if category.lower() == 'vegetations': - return self._content.vegetations - elif category.lower() == 'plants': - return self._content.plants - elif category.lower() == 'soils': - return self._content.soils - else: - raise ValueError(f'Unknown category [{category}]') + if category.lower() == 'vegetations': + return self._content.vegetations + if category.lower() == 'plants': + return self._content.plants + if category.lower() == 'soils': + return self._content.soils + raise ValueError(f'Unknown category [{category}]') diff --git a/hub/catalog_factories/usage/comnet_catalog.py b/hub/catalog_factories/usage/comnet_catalog.py index 27fefb6e..fb6f2b00 100644 --- a/hub/catalog_factories/usage/comnet_catalog.py +++ b/hub/catalog_factories/usage/comnet_catalog.py @@ -24,6 +24,9 @@ from hub.helpers.configuration_helper import ConfigurationHelper as ch class ComnetCatalog(Catalog): + """ + Comnet catalog class + """ def __init__(self, path): self._comnet_archetypes_path = str(path / 'comnet_archetypes.xlsx') self._comnet_schedules_path = str(path / 'comnet_schedules_archetypes.xlsx') diff --git a/hub/catalog_factories/usage/nrcan_catalog.py b/hub/catalog_factories/usage/nrcan_catalog.py index 0c717276..fda4ac40 100644 --- a/hub/catalog_factories/usage/nrcan_catalog.py +++ b/hub/catalog_factories/usage/nrcan_catalog.py @@ -24,11 +24,14 @@ from hub.catalog_factories.usage.usage_helper import UsageHelper class NrcanCatalog(Catalog): + """ + Nrcan catalog class + """ def __init__(self, path): path = str(path / 'nrcan.xml') self._content = None self._schedules = {} - with open(path) as xml: + with open(path, 'r', encoding='utf-8') as xml: self._metadata = xmltodict.parse(xml.read()) self._base_url = self._metadata['nrcan']['@base_url'] self._load_schedules() @@ -70,8 +73,10 @@ class NrcanCatalog(Catalog): self._schedules[schedule_type['name']] = _schedules def _get_schedules(self, name): + schedule = None if name in self._schedules: - return self._schedules[name] + schedule = self._schedules[name] + return schedule def _load_archetypes(self): usages = [] @@ -94,7 +99,10 @@ class NrcanCatalog(Catalog): # W/m2 appliances_density = space_type['electric_equipment_per_area_w_per_m2'] # peak flow in gallons/h/m2 - domestic_hot_water_peak_flow = space_type['service_water_heating_peak_flow_per_area'] * cte.GALLONS_TO_QUBIC_METERS / cte.HOUR_TO_SECONDS + domestic_hot_water_peak_flow = ( + space_type['service_water_heating_peak_flow_per_area'] * + cte.GALLONS_TO_QUBIC_METERS / cte.HOUR_TO_SECONDS + ) space_types_dictionary[usage_type] = {'occupancy_per_area': occupancy_density, 'lighting_per_area': lighting_density, 'electric_equipment_per_area': appliances_density, diff --git a/hub/catalog_factories/usage_catalog_factory.py b/hub/catalog_factories/usage_catalog_factory.py index 9c46a475..8e826cad 100644 --- a/hub/catalog_factories/usage_catalog_factory.py +++ b/hub/catalog_factories/usage_catalog_factory.py @@ -4,17 +4,21 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ -import logging from pathlib import Path from typing import TypeVar + from hub.catalog_factories.usage.comnet_catalog import ComnetCatalog from hub.catalog_factories.usage.nrcan_catalog import NrcanCatalog from hub.helpers.utils import validate_import_export_type + Catalog = TypeVar('Catalog') class UsageCatalogFactory: + """ + Usage catalog factory class + """ def __init__(self, handler, base_path=None): if base_path is None: base_path = Path(Path(__file__).parent.parent / 'data/usage') diff --git a/hub/exports/formats/triangular.py b/hub/exports/formats/triangular.py index eada8772..25715d5b 100644 --- a/hub/exports/formats/triangular.py +++ b/hub/exports/formats/triangular.py @@ -28,5 +28,5 @@ class Triangular: for building in self._city.buildings: trimesh = trimesh.union(building.simplified_polyhedron.trimesh) - with open(file_path, self._write_mode, encoding='utf-8') as file: + with open(file_path, self._write_mode) as file: file.write(trimesh.export(file_type=self._triangular_format)) diff --git a/hub/helpers/auth.py b/hub/helpers/auth.py index 9797f51b..b6f78b6a 100644 --- a/hub/helpers/auth.py +++ b/hub/helpers/auth.py @@ -8,7 +8,7 @@ Project Coder Peter Yefi peteryefi@gmail.com import bcrypt -class Auth(object): +class Auth: """ Auth class """ diff --git a/hub/helpers/data/montreal_function_to_hub_function.py b/hub/helpers/data/montreal_function_to_hub_function.py index 18ed172e..814a4f61 100644 --- a/hub/helpers/data/montreal_function_to_hub_function.py +++ b/hub/helpers/data/montreal_function_to_hub_function.py @@ -9,6 +9,9 @@ import hub.helpers.constants as cte class MontrealFunctionToHubFunction: + """ + Montreal function to hub function class + """ def __init__(self): self._dictionary = {'1000': cte.RESIDENTIAL, @@ -584,4 +587,8 @@ class MontrealFunctionToHubFunction: @property def dictionary(self) -> dict: + """ + Get the dictionary + :return: {} + """ return self._dictionary diff --git a/hub/helpers/data/montreal_system_to_hub_energy_generation_system.py b/hub/helpers/data/montreal_system_to_hub_energy_generation_system.py index 4e5ce77a..9f2237a1 100644 --- a/hub/helpers/data/montreal_system_to_hub_energy_generation_system.py +++ b/hub/helpers/data/montreal_system_to_hub_energy_generation_system.py @@ -9,7 +9,9 @@ import hub.helpers.constants as cte class MontrealSystemToHubEnergyGenerationSystem: - + """ + Montreal's system to hub energy generation system class + """ def __init__(self): self._dictionary = { 'Unitary air conditioner with baseboard heater fuel fired boiler': cte.BOILER, @@ -31,4 +33,8 @@ class MontrealSystemToHubEnergyGenerationSystem: @property def dictionary(self) -> dict: + """ + Get the dictionary + :return: {} + """ return self._dictionary diff --git a/hub/helpers/peak_calculation/loads_calculation.py b/hub/helpers/peak_calculation/loads_calculation.py index c103a330..5a18867b 100644 --- a/hub/helpers/peak_calculation/loads_calculation.py +++ b/hub/helpers/peak_calculation/loads_calculation.py @@ -59,6 +59,10 @@ class LoadsCalculation: return load_ventilation def get_heating_transmitted_load(self, ambient_temperature, ground_temperature): + """ + Calculates the heating transmitted load + :return: int + """ heating_load_transmitted = 0 for internal_zone in self._building.internal_zones: for thermal_zone in internal_zone.thermal_zones: @@ -68,6 +72,10 @@ class LoadsCalculation: return heating_load_transmitted def get_cooling_transmitted_load(self, ambient_temperature, ground_temperature): + """ + Calculates the cooling transmitted load + :return: int + """ cooling_load_transmitted = 0 for internal_zone in self._building.internal_zones: for thermal_zone in internal_zone.thermal_zones: @@ -77,6 +85,10 @@ class LoadsCalculation: return cooling_load_transmitted def get_heating_ventilation_load_sensible(self, ambient_temperature): + """ + Calculates the heating ventilation load sensible + :return: int + """ heating_ventilation_load = 0 for internal_zone in self._building.internal_zones: for thermal_zone in internal_zone.thermal_zones: @@ -85,6 +97,10 @@ class LoadsCalculation: return heating_ventilation_load def get_cooling_ventilation_load_sensible(self, ambient_temperature): + """ + Calculates the cooling ventilation load sensible + :return: int + """ cooling_ventilation_load = 0 for internal_zone in self._building.internal_zones: for thermal_zone in internal_zone.thermal_zones: @@ -93,6 +109,10 @@ class LoadsCalculation: return cooling_ventilation_load def get_internal_load_sensible(self): + """ + Calculates the internal load sensible + :return: int + """ cooling_load_occupancy_sensible = 0 cooling_load_lighting = 0 cooling_load_equipment_sensible = 0 @@ -113,6 +133,10 @@ class LoadsCalculation: return internal_load def get_radiation_load(self, irradiance_format, hour): + """ + Calculates the radiation load + :return: int + """ cooling_load_radiation = 0 for internal_zone in self._building.internal_zones: for thermal_zone in internal_zone.thermal_zones: