From 6854b35647f0be2ec3b32a2b6cf4b17b5ec07e9a Mon Sep 17 00:00:00 2001 From: Alireza Adli Date: Wed, 17 Jul 2024 10:31:33 -0400 Subject: [PATCH] Add setters for archetypes and constructions catalogues --- .../access_nrcan_catalogue.py | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/hub/city_model_structure/life_cycle_assessment/access_nrcan_catalogue.py b/hub/city_model_structure/life_cycle_assessment/access_nrcan_catalogue.py index 4b2130da..c3fd5496 100644 --- a/hub/city_model_structure/life_cycle_assessment/access_nrcan_catalogue.py +++ b/hub/city_model_structure/life_cycle_assessment/access_nrcan_catalogue.py @@ -14,26 +14,31 @@ class AccessNrcanCatalog: """ AccessNrcanCatalog class """ - def __init__(self, path): + def __init__( + self, path, + archetypes='nrcan_archetypes.json', + constructions='nrcan_constructions.json'): self._path = Path(path) - self._archetypes = self._load_archetypes() - self._constructions = self._load_constructions() + self.archetypes = archetypes + self.constructions = constructions @property def archetypes(self): return self._archetypes + @archetypes.setter + def archetypes(self, archetypes): + archetypes_path = (self._path / archetypes).resolve() + self._archetypes = json.loads(archetypes_path.read_text()) + @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()) + @constructions.setter + def constructions(self, constructions): + constructions_path = (self._path / constructions).resolve() + self._constructions = json.loads(constructions_path.read_text()) def layers(self, opaque_surface_code, component_type): for opaque_surface in self.constructions['opaque_surfaces']: @@ -56,4 +61,4 @@ class AccessNrcanCatalog: elif archetype['climate_zone'] != climate_zone: continue else: - return archetype['constructions']['OutdoorsWall']['opaque_surface_name'] \ No newline at end of file + return archetype['constructions']['OutdoorsWall']['opaque_surface_name']