Compare commits

..

No commits in common. "9cbc2bc634668e7eb2a98887adfbde6b3cfffd9a" and "79c27244e6ddc2e3a9b2ac87826916f916f99c9d" have entirely different histories.

View File

@ -1,5 +1,6 @@
"""
access_nrcan_catalog module
Returns values from both nrcan_constructions.json and nrcan_archetypes.json
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2024 Concordia CERC group
Project developer: Alireza Adli alireza.adli@mail.concordia.ca
@ -13,27 +14,15 @@ from hub.helpers.data.hub_function_to_nrcan_construction_function \
class AccessNrcanCatalog:
"""
AccessNrcanCatalog class
"""
def __init__(
self, path,
archetypes='nrcan_archetypes.json',
constructions='nrcan_constructions_cap_3.json',
materials='nrcan_materials_dictionaries.json',
transparent_surfaces='nrcan_transparent_surfaces_dictionaries.json'):
"""
AccessNrcanCatalog eases accessing the below json files.
- It converts year of construction to the period of construction.
- It searches a specific material or transparent surface.
- The class finds the opaque surface code based on three parameters.
:param path: path to the below files
:param archetypes: a json file (a list of dictionaries) with building
archetypes' data
:param constructions: a json file (a list of dictionaries) with
building data based on NRCan
:param materials: a json file (a dictornaty of
dictionares to speed up the search) with construction material info.
:param transparent_surfaces: a json file (a dictionary of
dictionaries) with windows and skylights data.
"""
self._path = Path(path)
self.archetypes = archetypes
self.constructions = constructions
@ -84,11 +73,6 @@ class AccessNrcanCatalog:
@staticmethod
def year_to_period_of_construction(year_of_construction):
"""
Converts year of construction to the period of construction.
:param year_of_construction: <class 'int'>
:return: <class 'str'>
"""
period_of_construction = None
if 1000 <= year_of_construction <= 1900:
period_of_construction = '1000_1900'
@ -123,13 +107,6 @@ class AccessNrcanCatalog:
return period_of_construction
def layers(self, opaque_surface_code, component_type):
"""
Returns the corresponding layers of a specific opaque surface
and the component type.
:param opaque_surface_code: <class 'str'>
:param component_type: <class 'str'>
:return: <class 'dict'>
"""
for opaque_surface in self.constructions['opaque_surfaces']:
opaque_surface_key = list(opaque_surface)[0]
if opaque_surface_key != opaque_surface_code:
@ -137,36 +114,17 @@ class AccessNrcanCatalog:
elif opaque_surface[opaque_surface_key]['type'] == component_type:
return opaque_surface[opaque_surface_key]['layers']
def search_material(self, material_name):
"""
Search materials and bring up the specific material data
based on the material's name
:param material_name: <class 'str'>
:return: <class 'dict'>
"""
def search_materials(self, material_name):
return self.materials[f'{material_name}']
def search_transparent_surfaces(
self, surface_type, opaque_surface_code):
"""
Search transparent surfaces and bring up the specific surface data
based on its type and opaque surface code
:param surface_type: <class 'str'>
:param opaque_surface_code: <class 'str'>
:return: <class 'dict'>
"""
return self.transparent_surfaces[
f'{surface_type}_{opaque_surface_code}']
def find_opaque_surface(
self, function, period_of_construction, climate_zone):
"""
Returns the opaque_surface_name based on the below parameters.
:param function: <class 'str'>
:param period_of_construction: <class 'str'>
:param climate_zone: <class 'str'>
:return: <class 'str'>
"""
"""Returns the opaque_surface_name corresponding to the given arguments."""
for archetype in self.archetypes['archetypes']:
if archetype['function'] != function:
continue