hestia-earth-models 0.50.0__py3-none-any.whl → 0.51.1__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/agribalyse2016/fuelElectricity.py +7 -4
- hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py +14 -5
- hestia_earth/models/cycle/input/ecoinventV3.py +10 -2
- hestia_earth/models/cycle/input/hestiaAggregatedData.py +5 -2
- hestia_earth/models/emepEea2019/co2ToAirFuelCombustion.py +5 -2
- hestia_earth/models/emepEea2019/n2OToAirFuelCombustionDirect.py +5 -2
- hestia_earth/models/emepEea2019/nh3ToAirExcreta.py +10 -4
- hestia_earth/models/emepEea2019/noxToAirFuelCombustion.py +5 -2
- hestia_earth/models/emepEea2019/so2ToAirFuelCombustion.py +5 -2
- hestia_earth/models/emepEea2019/utils.py +22 -3
- hestia_earth/models/environmentalFootprintV3/{freshwaterEcotoxicityPotentialPaf.py → freshwaterEcotoxicityPotentialCtue.py} +2 -2
- hestia_earth/models/geospatialDatabase/aware.py +5 -4
- hestia_earth/models/geospatialDatabase/ecoregion.py +5 -4
- hestia_earth/models/geospatialDatabase/region.py +7 -11
- hestia_earth/models/geospatialDatabase/utils.py +39 -25
- hestia_earth/models/geospatialDatabase/waterDepth.py +5 -4
- hestia_earth/models/impact_assessment/__init__.py +3 -3
- hestia_earth/models/ipcc2019/ch4ToAirExcreta.py +4 -2
- hestia_earth/models/ipcc2019/croppingDuration.py +1 -1
- hestia_earth/models/ipcc2019/n2OToAirInorganicFertiliserIndirect.py +106 -0
- hestia_earth/models/ipcc2019/n2OToAirOrganicFertiliserIndirect.py +108 -0
- hestia_earth/models/ipcc2019/utils.py +37 -0
- hestia_earth/models/jarvisAndPain1994/__init__.py +13 -0
- hestia_earth/models/jarvisAndPain1994/n2ToAirExcreta.py +53 -0
- hestia_earth/models/koble2014/aboveGroundCropResidue.py +44 -21
- hestia_earth/models/koble2014/utils.py +5 -1
- hestia_earth/models/log.py +19 -0
- hestia_earth/models/mocking/search-results.json +301 -252
- hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py +15 -8
- hestia_earth/models/pooreNemecek2018/plantationProductiveLifespan.py +18 -6
- hestia_earth/models/pooreNemecek2018/rotationDuration.py +15 -5
- hestia_earth/models/pooreNemecek2018/utils.py +4 -2
- hestia_earth/models/schmidt2007/__init__.py +13 -0
- hestia_earth/models/schmidt2007/ch4ToAirWasteTreatment.py +60 -0
- hestia_earth/models/schmidt2007/utils.py +16 -0
- hestia_earth/models/transformation/input/excreta.py +4 -2
- hestia_earth/models/transformation/product/excreta.py +2 -2
- hestia_earth/models/usetoxV2/{freshwaterEcotoxicityPotentialPaf.py → freshwaterEcotoxicityPotentialCtue.py} +2 -2
- hestia_earth/models/utils/term.py +6 -0
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.50.0.dist-info → hestia_earth_models-0.51.1.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.50.0.dist-info → hestia_earth_models-0.51.1.dist-info}/RECORD +58 -44
- tests/models/emepEea2019/test_utils.py +17 -3
- tests/models/environmentalFootprintV3/{test_freshwaterEcotoxicityPotentialPaf.py → test_freshwaterEcotoxicityPotentialCtue.py} +1 -1
- tests/models/geospatialDatabase/test_region.py +4 -5
- tests/models/geospatialDatabase/test_utils.py +10 -1
- tests/models/ipcc2019/test_n2OToAirInorganicFertiliserIndirect.py +48 -0
- tests/models/ipcc2019/test_n2OToAirOrganicFertiliserIndirect.py +48 -0
- tests/models/jarvisAndPain1994/__init__.py +0 -0
- tests/models/jarvisAndPain1994/test_n2ToAirExcreta.py +37 -0
- tests/models/koble2014/test_aboveGroundCropResidue.py +13 -0
- tests/models/schmidt2007/__init__.py +0 -0
- tests/models/schmidt2007/test_ch4ToAirWasteTreatment.py +45 -0
- tests/models/schmidt2007/test_utils.py +39 -0
- tests/models/usetoxV2/{test_freshwaterEcotoxicityPotentialPaf.py → test_freshwaterEcotoxicityPotentialCtue.py} +1 -1
- {hestia_earth_models-0.50.0.dist-info → hestia_earth_models-0.51.1.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.50.0.dist-info → hestia_earth_models-0.51.1.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.50.0.dist-info → hestia_earth_models-0.51.1.dist-info}/top_level.txt +0 -0
|
@@ -2,7 +2,7 @@ from hestia_earth.schema import ProductStatsDefinition, TermTermType
|
|
|
2
2
|
from hestia_earth.utils.model import filter_list_term_type
|
|
3
3
|
from hestia_earth.utils.tools import list_sum, safe_parse_float
|
|
4
4
|
|
|
5
|
-
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
5
|
+
from hestia_earth.models.log import logRequirements, logShouldRun, log_as_table
|
|
6
6
|
from hestia_earth.models.utils.completeness import _is_term_type_incomplete
|
|
7
7
|
from hestia_earth.models.utils.product import _new_product
|
|
8
8
|
from hestia_earth.models.utils.crop import get_crop_lookup_value
|
|
@@ -41,20 +41,27 @@ def _run(product: dict):
|
|
|
41
41
|
return [_product(value)]
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
def _should_run_product(product: dict):
|
|
45
|
-
value = list_sum(product.get('value', [0]))
|
|
46
|
-
lookup_value = _get_lookup_value(product)
|
|
47
|
-
return value > 0 and lookup_value is not None
|
|
48
|
-
|
|
49
|
-
|
|
50
44
|
def _should_run(cycle: dict):
|
|
51
45
|
# filter crop products with matching data in the lookup
|
|
52
46
|
products = filter_list_term_type(cycle.get('products', []), TermTermType.CROP)
|
|
53
|
-
|
|
47
|
+
product_values = [
|
|
48
|
+
(product, list_sum(product.get('value', [0])), _get_lookup_value(product)) for product in products
|
|
49
|
+
]
|
|
50
|
+
product_logs = log_as_table([
|
|
51
|
+
{
|
|
52
|
+
'id': product.get('term', {}).get('@id'),
|
|
53
|
+
'value': value,
|
|
54
|
+
'lookup': lookup_value
|
|
55
|
+
} for product, value, lookup_value in product_values
|
|
56
|
+
])
|
|
57
|
+
products = [
|
|
58
|
+
product for product, value, lookup_value in product_values if all([value > 0, lookup_value is not None])
|
|
59
|
+
]
|
|
54
60
|
single_crop_product = len(products) == 1
|
|
55
61
|
term_type_incomplete = _is_term_type_incomplete(cycle, TERM_ID)
|
|
56
62
|
|
|
57
63
|
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
|
64
|
+
product_details=product_logs,
|
|
58
65
|
single_crop_product=single_crop_product,
|
|
59
66
|
term_type_cropResidue_incomplete=term_type_incomplete)
|
|
60
67
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from hestia_earth.schema import PracticeStatsDefinition
|
|
2
2
|
from hestia_earth.utils.tools import safe_parse_float
|
|
3
3
|
|
|
4
|
+
from hestia_earth.models.log import debugValues, log_as_table
|
|
4
5
|
from hestia_earth.models.utils.practice import _new_practice
|
|
5
6
|
from hestia_earth.models.utils.crop import get_crop_lookup_value
|
|
6
7
|
from .utils import run_products_average
|
|
@@ -25,11 +26,22 @@ RETURNS = {
|
|
|
25
26
|
TERM_ID = 'plantationProductiveLifespan'
|
|
26
27
|
|
|
27
28
|
|
|
28
|
-
def _get_value(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
def _get_value(cycle: dict):
|
|
30
|
+
def get(product: dict):
|
|
31
|
+
term_id = product.get('term', {}).get('@id', '')
|
|
32
|
+
plantationLifespan = get_plantationLifespan(product)
|
|
33
|
+
nonProductiveLifespan = safe_parse_float(get_crop_lookup_value(MODEL, TERM_ID, term_id, LOOKUPS['crop']), None)
|
|
34
|
+
product_id = product.get('term').get('@id')
|
|
35
|
+
product_id_logs = log_as_table({
|
|
36
|
+
'plantationLifespan': plantationLifespan,
|
|
37
|
+
'nonProductiveLifespan': nonProductiveLifespan
|
|
38
|
+
})
|
|
39
|
+
debugValues(cycle, model=MODEL, term=TERM_ID,
|
|
40
|
+
**{product_id: product_id_logs})
|
|
41
|
+
return plantationLifespan - nonProductiveLifespan if all([
|
|
42
|
+
plantationLifespan is not None, nonProductiveLifespan is not None
|
|
43
|
+
]) else None
|
|
44
|
+
return get
|
|
33
45
|
|
|
34
46
|
|
|
35
47
|
def _practice(value: float):
|
|
@@ -40,5 +52,5 @@ def _practice(value: float):
|
|
|
40
52
|
|
|
41
53
|
|
|
42
54
|
def run(cycle: dict):
|
|
43
|
-
value = run_products_average(cycle, TERM_ID, _get_value)
|
|
55
|
+
value = run_products_average(cycle, TERM_ID, _get_value(cycle))
|
|
44
56
|
return [_practice(value)] if value is not None else []
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from hestia_earth.schema import PracticeStatsDefinition
|
|
2
2
|
|
|
3
|
+
from hestia_earth.models.log import debugValues, log_as_table
|
|
3
4
|
from hestia_earth.models.utils.practice import _new_practice
|
|
4
5
|
from hestia_earth.models.utils import sum_values
|
|
5
6
|
from .plantationLifespan import _get_value as get_plantationLifespan
|
|
@@ -24,10 +25,19 @@ RETURNS = {
|
|
|
24
25
|
TERM_ID = 'rotationDuration'
|
|
25
26
|
|
|
26
27
|
|
|
27
|
-
def _get_value(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
def _get_value(cycle: dict):
|
|
29
|
+
def get(product: dict):
|
|
30
|
+
plantationLifespan = get_plantationLifespan(product)
|
|
31
|
+
longFallowPeriod = get_longFallowPeriod(product)
|
|
32
|
+
product_id = product.get('term').get('@id')
|
|
33
|
+
product_id_logs = log_as_table({
|
|
34
|
+
'plantationLifespan': plantationLifespan,
|
|
35
|
+
'longFallowPeriod': longFallowPeriod
|
|
36
|
+
})
|
|
37
|
+
debugValues(cycle, model=MODEL, term=TERM_ID,
|
|
38
|
+
**{product_id: product_id_logs})
|
|
39
|
+
return sum_values([plantationLifespan, longFallowPeriod])
|
|
40
|
+
return get
|
|
31
41
|
|
|
32
42
|
|
|
33
43
|
def _practice(value: float):
|
|
@@ -38,5 +48,5 @@ def _practice(value: float):
|
|
|
38
48
|
|
|
39
49
|
|
|
40
50
|
def run(cycle: dict):
|
|
41
|
-
value = run_products_average(cycle, TERM_ID, _get_value)
|
|
51
|
+
value = run_products_average(cycle, TERM_ID, _get_value(cycle))
|
|
42
52
|
return [_practice(value)] if value is not None else []
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from hestia_earth.utils.tools import non_empty_list, list_average
|
|
2
2
|
|
|
3
|
-
from hestia_earth.models.log import logShouldRun, logRequirements
|
|
3
|
+
from hestia_earth.models.log import logShouldRun, logRequirements, log_as_table
|
|
4
4
|
from . import MODEL
|
|
5
5
|
|
|
6
6
|
|
|
@@ -17,7 +17,9 @@ def run_products_average(cycle: dict, term_id: str, get_value_func):
|
|
|
17
17
|
|
|
18
18
|
logRequirements(cycle, model=MODEL, term=term_id,
|
|
19
19
|
has_values=has_values,
|
|
20
|
-
details=
|
|
20
|
+
details=log_as_table([
|
|
21
|
+
{'id': term_id, 'value': value} for term_id, value in values_by_product
|
|
22
|
+
]))
|
|
21
23
|
|
|
22
24
|
should_run = all([has_values])
|
|
23
25
|
logShouldRun(cycle, MODEL, term_id, should_run)
|
|
@@ -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 = 'schmidt2007'
|
|
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,60 @@
|
|
|
1
|
+
from hestia_earth.schema import EmissionMethodTier, EmissionStatsDefinition
|
|
2
|
+
from hestia_earth.utils.tools import list_sum
|
|
3
|
+
|
|
4
|
+
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
5
|
+
from hestia_earth.models.utils.emission import _new_emission
|
|
6
|
+
from .utils import get_waste_values
|
|
7
|
+
from . import MODEL
|
|
8
|
+
|
|
9
|
+
REQUIREMENTS = {
|
|
10
|
+
"Cycle": {
|
|
11
|
+
"or": {
|
|
12
|
+
"product": [
|
|
13
|
+
{"@type": "Product", "value": "", "term.termType": "waste"}
|
|
14
|
+
],
|
|
15
|
+
"completeness.waste": ""
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
RETURNS = {
|
|
20
|
+
"Emission": [{
|
|
21
|
+
"value": "",
|
|
22
|
+
"methodTier": "tier 1",
|
|
23
|
+
"statsDefinition": "modelled"
|
|
24
|
+
}]
|
|
25
|
+
}
|
|
26
|
+
LOOKUPS = {
|
|
27
|
+
"waste": "ch4EfSchmidt2007"
|
|
28
|
+
}
|
|
29
|
+
TERM_ID = 'ch4ToAirWasteTreatment'
|
|
30
|
+
TIER = EmissionMethodTier.TIER_1.value
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _emission(value: float):
|
|
34
|
+
emission = _new_emission(TERM_ID, MODEL)
|
|
35
|
+
emission['value'] = [value]
|
|
36
|
+
emission['methodTier'] = TIER
|
|
37
|
+
emission['statsDefinition'] = EmissionStatsDefinition.MODELLED.value
|
|
38
|
+
return emission
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _run(waste_values: list):
|
|
42
|
+
value = list_sum(waste_values)
|
|
43
|
+
return [_emission(value)]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _should_run(cycle: dict):
|
|
47
|
+
waste_values = get_waste_values(TERM_ID, cycle, LOOKUPS['waste'])
|
|
48
|
+
has_waste = len(waste_values) > 0
|
|
49
|
+
|
|
50
|
+
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
|
51
|
+
has_waste=has_waste)
|
|
52
|
+
|
|
53
|
+
should_run = any([has_waste])
|
|
54
|
+
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
|
55
|
+
return should_run, waste_values
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def run(cycle: dict):
|
|
59
|
+
should_run, waste_values = _should_run(cycle)
|
|
60
|
+
return _run(waste_values) if should_run else []
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from hestia_earth.schema import NodeType, TermTermType
|
|
2
|
+
from hestia_earth.utils.model import filter_list_term_type
|
|
3
|
+
from hestia_earth.utils.tools import non_empty_list
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.utils.completeness import _is_term_type_complete
|
|
6
|
+
from hestia_earth.models.utils.lookup import factor_value
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_waste_values(term_id: str, cycle: dict, lookup_col: str):
|
|
10
|
+
products = filter_list_term_type(cycle.get('products', []), TermTermType.WASTE)
|
|
11
|
+
values = non_empty_list(map(factor_value(None, term_id, f"{TermTermType.WASTE.value}.csv", lookup_col), products))
|
|
12
|
+
return [0] if all([
|
|
13
|
+
len(values) == 0,
|
|
14
|
+
_is_term_type_complete(cycle, {'termType': 'waste'}),
|
|
15
|
+
cycle.get('@type', cycle.get('type')) == NodeType.CYCLE.value # ignore adding 0 value for Transformation
|
|
16
|
+
]) else values
|
|
@@ -31,7 +31,8 @@ RETURNS = {
|
|
|
31
31
|
"inputs": [{
|
|
32
32
|
"@type": "Input",
|
|
33
33
|
"term.termType": "excreta",
|
|
34
|
-
"value": ""
|
|
34
|
+
"value": "",
|
|
35
|
+
"fromCycle": "true"
|
|
35
36
|
}]
|
|
36
37
|
}]
|
|
37
38
|
}
|
|
@@ -49,7 +50,8 @@ def _to_input(transformation: dict):
|
|
|
49
50
|
return {
|
|
50
51
|
**data,
|
|
51
52
|
**_new_input(product.get('term')),
|
|
52
|
-
'value': [v * ratio for v in product.get('value', [])]
|
|
53
|
+
'value': [v * ratio for v in product.get('value', [])],
|
|
54
|
+
'fromCycle': True
|
|
53
55
|
}
|
|
54
56
|
return new_input
|
|
55
57
|
|
|
@@ -10,7 +10,7 @@ from hestia_earth.utils.tools import list_sum, non_empty_list
|
|
|
10
10
|
from hestia_earth.utils.model import filter_list_term_type
|
|
11
11
|
|
|
12
12
|
from hestia_earth.models.log import debugValues, logRequirements, logShouldRun
|
|
13
|
-
from hestia_earth.models.utils import get_kg_term_units
|
|
13
|
+
from hestia_earth.models.utils import get_kg_term_units, _omit
|
|
14
14
|
from hestia_earth.models.utils.product import _new_product
|
|
15
15
|
from hestia_earth.models.utils.constant import Units, convert_to_N
|
|
16
16
|
from hestia_earth.models.utils.term import get_lookup_value
|
|
@@ -73,7 +73,7 @@ def _add_product(transformation: dict, units: str, inputs: list, emissions: list
|
|
|
73
73
|
should_run = all([has_value])
|
|
74
74
|
logShouldRun(transformation, MODEL_LOG, term_id, should_run)
|
|
75
75
|
return {
|
|
76
|
-
**input_same_units,
|
|
76
|
+
**_omit(input_same_units, ['fromCycle']),
|
|
77
77
|
**_new_product(term_id, _product_value(input_same_units, emissions))
|
|
78
78
|
} if should_run else None
|
|
79
79
|
|
|
@@ -17,9 +17,9 @@ RETURNS = {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
LOOKUPS = {
|
|
20
|
-
"pesticideAI": "
|
|
20
|
+
"pesticideAI": "pafM3DFreshwaterEcotoxicityUsetox2-1Hc50Ec50eq"
|
|
21
21
|
}
|
|
22
|
-
TERM_ID = '
|
|
22
|
+
TERM_ID = 'freshwaterEcotoxicityPotentialCtue'
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def _indicator(value: float):
|
|
@@ -23,6 +23,7 @@ def get_liquid_fuel_terms():
|
|
|
23
23
|
"""
|
|
24
24
|
Find all "liquid" `fuel` terms from the Glossary:
|
|
25
25
|
- https://hestia.earth/glossary?termType=fuel&query=gasoline
|
|
26
|
+
- https://hestia.earth/glossary?termType=fuel&query=petrol
|
|
26
27
|
- https://hestia.earth/glossary?termType=fuel&query=diesel
|
|
27
28
|
|
|
28
29
|
Returns
|
|
@@ -50,6 +51,11 @@ def get_liquid_fuel_terms():
|
|
|
50
51
|
"name": "gasoline*"
|
|
51
52
|
}
|
|
52
53
|
},
|
|
54
|
+
{
|
|
55
|
+
"regexp": {
|
|
56
|
+
"name": "petrol*"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
53
59
|
{
|
|
54
60
|
"regexp": {
|
|
55
61
|
"name": "diesel*"
|
hestia_earth/models/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = '0.
|
|
1
|
+
VERSION = '0.51.1'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hestia-earth-models
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.51.1
|
|
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
|
|
@@ -11,7 +11,7 @@ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.6
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: hestia-earth.schema ==
|
|
14
|
+
Requires-Dist: hestia-earth.schema ==23.*
|
|
15
15
|
Requires-Dist: hestia-earth.utils >=0.11.1
|
|
16
16
|
Requires-Dist: python-dateutil >=2.8.1
|
|
17
17
|
Requires-Dist: CurrencyConverter ==0.16.8
|