hestia-earth-models 0.64.3__py3-none-any.whl → 0.64.4__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/fantkeEtAl2016/__init__.py +13 -0
- hestia_earth/models/fantkeEtAl2016/damageToHumanHealthParticulateMatterFormation.py +49 -0
- hestia_earth/models/frischknechtEtAl2000/__init__.py +13 -0
- hestia_earth/models/frischknechtEtAl2000/ionisingRadiationKbqU235Eq.py +90 -0
- hestia_earth/models/ipcc2019/animal/liveweightGain.py +4 -3
- hestia_earth/models/ipcc2019/animal/liveweightPerHead.py +4 -3
- hestia_earth/models/ipcc2019/animal/weightAtMaturity.py +5 -4
- hestia_earth/models/mocking/search-results.json +16 -16
- hestia_earth/models/site/soilMeasurement.py +2 -2
- hestia_earth/models/utils/emission.py +6 -2
- hestia_earth/models/utils/impact_assessment.py +10 -5
- hestia_earth/models/utils/lookup.py +5 -3
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.64.3.dist-info → hestia_earth_models-0.64.4.dist-info}/METADATA +1 -1
- {hestia_earth_models-0.64.3.dist-info → hestia_earth_models-0.64.4.dist-info}/RECORD +22 -14
- tests/models/fantkeEtAl2016/__init__.py +0 -0
- tests/models/fantkeEtAl2016/test_damageToHumanHealthParticulateMatterFormation.py +20 -0
- tests/models/frischknechtEtAl2000/__init__.py +0 -0
- tests/models/frischknechtEtAl2000/test_ionisingRadiationKbqU235Eq.py +70 -0
- {hestia_earth_models-0.64.3.dist-info → hestia_earth_models-0.64.4.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.64.3.dist-info → hestia_earth_models-0.64.4.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.64.3.dist-info → hestia_earth_models-0.64.4.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from os.path import dirname, abspath
|
|
2
|
+
import sys
|
|
3
|
+
from importlib import import_module
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.utils.blank_node import run_if_required
|
|
6
|
+
|
|
7
|
+
CURRENT_DIR = dirname(abspath(__file__)) + '/'
|
|
8
|
+
sys.path.append(CURRENT_DIR)
|
|
9
|
+
MODEL = 'fantkeEtAl2016'
|
|
10
|
+
PKG = '.'.join(['hestia_earth', 'models', MODEL])
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def run(model: str, data): return run_if_required(MODEL, model, data, import_module(f".{model}", package=PKG))
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from hestia_earth.utils.lookup import column_name
|
|
2
|
+
|
|
3
|
+
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
4
|
+
from . import MODEL
|
|
5
|
+
from ..utils.impact_assessment import impact_lookup_value
|
|
6
|
+
from ..utils.indicator import _new_indicator
|
|
7
|
+
|
|
8
|
+
REQUIREMENTS = {
|
|
9
|
+
"ImpactAssessment": {
|
|
10
|
+
"emissionsResourceUse": [
|
|
11
|
+
{
|
|
12
|
+
"@type": "Indicator", "value": "", "term.termType": "emission"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
TERM_ID = 'damageToHumanHealthParticulateMatterFormation'
|
|
19
|
+
|
|
20
|
+
LOOKUPS = {
|
|
21
|
+
"emission": "damageToHumanHealthParticulateMatterFormationFantkeEtAl2016"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
RETURNS = {
|
|
25
|
+
"Indicator": {
|
|
26
|
+
"value": ""
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
default_group_key = 'default'
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _indicator(value: float):
|
|
34
|
+
indicator = _new_indicator(TERM_ID, MODEL)
|
|
35
|
+
indicator['value'] = value
|
|
36
|
+
return indicator
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def run(impact_assessment: dict):
|
|
40
|
+
value = impact_lookup_value(model=MODEL, term_id=TERM_ID, impact=impact_assessment,
|
|
41
|
+
lookup_col=column_name(LOOKUPS['emission']),
|
|
42
|
+
grouped_key=default_group_key)
|
|
43
|
+
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
44
|
+
value=value)
|
|
45
|
+
|
|
46
|
+
should_run = all([value is not None])
|
|
47
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, should_run)
|
|
48
|
+
|
|
49
|
+
return _indicator(value) if should_run else None
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from os.path import dirname, abspath
|
|
2
|
+
import sys
|
|
3
|
+
from importlib import import_module
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.utils.blank_node import run_if_required
|
|
6
|
+
|
|
7
|
+
CURRENT_DIR = dirname(abspath(__file__)) + '/'
|
|
8
|
+
sys.path.append(CURRENT_DIR)
|
|
9
|
+
MODEL = 'frischknechtEtAl2000'
|
|
10
|
+
PKG = '.'.join(['hestia_earth', 'models', MODEL])
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def run(model: str, data): return run_if_required(MODEL, model, data, import_module(f".{model}", package=PKG))
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from functools import reduce
|
|
2
|
+
from hestia_earth.schema import TermTermType
|
|
3
|
+
from hestia_earth.utils.tools import list_sum, flatten, non_empty_list
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
6
|
+
from hestia_earth.models.utils.emission import filter_emission_inputs
|
|
7
|
+
from hestia_earth.models.utils.indicator import _new_indicator
|
|
8
|
+
from hestia_earth.models.utils.lookup import factor_value
|
|
9
|
+
from . import MODEL
|
|
10
|
+
|
|
11
|
+
REQUIREMENTS = {
|
|
12
|
+
"ImpactAssessment": {
|
|
13
|
+
"emissionsResourceUse": [{
|
|
14
|
+
"@type": "Indicator",
|
|
15
|
+
"value": "",
|
|
16
|
+
"term.@id": [
|
|
17
|
+
"ionisingCompoundsToAirInputsProduction",
|
|
18
|
+
"ionisingCompoundsToWaterInputsProduction",
|
|
19
|
+
"ionisingCompoundsToSaltwaterInputsProduction"
|
|
20
|
+
],
|
|
21
|
+
"inputs": [{"@type": "Input", "term.termType": "waste"}]
|
|
22
|
+
}]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
LOOKUPS = {
|
|
26
|
+
"waste": [
|
|
27
|
+
"ionisingCompoundsToAirInputsProduction",
|
|
28
|
+
"ionisingCompoundsToWaterInputsProduction",
|
|
29
|
+
"ionisingCompoundsToSaltwaterInputsProduction"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
RETURNS = {
|
|
33
|
+
"Indicator": {
|
|
34
|
+
"value": "",
|
|
35
|
+
"inputs": ""
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
TERM_ID = 'ionisingRadiationKbqU235Eq'
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _indicator(value: float, input: dict):
|
|
43
|
+
indicator = _new_indicator(TERM_ID, MODEL)
|
|
44
|
+
indicator['value'] = value
|
|
45
|
+
indicator['inputs'] = [input]
|
|
46
|
+
return indicator
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _run(grouped_emissions_inputs: list):
|
|
50
|
+
input = grouped_emissions_inputs[0].get('input')
|
|
51
|
+
values = [
|
|
52
|
+
factor_value(
|
|
53
|
+
model=MODEL,
|
|
54
|
+
term_id=TERM_ID,
|
|
55
|
+
lookup_name=f"{TermTermType.WASTE.value}.csv",
|
|
56
|
+
lookup_col=i.get('emission').get('term', {}).get('@id')
|
|
57
|
+
)(data=i.get('emission') | {'term': i.get('input')})
|
|
58
|
+
for i in grouped_emissions_inputs
|
|
59
|
+
]
|
|
60
|
+
value = list_sum(values)
|
|
61
|
+
return _indicator(value, input) if value else None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _should_run(impact_assessment: dict):
|
|
65
|
+
emissions = flatten([
|
|
66
|
+
([
|
|
67
|
+
{'emission': emission, 'input': input}
|
|
68
|
+
for input in filter_emission_inputs(emission, TermTermType.WASTE)
|
|
69
|
+
])
|
|
70
|
+
for emission in impact_assessment.get('emissionsResourceUse', [])
|
|
71
|
+
if emission.get('term', {}).get('@id') in LOOKUPS[TermTermType.WASTE.value]
|
|
72
|
+
])
|
|
73
|
+
emissions_per_input = reduce(
|
|
74
|
+
lambda p, c: p | {c.get('input').get('@id'): p.get(c.get('input').get('@id'), []) + [c]},
|
|
75
|
+
emissions,
|
|
76
|
+
{}
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
logRequirements(impact_assessment, model=MODEL,
|
|
80
|
+
has_emissions=bool(emissions_per_input))
|
|
81
|
+
|
|
82
|
+
should_run = all([emissions_per_input])
|
|
83
|
+
|
|
84
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, should_run)
|
|
85
|
+
return should_run, emissions_per_input
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def run(impact_assessment: dict):
|
|
89
|
+
should_run, emissions_per_input = _should_run(impact_assessment)
|
|
90
|
+
return non_empty_list(map(_run, emissions_per_input.values())) if should_run else []
|
|
@@ -65,10 +65,11 @@ def _should_run(cycle: dict):
|
|
|
65
65
|
} for animal in live_animals]
|
|
66
66
|
|
|
67
67
|
def _should_run_animal(value: dict):
|
|
68
|
+
animal = value.get('animal')
|
|
68
69
|
lookup_value = value.get('value')
|
|
69
|
-
term_id =
|
|
70
|
+
term_id = animal.get('term').get('@id')
|
|
70
71
|
|
|
71
|
-
logRequirements(cycle, model=MODEL, term=term_id,
|
|
72
|
+
logRequirements(cycle, model=MODEL, term=term_id, property=TERM_ID,
|
|
72
73
|
country_id=country_id,
|
|
73
74
|
liveweightGain=lookup_value)
|
|
74
75
|
|
|
@@ -76,7 +77,7 @@ def _should_run(cycle: dict):
|
|
|
76
77
|
country_id,
|
|
77
78
|
lookup_value is not None
|
|
78
79
|
])
|
|
79
|
-
logShouldRun(cycle, MODEL, term_id, should_run)
|
|
80
|
+
logShouldRun(cycle, MODEL, term_id, should_run, property=TERM_ID)
|
|
80
81
|
|
|
81
82
|
return should_run
|
|
82
83
|
|
|
@@ -65,10 +65,11 @@ def _should_run(cycle: dict):
|
|
|
65
65
|
} for animal in live_animals]
|
|
66
66
|
|
|
67
67
|
def _should_run_animal(value: dict):
|
|
68
|
+
animal = value.get('animal')
|
|
68
69
|
lookup_value = value.get('value')
|
|
69
|
-
term_id =
|
|
70
|
+
term_id = animal.get('term').get('@id')
|
|
70
71
|
|
|
71
|
-
logRequirements(cycle, model=MODEL, term=term_id,
|
|
72
|
+
logRequirements(cycle, model=MODEL, term=term_id, property=TERM_ID,
|
|
72
73
|
country_id=country_id,
|
|
73
74
|
liveweightPerHead=lookup_value)
|
|
74
75
|
|
|
@@ -76,7 +77,7 @@ def _should_run(cycle: dict):
|
|
|
76
77
|
country_id,
|
|
77
78
|
lookup_value is not None
|
|
78
79
|
])
|
|
79
|
-
logShouldRun(cycle, MODEL, term_id, should_run)
|
|
80
|
+
logShouldRun(cycle, MODEL, term_id, should_run, property=TERM_ID)
|
|
80
81
|
|
|
81
82
|
return should_run
|
|
82
83
|
|
|
@@ -76,12 +76,13 @@ def _should_run(cycle: dict):
|
|
|
76
76
|
} for animal in live_animals]
|
|
77
77
|
|
|
78
78
|
def _should_run_animal(value: dict):
|
|
79
|
+
animal = value.get('animal')
|
|
79
80
|
lookup_value = value.get('value')
|
|
80
|
-
term_id =
|
|
81
|
-
liveweightPerHead = find_term_match(
|
|
81
|
+
term_id = animal.get('term').get('@id')
|
|
82
|
+
liveweightPerHead = find_term_match(animal.get('properties', []), 'liveweightPerHead', {})
|
|
82
83
|
liveweightPerHead_value = liveweightPerHead.get('value')
|
|
83
84
|
|
|
84
|
-
logRequirements(cycle, model=MODEL, term=term_id,
|
|
85
|
+
logRequirements(cycle, model=MODEL, term=term_id, property=TERM_ID,
|
|
85
86
|
country_id=country_id,
|
|
86
87
|
weightAtMaturity=lookup_value,
|
|
87
88
|
liveweightPerHead=liveweightPerHead_value)
|
|
@@ -91,7 +92,7 @@ def _should_run(cycle: dict):
|
|
|
91
92
|
lookup_value is not None,
|
|
92
93
|
lookup_value is None or liveweightPerHead_value is None or lookup_value >= liveweightPerHead_value
|
|
93
94
|
])
|
|
94
|
-
logShouldRun(cycle, MODEL, term_id, should_run)
|
|
95
|
+
logShouldRun(cycle, MODEL, term_id, should_run, property=TERM_ID)
|
|
95
96
|
|
|
96
97
|
return should_run
|
|
97
98
|
|
|
@@ -1768,7 +1768,7 @@
|
|
|
1768
1768
|
"@type": "Term",
|
|
1769
1769
|
"name": "Generic crop, seed",
|
|
1770
1770
|
"@id": "genericCropSeed",
|
|
1771
|
-
"_score": 25.
|
|
1771
|
+
"_score": 25.537537
|
|
1772
1772
|
}
|
|
1773
1773
|
]
|
|
1774
1774
|
},
|
|
@@ -2004,61 +2004,61 @@
|
|
|
2004
2004
|
"@type": "Term",
|
|
2005
2005
|
"name": "Glass or high accessible cover",
|
|
2006
2006
|
"@id": "glassOrHighAccessibleCover",
|
|
2007
|
-
"_score": 58.
|
|
2007
|
+
"_score": 58.69941
|
|
2008
2008
|
},
|
|
2009
2009
|
{
|
|
2010
2010
|
"@type": "Term",
|
|
2011
2011
|
"name": "River or stream",
|
|
2012
2012
|
"@id": "riverOrStream",
|
|
2013
|
-
"_score": 49.
|
|
2013
|
+
"_score": 49.892113
|
|
2014
2014
|
},
|
|
2015
2015
|
{
|
|
2016
2016
|
"@type": "Term",
|
|
2017
2017
|
"name": "Other natural vegetation",
|
|
2018
2018
|
"@id": "otherNaturalVegetation",
|
|
2019
|
-
"_score": 39.
|
|
2019
|
+
"_score": 39.190735
|
|
2020
2020
|
},
|
|
2021
2021
|
{
|
|
2022
2022
|
"@type": "Term",
|
|
2023
2023
|
"name": "Natural forest",
|
|
2024
2024
|
"@id": "naturalForest",
|
|
2025
|
-
"_score": 30.
|
|
2025
|
+
"_score": 30.287527
|
|
2026
2026
|
},
|
|
2027
2027
|
{
|
|
2028
2028
|
"@type": "Term",
|
|
2029
2029
|
"name": "Permanent pasture",
|
|
2030
2030
|
"@id": "permanentPasture",
|
|
2031
|
-
"_score": 27.
|
|
2031
|
+
"_score": 27.72403
|
|
2032
2032
|
},
|
|
2033
2033
|
{
|
|
2034
2034
|
"@type": "Term",
|
|
2035
2035
|
"name": "Animal housing",
|
|
2036
2036
|
"@id": "animalHousing",
|
|
2037
|
-
"_score": 26.
|
|
2037
|
+
"_score": 26.560026
|
|
2038
2038
|
},
|
|
2039
2039
|
{
|
|
2040
2040
|
"@type": "Term",
|
|
2041
2041
|
"name": "Root or tuber crop plant",
|
|
2042
2042
|
"@id": "rootOrTuberCropPlant",
|
|
2043
|
-
"_score": 24.
|
|
2043
|
+
"_score": 24.472519
|
|
2044
2044
|
},
|
|
2045
2045
|
{
|
|
2046
2046
|
"@type": "Term",
|
|
2047
2047
|
"name": "High intensity grazing pasture",
|
|
2048
2048
|
"@id": "highIntensityGrazingPasture",
|
|
2049
|
-
"_score": 23.
|
|
2049
|
+
"_score": 23.215178
|
|
2050
2050
|
},
|
|
2051
2051
|
{
|
|
2052
2052
|
"@type": "Term",
|
|
2053
2053
|
"name": "Permanent cropland",
|
|
2054
2054
|
"@id": "permanentCropland",
|
|
2055
|
-
"_score": 19.
|
|
2055
|
+
"_score": 19.953989
|
|
2056
2056
|
},
|
|
2057
2057
|
{
|
|
2058
2058
|
"@type": "Term",
|
|
2059
2059
|
"name": "Forest",
|
|
2060
2060
|
"@id": "forest",
|
|
2061
|
-
"_score": 19.
|
|
2061
|
+
"_score": 19.567623
|
|
2062
2062
|
}
|
|
2063
2063
|
]
|
|
2064
2064
|
},
|
|
@@ -2101,15 +2101,15 @@
|
|
|
2101
2101
|
"results": [
|
|
2102
2102
|
{
|
|
2103
2103
|
"@type": "Term",
|
|
2104
|
-
"@id": "
|
|
2104
|
+
"@id": "diesel1D"
|
|
2105
2105
|
},
|
|
2106
2106
|
{
|
|
2107
2107
|
"@type": "Term",
|
|
2108
|
-
"@id": "
|
|
2108
|
+
"@id": "marineDieselOil"
|
|
2109
2109
|
},
|
|
2110
2110
|
{
|
|
2111
2111
|
"@type": "Term",
|
|
2112
|
-
"@id": "
|
|
2112
|
+
"@id": "petrolBurntIn2StrokeEngine"
|
|
2113
2113
|
},
|
|
2114
2114
|
{
|
|
2115
2115
|
"@type": "Term",
|
|
@@ -2125,11 +2125,11 @@
|
|
|
2125
2125
|
},
|
|
2126
2126
|
{
|
|
2127
2127
|
"@type": "Term",
|
|
2128
|
-
"@id": "
|
|
2128
|
+
"@id": "petrolBurntIn4StrokeEngine"
|
|
2129
2129
|
},
|
|
2130
2130
|
{
|
|
2131
2131
|
"@type": "Term",
|
|
2132
|
-
"@id": "
|
|
2132
|
+
"@id": "petrol"
|
|
2133
2133
|
},
|
|
2134
2134
|
{
|
|
2135
2135
|
"@type": "Term",
|
|
@@ -152,7 +152,6 @@ def _get_depths_from_measurements(measurements: list) -> list:
|
|
|
152
152
|
|
|
153
153
|
|
|
154
154
|
def _should_run(site: dict):
|
|
155
|
-
# we only work with measurements with depths
|
|
156
155
|
measurements = site.get("measurements", [])
|
|
157
156
|
measurement_sensitivity = {
|
|
158
157
|
m.get('term', {}).get('@id'): get_lookup_value(
|
|
@@ -160,6 +159,7 @@ def _should_run(site: dict):
|
|
|
160
159
|
)
|
|
161
160
|
for m in measurements
|
|
162
161
|
}
|
|
162
|
+
# we only work with measurements with depths
|
|
163
163
|
measurements_with_depths = [m for m in measurements if all([
|
|
164
164
|
not measurement_sensitivity[m.get("term", {}).get('@id')],
|
|
165
165
|
m.get('value', []),
|
|
@@ -175,7 +175,7 @@ def _should_run(site: dict):
|
|
|
175
175
|
should_run = has_measurements_with_depths
|
|
176
176
|
for measurement in measurements_with_depths:
|
|
177
177
|
term_id = measurement.get("term", {}).get("@id", {})
|
|
178
|
-
logShouldRun(site, MODEL, term_id, should_run)
|
|
178
|
+
logShouldRun(site, MODEL, term_id, should_run, model_key=MODEL_KEY)
|
|
179
179
|
return should_run, measurements_with_depths
|
|
180
180
|
|
|
181
181
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from collections.abc import Iterable
|
|
2
2
|
from typing import Optional, Union
|
|
3
|
-
|
|
4
|
-
from hestia_earth.schema import EmissionMethodTier, SchemaType
|
|
3
|
+
from hestia_earth.schema import EmissionMethodTier, SchemaType, TermTermType
|
|
5
4
|
from hestia_earth.utils.api import download_hestia
|
|
6
5
|
from hestia_earth.utils.model import linked_node
|
|
7
6
|
from hestia_earth.utils.lookup import get_table_value, download_lookup, column_name
|
|
@@ -103,3 +102,8 @@ def to_emission_method_tier(method: Union[EmissionMethodTier, str]) -> Optional[
|
|
|
103
102
|
else EmissionMethodTier(method) if method in EMISSION_METHOD_TIERS
|
|
104
103
|
else None
|
|
105
104
|
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def filter_emission_inputs(emission: dict, term_type: TermTermType):
|
|
108
|
+
inputs = emission.get('inputs', [])
|
|
109
|
+
return [i for i in inputs if i.get('termType') == term_type.value]
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
1
3
|
from hestia_earth.utils.model import find_term_match
|
|
2
4
|
from hestia_earth.utils.tools import list_sum, safe_parse_date
|
|
3
5
|
|
|
4
|
-
from ..log import logRequirements
|
|
5
6
|
from .lookup import factor_value, _term_factor_value, _aware_factor_value
|
|
6
7
|
from .product import find_by_product
|
|
7
8
|
from .site import region_level_1_id
|
|
9
|
+
from ..log import logRequirements
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
def impact_end_year(impact_assessment: dict) -> int:
|
|
@@ -85,7 +87,8 @@ def get_country_id(impact_assessment: dict) -> str:
|
|
|
85
87
|
return impact_assessment.get('country', get_site(impact_assessment).get('country', {})).get('@id')
|
|
86
88
|
|
|
87
89
|
|
|
88
|
-
def impact_lookup_value(model: str, term_id: str, impact: dict, lookup_col: str
|
|
90
|
+
def impact_lookup_value(model: str, term_id: str, impact: dict, lookup_col: str,
|
|
91
|
+
grouped_key: Optional[str] = None) -> float:
|
|
89
92
|
"""
|
|
90
93
|
Calculate the value of the impact based on lookup factors and emissions value.
|
|
91
94
|
|
|
@@ -95,18 +98,20 @@ def impact_lookup_value(model: str, term_id: str, impact: dict, lookup_col: str)
|
|
|
95
98
|
The model to display in the logs only.
|
|
96
99
|
term_id : str
|
|
97
100
|
The term to display in the logs only.
|
|
98
|
-
|
|
101
|
+
impact : dict
|
|
99
102
|
The `ImpactAssessment`.
|
|
100
103
|
lookup_col : str
|
|
101
104
|
The lookup column to fetch the factors from.
|
|
102
|
-
|
|
105
|
+
grouped_key : str
|
|
106
|
+
key of grouped data to extract in a lookup table
|
|
103
107
|
Returns
|
|
104
108
|
-------
|
|
105
109
|
int
|
|
106
110
|
The impact total value.
|
|
107
111
|
"""
|
|
108
112
|
nodes = impact.get('emissionsResourceUse', [])
|
|
109
|
-
|
|
113
|
+
|
|
114
|
+
factors = list(map(factor_value(model, term_id, 'emission.csv', lookup_col, grouped_key), nodes))
|
|
110
115
|
values = [value for value in factors if value is not None]
|
|
111
116
|
return list_sum(values) if len(values) > 0 else None
|
|
112
117
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
1
3
|
from hestia_earth.schema import SchemaType
|
|
2
4
|
from hestia_earth.utils.lookup import (
|
|
3
5
|
download_lookup, get_table_value, column_name, extract_grouped_data, _get_single_table_value
|
|
@@ -12,17 +14,17 @@ def _node_value(node):
|
|
|
12
14
|
return list_sum(value) if isinstance(value, list) else value
|
|
13
15
|
|
|
14
16
|
|
|
15
|
-
def factor_value(model: str, term_id: str, lookup_name: str, lookup_col: str):
|
|
17
|
+
def factor_value(model: str, term_id: str, lookup_name: str, lookup_col: str, grouped_key: Optional[str] = None):
|
|
16
18
|
lookup = download_lookup(lookup_name)
|
|
17
19
|
|
|
18
20
|
def get_value(data: dict):
|
|
19
21
|
node_term_id = data.get('term', {}).get('@id')
|
|
20
|
-
|
|
22
|
+
grouped_data_key = grouped_key or data.get('methodModel', {}).get('@id')
|
|
21
23
|
value = _node_value(data)
|
|
22
24
|
coefficient = get_table_value(lookup, 'termid', node_term_id, column_name(lookup_col))
|
|
23
25
|
# value is either a number or matching between a model and a value (restrict value to specific model only)
|
|
24
26
|
coefficient = safe_parse_float(
|
|
25
|
-
extract_grouped_data(coefficient,
|
|
27
|
+
extract_grouped_data(coefficient, grouped_data_key), None
|
|
26
28
|
) if ':' in str(coefficient) else safe_parse_float(coefficient, None)
|
|
27
29
|
if value is not None and coefficient is not None:
|
|
28
30
|
if model:
|
hestia_earth/models/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = '0.64.
|
|
1
|
+
VERSION = '0.64.4'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hestia-earth-models
|
|
3
|
-
Version: 0.64.
|
|
3
|
+
Version: 0.64.4
|
|
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
|
|
@@ -4,7 +4,7 @@ hestia_earth/models/cache_sites.py,sha256=KQp9cUKE-aIcYJoMWEtKFYS8gBFfsx5LKQhqoW
|
|
|
4
4
|
hestia_earth/models/log.py,sha256=DbfNcGzaC5hzkuMDxQqW6XYoNBI4Uxw4SIoOYoZA6og,3474
|
|
5
5
|
hestia_earth/models/preload_requests.py,sha256=Ibx-YOhR_1yuyFBxsLUbvJHVK7PLyMLoPu5l9jDN_Qk,1342
|
|
6
6
|
hestia_earth/models/requirements.py,sha256=eU4yT443fx7BnaokhrLB_PCizJI7Y6m4auyo8vQauNg,17363
|
|
7
|
-
hestia_earth/models/version.py,sha256=
|
|
7
|
+
hestia_earth/models/version.py,sha256=LaDtOBoFznCDnauZfj0nYNmRMiVXWIWV8CNR0xo5dqc,19
|
|
8
8
|
hestia_earth/models/agribalyse2016/__init__.py,sha256=WvK0qCQbnYtg9oZxrACd1wGormZyXibPtpCnIQeDqbw,415
|
|
9
9
|
hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=tnGxBmJdPfPFfehLUQcefEqy1lHvzsSpx_s7O8nf3Zs,4412
|
|
10
10
|
hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=BPjnWmg73i_OxM2ouCdMTWZtPIqyoUAXrvutntyteE0,3390
|
|
@@ -138,6 +138,8 @@ hestia_earth/models/environmentalFootprintV3/__init__.py,sha256=lzg9qccwd9tbspw0
|
|
|
138
138
|
hestia_earth/models/environmentalFootprintV3/freshwaterEcotoxicityPotentialCtue.py,sha256=X62-4v0NJdM_Z5kLK3NuU4GNEeSrXlKlMZQB_o4JZ6c,1018
|
|
139
139
|
hestia_earth/models/epa2014/__init__.py,sha256=ckGf_6X7CCzI_18OqchEkuJAXKXM1x7V53u480ckknM,408
|
|
140
140
|
hestia_earth/models/epa2014/no3ToGroundwaterExcreta.py,sha256=fN4fOOcjBg3tl0lzNeJ8mzg6mrvQRxilx-R5Gc4l4Nw,1724
|
|
141
|
+
hestia_earth/models/fantkeEtAl2016/__init__.py,sha256=NtOlRmjTA4e8i0nW8erwdm-DDtfYlbLiARqqv82bkU4,415
|
|
142
|
+
hestia_earth/models/fantkeEtAl2016/damageToHumanHealthParticulateMatterFormation.py,sha256=OX9mWisIrOId_ZeagUMsvWCzKt_yNzXKxHUdJTzaeFk,1341
|
|
141
143
|
hestia_earth/models/faostat2018/__init__.py,sha256=ecN-pKF1pkFnzmooBrg1VAxJkG76q9v4piiaKGP_vbo,412
|
|
142
144
|
hestia_earth/models/faostat2018/coldCarcassWeightPerHead.py,sha256=y1ouj5FBrnGWxd4dIC7luG6iQwiMrm1CGgYbXCcKS8E,3139
|
|
143
145
|
hestia_earth/models/faostat2018/coldDressedCarcassWeightPerHead.py,sha256=Aphq7r06Q5-RDer4i1CneOLifVQCKTiVPTIWE3AxLfE,3230
|
|
@@ -149,6 +151,8 @@ hestia_earth/models/faostat2018/seed.py,sha256=ts9PKs9UnZnJ9nPFlL7etL1Qb9uIWIES8
|
|
|
149
151
|
hestia_earth/models/faostat2018/utils.py,sha256=Ud2vu_8ze5VFfeBFBzUKdJTWRfxVJO4VUTdgwaLJU-w,3715
|
|
150
152
|
hestia_earth/models/faostat2018/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
151
153
|
hestia_earth/models/faostat2018/product/price.py,sha256=X7Zxa-rXthzYdgw2lzybbHc-oKGE5nyXpBn-BfZC_7w,7753
|
|
154
|
+
hestia_earth/models/frischknechtEtAl2000/__init__.py,sha256=Fixyy9UwoCGP5-MHyJu_ctS40SQ2imfvZo8a547029U,421
|
|
155
|
+
hestia_earth/models/frischknechtEtAl2000/ionisingRadiationKbqU235Eq.py,sha256=8Y5-dIlswtrQYjDth3ahJ5z2CKwh3OnhV3rRSinMGrE,2885
|
|
152
156
|
hestia_earth/models/geospatialDatabase/__init__.py,sha256=TH-FW3aoL7r1GquRChr7rde7uQonKQRDR00udG8tDrQ,957
|
|
153
157
|
hestia_earth/models/geospatialDatabase/aware.py,sha256=cbxFnShXW8QUCIjU4uuO1DdK9KhYiLf41ZVjS9hSppI,1358
|
|
154
158
|
hestia_earth/models/geospatialDatabase/clayContent.py,sha256=u8SQKx-zu3vhMQ-XOJgqyUn-tlCCIy-VG7zpl5AyjtY,3386
|
|
@@ -269,11 +273,11 @@ hestia_earth/models/ipcc2019/pastureGrass.py,sha256=w8LMbxJTdZtC2nrWoooPA0jrA9-F
|
|
|
269
273
|
hestia_earth/models/ipcc2019/pastureGrass_utils.py,sha256=Bzz4yPDdA7YVUhhJhQCCVu0uKONeO3b6a48_ZITZgzU,13889
|
|
270
274
|
hestia_earth/models/ipcc2019/utils.py,sha256=MSDMu15D9DnilFUgi4_6jYXC0FaKso3OODauGTMB6hs,6229
|
|
271
275
|
hestia_earth/models/ipcc2019/animal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
272
|
-
hestia_earth/models/ipcc2019/animal/liveweightGain.py,sha256=
|
|
273
|
-
hestia_earth/models/ipcc2019/animal/liveweightPerHead.py,sha256=
|
|
276
|
+
hestia_earth/models/ipcc2019/animal/liveweightGain.py,sha256=Gwd6J6k-W84EAsC_cNMLaNy3p4-2pqCSc3grBfPvanw,2618
|
|
277
|
+
hestia_earth/models/ipcc2019/animal/liveweightPerHead.py,sha256=Lhnk58SvVtM2FayljOBPHFFx5OBFFqsiaVG8ZjwCaXA,2634
|
|
274
278
|
hestia_earth/models/ipcc2019/animal/pastureGrass.py,sha256=edBXCVjJB5ZBGJ9_zE3H6xKpT84hPqe3dv5JF879tXw,12066
|
|
275
279
|
hestia_earth/models/ipcc2019/animal/utils.py,sha256=ziyphGLEO_eitOLtBG0BLpJfmN3csqUetFZuDo8FX2U,990
|
|
276
|
-
hestia_earth/models/ipcc2019/animal/weightAtMaturity.py,sha256=
|
|
280
|
+
hestia_earth/models/ipcc2019/animal/weightAtMaturity.py,sha256=IHrG6cqLVhOiIbrvK0w5xDu4bHmy5om-1qBKMmkFC2o,3376
|
|
277
281
|
hestia_earth/models/ipcc2021/__init__.py,sha256=VTgGFKhwMmk_nuI1RRq0in27fHYVPBonlXlPK00K8no,409
|
|
278
282
|
hestia_earth/models/ipcc2021/gwp100.py,sha256=v-DYU-11XnWI1Ns1GEiKrJqL3JafxvhTsLmuBuFcxJU,1021
|
|
279
283
|
hestia_earth/models/jarvisAndPain1994/__init__.py,sha256=ercUwy29sV7oPIESj8UjsGB5lqiBCss9OZcbjxeeG8E,418
|
|
@@ -386,7 +390,7 @@ hestia_earth/models/linkedImpactAssessment/landTransformationFromPermanentPastur
|
|
|
386
390
|
hestia_earth/models/linkedImpactAssessment/utils.py,sha256=dGwGc2d-8_WQElTpfyPmz5vQtL-LHQRmiZnCTuPXMDs,1876
|
|
387
391
|
hestia_earth/models/mocking/__init__.py,sha256=n3Fkkrvh8zHNWiJZmnfQ7WZ91JRzAO9P6pSG1JpwtXo,687
|
|
388
392
|
hestia_earth/models/mocking/mock_search.py,sha256=qgABw-sZK37XtsALKt8AHF2VJPUrZSnHv5Qj1Dn93oA,2405
|
|
389
|
-
hestia_earth/models/mocking/search-results.json,sha256=
|
|
393
|
+
hestia_earth/models/mocking/search-results.json,sha256=1YcAYDF-b_Qv_I2sSi0GgXvsSsv4QwUotHAmADSWwSw,53136
|
|
390
394
|
hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
|
|
391
395
|
hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=Qt-mel4dkhK6N5uUOutNOinCTFjbjtGzITaaI0LvYc4,2396
|
|
392
396
|
hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=JT0RybbvWVlo01FO8K0Yj41HrEaJT3Kj1xfayr2X-xw,2315
|
|
@@ -502,7 +506,7 @@ hestia_earth/models/site/precipitationMonthly.py,sha256=yGUbiUCu1Prp3qVHuZodGrcf
|
|
|
502
506
|
hestia_earth/models/site/rainfallAnnual.py,sha256=Ix_B8Ny7IIRkJ_3lUvoHOjPgqCyR9I0U3_ADUUtMqsY,2003
|
|
503
507
|
hestia_earth/models/site/rainfallMonthly.py,sha256=2Uo8F-YxnTK0_txlHmiAyVp1bGfWD4bneRKyg4tdQkI,1881
|
|
504
508
|
hestia_earth/models/site/salineWater.py,sha256=wO_Dyufqni66qSCpunrJUr0ou45QrcpZc8-GtZDH9VU,1256
|
|
505
|
-
hestia_earth/models/site/soilMeasurement.py,sha256=
|
|
509
|
+
hestia_earth/models/site/soilMeasurement.py,sha256=YMKeChGcj9lxM9c7p68LlQhqMPHAD9AEsNsDr69Q1Kw,7185
|
|
506
510
|
hestia_earth/models/site/temperatureAnnual.py,sha256=Q3b1RH2_hpA0JWwOYA5nKgMGcXHjV8-akXT9vB0cbwc,2012
|
|
507
511
|
hestia_earth/models/site/temperatureMonthly.py,sha256=yXwpFCGT2tUqvVBNedaPyBmN_KlzZqo5yv2TWem1pBk,1890
|
|
508
512
|
hestia_earth/models/site/totalNitrogenPerKgSoil.py,sha256=8ERrTZpN_yCRUyFg_EYaX4abE9jLcyX3lx3MO4Bi6CE,1938
|
|
@@ -561,17 +565,17 @@ hestia_earth/models/utils/currency.py,sha256=f_ArJANb--pZq4LL49SXQ1AMX_oKroqwBXK
|
|
|
561
565
|
hestia_earth/models/utils/cycle.py,sha256=W-VIReb1OVooV6EIj-P6gUlr-W17_6USdnnj4ihMTTc,16741
|
|
562
566
|
hestia_earth/models/utils/descriptive_stats.py,sha256=qOyG8_TpWYmaxZ0h99n9L71gDLLiVMrMf0ChtxnZLjw,8559
|
|
563
567
|
hestia_earth/models/utils/ecoClimateZone.py,sha256=A3ZtF_B2wr6v7clbVi0zWQ-bOXRoOKq4vGq8mhNf9Ec,4316
|
|
564
|
-
hestia_earth/models/utils/emission.py,sha256=
|
|
568
|
+
hestia_earth/models/utils/emission.py,sha256=YqglUfZSyyvlgfRriZuXmJUDmjwWz5dM5AebIgLwvgk,3964
|
|
565
569
|
hestia_earth/models/utils/excretaManagement.py,sha256=NuWPQjFZxMVt9sYgBjcqhGWCFk_OKb3sA9Ovcff3fRQ,428
|
|
566
570
|
hestia_earth/models/utils/feedipedia.py,sha256=ImUAURcwJDtSvu1s4MDeM1VpbU8mVTp9jh9ENNOB0Mw,3515
|
|
567
571
|
hestia_earth/models/utils/fertiliser.py,sha256=DBO4OBNgnQJ0fCQMDkIk_ZGZX-uKGaTFZCEXfAnJciY,690
|
|
568
572
|
hestia_earth/models/utils/fuel.py,sha256=r1MKMMxg-PYiVlRutP83RuvY2rsdCQ1iN6ekSGGQGpA,1379
|
|
569
|
-
hestia_earth/models/utils/impact_assessment.py,sha256=
|
|
573
|
+
hestia_earth/models/utils/impact_assessment.py,sha256=ma2oINLTIL1qplqC5D1_DbQu4EILpMXSgYNEslxIa2Y,7059
|
|
570
574
|
hestia_earth/models/utils/indicator.py,sha256=IFrVIUYpmdVLOR1SKkrTReDbG1Tzq2b6daVvLMYpCs4,537
|
|
571
575
|
hestia_earth/models/utils/inorganicFertiliser.py,sha256=_dLBY-otGkLr8PobR5dQ89bF2uwc2PB4JPrHFSksMEQ,1900
|
|
572
576
|
hestia_earth/models/utils/input.py,sha256=YycsAbSBfVDMu6PftDsisMFGnEp87wOj-3rrnHnOgzo,4927
|
|
573
577
|
hestia_earth/models/utils/liveAnimal.py,sha256=GnajBPZw5d94raf80KtLloaOqlfqGAPwUtP9bRlGWeE,1754
|
|
574
|
-
hestia_earth/models/utils/lookup.py,sha256=
|
|
578
|
+
hestia_earth/models/utils/lookup.py,sha256=yJB5IzsK7mZ_jQIdwb3TA5KZQL7Vneuvqr_O0GPjBDs,6758
|
|
575
579
|
hestia_earth/models/utils/measurement.py,sha256=rxrrOVdkDm-J0QVjCEapa4z4KY3hUw-brAeb0pW1nIc,12221
|
|
576
580
|
hestia_earth/models/utils/organicFertiliser.py,sha256=2HY-a0EBzUw4DkEAXClLMXVCEZTKYf0BwFHBo7lQ5Tg,363
|
|
577
581
|
hestia_earth/models/utils/pesticideAI.py,sha256=6f8b-dFm3qr-eY049_eOvj_iDk4XBam61csozdDAvyA,2361
|
|
@@ -712,6 +716,8 @@ tests/models/environmentalFootprintV3/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCe
|
|
|
712
716
|
tests/models/environmentalFootprintV3/test_freshwaterEcotoxicityPotentialCtue.py,sha256=lIgsdGh_0eDi-rPcCOrSSjVYNiET2GCSRkAHdugAkDk,851
|
|
713
717
|
tests/models/epa2014/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
714
718
|
tests/models/epa2014/test_no3ToGroundwaterExcreta.py,sha256=ESVz4UURvQfhjGBTxjuAV_bymMBcvGNfLAkYMvNup9U,1217
|
|
719
|
+
tests/models/fantkeEtAl2016/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
720
|
+
tests/models/fantkeEtAl2016/test_damageToHumanHealthParticulateMatterFormation.py,sha256=yeN5w1_xKed10nHIlkb8dEOLcZ81TEAI41YvgnkB9n4,726
|
|
715
721
|
tests/models/faostat2018/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
716
722
|
tests/models/faostat2018/test_coldCarcassWeightPerHead.py,sha256=RImhLygwrJ2RoEHjDwhuymvLEitOtNleP_lLoBhiNOs,1736
|
|
717
723
|
tests/models/faostat2018/test_coldDressedCarcassWeightPerHead.py,sha256=hZVKMtf-F5Iz7igZVahDJoqzfm2VtcIlwWBPCry7kqw,1594
|
|
@@ -722,6 +728,8 @@ tests/models/faostat2018/test_readyToCookWeightPerHead.py,sha256=pMDcONs0WUvANcJ
|
|
|
722
728
|
tests/models/faostat2018/test_seed.py,sha256=tUXoNVveX0m0ed9UXB4zXxIZsPxktXyUXlbWuUKG0sQ,1705
|
|
723
729
|
tests/models/faostat2018/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
724
730
|
tests/models/faostat2018/product/test_price.py,sha256=vUTT-FZVbXnDrwQVOgq8PWTDuFK_gAT6aqJ9ZK6Qcsc,3493
|
|
731
|
+
tests/models/frischknechtEtAl2000/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
732
|
+
tests/models/frischknechtEtAl2000/test_ionisingRadiationKbqU235Eq.py,sha256=Fa44zHKi0XZPq_68g7BtOuFlpciefH9yIEgsVDWhlBg,2096
|
|
725
733
|
tests/models/geospatialDatabase/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
726
734
|
tests/models/geospatialDatabase/test_aware.py,sha256=tbBBvXrOqdO0cMPJTa02UfhlwfosH8iNoJLzZNFs1NU,857
|
|
727
735
|
tests/models/geospatialDatabase/test_clayContent.py,sha256=GqFAPIOkXfDpJFkI-vK6l3hK0Ap36lLCWGhXCly-DME,1797
|
|
@@ -1132,8 +1140,8 @@ tests/models/utils/test_source.py,sha256=_Ol-OrJs2Tt9iZAZ_RY2qRuSbnE4yz5OuEGkDSb
|
|
|
1132
1140
|
tests/models/utils/test_term.py,sha256=M5Sa26v2gzQYbZ4H_fo7DspnaCx__-WtL-MULGapCWk,3509
|
|
1133
1141
|
tests/models/webbEtAl2012AndSintermannEtAl2012/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
1134
1142
|
tests/models/webbEtAl2012AndSintermannEtAl2012/test_nh3ToAirOrganicFertiliser.py,sha256=qi2FNXS5Af2WDtm7nq_FsprH3BfCF0XxnE0XHmC4aIY,2244
|
|
1135
|
-
hestia_earth_models-0.64.
|
|
1136
|
-
hestia_earth_models-0.64.
|
|
1137
|
-
hestia_earth_models-0.64.
|
|
1138
|
-
hestia_earth_models-0.64.
|
|
1139
|
-
hestia_earth_models-0.64.
|
|
1143
|
+
hestia_earth_models-0.64.4.dist-info/LICENSE,sha256=AC7h7GAgCZGJK_Tzh6LUCrML9gQEfowWwecEw2w54QM,1154
|
|
1144
|
+
hestia_earth_models-0.64.4.dist-info/METADATA,sha256=C3SCtTmEIhSB6heG-RANYgdLAN6qncOUSZra2tgwG3E,3343
|
|
1145
|
+
hestia_earth_models-0.64.4.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
1146
|
+
hestia_earth_models-0.64.4.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
|
|
1147
|
+
hestia_earth_models-0.64.4.dist-info/RECORD,,
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from unittest.mock import patch
|
|
3
|
+
|
|
4
|
+
from hestia_earth.models.fantkeEtAl2016.damageToHumanHealthParticulateMatterFormation import MODEL, TERM_ID, run
|
|
5
|
+
from tests.utils import fixtures_path, fake_new_indicator
|
|
6
|
+
|
|
7
|
+
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
|
12
|
+
def test_run(mocked_indicator):
|
|
13
|
+
with open(f"{fixtures_folder}/impactassessment.jsonld", encoding='utf-8') as f:
|
|
14
|
+
impactassessment = json.load(f)
|
|
15
|
+
|
|
16
|
+
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
17
|
+
expected = json.load(f)
|
|
18
|
+
|
|
19
|
+
value = run(impactassessment)
|
|
20
|
+
assert value == expected
|
|
File without changes
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import pytest
|
|
3
|
+
from unittest.mock import patch
|
|
4
|
+
from tests.utils import fixtures_path, fake_new_indicator
|
|
5
|
+
|
|
6
|
+
from hestia_earth.models.frischknechtEtAl2000.ionisingRadiationKbqU235Eq import MODEL, TERM_ID, run, _should_run
|
|
7
|
+
|
|
8
|
+
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
9
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@pytest.mark.parametrize(
|
|
13
|
+
'test_name,impact,expected_should_run',
|
|
14
|
+
[
|
|
15
|
+
(
|
|
16
|
+
'no emissionsResourceUse => no run',
|
|
17
|
+
{},
|
|
18
|
+
False
|
|
19
|
+
),
|
|
20
|
+
(
|
|
21
|
+
'no emissions in the lookups list => no run',
|
|
22
|
+
{
|
|
23
|
+
'emissionsResourceUse': [
|
|
24
|
+
{
|
|
25
|
+
'term': {'@id': 'co2ToAirInputsProduction'}
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
False
|
|
30
|
+
),
|
|
31
|
+
(
|
|
32
|
+
'with emissions in the lookup list but no waste inputs => no run',
|
|
33
|
+
{
|
|
34
|
+
'emissionsResourceUse': [
|
|
35
|
+
{
|
|
36
|
+
'term': {'@id': 'ionisingCompoundsToAirInputsProduction'}
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
False
|
|
41
|
+
),
|
|
42
|
+
(
|
|
43
|
+
'with emissions in the lookup list and waste inputs => run',
|
|
44
|
+
{
|
|
45
|
+
'emissionsResourceUse': [
|
|
46
|
+
{
|
|
47
|
+
'term': {'@id': 'ionisingCompoundsToAirInputsProduction'},
|
|
48
|
+
'inputs': [{'termType': 'waste'}]
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
True
|
|
53
|
+
)
|
|
54
|
+
]
|
|
55
|
+
)
|
|
56
|
+
def test_should_run(test_name, impact, expected_should_run):
|
|
57
|
+
should_run, *args = _should_run(impact)
|
|
58
|
+
assert should_run == expected_should_run, test_name
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
|
62
|
+
def test_run(*args):
|
|
63
|
+
with open(f"{fixtures_folder}/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
64
|
+
impactassessment = json.load(f)
|
|
65
|
+
|
|
66
|
+
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
67
|
+
expected = json.load(f)
|
|
68
|
+
|
|
69
|
+
value = run(impactassessment)
|
|
70
|
+
assert value == expected
|
|
File without changes
|
|
File without changes
|
|
File without changes
|