hestia-earth-models 0.64.8__py3-none-any.whl → 0.64.10__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.
Potentially problematic release.
This version of hestia-earth-models might be problematic. Click here for more details.
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionFossilFuels.py +175 -0
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionMineralsAndMetals.py +136 -0
- hestia_earth/models/cycle/siteArea.py +2 -1
- hestia_earth/models/environmentalFootprintV3/soilQualityIndexLandOccupation.py +73 -82
- hestia_earth/models/environmentalFootprintV3/soilQualityIndexLandTransformation.py +102 -116
- hestia_earth/models/environmentalFootprintV3/soilQualityIndexTotalLandUseEffects.py +27 -16
- hestia_earth/models/faostat2018/landTransformationFromCropland100YearAverage.py +3 -2
- hestia_earth/models/faostat2018/landTransformationFromCropland20YearAverage.py +3 -2
- hestia_earth/models/frischknechtEtAl2000/ionisingRadiationKbqU235Eq.py +69 -37
- hestia_earth/models/ipcc2019/aboveGroundBiomass.py +31 -243
- hestia_earth/models/ipcc2019/animal/fatContent.py +38 -0
- hestia_earth/models/ipcc2019/animal/liveweightGain.py +3 -54
- hestia_earth/models/ipcc2019/animal/liveweightPerHead.py +3 -54
- hestia_earth/models/ipcc2019/animal/pregnancyRateTotal.py +38 -0
- hestia_earth/models/ipcc2019/animal/trueProteinContent.py +38 -0
- hestia_earth/models/ipcc2019/animal/utils.py +87 -3
- hestia_earth/models/ipcc2019/animal/weightAtMaturity.py +4 -10
- hestia_earth/models/ipcc2019/belowGroundBiomass.py +529 -0
- hestia_earth/models/ipcc2019/biomass_utils.py +406 -0
- hestia_earth/models/ipcc2019/{co2ToAirAboveGroundBiomassStockChangeLandUseChange.py → co2ToAirAboveGroundBiomassStockChange.py} +19 -7
- hestia_earth/models/ipcc2019/{co2ToAirBelowGroundBiomassStockChangeLandUseChange.py → co2ToAirBelowGroundBiomassStockChange.py} +19 -7
- hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +402 -73
- hestia_earth/models/ipcc2019/{co2ToAirSoilOrganicCarbonStockChangeManagementChange.py → co2ToAirSoilOrganicCarbonStockChange.py} +20 -8
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py +3 -1
- hestia_earth/models/ipcc2019/pastureGrass_utils.py +6 -7
- hestia_earth/models/lcImpactAllEffects100Years/damageToFreshwaterEcosystemsFreshwaterEutrophication.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToFreshwaterEcosystemsWaterStress.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthParticulateMatterFormation.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthWaterStress.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToMarineEcosystemsMarineEutrophication.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToTerrestrialEcosystemsPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToTerrestrialEcosystemsTerrestrialAcidification.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToFreshwaterEcosystemsFreshwaterEutrophication.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToFreshwaterEcosystemsWaterStress.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthParticulateMatterFormation.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthWaterStress.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToMarineEcosystemsMarineEutrophication.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToTerrestrialEcosystemsPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToTerrestrialEcosystemsTerrestrialAcidification.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToFreshwaterEcosystemsFreshwaterEutrophication.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToFreshwaterEcosystemsWaterStress.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthParticulateMatterFormation.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthWaterStress.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToMarineEcosystemsMarineEutrophication.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToTerrestrialEcosystemsPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToTerrestrialEcosystemsTerrestrialAcidification.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToFreshwaterEcosystemsFreshwaterEutrophication.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToFreshwaterEcosystemsWaterStress.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthParticulateMatterFormation.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthWaterStress.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToMarineEcosystemsMarineEutrophication.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToTerrestrialEcosystemsPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToTerrestrialEcosystemsTerrestrialAcidification.py +2 -2
- hestia_earth/models/mocking/build_mock_search.py +44 -0
- hestia_earth/models/mocking/mock_search.py +8 -49
- hestia_earth/models/mocking/search-results.json +3078 -575
- hestia_earth/models/poschEtAl2008/terrestrialAcidificationPotentialAccumulatedExceedance.py +6 -3
- hestia_earth/models/poschEtAl2008/terrestrialEutrophicationPotentialAccumulatedExceedance.py +6 -3
- hestia_earth/models/preload_requests.py +1 -1
- hestia_earth/models/schmidt2007/utils.py +13 -4
- hestia_earth/models/utils/__init__.py +5 -4
- hestia_earth/models/utils/blank_node.py +73 -3
- hestia_earth/models/utils/constant.py +8 -1
- hestia_earth/models/utils/cycle.py +10 -13
- hestia_earth/models/utils/fuel.py +1 -1
- hestia_earth/models/utils/impact_assessment.py +39 -15
- hestia_earth/models/utils/lookup.py +36 -7
- hestia_earth/models/utils/pesticideAI.py +1 -1
- hestia_earth/models/utils/property.py +11 -4
- hestia_earth/models/utils/term.py +15 -8
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.64.8.dist-info → hestia_earth_models-0.64.10.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.64.8.dist-info → hestia_earth_models-0.64.10.dist-info}/RECORD +103 -90
- {hestia_earth_models-0.64.8.dist-info → hestia_earth_models-0.64.10.dist-info}/WHEEL +1 -1
- tests/models/cml2001Baseline/test_abioticResourceDepletionFossilFuels.py +196 -0
- tests/models/cml2001Baseline/test_abioticResourceDepletionMineralsAndMetals.py +124 -0
- tests/models/edip2003/test_ozoneDepletionPotential.py +1 -13
- tests/models/environmentalFootprintV3/test_soilQualityIndexLandOccupation.py +97 -66
- tests/models/environmentalFootprintV3/test_soilQualityIndexLandTransformation.py +136 -74
- tests/models/environmentalFootprintV3/test_soilQualityIndexTotalLandUseEffects.py +15 -10
- tests/models/frischknechtEtAl2000/test_ionisingRadiationKbqU235Eq.py +67 -44
- tests/models/impact_assessment/test_emissions.py +1 -0
- tests/models/ipcc2019/animal/test_fatContent.py +22 -0
- tests/models/ipcc2019/animal/test_liveweightGain.py +4 -2
- tests/models/ipcc2019/animal/test_liveweightPerHead.py +4 -2
- tests/models/ipcc2019/animal/test_pregnancyRateTotal.py +22 -0
- tests/models/ipcc2019/animal/test_trueProteinContent.py +22 -0
- tests/models/ipcc2019/animal/test_weightAtMaturity.py +2 -1
- tests/models/ipcc2019/test_aboveGroundBiomass.py +27 -63
- tests/models/ipcc2019/test_belowGroundBiomass.py +146 -0
- tests/models/ipcc2019/test_biomass_utils.py +115 -0
- tests/models/ipcc2019/{test_co2ToAirAboveGroundBiomassStockChangeLandUseChange.py → test_co2ToAirAboveGroundBiomassStockChange.py} +5 -5
- tests/models/ipcc2019/{test_co2ToAirBelowGroundBiomassStockChangeLandUseChange.py → test_co2ToAirBelowGroundBiomassStockChange.py} +5 -5
- tests/models/ipcc2019/{test_co2ToAirSoilOrganicCarbonStockChangeManagementChange.py → test_co2ToAirSoilOrganicCarbonStockChange.py} +5 -5
- tests/models/ipcc2021/test_gwp100.py +2 -2
- tests/models/poschEtAl2008/test_terrestrialAcidificationPotentialAccumulatedExceedance.py +30 -17
- tests/models/poschEtAl2008/test_terrestrialEutrophicationPotentialAccumulatedExceedance.py +28 -14
- hestia_earth/models/ipcc2019/aboveGroundBiomass_utils.py +0 -180
- tests/models/ipcc2019/test_aboveGroundBiomass_utils.py +0 -92
- {hestia_earth_models-0.64.8.dist-info → hestia_earth_models-0.64.10.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.64.8.dist-info → hestia_earth_models-0.64.10.dist-info}/top_level.txt +0 -0
|
@@ -4,6 +4,7 @@ from hestia_earth.models.log import logRequirements, logShouldRun
|
|
|
4
4
|
from hestia_earth.models.utils.blank_node import cumulative_nodes_term_match
|
|
5
5
|
from hestia_earth.models.utils.emission import _new_emission
|
|
6
6
|
|
|
7
|
+
from .organicCarbonPerHa_tier_1_utils import _assign_ipcc_land_use_category
|
|
7
8
|
from .co2ToAirCarbonStockChange_utils import create_run_function, create_should_run_function
|
|
8
9
|
from . import MODEL
|
|
9
10
|
|
|
@@ -40,7 +41,10 @@ RETURNS = {
|
|
|
40
41
|
"depth": "30"
|
|
41
42
|
}]
|
|
42
43
|
}
|
|
43
|
-
TERM_ID = 'co2ToAirSoilOrganicCarbonStockChangeManagementChange'
|
|
44
|
+
TERM_ID = 'co2ToAirSoilOrganicCarbonStockChangeLandUseChange,co2ToAirSoilOrganicCarbonStockChangeManagementChange'
|
|
45
|
+
|
|
46
|
+
_LU_EMISSION_TERM_ID = "co2ToAirSoilOrganicCarbonStockChangeLandUseChange"
|
|
47
|
+
_MG_EMISSION_TERM_ID = "co2ToAirSoilOrganicCarbonStockChangeManagementChange"
|
|
44
48
|
|
|
45
49
|
_DEPTH_UPPER = 0
|
|
46
50
|
_DEPTH_LOWER = 30
|
|
@@ -57,6 +61,7 @@ _SITE_TYPE_SYSTEMS_MAPPING = {
|
|
|
57
61
|
|
|
58
62
|
def _emission(
|
|
59
63
|
*,
|
|
64
|
+
term_id: str,
|
|
60
65
|
value: list[float],
|
|
61
66
|
method_tier: EmissionMethodTier,
|
|
62
67
|
sd: list[float] = None,
|
|
@@ -94,7 +99,7 @@ def _emission(
|
|
|
94
99
|
"methodTier": method_tier.value,
|
|
95
100
|
"depth": _DEPTH_LOWER
|
|
96
101
|
}
|
|
97
|
-
emission = _new_emission(
|
|
102
|
+
emission = _new_emission(term_id, MODEL) | {
|
|
98
103
|
key: value for key, value in update_dict.items() if value
|
|
99
104
|
}
|
|
100
105
|
return emission
|
|
@@ -115,17 +120,24 @@ def run(cycle: dict) -> list[dict]:
|
|
|
115
120
|
A list of [Emission nodes](https://www.hestia.earth/schema/Emission) containing model results.
|
|
116
121
|
"""
|
|
117
122
|
should_run_exec = create_should_run_function(
|
|
118
|
-
_CARBON_STOCK_TERM_ID,
|
|
119
|
-
_should_compile_inventory_func,
|
|
120
|
-
|
|
123
|
+
carbon_stock_term_id=_CARBON_STOCK_TERM_ID,
|
|
124
|
+
should_compile_inventory_func=_should_compile_inventory_func,
|
|
125
|
+
summarise_land_use_func=lambda nodes: _assign_ipcc_land_use_category(nodes, None),
|
|
126
|
+
detect_land_use_change_func=lambda a, b: a != b,
|
|
127
|
+
should_run_measurement_func=_should_run_measurement_func,
|
|
121
128
|
)
|
|
122
129
|
|
|
123
|
-
run_exec = create_run_function(
|
|
130
|
+
run_exec = create_run_function(
|
|
131
|
+
new_emission_func=_emission,
|
|
132
|
+
land_use_change_emission_term_id=_LU_EMISSION_TERM_ID,
|
|
133
|
+
management_change_emission_term_id=_MG_EMISSION_TERM_ID
|
|
134
|
+
)
|
|
124
135
|
|
|
125
136
|
should_run, cycle_id, inventory, logs = should_run_exec(cycle)
|
|
126
137
|
|
|
127
|
-
|
|
128
|
-
|
|
138
|
+
for term_id in [_LU_EMISSION_TERM_ID, _MG_EMISSION_TERM_ID]:
|
|
139
|
+
logRequirements(cycle, model=MODEL, term=term_id, **logs)
|
|
140
|
+
logShouldRun(cycle, MODEL, term_id, should_run)
|
|
129
141
|
|
|
130
142
|
return run_exec(cycle_id, inventory) if should_run else []
|
|
131
143
|
|
|
@@ -24,7 +24,6 @@ from . import MODEL # noqa
|
|
|
24
24
|
|
|
25
25
|
REQUIREMENTS = {
|
|
26
26
|
"Site": {
|
|
27
|
-
"siteType": ["cropland", "permanent pasture", "forest", "other natural vegetation"],
|
|
28
27
|
"management": [
|
|
29
28
|
{"@type": "Management", "value": "", "term.termType": "landCover"}
|
|
30
29
|
],
|
|
@@ -88,6 +87,9 @@ REQUIREMENTS = {
|
|
|
88
87
|
},
|
|
89
88
|
{"@type": "Management", "value": "", "startDate": "", "endDate": "", "term.@id": "shortBareFallow"}
|
|
90
89
|
]
|
|
90
|
+
},
|
|
91
|
+
"none": {
|
|
92
|
+
"siteType": ["glass or high accessible cover"]
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
}
|
|
@@ -4,6 +4,7 @@ from hestia_earth.utils.lookup import download_lookup, get_table_value, column_n
|
|
|
4
4
|
from hestia_earth.utils.tools import list_sum, safe_parse_float
|
|
5
5
|
|
|
6
6
|
from hestia_earth.models.log import debugValues
|
|
7
|
+
from hestia_earth.models.utils import weighted_average
|
|
7
8
|
from hestia_earth.models.utils.input import get_feed_inputs
|
|
8
9
|
from hestia_earth.models.utils.term import get_lookup_value
|
|
9
10
|
from hestia_earth.models.utils.property import get_node_property, get_node_property_value, node_property_lookup_value
|
|
@@ -30,17 +31,15 @@ def _get_activityCoefficient(animal: dict, systems: list) -> float:
|
|
|
30
31
|
term_id = term.get('@id')
|
|
31
32
|
lookup = download_lookup('system-liveAnimal-activityCoefficient-ipcc2019.csv')
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
values = [(
|
|
34
35
|
safe_parse_float(
|
|
35
36
|
get_table_value(lookup, 'termid', system.get('term', {}).get('@id'), column_name(term_id)),
|
|
36
37
|
0
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
list_sum(system.get('value', [0])) for system in systems
|
|
41
|
-
])
|
|
38
|
+
),
|
|
39
|
+
list_sum(system.get('value', [0]))
|
|
40
|
+
) for system in systems]
|
|
42
41
|
|
|
43
|
-
return
|
|
42
|
+
return weighted_average(values)
|
|
44
43
|
|
|
45
44
|
|
|
46
45
|
def _calculate_NEm(cycle: dict, animal: dict) -> float:
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv", 'allEffects')
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthParticulateMatterFormation.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthPhotochemicalOzoneFormation.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -47,5 +47,5 @@ def run(impact_assessment: dict):
|
|
|
47
47
|
)
|
|
48
48
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
49
49
|
value=value)
|
|
50
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
51
|
-
return _indicator(value)
|
|
50
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
51
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactAllEffects100Years/damageToMarineEcosystemsMarineEutrophication.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv", 'allEffects')
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthParticulateMatterFormation.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthPhotochemicalOzoneFormation.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -47,5 +47,5 @@ def run(impact_assessment: dict):
|
|
|
47
47
|
)
|
|
48
48
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
49
49
|
value=value)
|
|
50
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
51
|
-
return _indicator(value)
|
|
50
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
51
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactAllEffectsInfinite/damageToMarineEcosystemsMarineEutrophication.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactCertainEffects100Years/damageToFreshwaterEcosystemsWaterStress.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv", 'certainEffects')
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthParticulateMatterFormation.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthPhotochemicalOzoneFormation.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -47,5 +47,5 @@ def run(impact_assessment: dict):
|
|
|
47
47
|
)
|
|
48
48
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
49
49
|
value=value)
|
|
50
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
51
|
-
return _indicator(value)
|
|
50
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
51
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactCertainEffects100Years/damageToMarineEcosystemsMarineEutrophication.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactCertainEffectsInfinite/damageToFreshwaterEcosystemsWaterStress.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv", 'certainEffects')
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthParticulateMatterFormation.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthPhotochemicalOzoneFormation.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -47,5 +47,5 @@ def run(impact_assessment: dict):
|
|
|
47
47
|
)
|
|
48
48
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
49
49
|
value=value)
|
|
50
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
51
|
-
return _indicator(value)
|
|
50
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
51
|
+
return None if value is None else _indicator(value)
|
hestia_earth/models/lcImpactCertainEffectsInfinite/damageToMarineEcosystemsMarineEutrophication.py
CHANGED
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -33,5 +33,5 @@ def run(impact_assessment: dict):
|
|
|
33
33
|
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
34
34
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
35
35
|
value=value)
|
|
36
|
-
logShouldRun(impact_assessment, MODEL, TERM_ID,
|
|
37
|
-
return _indicator(value)
|
|
36
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
|
|
37
|
+
return None if value is None else _indicator(value)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from inspect import getmembers, isfunction
|
|
2
|
+
from hestia_earth.utils.tools import flatten
|
|
3
|
+
|
|
4
|
+
from hestia_earth.models.utils import term
|
|
5
|
+
|
|
6
|
+
_IGNORE_FUNC = ['get_lookup_value', 'get_table_value']
|
|
7
|
+
_original_search_func = term.search
|
|
8
|
+
_original_find_node_func = term.find_node
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _map_results(results):
|
|
12
|
+
# returning the whole term
|
|
13
|
+
return [results] if isinstance(results, dict) else (
|
|
14
|
+
{'@type': 'Term', '@id': results} if isinstance(results, str) else
|
|
15
|
+
flatten(map(_map_results, results)) if isinstance(results, list) else
|
|
16
|
+
None
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _create_search_result(data: tuple):
|
|
21
|
+
search_query = {}
|
|
22
|
+
|
|
23
|
+
def new_search(query: dict, *_a, **_b):
|
|
24
|
+
nonlocal search_query
|
|
25
|
+
search_query = query
|
|
26
|
+
return _original_search_func(query, *_a, **_b)
|
|
27
|
+
|
|
28
|
+
term.search = new_search
|
|
29
|
+
|
|
30
|
+
def new_find_node(_n, query: dict, *_a, **_b):
|
|
31
|
+
nonlocal search_query
|
|
32
|
+
search_query = query
|
|
33
|
+
return _original_find_node_func(_n, query, *_a, **_b)
|
|
34
|
+
|
|
35
|
+
term.find_node = new_find_node
|
|
36
|
+
|
|
37
|
+
function_name, func = data
|
|
38
|
+
res = func()
|
|
39
|
+
return {'name': function_name, 'query': search_query, 'results': _map_results(res)}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def create_search_results():
|
|
43
|
+
funcs = list(filter(lambda v: v[0].startswith('get_') and not v[0] in _IGNORE_FUNC, getmembers(term, isfunction)))
|
|
44
|
+
return list(map(_create_search_result, funcs))
|
|
@@ -1,48 +1,9 @@
|
|
|
1
|
-
from inspect import getmembers, isfunction
|
|
2
1
|
import json
|
|
3
|
-
from hestia_earth.utils.tools import flatten
|
|
4
2
|
|
|
5
3
|
from hestia_earth.models.utils import term
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def _map_results(results):
|
|
11
|
-
# returning the whole term
|
|
12
|
-
return [results] if isinstance(results, dict) else (
|
|
13
|
-
{'@type': 'Term', '@id': results} if isinstance(results, str) else
|
|
14
|
-
flatten(map(_map_results, results)) if isinstance(results, list) else
|
|
15
|
-
None
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def _create_search_result(data: tuple):
|
|
20
|
-
search_query = {}
|
|
21
|
-
|
|
22
|
-
original_search = term.search
|
|
23
|
-
|
|
24
|
-
def new_search(query: dict, *_a, **_b):
|
|
25
|
-
nonlocal search_query
|
|
26
|
-
search_query = query
|
|
27
|
-
return original_search(query, *_a, **_b)
|
|
28
|
-
term.search = new_search
|
|
29
|
-
|
|
30
|
-
original_find_node = term.find_node
|
|
31
|
-
|
|
32
|
-
def new_find_node(_n, query: dict, *_a, **_b):
|
|
33
|
-
nonlocal search_query
|
|
34
|
-
search_query = query
|
|
35
|
-
return original_find_node(_n, query, *_a, **_b)
|
|
36
|
-
term.find_node = new_find_node
|
|
37
|
-
|
|
38
|
-
function_name, func = data
|
|
39
|
-
res = func()
|
|
40
|
-
return {'name': function_name, 'query': search_query, 'results': _map_results(res)}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def create_search_results():
|
|
44
|
-
funcs = list(filter(lambda v: v[0].startswith('get_') and not v[0] in IGNORE_FUNC, getmembers(term, isfunction)))
|
|
45
|
-
return list(map(_create_search_result, funcs))
|
|
5
|
+
_original_search_func = term.search
|
|
6
|
+
_original_find_node_func = term.find_node
|
|
46
7
|
|
|
47
8
|
|
|
48
9
|
def _load_results(filepath: str):
|
|
@@ -56,22 +17,20 @@ def _find_search_result(filepath: str, query: dict):
|
|
|
56
17
|
return None if res is None else res.get('results', [])
|
|
57
18
|
|
|
58
19
|
|
|
59
|
-
def _mocked_search(
|
|
20
|
+
def _mocked_search(filepath: str):
|
|
60
21
|
def mock(query: dict, **kwargs):
|
|
61
22
|
result = _find_search_result(filepath, query)
|
|
62
|
-
return
|
|
23
|
+
return _original_search_func(query, **kwargs) if result is None else result
|
|
63
24
|
return mock
|
|
64
25
|
|
|
65
26
|
|
|
66
|
-
def _mocked_find_node(
|
|
27
|
+
def _mocked_find_node(filepath: str):
|
|
67
28
|
def mock(node_type: str, query: dict, **kwargs):
|
|
68
29
|
result = _find_search_result(filepath, query)
|
|
69
|
-
return
|
|
30
|
+
return _original_find_node_func(node_type, query, **kwargs) if result is None else result
|
|
70
31
|
return mock
|
|
71
32
|
|
|
72
33
|
|
|
73
34
|
def mock(filepath: str):
|
|
74
|
-
|
|
75
|
-
term.
|
|
76
|
-
original_find_node = term.find_node
|
|
77
|
-
term.find_node = _mocked_find_node(original_find_node, filepath)
|
|
35
|
+
term.search = _mocked_search(filepath)
|
|
36
|
+
term.find_node = _mocked_find_node(filepath)
|