Add parameters and default parameters to the constructor & add calculate_emission

This commit is contained in:
Alireza Adli 2024-07-16 10:25:31 -04:00
parent e6e39020b2
commit 03c0cdd853
2 changed files with 24 additions and 15 deletions

Binary file not shown.

View File

@ -7,7 +7,6 @@ Code contributors: Alireza Adli alireza.adli@concordia.ca
Mohammad Reza Seyedabadi mohammad.seyedabadi@mail.concordia.ca
"""
import glob
from pathlib import Path
from hub.imports.geometry_factory import GeometryFactory
@ -16,21 +15,31 @@ from hub.helpers.dictionaries import Dictionaries
class LCACarbonWorkflow:
def __init__(self, city_path):
file_path = (Path(__file__).parent / 'input_files' / city_path)
out_path = (Path(__file__).parent / 'out_files')
def __init__(
self,
city_path,
catalogue_path,
catalogue='nrcan',
building_parameters=('height', 'year_of_construction', 'function')):
self.file_path = (Path(__file__).parent / 'input_files' / city_path)
self.catalogue_path = (Path(__file__).parent / 'input_files' / catalogue_path)
self.out_path = (Path(__file__).parent / 'out_files')
self.handler = catalogue
self.height, self.year_of_construction, self.function = \
building_parameters
print('[simulation start]')
city = GeometryFactory('geojson',
path=file_path,
height_field='height',
year_of_construction_field='year_of_construction',
function_field='function',
self.city = GeometryFactory(
'geojson',
path=self.file_path,
height_field=self.height,
year_of_construction_field=self.year_of_construction,
function_field=self.function,
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
print(f'city created from {file_path}')
ConstructionFactory('nrcan', city).enrich()
print(len(city.buildings[0].surfaces))
print(f'city created from {self.file_path}')
ConstructionFactory(self.handler, self.city).enrich()
if __name__ == '__main__':
lca_calc = LCACarbonWorkflow('output_buildings_test.geojson')
def calculate_emission(self):
for building in self.city.buildings:
return len(building.surfaces)