Modify machine and access
This commit is contained in:
parent
d52c8bf73a
commit
d41ce5371e
|
@ -0,0 +1,59 @@
|
|||
"""
|
||||
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
|
||||
Code contributors: Alireza Adli alireza.adli@concordia.ca
|
||||
"""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class AccessNrcanCatalog:
|
||||
"""
|
||||
AccessNrcanCatalog class
|
||||
"""
|
||||
def __init__(self, path):
|
||||
self._path = Path(path)
|
||||
self._archetypes = self._load_archetypes()
|
||||
self._constructions = self._load_constructions()
|
||||
|
||||
@property
|
||||
def archetypes(self):
|
||||
return self._archetypes
|
||||
|
||||
@property
|
||||
def constructions(self):
|
||||
return self._constructions
|
||||
|
||||
def _load_archetypes(self):
|
||||
archetypes_path = (self._path / 'nrcan_archetypes.json').resolve()
|
||||
return json.loads(archetypes_path.read_text())
|
||||
|
||||
def _load_constructions(self):
|
||||
constructions_path = (self._path / 'nrcan_constructions.json').resolve()
|
||||
return json.loads(constructions_path.read_text())
|
||||
|
||||
def layers(self, opaque_surface_code, component_type):
|
||||
for opaque_surface in self.constructions['opaque_surfaces']:
|
||||
opaque_surface_key = list(opaque_surface)[0]
|
||||
if opaque_surface_key != opaque_surface_code:
|
||||
continue
|
||||
elif opaque_surface[opaque_surface_key]['type'] == component_type:
|
||||
return opaque_surface[opaque_surface_key]['layers']
|
||||
|
||||
def nrcan_windows(self, window_code):
|
||||
return self._constructions['transparent_surfaces'][0][window_code]
|
||||
|
||||
def find_opaque_surface(self, function, period_of_construction, climate_zone):
|
||||
"""Returns the opaque_surface_name corresponding to the given arguments."""
|
||||
for archetype in self.archetypes['archetypes']:
|
||||
if archetype['function'] != function:
|
||||
continue
|
||||
elif archetype['period_of_construction'] != period_of_construction:
|
||||
continue
|
||||
elif archetype['climate_zone'] != climate_zone:
|
||||
continue
|
||||
else:
|
||||
return archetype['constructions']['OutdoorsWall']['opaque_surface_name']
|
|
@ -64,6 +64,5 @@ class Machine:
|
|||
def total_machine_emssion(self):
|
||||
""":return: float"""
|
||||
return self._work_efficiency_rate * \
|
||||
self._energy_consumption_rate * \
|
||||
self._emission_factor
|
||||
|
||||
self._energy_consumption_rate * \
|
||||
self._emission_factor
|
||||
|
|
Loading…
Reference in New Issue
Block a user