hestia-earth-models 0.70.0__py3-none-any.whl → 0.70.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hestia_earth/models/aware/scarcityWeightedWaterUse.py +8 -16
- hestia_earth/models/cml2001Baseline/resourceUseMineralsAndMetalsDuringCycle.py +2 -1
- hestia_earth/models/config/Cycle.json +98 -50
- hestia_earth/models/config/ImpactAssessment.json +12 -4
- hestia_earth/models/config/Site.json +40 -21
- hestia_earth/models/cycle/transformation.py +1 -1
- hestia_earth/models/cycle/utils.py +0 -6
- hestia_earth/models/data/ecoinventV3/__init__.py +15 -13
- hestia_earth/models/ecoalimV9/__init__.py +13 -0
- hestia_earth/models/ecoalimV9/cycle.py +128 -0
- hestia_earth/models/ecoalimV9/impact_assessment.py +125 -0
- hestia_earth/models/ecoalimV9/utils.py +31 -0
- hestia_earth/models/ecoinventV3/__init__.py +6 -14
- hestia_earth/models/ecoinventV3/utils.py +1 -29
- hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py +8 -2
- hestia_earth/models/emissionNotRelevant/__init__.py +33 -8
- hestia_earth/models/{cycle → hestia}/aboveGroundCropResidue.py +4 -3
- hestia_earth/models/{cycle → hestia}/aboveGroundCropResidueTotal.py +1 -1
- hestia_earth/models/{site → hestia}/brackishWater.py +1 -1
- hestia_earth/models/{site → hestia}/cationExchangeCapacityPerKgSoil.py +1 -1
- hestia_earth/models/{cycle → hestia}/coldCarcassWeightPerHead.py +1 -1
- hestia_earth/models/{cycle → hestia}/coldDressedCarcassWeightPerHead.py +1 -1
- hestia_earth/models/{cycle → hestia}/concentrateFeed.py +1 -1
- hestia_earth/models/{cycle → hestia}/cropResidueManagement.py +1 -1
- hestia_earth/models/{cycle → hestia}/croppingIntensity.py +1 -1
- hestia_earth/models/{cycle → hestia}/energyContentLowerHeatingValue.py +1 -1
- hestia_earth/models/{cycle → hestia}/excretaKgMass.py +8 -3
- hestia_earth/models/{cycle → hestia}/excretaKgN.py +1 -1
- hestia_earth/models/{cycle → hestia}/excretaKgVs.py +1 -1
- hestia_earth/models/{cycle → hestia}/feedConversionRatio/__init__.py +1 -1
- hestia_earth/models/{site → hestia}/flowingWater.py +1 -1
- hestia_earth/models/{site → hestia}/freshWater.py +1 -1
- hestia_earth/models/{cycle → hestia}/inorganicFertiliser.py +1 -1
- hestia_earth/models/{cycle → hestia}/irrigatedTypeUnspecified.py +14 -19
- hestia_earth/models/hestia/landCover.py +30 -22
- hestia_earth/models/{cycle → hestia}/liveAnimal.py +1 -1
- hestia_earth/models/{cycle → hestia}/longFallowRatio.py +1 -1
- hestia_earth/models/{site → hestia}/management.py +4 -6
- hestia_earth/models/{cycle → hestia}/materialAndSubstrate.py +1 -1
- hestia_earth/models/{cycle → hestia}/milkYield.py +1 -1
- hestia_earth/models/{site → hestia}/netPrimaryProduction.py +1 -1
- hestia_earth/models/{site → hestia}/organicCarbonPerHa.py +1 -1
- hestia_earth/models/hestia/pToSurfaceWaterAquacultureSystems.py +148 -0
- hestia_earth/models/{cycle → hestia}/pastureGrass.py +1 -1
- hestia_earth/models/{cycle → hestia}/pastureSystem.py +1 -1
- hestia_earth/models/{site → hestia}/potentialEvapotranspirationAnnual.py +3 -3
- hestia_earth/models/{site → hestia}/potentialEvapotranspirationMonthly.py +3 -3
- hestia_earth/models/{site → hestia}/precipitationAnnual.py +3 -3
- hestia_earth/models/{site → hestia}/precipitationMonthly.py +3 -3
- hestia_earth/models/{site → hestia}/rainfallAnnual.py +3 -3
- hestia_earth/models/{site → hestia}/rainfallMonthly.py +3 -3
- hestia_earth/models/{cycle → hestia}/readyToCookWeightPerHead.py +1 -1
- hestia_earth/models/{cycle → hestia}/residueBurnt.py +1 -1
- hestia_earth/models/{cycle → hestia}/residueIncorporated.py +1 -1
- hestia_earth/models/{cycle → hestia}/residueLeftOnField.py +1 -1
- hestia_earth/models/hestia/residueRemoved.py +65 -13
- hestia_earth/models/{site → hestia}/salineWater.py +1 -1
- hestia_earth/models/{site → hestia}/soilMeasurement.py +1 -1
- hestia_earth/models/{cycle → hestia}/stockingDensityAnimalHousingAverage.py +1 -1
- hestia_earth/models/{site → hestia}/temperatureAnnual.py +3 -3
- hestia_earth/models/{site → hestia}/temperatureMonthly.py +3 -3
- hestia_earth/models/{site → hestia}/totalNitrogenPerKgSoil.py +1 -1
- hestia_earth/models/{cycle → hestia}/unknownPreSeasonWaterRegime.py +1 -1
- hestia_earth/models/hestia/utils.py +93 -0
- hestia_earth/models/{site → hestia}/waterDepth.py +1 -1
- hestia_earth/models/hestia/waterSalinity.py +78 -0
- hestia_earth/models/ipcc2019/aboveGroundBiomass.py +1 -1
- hestia_earth/models/ipcc2019/belowGroundBiomass.py +1 -1
- hestia_earth/models/ipcc2019/biomass_utils.py +2 -4
- hestia_earth/models/ipcc2019/ch4ToAirFloodedRice.py +166 -79
- hestia_earth/models/ipcc2019/ch4ToAirOrganicSoilCultivation.py +270 -0
- hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChange.py +0 -3
- hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChange.py +0 -3
- hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +88 -63
- hestia_earth/models/ipcc2019/co2ToAirLimeHydrolysis.py +7 -5
- hestia_earth/models/ipcc2019/co2ToAirOrganicSoilCultivation.py +215 -0
- hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py +0 -3
- hestia_earth/models/ipcc2019/co2ToAirUreaHydrolysis.py +16 -9
- hestia_earth/models/ipcc2019/n2OToAirOrganicSoilCultivationDirect.py +161 -0
- hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +35 -47
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1.py +86 -1
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2.py +127 -1
- hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py +7 -5
- hestia_earth/models/ipcc2019/organicSoilCultivation_utils.py +159 -0
- hestia_earth/models/mocking/search-results.json +1113 -1113
- hestia_earth/models/pooreNemecek2018/utils.py +8 -2
- hestia_earth/models/schmidt2007/ch4ToAirWasteTreatment.py +1 -4
- hestia_earth/models/schmidt2007/h2SToAirWasteTreatment.py +1 -4
- hestia_earth/models/schmidt2007/n2OToAirWasteTreatmentDirect.py +1 -4
- hestia_earth/models/schmidt2007/nh3ToAirWasteTreatment.py +1 -4
- hestia_earth/models/site/grouped_measurement.py +132 -0
- hestia_earth/models/utils/__init__.py +4 -3
- hestia_earth/models/utils/background_emissions.py +52 -0
- hestia_earth/models/utils/blank_node.py +47 -14
- hestia_earth/models/utils/constant.py +26 -20
- hestia_earth/models/utils/impact_assessment.py +26 -17
- hestia_earth/models/utils/lookup.py +48 -39
- hestia_earth/models/utils/measurement.py +3 -3
- hestia_earth/models/utils/product.py +39 -1
- hestia_earth/models/utils/property.py +14 -6
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.70.0.dist-info → hestia_earth_models-0.70.2.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.70.0.dist-info → hestia_earth_models-0.70.2.dist-info}/RECORD +187 -171
- tests/models/aware/test_scarcityWeightedWaterUse.py +1 -12
- tests/models/ecoalimV9/__init__.py +0 -0
- tests/models/ecoalimV9/test_cycle.py +21 -0
- tests/models/ecoalimV9/test_impact_assessment.py +24 -0
- tests/models/environmentalFootprintV3_1/test_scarcityWeightedWaterUse.py +4 -2
- tests/models/{cycle → hestia}/test_aboveGroundCropResidue.py +1 -1
- tests/models/{cycle → hestia}/test_aboveGroundCropResidueTotal.py +1 -1
- tests/models/{site → hestia}/test_brackishWater.py +1 -1
- tests/models/{site → hestia}/test_cationExchangeCapacityPerKgSoil.py +1 -1
- tests/models/{cycle → hestia}/test_coldCarcassWeightPerHead.py +1 -1
- tests/models/{cycle → hestia}/test_coldDressedCarcassWeightPerHead.py +1 -1
- tests/models/{cycle → hestia}/test_concentrateFeed.py +1 -1
- tests/models/{cycle → hestia}/test_cropResidueManagement.py +1 -1
- tests/models/{cycle → hestia}/test_croppingIntensity.py +1 -1
- tests/models/{cycle → hestia}/test_energyContentLowerHeatingValue.py +5 -3
- tests/models/{cycle → hestia}/test_excretaKgMass.py +1 -1
- tests/models/{cycle → hestia}/test_excretaKgN.py +1 -1
- tests/models/{cycle → hestia}/test_excretaKgVs.py +1 -1
- tests/models/{cycle → hestia}/test_feedConversionRatio.py +3 -4
- tests/models/{site → hestia}/test_flowingWater.py +1 -1
- tests/models/{site → hestia}/test_freshWater.py +1 -1
- tests/models/{cycle → hestia}/test_inorganicFertiliser.py +1 -1
- tests/models/{cycle → hestia}/test_irrigatedTypeUnspecified.py +2 -5
- tests/models/hestia/test_landCover.py +4 -34
- tests/models/{cycle → hestia}/test_liveAnimal.py +1 -1
- tests/models/{cycle → hestia}/test_longFallowRatio.py +1 -1
- tests/models/{site → hestia}/test_management.py +1 -1
- tests/models/{cycle → hestia}/test_materialsAndSubstrate.py +1 -1
- tests/models/{cycle → hestia}/test_milkYield.py +1 -1
- tests/models/{site → hestia}/test_netPrimaryProduction.py +1 -1
- tests/models/{site → hestia}/test_organicCarbonPerHa.py +1 -1
- tests/models/{site → hestia}/test_organicCarbonPerKgSoil.py +1 -1
- tests/models/{site → hestia}/test_organicCarbonPerM3Soil.py +1 -1
- tests/models/{site → hestia}/test_organicMatterPerKgSoil.py +1 -1
- tests/models/{site → hestia}/test_organicMatterPerM3Soil.py +1 -1
- tests/models/hestia/test_pToSurfaceWaterAquacultureSystems.py +56 -0
- tests/models/{cycle → hestia}/test_pastureGrass.py +1 -1
- tests/models/{cycle → hestia}/test_pastureSystem.py +1 -1
- tests/models/{site → hestia}/test_potentialEvapotranspirationAnnual.py +1 -1
- tests/models/{site → hestia}/test_potentialEvapotranspirationMonthly.py +1 -1
- tests/models/{site → hestia}/test_precipitationAnnual.py +1 -1
- tests/models/{site → hestia}/test_precipitationMonthly.py +1 -1
- tests/models/{site → hestia}/test_rainfallAnnual.py +1 -1
- tests/models/{site → hestia}/test_rainfallMonthly.py +1 -1
- tests/models/{cycle → hestia}/test_readyToCookWeightPerHead.py +1 -1
- tests/models/{cycle → hestia}/test_residueBurnt.py +1 -1
- tests/models/{cycle → hestia}/test_residueIncorporated.py +1 -1
- tests/models/{cycle → hestia}/test_residueLeftOnField.py +1 -1
- tests/models/hestia/test_residueRemoved.py +15 -3
- tests/models/{site → hestia}/test_salineWater.py +1 -1
- tests/models/{site → hestia}/test_soilMeasurement.py +13 -21
- tests/models/{cycle → hestia}/test_stockingDensityAnimalHousingAverage.py +1 -1
- tests/models/{site → hestia}/test_temperatureAnnual.py +1 -1
- tests/models/{site → hestia}/test_temperatureMonthly.py +1 -1
- tests/models/{site → hestia}/test_totalNitrogenPerKgSoil.py +1 -1
- tests/models/{cycle → hestia}/test_unknownPreSeasonWaterRegime.py +1 -1
- tests/models/{site → hestia}/test_waterDepth.py +1 -1
- tests/models/hestia/test_waterSalinity.py +26 -0
- tests/models/ipcc2019/test_ch4ToAirEntericFermentation.py +2 -5
- tests/models/ipcc2019/test_ch4ToAirFloodedRice.py +10 -42
- tests/models/ipcc2019/test_ch4ToAirOrganicSoilCultivation.py +61 -0
- tests/models/ipcc2019/test_co2ToAirAboveGroundBiomassStockChange.py +11 -9
- tests/models/ipcc2019/test_co2ToAirBelowGroundBiomassStockChange.py +10 -8
- tests/models/ipcc2019/test_co2ToAirLimeHydrolysis.py +1 -1
- tests/models/ipcc2019/test_co2ToAirOrganicSoilCultivation.py +62 -0
- tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py +11 -8
- tests/models/ipcc2019/test_n2OToAirOrganicSoilCultivationDirect.py +61 -0
- tests/models/ipcc2019/test_nonCo2EmissionsToAirNaturalVegetationBurning.py +3 -2
- tests/models/site/test_grouped_measurement.py +20 -0
- tests/models/test_ecoinventV3AndEmberClimate.py +2 -2
- tests/models/test_emissionNotRelevant.py +0 -8
- tests/models/utils/test_measurement.py +1 -1
- hestia_earth/models/cycle/residueRemoved.py +0 -54
- hestia_earth/models/hestia/nh3ToSurfaceWaterAquacultureSystems.py +0 -64
- hestia_earth/models/site/utils.py +0 -93
- tests/models/cycle/test_residueRemoved.py +0 -37
- tests/models/hestia/test_nh3ToSurfaceWaterAquacultureSystems.py +0 -51
- /hestia_earth/models/{cycle → hestia}/feedConversionRatio/feedConversionRatioCarbon.py +0 -0
- /hestia_earth/models/{cycle → hestia}/feedConversionRatio/feedConversionRatioDryMatter.py +0 -0
- /hestia_earth/models/{cycle → hestia}/feedConversionRatio/feedConversionRatioEnergy.py +0 -0
- /hestia_earth/models/{cycle → hestia}/feedConversionRatio/feedConversionRatioFedWeight.py +0 -0
- /hestia_earth/models/{cycle → hestia}/feedConversionRatio/feedConversionRatioNitrogen.py +0 -0
- /hestia_earth/models/{site → hestia}/organicCarbonPerKgSoil.py +0 -0
- /hestia_earth/models/{site → hestia}/organicCarbonPerM3Soil.py +0 -0
- /hestia_earth/models/{site → hestia}/organicMatterPerKgSoil.py +0 -0
- /hestia_earth/models/{site → hestia}/organicMatterPerM3Soil.py +0 -0
- {hestia_earth_models-0.70.0.dist-info → hestia_earth_models-0.70.2.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.70.0.dist-info → hestia_earth_models-0.70.2.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.70.0.dist-info → hestia_earth_models-0.70.2.dist-info}/top_level.txt +0 -0
@@ -26,7 +26,8 @@ def _factor_value(model: str, term_id: str, lookup_name: str, lookup_col: str, g
|
|
26
26
|
coefficient = get_region_lookup_value(lookup_name, node_term_id, lookup_col, model=model, term=term_id)
|
27
27
|
# value is either a number or matching between a model and a value (restrict value to specific model only)
|
28
28
|
coefficient = safe_parse_float(
|
29
|
-
extract_grouped_data(coefficient, grouped_data_key),
|
29
|
+
extract_grouped_data(coefficient, grouped_data_key),
|
30
|
+
default=None
|
30
31
|
) if ':' in str(coefficient) else safe_parse_float(coefficient, None)
|
31
32
|
if value is not None and coefficient is not None:
|
32
33
|
if model:
|
@@ -39,43 +40,15 @@ def _factor_value(model: str, term_id: str, lookup_name: str, lookup_col: str, g
|
|
39
40
|
return get_value
|
40
41
|
|
41
42
|
|
42
|
-
def all_factor_value(
|
43
|
-
model: str,
|
44
|
-
term_id: str,
|
45
|
-
node: dict,
|
46
|
-
lookup_name: str,
|
47
|
-
lookup_col: str,
|
48
|
-
blank_nodes: List[dict],
|
49
|
-
grouped_key: Optional[str] = None,
|
50
|
-
default_no_values=0
|
51
|
-
):
|
52
|
-
values = list(map(_factor_value(model, term_id, lookup_name, lookup_col, grouped_key), blank_nodes))
|
53
|
-
|
54
|
-
has_values = len(values) > 0
|
55
|
-
missing_values = set([v.get('id') for v in values if v.get('value') and v.get('coefficient') is None])
|
56
|
-
all_with_factors = not missing_values
|
57
|
-
|
58
|
-
for missing_value in missing_values:
|
59
|
-
debugMissingLookup(lookup_name, 'termid', missing_value, lookup_col, None, model=model, term=term_id)
|
60
|
-
|
61
|
-
debugValues(node, model=model, term=term_id,
|
62
|
-
all_with_factors=all_with_factors,
|
63
|
-
missing_lookup_factor=';'.join(missing_values),
|
64
|
-
has_values=has_values,
|
65
|
-
values_used=log_as_table(values))
|
66
|
-
|
67
|
-
values = [float((v.get('value') or 0) * (v.get('coefficient') or 0)) for v in values]
|
68
|
-
|
69
|
-
# fail if some factors are missing
|
70
|
-
return None if not all_with_factors else (list_sum(values) if has_values else default_no_values)
|
71
|
-
|
72
|
-
|
73
43
|
def _term_factor_value(model: str, term_id: str, lookup_name: str, lookup_term_id: str, group_key: str = None):
|
74
44
|
def get_value(data: dict):
|
75
45
|
node_term_id = data.get('term', {}).get('@id')
|
76
46
|
value = _node_value(data)
|
77
47
|
coefficient = get_region_lookup_value(lookup_name, lookup_term_id, node_term_id, model=model, term=term_id)
|
78
|
-
coefficient = safe_parse_float(
|
48
|
+
coefficient = safe_parse_float(
|
49
|
+
extract_grouped_data(coefficient, group_key) if group_key else coefficient,
|
50
|
+
default=None
|
51
|
+
)
|
79
52
|
if value is not None and coefficient is not None:
|
80
53
|
debugValues(data, model=model, term=term_id,
|
81
54
|
node=node_term_id,
|
@@ -90,23 +63,59 @@ def _aware_factor_value(model: str, term_id: str, lookup_name: str, aware_id: st
|
|
90
63
|
lookup_col = column_name('awareWaterBasinId')
|
91
64
|
|
92
65
|
def get_value(data: dict):
|
66
|
+
node_term_id = data.get('term', {}).get('@id')
|
67
|
+
value = _node_value(data)
|
68
|
+
|
93
69
|
try:
|
94
|
-
node_term_id = data.get('term', {}).get('@id')
|
95
|
-
value = _node_value(data)
|
96
70
|
coefficient = _get_single_table_value(lookup, lookup_col, int(aware_id), column_name(node_term_id))
|
97
|
-
coefficient = safe_parse_float(
|
71
|
+
coefficient = safe_parse_float(
|
72
|
+
extract_grouped_data(coefficient, group_key),
|
73
|
+
default=None
|
74
|
+
) if group_key else coefficient
|
98
75
|
if value is not None and coefficient is not None:
|
99
76
|
debugValues(data, model=model, term=term_id,
|
100
77
|
node=node_term_id,
|
101
78
|
value=value,
|
102
79
|
coefficient=coefficient)
|
103
|
-
return value * coefficient
|
104
|
-
return None
|
105
80
|
except ValueError: # factor does not exist
|
106
|
-
|
81
|
+
coefficient = None
|
82
|
+
|
83
|
+
return {'id': node_term_id, 'value': value, 'coefficient': coefficient}
|
107
84
|
return get_value
|
108
85
|
|
109
86
|
|
87
|
+
def all_factor_value(
|
88
|
+
model: str,
|
89
|
+
term_id: str,
|
90
|
+
node: dict,
|
91
|
+
lookup_name: str,
|
92
|
+
lookup_col: str,
|
93
|
+
blank_nodes: List[dict],
|
94
|
+
grouped_key: Optional[str] = None,
|
95
|
+
default_no_values=0,
|
96
|
+
factor_value_func=_factor_value
|
97
|
+
):
|
98
|
+
values = list(map(factor_value_func(model, term_id, lookup_name, lookup_col, grouped_key), blank_nodes))
|
99
|
+
|
100
|
+
has_values = len(values) > 0
|
101
|
+
missing_values = set([v.get('id') for v in values if v.get('value') and v.get('coefficient') is None])
|
102
|
+
all_with_factors = not missing_values
|
103
|
+
|
104
|
+
for missing_value in missing_values:
|
105
|
+
debugMissingLookup(lookup_name, 'termid', missing_value, lookup_col, None, model=model, term=term_id)
|
106
|
+
|
107
|
+
debugValues(node, model=model, term=term_id,
|
108
|
+
all_with_factors=all_with_factors,
|
109
|
+
missing_lookup_factor=';'.join(missing_values),
|
110
|
+
has_values=has_values,
|
111
|
+
values_used=log_as_table(values))
|
112
|
+
|
113
|
+
values = [float((v.get('value') or 0) * (v.get('coefficient') or 0)) for v in values]
|
114
|
+
|
115
|
+
# fail if some factors are missing
|
116
|
+
return None if not all_with_factors else (list_sum(values) if has_values else default_no_values)
|
117
|
+
|
118
|
+
|
110
119
|
def _country_in_lookup(country_id: str):
|
111
120
|
def in_lookup(lookup_name: str):
|
112
121
|
return (
|
@@ -10,7 +10,7 @@ from hestia_earth.utils.date import diff_in_days
|
|
10
10
|
|
11
11
|
from . import flatten_args
|
12
12
|
from .blank_node import most_relevant_blank_node_by_id
|
13
|
-
from .method import
|
13
|
+
from .method import include_method
|
14
14
|
from .term import download_term, get_lookup_value
|
15
15
|
|
16
16
|
|
@@ -26,10 +26,10 @@ MEASUREMENT_REDUCE = {
|
|
26
26
|
MEASUREMENT_METHOD_CLASSIFICATIONS = [e.value for e in MeasurementMethodClassification]
|
27
27
|
|
28
28
|
|
29
|
-
def _new_measurement(term,
|
29
|
+
def _new_measurement(term, method=None):
|
30
30
|
node = {'@type': SchemaType.MEASUREMENT.value}
|
31
31
|
node['term'] = linked_node(term if isinstance(term, dict) else download_term(term))
|
32
|
-
return
|
32
|
+
return include_method(node, term_id=method)
|
33
33
|
|
34
34
|
|
35
35
|
def measurement_value(measurement: dict, is_larger_unit: bool = False) -> float:
|
@@ -166,6 +166,12 @@ PRODUCT_UNITS_CONVERSIONS = {
|
|
166
166
|
],
|
167
167
|
Units.KG_VS.value: [
|
168
168
|
('volatileSolidsContent', True)
|
169
|
+
],
|
170
|
+
Units.KG_P.value: [
|
171
|
+
('phosphorusContentAsP', True)
|
172
|
+
],
|
173
|
+
Units.KG_P2O5.value: [
|
174
|
+
('phosphateContentAsP2O5', True)
|
169
175
|
]
|
170
176
|
},
|
171
177
|
Units.KG_N.value: {
|
@@ -175,6 +181,14 @@ PRODUCT_UNITS_CONVERSIONS = {
|
|
175
181
|
Units.KG_VS.value: [
|
176
182
|
('nitrogenContent', False),
|
177
183
|
('volatileSolidsContent', True)
|
184
|
+
],
|
185
|
+
Units.KG_P.value: [
|
186
|
+
('nitrogenContent', False),
|
187
|
+
('phosphorusContentAsP', True)
|
188
|
+
],
|
189
|
+
Units.KG_P2O5.value: [
|
190
|
+
('nitrogenContent', False),
|
191
|
+
('phosphateContentAsP2O5', True)
|
178
192
|
]
|
179
193
|
},
|
180
194
|
Units.KG_VS.value: {
|
@@ -215,6 +229,12 @@ PRODUCT_UNITS_CONVERSIONS = {
|
|
215
229
|
],
|
216
230
|
True
|
217
231
|
)
|
232
|
+
],
|
233
|
+
Units.KG_P.value: [
|
234
|
+
('phosphorusContentAsP', True)
|
235
|
+
],
|
236
|
+
Units.KG_P2O5.value: [
|
237
|
+
('phosphateContentAsP2O5', True)
|
218
238
|
]
|
219
239
|
},
|
220
240
|
Units.KG_COLD_CARCASS_WEIGHT.value: {
|
@@ -225,6 +245,12 @@ PRODUCT_UNITS_CONVERSIONS = {
|
|
225
245
|
Units.KG_COLD_CARCASS_WEIGHT.value: [],
|
226
246
|
Units.KG_READY_TO_COOK_WEIGHT.value: [
|
227
247
|
('processingConversionColdCarcassWeightToReadyToCookWeight', True)
|
248
|
+
],
|
249
|
+
Units.KG_P.value: [
|
250
|
+
('phosphorusContentAsP', True)
|
251
|
+
],
|
252
|
+
Units.KG_P2O5.value: [
|
253
|
+
('phosphateContentAsP2O5', True)
|
228
254
|
]
|
229
255
|
},
|
230
256
|
Units.KG_COLD_DRESSED_CARCASS_WEIGHT.value: {
|
@@ -237,6 +263,12 @@ PRODUCT_UNITS_CONVERSIONS = {
|
|
237
263
|
Units.KG_COLD_CARCASS_WEIGHT.value: [],
|
238
264
|
Units.KG_READY_TO_COOK_WEIGHT.value: [
|
239
265
|
('processingConversionColdDressedCarcassWeightToReadyToCookWeight', True)
|
266
|
+
],
|
267
|
+
Units.KG_P.value: [
|
268
|
+
('phosphorusContentAsP', True)
|
269
|
+
],
|
270
|
+
Units.KG_P2O5.value: [
|
271
|
+
('phosphateContentAsP2O5', True)
|
240
272
|
]
|
241
273
|
},
|
242
274
|
Units.KG_READY_TO_COOK_WEIGHT.value: {
|
@@ -262,7 +294,13 @@ PRODUCT_UNITS_CONVERSIONS = {
|
|
262
294
|
Units.KG_COLD_DRESSED_CARCASS_WEIGHT.value: [
|
263
295
|
('processingConversionColdDressedCarcassWeightToReadyToCookWeight', False)
|
264
296
|
],
|
265
|
-
Units.KG_READY_TO_COOK_WEIGHT.value: []
|
297
|
+
Units.KG_READY_TO_COOK_WEIGHT.value: [],
|
298
|
+
Units.KG_P.value: [
|
299
|
+
('phosphorusContentAsP', True)
|
300
|
+
],
|
301
|
+
Units.KG_P2O5.value: [
|
302
|
+
('phosphateContentAsP2O5', True)
|
303
|
+
]
|
266
304
|
},
|
267
305
|
Units.HEAD.value: {
|
268
306
|
Units.KG_LIVEWEIGHT.value: [
|
@@ -50,7 +50,12 @@ def find_term_property(term, property: str, default=None) -> dict:
|
|
50
50
|
return find_term_match(props, property, default)
|
51
51
|
|
52
52
|
|
53
|
-
def get_node_property(
|
53
|
+
def get_node_property(
|
54
|
+
node: dict,
|
55
|
+
property: str,
|
56
|
+
find_default_property: bool = True,
|
57
|
+
download_from_hestia: bool = False
|
58
|
+
) -> dict:
|
54
59
|
"""
|
55
60
|
Get the property by `@id` linked to the Blank Node in the glossary.
|
56
61
|
|
@@ -66,6 +71,8 @@ def get_node_property(node: dict, property: str, find_default_property: bool = T
|
|
66
71
|
The `term.@id` of the property. Example: `nitrogenContent`.
|
67
72
|
find_default_property : bool
|
68
73
|
Default to fetching the property from the `defaultProperties` of the `Term`.
|
74
|
+
download_from_hestia : bool
|
75
|
+
Default to downloading the Term from HESTIA.
|
69
76
|
|
70
77
|
Returns
|
71
78
|
-------
|
@@ -76,7 +83,9 @@ def get_node_property(node: dict, property: str, find_default_property: bool = T
|
|
76
83
|
return find_term_property(node.get('term', {}), property, {}) if all([
|
77
84
|
find_default_property,
|
78
85
|
prop is None
|
79
|
-
]) else (
|
86
|
+
]) else (
|
87
|
+
prop or ({'term': download_term(property, TermTermType.PROPERTY)} if download_from_hestia else {})
|
88
|
+
)
|
80
89
|
|
81
90
|
|
82
91
|
def node_has_no_property(term_id: str):
|
@@ -91,9 +100,8 @@ def node_property_lookup_value(model: str, node_term: dict, prop_id: str, defaul
|
|
91
100
|
# as the lookup table might not exist, we are making sure we return `0` in thise case
|
92
101
|
try:
|
93
102
|
lookup_name = f"{node_term.get('termType')}-property.csv"
|
94
|
-
lookup = download_lookup(lookup_name)
|
95
103
|
term_id = node_term.get('@id')
|
96
|
-
lookup_value = get_table_value(
|
104
|
+
lookup_value = get_table_value(download_lookup(lookup_name), 'termid', term_id, column_name(prop_id))
|
97
105
|
value = extract_grouped_data(lookup_value, 'Avg') if (
|
98
106
|
isinstance(lookup_value, str) and 'Avg' in lookup_value
|
99
107
|
) else lookup_value
|
@@ -104,8 +112,8 @@ def node_property_lookup_value(model: str, node_term: dict, prop_id: str, defaul
|
|
104
112
|
|
105
113
|
|
106
114
|
def get_node_property_value(model: str, node: dict, prop_id: str, default=None, handle_percents=True, **log_args):
|
107
|
-
prop = get_node_property(node, prop_id)
|
108
|
-
term = (prop or {}).get('term')
|
115
|
+
prop = get_node_property(node, prop_id, download_from_hestia=True)
|
116
|
+
term = (prop or {}).get('term')
|
109
117
|
units = (term or {}).get('units')
|
110
118
|
value = prop.get('value') if prop else node_property_lookup_value(model, node.get('term', {}), prop_id, **log_args)
|
111
119
|
return default if value is None else (value / 100 if units == '%' and handle_percents else value)
|
hestia_earth/models/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
VERSION = '0.70.
|
1
|
+
VERSION = '0.70.2'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: hestia-earth-models
|
3
|
-
Version: 0.70.
|
3
|
+
Version: 0.70.2
|
4
4
|
Summary: HESTIA's set of modules for filling gaps in the activity data using external datasets (e.g. populating soil properties with a geospatial dataset using provided coordinates) and internal lookups (e.g. populating machinery use from fuel use). Includes rules for when gaps should be filled versus not (e.g. never gap fill yield, gap fill crop residue if yield provided etc.).
|
5
5
|
Home-page: https://gitlab.com/hestia-earth/hestia-engine-models
|
6
6
|
Author: HESTIA Team
|
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3.6
|
|
12
12
|
Description-Content-Type: text/markdown
|
13
13
|
License-File: LICENSE
|
14
14
|
Requires-Dist: hestia-earth-schema==31.*
|
15
|
-
Requires-Dist: hestia-earth-utils>=0.14.
|
15
|
+
Requires-Dist: hestia-earth-utils>=0.14.1
|
16
16
|
Requires-Dist: python-dateutil>=2.8.1
|
17
17
|
Requires-Dist: CurrencyConverter==0.16.8
|
18
18
|
Requires-Dist: haversine>=2.7.0
|