Compare commits

..

6 Commits

Author SHA1 Message Date
9cbc2bc634 Correct indentation 2024-10-14 10:52:33 -04:00
317a20917f Clean comments 2024-10-13 12:41:48 -04:00
38c468b29b Finalize comments 2024-10-13 12:40:24 -04:00
b50724690f Return to the original name 2024-10-13 12:36:10 -04:00
f142332cb9 Change search_materials name 2024-10-13 12:16:55 -04:00
3a1f418577 Add comments 2024-10-13 12:13:14 -04:00

View File

@ -1,6 +1,5 @@
"""
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
@ -14,15 +13,27 @@ 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
@ -73,6 +84,11 @@ 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'
@ -107,6 +123,13 @@ 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:
@ -114,17 +137,36 @@ class AccessNrcanCatalog:
elif opaque_surface[opaque_surface_key]['type'] == component_type:
return opaque_surface[opaque_surface_key]['layers']
def search_materials(self, material_name):
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'>
"""
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 corresponding to the given arguments."""
"""
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'>
"""
for archetype in self.archetypes['archetypes']:
if archetype['function'] != function:
continue