hub/imports/life_cycle_assessment/lca_material.py

41 lines
1.6 KiB
Python
Raw Normal View History

2021-11-15 10:35:31 -05:00
"""
CityGml module parses citygml_classes files and import the geometry into the city model structure
SPDX - License - Identifier: LGPL - 3.0 - or -later
2021-11-22 20:57:29 -05:00
Copyright © 2020 Project Author Atiya atiya.atiya@mail.concordia.ca
Contributor Mohammad Reza mohammad.seyedabadi@mail.concordia.ca
2021-11-15 10:35:31 -05:00
"""
import xmltodict
from pathlib import Path
2021-11-18 16:55:49 -05:00
from city_model_structure.building_demand.material import Material
2021-11-15 10:35:31 -05:00
class LcaMaterial:
def __init__(self, city, base_path):
self._city = city
self._base_path = base_path
self._lca = None
def enrich(self):
2022-03-08 19:19:52 -05:00
self._city.materials = []
2021-11-15 10:35:31 -05:00
path = Path(self._base_path / 'lca_data.xml').resolve()
with open(path) as xml:
self._lca = xmltodict.parse(xml.read())
2021-11-16 14:25:25 -05:00
for material in self._lca["library"]["building_materials"]['material']:
2022-03-08 19:19:52 -05:00
_material = Material()
_material.type = material['@type']
_material.id = material['@id']
_material.name = material['@name']
_material.density=material['density']['#text']
_material.density_unit=material['density']['@unit']
_material.embodied_carbon=material['embodied_carbon']['#text']
_material.embodied_carbon_unit=material['embodied_carbon']['@unit']
_material.recycling_ratio=material['recycling_ratio']
_material.onsite_recycling_ratio=material['onsite_recycling_ratio']
_material.company_recycling_ratio=material['company_recycling_ratio']
_material.landfilling_ratio=material['landfilling_ratio']
_material.cost=material['cost']['#text']
_material._cost_unit=material['cost']['@unit']
self._city.materials.append(_material)