forked from s_ranjbar/city_retrofit
Bug correction and code quality improvements
This commit is contained in:
parent
11ba482e73
commit
0956f40e42
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,6 +7,9 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
|||
|
||||
|
||||
class Material:
|
||||
"""
|
||||
Material class
|
||||
"""
|
||||
def __init__(self, material_id,
|
||||
name,
|
||||
solar_absorptance,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -11,6 +11,9 @@ from hub.catalog_factories.data_models.cost.income import Income
|
|||
|
||||
|
||||
class Archetype:
|
||||
"""
|
||||
Archetype class
|
||||
"""
|
||||
def __init__(self,
|
||||
lod,
|
||||
function,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@ from typing import Union
|
|||
|
||||
|
||||
class Fuel:
|
||||
"""
|
||||
Fuel class
|
||||
"""
|
||||
def __init__(self, fuel_type,
|
||||
fixed_monthly=None,
|
||||
fixed_power=None,
|
||||
|
|
|
@ -9,6 +9,9 @@ from typing import Union
|
|||
|
||||
|
||||
class Income:
|
||||
"""
|
||||
Income class
|
||||
"""
|
||||
def __init__(self, construction_subsidy=None,
|
||||
hvac_subsidy=None,
|
||||
photovoltaic_subsidy=None,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -18,5 +18,3 @@ class InternalGain:
|
|||
self._radiative_fraction = radiative_fraction
|
||||
self._latent_fraction = latent_fraction
|
||||
self._schedules = schedules
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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}]')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -8,7 +8,7 @@ Project Coder Peter Yefi peteryefi@gmail.com
|
|||
import bcrypt
|
||||
|
||||
|
||||
class Auth(object):
|
||||
class Auth:
|
||||
"""
|
||||
Auth class
|
||||
"""
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user