diff --git a/catalogs/data_model/greenery/greenery_content.py b/catalogs/data_model/greenery/greenery_content.py new file mode 100644 index 00000000..04018d5b --- /dev/null +++ b/catalogs/data_model/greenery/greenery_content.py @@ -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 + diff --git a/catalogs/data_model/greenery/plant.py b/catalogs/data_model/greenery/plant.py new file mode 100644 index 00000000..0a55269d --- /dev/null +++ b/catalogs/data_model/greenery/plant.py @@ -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 diff --git a/catalogs/data_model/greenery/plant_percentage.py b/catalogs/data_model/greenery/plant_percentage.py new file mode 100644 index 00000000..023ddfda --- /dev/null +++ b/catalogs/data_model/greenery/plant_percentage.py @@ -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 diff --git a/catalogs/data_model/greenery/soil.py b/catalogs/data_model/greenery/soil.py new file mode 100644 index 00000000..177c3662 --- /dev/null +++ b/catalogs/data_model/greenery/soil.py @@ -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 diff --git a/catalogs/data_model/greenery/vegetation.py b/catalogs/data_model/greenery/vegetation.py new file mode 100644 index 00000000..ec829f70 --- /dev/null +++ b/catalogs/data_model/greenery/vegetation.py @@ -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 diff --git a/catalogs/greenery/greenery_catalog.py b/catalogs/greenery/greenery_catalog.py index 3ede5ab9..b9b8897c 100644 --- a/catalogs/greenery/greenery_catalog.py +++ b/catalogs/greenery/greenery_catalog.py @@ -8,6 +8,11 @@ from pyecore.resources import ResourceSet, URI from catalogs.greenery.ecore_greenery.greenerycatalog import GreeneryCatalog as gc from catalogs.catalog import Catalog 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): @@ -20,11 +25,27 @@ class GreeneryCatalog(Catalog): resource_set.metamodel_registry[data_model_root.nsURI] = data_model_root resource = resource_set.get_resource(URI(str(path))) catalog_data: gc = resource.contents[0] - self._data = {'vegetation': []} - vegetation = [] + + vegetations = [] for vegetation_category in catalog_data.vegetationCategories: - vegetation.append({vegetation_category.name: []}) - self._data['vegetation'] = vegetation + name = vegetation_category.name + 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 def names(self): @@ -32,10 +53,17 @@ class GreeneryCatalog(Catalog): :parm: """ _names = [] - for category in self._data: - for value in self._data[category]: - for key in value.keys(): - _names.append(key) + for vegetation in self._data.vegetations: + _names.append(vegetation.name) + for plant in self._data.plants: + _names.append(plant.name) + for soil in self._data.soils: + _names.append(soil.name) return _names + def get_entry(self, name): + return 'value' + @property + def entries(self): + pass diff --git a/catalogs/greenery_catalog_factory.py b/catalogs/greenery_catalog_factory.py index 8e7dfe29..3491d716 100644 --- a/catalogs/greenery_catalog_factory.py +++ b/catalogs/greenery_catalog_factory.py @@ -41,4 +41,4 @@ class GreeneryCatalogFactory: Enrich the city given to the class using the class given handler :return: City """ - return GreeneryCatalog((self._path / 'ecore_greenery_catalog.xml').resolve()) \ No newline at end of file + return GreeneryCatalog((self._path / 'ecore_greenery_catalog.xml').resolve()) diff --git a/helpers/yearly_from_daily_schedules.py b/helpers/yearly_from_daily_schedules.py index c7c3bac5..2c4cd21a 100644 --- a/helpers/yearly_from_daily_schedules.py +++ b/helpers/yearly_from_daily_schedules.py @@ -32,7 +32,8 @@ class YearlyFromDailySchedules: values = [] 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) values.extend(weekly_schedules[week_day]) yearly_schedule.type = self._daily_schedules[0].type diff --git a/requirements.txt b/requirements.txt index 457ca623..5329b459 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,4 +15,6 @@ parseidf~=1.0.0 ply~=3.11 rhino3dm~=7.11.1 scipy==1.7.1 -PyYAML==6.0 \ No newline at end of file +PyYAML==6.0 +yaml~=0.2.5 +pyecore~=0.12.2 \ No newline at end of file