added also to_dictionary to greenery catalog (Greenery catalog must be reviewed!!)

This commit is contained in:
Pilar Monsalvete 2023-07-13 17:00:33 -04:00
parent 6ab3ee3dc3
commit 24620d485e
5 changed files with 99 additions and 0 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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