diff --git a/hub/catalog_factories/data_models/greenery/content.py b/hub/catalog_factories/data_models/greenery/content.py index 2087e7f7..c2544f98 100644 --- a/hub/catalog_factories/data_models/greenery/content.py +++ b/hub/catalog_factories/data_models/greenery/content.py @@ -35,3 +35,21 @@ class Content: All soils in the catalog """ return self._soils + + def to_dictionary(self): + """Class content to dictionary""" + _archetypes = [] + for _archetype in self.vegetations: + _archetypes.append(_archetype.to_dictionary()) + content = {'Archetypes': _archetypes} + + return content + + def __str__(self): + """Print content""" + _archetypes = [] + for _archetype in self.vegetations: + _archetypes.append(_archetype.to_dictionary()) + content = {'Archetypes': _archetypes} + + return str(content) diff --git a/hub/catalog_factories/data_models/greenery/plant.py b/hub/catalog_factories/data_models/greenery/plant.py index ea6bfa95..470fc593 100644 --- a/hub/catalog_factories/data_models/greenery/plant.py +++ b/hub/catalog_factories/data_models/greenery/plant.py @@ -96,3 +96,22 @@ class Plant: :return: [Soil] """ return self._grows_on + + def to_dictionary(self): + """Class content to dictionary""" + _soils = [] + for _soil in self.grows_on: + _soils.append(_soil.to_dictionary()) + content = {'Plant': {'name': self.name, + 'category': self.category, + 'height [m]': self.height, + 'leaf area index': self.leaf_area_index, + 'leaf reflectivity': self.leaf_reflectivity, + 'leaf emissivity': self.leaf_emissivity, + 'minimal stomatal resistance [s/m]': self.minimal_stomatal_resistance, + 'co2 sequestration [kg????]': self.co2_sequestration, + 'soils where it grows on': _soils + } + } + + return content diff --git a/hub/catalog_factories/data_models/greenery/plant_percentage.py b/hub/catalog_factories/data_models/greenery/plant_percentage.py index 8f72846b..5cf6c48d 100644 --- a/hub/catalog_factories/data_models/greenery/plant_percentage.py +++ b/hub/catalog_factories/data_models/greenery/plant_percentage.py @@ -24,3 +24,23 @@ class PlantPercentage(HubPlant): :return: float """ return self._percentage + + def to_dictionary(self): + """Class content to dictionary""" + _soils = [] + for _soil in self.grows_on: + _soils.append(_soil.to_dictionary()) + content = {'Plant': {'name': self.name, + 'percentage': self.percentage, + 'category': self.category, + 'height [m]': self.height, + 'leaf area index': self.leaf_area_index, + 'leaf reflectivity': self.leaf_reflectivity, + 'leaf emissivity': self.leaf_emissivity, + 'minimal stomatal resistance [s/m]': self.minimal_stomatal_resistance, + 'co2 sequestration [kg????]': self.co2_sequestration, + 'soils where it grows on': _soils + } + } + + return content diff --git a/hub/catalog_factories/data_models/greenery/soil.py b/hub/catalog_factories/data_models/greenery/soil.py index 099ba03f..e815254d 100644 --- a/hub/catalog_factories/data_models/greenery/soil.py +++ b/hub/catalog_factories/data_models/greenery/soil.py @@ -110,3 +110,20 @@ class Soil: :return: float """ return self._initial_volumetric_moisture_content + + def to_dictionary(self): + """Class content to dictionary""" + content = {'Soil': {'name': self.name, +# 'roughness': self.roughness, # todo: this line prints value=2???? + 'dry conductivity [W/m2K]': self.dry_conductivity, + 'dry density [kg/m3]': self.dry_density, + 'dry specific heat [J/kgK]': self.dry_specific_heat, + 'thermal absorptance': self.thermal_absorptance, + 'solar absorptance': self.solar_absorptance, + 'visible absorptance': self.visible_absorptance, + 'saturation volumetric moisture content [units??]': self.saturation_volumetric_moisture_content, + 'residual volumetric moisture content [units??]': self.residual_volumetric_moisture_content + } + } + + return content diff --git a/hub/catalog_factories/data_models/greenery/vegetation.py b/hub/catalog_factories/data_models/greenery/vegetation.py index ec3a9a1c..ae92fb21 100644 --- a/hub/catalog_factories/data_models/greenery/vegetation.py +++ b/hub/catalog_factories/data_models/greenery/vegetation.py @@ -171,3 +171,28 @@ class Vegetation: :return: float """ return self._soil_initial_volumetric_moisture_content + + def to_dictionary(self): + """Class content to dictionary""" + _plants = [] + for _plant in self.plant_percentages: + _plants.append(_plant.to_dictionary()) + content = {'Archetype': {'name': self.name, + 'category': self.category, + 'air gap thickness [m]': self.air_gap, + 'soil thickness [m]': self.soil_thickness, + 'soil name': self.soil_name, +# 'soil roughness': self.soil_roughness, # todo: this line prints value=2???? + 'dry soil conductivity [W/m2K]': self.dry_soil_conductivity, + 'dry soil density [kg/m3]': self.dry_soil_density, + 'dry soil specific heat [J/kgK]': self.dry_soil_specific_heat, + 'soil thermal absorptance': self.soil_thermal_absorptance, + 'soil solar absorptance': self.soil_solar_absorptance, + 'soil visible absorptance': self.soil_visible_absorptance, + 'soil saturation volumetric moisture content [units??]': self.soil_saturation_volumetric_moisture_content, + 'soil residual volumetric moisture content [units??]': self.soil_residual_volumetric_moisture_content, + 'plants': _plants + } + } + + return content