Partial implementation for the greenery catalog integration

This commit is contained in:
Guille Gutierrez 2022-03-08 20:25:50 -05:00
parent 7db319f3fd
commit 868dfe22d5
9 changed files with 412 additions and 11 deletions

View File

@ -0,0 +1,33 @@
"""
Greenery catalog content
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
class GreeneryContent:
def __init__(self, vegetations, plants, soils):
self._vegetations = vegetations
self._plants = plants
self._soils = soils
@property
def vegetations(self):
"""
All vegetation in the catalog
"""
return self._vegetations
@property
def plants(self):
"""
All plants in the catalog
"""
return self._plants
@property
def soils(self):
"""
All soils in the catalog
"""
return self._soils

View File

@ -0,0 +1,73 @@
"""
Greenery catalog data model Plant class
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
class Plant:
def __init__(self, category, plant):
self._name = plant.name
self._category = category
self._height = plant.height
self._leaf_area_index = plant.leafAreaIndex
self._leaf_reflectivity = plant.leafReflectivity
self._leaf_emissivity = plant.leafEmissivity
self._minimal_stomatal_resistance = plant.minimalStomatalResistance
self._co2_sequestration = plant.co2Sequestration
@property
def name(self):
"""
Get plant name
"""
return self._name
@property
def category(self):
"""
Get plant category name
"""
return self._category
@property
def height(self):
"""
Get plant height
"""
return self._height
@property
def leaf_area_index(self):
"""
Get plant leaf area index
"""
return self._leaf_area_index
@property
def leaf_reflectivity(self):
"""
Get plant leaf area index
"""
return self._leaf_reflectivity
@property
def leaf_emissivity(self):
"""
Get plant leaf emissivity
"""
return self._leaf_emissivity
@property
def minimal_stomatal_resistance(self):
"""
Get plant minimal stomatal resistance
"""
return self._minimal_stomatal_resistance
@property
def co2_sequestration(self):
"""
Get plant co2 sequestration capacity
"""
return self._co2_sequestration

View File

@ -0,0 +1,17 @@
"""
Greenery catalog data model Plant percentage class
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
from catalogs.data_model.greenery.plant import Plant
class PlantPercentage(Plant):
def __init__(self, percentage, plant):
super().__init__("unknown", plant)
self._percentage = percentage
@property
def percentage(self):
return self._percentage

View File

@ -0,0 +1,96 @@
"""
Greenery catalog data model Soil class
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
class Soil:
def __init__(self, soil):
self._name = soil.name
self._roughness = soil.roughness
self._dry_conductivity = soil.conductivityOfDrySoil
self._dry_density = soil.densityOfDrySoil
self._dry_specific_heat = soil.specificHeatOfDrySoil
self._thermal_absorptance = soil.thermalAbsorptance
self._solar_absorptance = soil.solarAbsorptance
self._visible_absorptance = soil.visibleAbsorptance
self._saturation_volumetric_moisture_content = soil.saturationVolumetricMoistureContent
self._residual_volumetric_moisture_content = soil.residualVolumetricMoistureContent
self._initial_volumetric_moisture_content = soil.initialVolumetricMoistureContent
@property
def name(self):
"""
Get soil name
"""
return self._name
@property
def roughness(self):
"""
Get soil roughness
"""
return self._roughness
@property
def dry_conductivity(self):
"""
Get soil dry conductivity
"""
return self._dry_conductivity
@property
def dry_density(self):
"""
Get soil dry density
"""
return self._dry_density
@property
def dry_specific_heat(self):
"""
Get soil dry specific heat
"""
return self._dry_specific_heat
@property
def thermal_absorptance(self):
"""
Get soil thermal absortance
"""
return self._thermal_absorptance
@property
def solar_absorptance(self):
"""
Get soil solar absortance
"""
return self._solar_absorptance
@property
def visible_absorptance(self):
"""
Get soil visible absortance
"""
return self._visible_absorptance
@property
def saturation_volumetric_moisture_content(self):
"""
Get soil saturation volumetric moisture content
"""
return self._saturation_volumetric_moisture_content
@property
def residual_volumetric_moisture_content(self):
"""
Get soil residual volumetric moisture content
"""
return self._residual_volumetric_moisture_content
@property
def initial_volumetric_moisture_content(self):
"""
Get soil initial volumetric moisture content
"""
return self._initial_volumetric_moisture_content

View File

@ -0,0 +1,151 @@
"""
Greenery catalog data model Vegetation class
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
from catalogs.data_model.greenery.plant_percentage import PlantPercentage
class Vegetation:
def __init__(self, category, vegetation, plant_percentages):
self._name = vegetation.name
self._category = category
self._soil_thickness = vegetation.thicknessOfSoil
self._management = vegetation.management
self._air_gap = vegetation.airGap
self._soil_name = vegetation.soil.name
self._soil_roughness = vegetation.soil.roughness
self._dry_soil_conductivity = vegetation.soil.conductivityOfDrySoil
self._dry_soil_density = vegetation.soil.densityOfDrySoil
self._dry_soil_specific_heat = vegetation.soil.specificHeatOfDrySoil
self._soil_thermal_absorptance = vegetation.soil.thermalAbsorptance
self._soil_solar_absorptance = vegetation.soil.solarAbsorptance
self._soil_visible_absorptance = vegetation.soil.visibleAbsorptance
self._soil_saturation_volumetric_moisture_content = vegetation.soil.saturationVolumetricMoistureContent
self._soil_residual_volumetric_moisture_content = vegetation.soil.residualVolumetricMoistureContent
self._soil_initial_volumetric_moisture_content = vegetation.soil.initialVolumetricMoistureContent
self._plant_percentages = plant_percentages
@property
def name(self):
"""
Get vegetation name
"""
return self._name
@property
def category(self):
"""
Get vegetation category
"""
return self._category
@property
def soil_thickness(self):
"""
Get soil thickness
"""
return self._soil_thickness
@property
def management(self):
"""
Get management
"""
return self._management
@property
def air_gap(self):
"""
Get air gap
"""
return self._air_gap
@property
def plant_percentages(self) -> [PlantPercentage]:
"""
Get plant percentages
"""
percentage = 0.0
for plant_percentage in self._plant_percentages:
percentage += plant_percentage.percentage
if percentage > 100:
raise ValueError('the plant percentage in this vegetation is over 100%')
return self._plant_percentages
@property
def soil_name(self):
"""
Get soil name
"""
return self._soil_name
@property
def soil_roughness(self):
"""
Get soil roughness
"""
return self._soil_roughness
@property
def dry_soil_conductivity(self):
"""
Get soil dry conductivity
"""
return self._dry_soil_conductivity
@property
def dry_soil_density(self):
"""
Get soil dry density
"""
return self._dry_soil_density
@property
def dry_soil_specific_heat(self):
"""
Get soil dry specific heat
"""
return self._dry_soil_specific_heat
@property
def soil_thermal_absorptance(self):
"""
Get soil thermal absortance
"""
return self._soil_thermal_absorptance
@property
def soil_solar_absorptance(self):
"""
Get soil solar absortance
"""
return self._soil_solar_absorptance
@property
def soil_visible_absorptance(self):
"""
Get soil visible absortance
"""
return self._soil_visible_absorptance
@property
def soil_saturation_volumetric_moisture_content(self):
"""
Get soil saturation volumetric moisture content
"""
return self._soil_saturation_volumetric_moisture_content
@property
def soil_residual_volumetric_moisture_content(self):
"""
Get soil residual volumetric moisture content
"""
return self._soil_residual_volumetric_moisture_content
@property
def soil_initial_volumetric_moisture_content(self):
"""
Get soil initial volumetric moisture content
"""
return self._soil_initial_volumetric_moisture_content

View File

@ -8,6 +8,11 @@ from pyecore.resources import ResourceSet, URI
from catalogs.greenery.ecore_greenery.greenerycatalog import GreeneryCatalog as gc from catalogs.greenery.ecore_greenery.greenerycatalog import GreeneryCatalog as gc
from catalogs.catalog import Catalog from catalogs.catalog import Catalog
from pathlib import Path from pathlib import Path
from catalogs.data_model.greenery.vegetation import Vegetation as libs_vegetation
from catalogs.data_model.greenery.plant import Plant as libs_plant
from catalogs.data_model.greenery.soil import Soil as libs_soil
from catalogs.data_model.greenery.plant_percentage import PlantPercentage as libs_pp
from catalogs.data_model.greenery.greenery_content import GreeneryContent
class GreeneryCatalog(Catalog): class GreeneryCatalog(Catalog):
@ -20,11 +25,27 @@ class GreeneryCatalog(Catalog):
resource_set.metamodel_registry[data_model_root.nsURI] = data_model_root resource_set.metamodel_registry[data_model_root.nsURI] = data_model_root
resource = resource_set.get_resource(URI(str(path))) resource = resource_set.get_resource(URI(str(path)))
catalog_data: gc = resource.contents[0] catalog_data: gc = resource.contents[0]
self._data = {'vegetation': []}
vegetation = [] vegetations = []
for vegetation_category in catalog_data.vegetationCategories: for vegetation_category in catalog_data.vegetationCategories:
vegetation.append({vegetation_category.name: []}) name = vegetation_category.name
self._data['vegetation'] = vegetation for vegetation in vegetation_category.vegetationTemplates:
plant_percentages = []
for plant_percentage in vegetation.plants:
plant_percentages.append(libs_pp(plant_percentage.percentage, plant_percentage.plant))
vegetations.append(libs_vegetation(name, vegetation, plant_percentages))
plants = []
for plant_category in catalog_data.plantCategories:
name = plant_category.name
for plant in plant_category.plants:
plants.append(libs_plant(name, plant))
soils = []
for soil in catalog_data.soils:
soils.append(libs_soil(soil))
self._data = GreeneryContent(vegetations, plants, soils)
@property @property
def names(self): def names(self):
@ -32,10 +53,17 @@ class GreeneryCatalog(Catalog):
:parm: :parm:
""" """
_names = [] _names = []
for category in self._data: for vegetation in self._data.vegetations:
for value in self._data[category]: _names.append(vegetation.name)
for key in value.keys(): for plant in self._data.plants:
_names.append(key) _names.append(plant.name)
for soil in self._data.soils:
_names.append(soil.name)
return _names return _names
def get_entry(self, name):
return 'value'
@property
def entries(self):
pass

View File

@ -41,4 +41,4 @@ class GreeneryCatalogFactory:
Enrich the city given to the class using the class given handler Enrich the city given to the class using the class given handler
:return: City :return: City
""" """
return GreeneryCatalog((self._path / 'ecore_greenery_catalog.xml').resolve()) return GreeneryCatalog((self._path / 'ecore_greenery_catalog.xml').resolve())

View File

@ -32,7 +32,8 @@ class YearlyFromDailySchedules:
values = [] values = []
for month in range(1, 13): for month in range(1, 13):
for day in range(1, cal.monthlen(self._year, month)+1): _, number_days = cal.monthrange(self._year, month)
for day in range(1, number_days+1):
week_day = cal.weekday(self._year, month, day) week_day = cal.weekday(self._year, month, day)
values.extend(weekly_schedules[week_day]) values.extend(weekly_schedules[week_day])
yearly_schedule.type = self._daily_schedules[0].type yearly_schedule.type = self._daily_schedules[0].type

View File

@ -15,4 +15,6 @@ parseidf~=1.0.0
ply~=3.11 ply~=3.11
rhino3dm~=7.11.1 rhino3dm~=7.11.1
scipy==1.7.1 scipy==1.7.1
PyYAML==6.0 PyYAML==6.0
yaml~=0.2.5
pyecore~=0.12.2