hestia-earth-models 0.57.2__py3-none-any.whl → 0.59.0__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/cycle/aboveGroundCropResidueTotal.py +17 -12
- hestia_earth/models/cycle/excretaKgMass.py +4 -5
- hestia_earth/models/cycle/excretaKgN.py +4 -5
- hestia_earth/models/cycle/excretaKgVs.py +4 -5
- hestia_earth/models/cycle/inorganicFertiliser.py +2 -2
- hestia_earth/models/cycle/{irrigated.py → irrigatedTypeUnspecified.py} +4 -4
- hestia_earth/models/cycle/liveAnimal.py +9 -11
- hestia_earth/models/cycle/milkYield.py +154 -0
- hestia_earth/models/cycle/residueIncorporated.py +1 -1
- hestia_earth/models/cycle/utils.py +6 -0
- hestia_earth/models/emepEea2019/nh3ToAirInorganicFertiliser.py +3 -3
- hestia_earth/models/faostat2018/seed.py +2 -3
- hestia_earth/models/geospatialDatabase/clayContent.py +17 -4
- hestia_earth/models/geospatialDatabase/sandContent.py +17 -4
- hestia_earth/models/geospatialDatabase/siltContent.py +2 -2
- hestia_earth/models/impact_assessment/irrigated.py +0 -3
- hestia_earth/models/ipcc2006/co2ToAirOrganicSoilCultivation.py +2 -2
- hestia_earth/models/ipcc2006/n2OToAirCropResidueDecompositionIndirect.py +2 -2
- hestia_earth/models/ipcc2006/n2OToAirExcretaDirect.py +1 -1
- hestia_earth/models/ipcc2006/n2OToAirExcretaIndirect.py +8 -4
- hestia_earth/models/ipcc2006/n2OToAirInorganicFertiliserDirect.py +4 -1
- hestia_earth/models/ipcc2006/n2OToAirInorganicFertiliserIndirect.py +1 -1
- hestia_earth/models/ipcc2006/n2OToAirOrganicFertiliserDirect.py +1 -1
- hestia_earth/models/ipcc2006/n2OToAirOrganicFertiliserIndirect.py +1 -1
- hestia_earth/models/ipcc2006/utils.py +11 -8
- hestia_earth/models/ipcc2019/ch4ToAirEntericFermentation.py +4 -4
- hestia_earth/models/ipcc2019/ch4ToAirFloodedRice.py +16 -7
- hestia_earth/models/ipcc2019/co2ToAirSoilCarbonStockChangeManagementChange.py +759 -0
- hestia_earth/models/ipcc2019/croppingDuration.py +12 -6
- hestia_earth/models/ipcc2019/n2OToAirCropResidueDecompositionDirect.py +5 -52
- hestia_earth/models/ipcc2019/n2OToAirInorganicFertiliserDirect.py +104 -0
- hestia_earth/models/ipcc2019/n2OToAirInorganicFertiliserIndirect.py +1 -1
- hestia_earth/models/ipcc2019/n2OToAirOrganicFertiliserDirect.py +105 -0
- hestia_earth/models/ipcc2019/n2OToAirOrganicFertiliserIndirect.py +1 -1
- hestia_earth/models/ipcc2019/no3ToGroundwaterCropResidueDecomposition.py +1 -1
- hestia_earth/models/ipcc2019/no3ToGroundwaterExcreta.py +1 -1
- hestia_earth/models/ipcc2019/no3ToGroundwaterInorganicFertiliser.py +1 -1
- hestia_earth/models/ipcc2019/no3ToGroundwaterOrganicFertiliser.py +1 -1
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py +1088 -1268
- hestia_earth/models/ipcc2019/pastureGrass.py +4 -4
- hestia_earth/models/ipcc2019/utils.py +102 -1
- hestia_earth/models/koble2014/aboveGroundCropResidue.py +15 -17
- hestia_earth/models/koble2014/cropResidueManagement.py +2 -2
- hestia_earth/models/koble2014/utils.py +19 -3
- hestia_earth/models/linkedImpactAssessment/__init__.py +4 -2
- hestia_earth/models/log.py +15 -3
- hestia_earth/models/mocking/search-results.json +184 -118
- hestia_earth/models/pooreNemecek2018/excretaKgN.py +6 -7
- hestia_earth/models/pooreNemecek2018/excretaKgVs.py +7 -6
- hestia_earth/models/pooreNemecek2018/no3ToGroundwaterCropResidueDecomposition.py +3 -2
- hestia_earth/models/pooreNemecek2018/no3ToGroundwaterExcreta.py +3 -2
- hestia_earth/models/pooreNemecek2018/no3ToGroundwaterInorganicFertiliser.py +3 -2
- hestia_earth/models/pooreNemecek2018/saplings.py +0 -1
- hestia_earth/models/site/management.py +168 -0
- hestia_earth/models/site/organicCarbonPerHa.py +251 -89
- hestia_earth/models/stehfestBouwman2006/n2OToAirCropResidueDecompositionDirect.py +3 -2
- hestia_earth/models/stehfestBouwman2006/n2OToAirExcretaDirect.py +3 -2
- hestia_earth/models/stehfestBouwman2006/n2OToAirInorganicFertiliserDirect.py +3 -2
- hestia_earth/models/stehfestBouwman2006/n2OToAirOrganicFertiliserDirect.py +3 -2
- hestia_earth/models/stehfestBouwman2006/noxToAirCropResidueDecomposition.py +3 -2
- hestia_earth/models/stehfestBouwman2006/noxToAirExcreta.py +3 -2
- hestia_earth/models/stehfestBouwman2006/noxToAirInorganicFertiliser.py +3 -2
- hestia_earth/models/stehfestBouwman2006/noxToAirOrganicFertiliser.py +3 -2
- hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirCropResidueDecomposition.py +3 -2
- hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirExcreta.py +3 -2
- hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirInorganicFertiliser.py +3 -2
- hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirOrganicFertiliser.py +3 -2
- hestia_earth/models/utils/aggregated.py +1 -0
- hestia_earth/models/utils/blank_node.py +394 -72
- hestia_earth/models/utils/cropResidue.py +13 -0
- hestia_earth/models/utils/cycle.py +18 -9
- hestia_earth/models/utils/measurement.py +1 -1
- hestia_earth/models/utils/property.py +4 -4
- hestia_earth/models/utils/term.py +48 -3
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.57.2.dist-info → hestia_earth_models-0.59.0.dist-info}/METADATA +5 -9
- {hestia_earth_models-0.57.2.dist-info → hestia_earth_models-0.59.0.dist-info}/RECORD +109 -97
- {hestia_earth_models-0.57.2.dist-info → hestia_earth_models-0.59.0.dist-info}/WHEEL +1 -1
- tests/models/cycle/animal/input/test_hestiaAggregatedData.py +2 -14
- tests/models/cycle/input/test_hestiaAggregatedData.py +4 -16
- tests/models/cycle/test_coldCarcassWeightPerHead.py +1 -1
- tests/models/cycle/test_coldDressedCarcassWeightPerHead.py +1 -1
- tests/models/cycle/{test_irrigated.py → test_irrigatedTypeUnspecified.py} +1 -1
- tests/models/cycle/test_milkYield.py +58 -0
- tests/models/cycle/test_readyToCookWeightPerHead.py +1 -1
- tests/models/emepEea2019/test_nh3ToAirInorganicFertiliser.py +1 -1
- tests/models/geospatialDatabase/test_clayContent.py +9 -3
- tests/models/geospatialDatabase/test_sandContent.py +9 -3
- tests/models/ipcc2006/test_n2OToAirExcretaDirect.py +7 -2
- tests/models/ipcc2006/test_n2OToAirExcretaIndirect.py +1 -1
- tests/models/ipcc2006/test_n2OToAirInorganicFertiliserDirect.py +7 -2
- tests/models/ipcc2006/test_n2OToAirInorganicFertiliserIndirect.py +7 -2
- tests/models/ipcc2006/test_n2OToAirOrganicFertiliserDirect.py +7 -2
- tests/models/ipcc2006/test_n2OToAirOrganicFertiliserIndirect.py +7 -2
- tests/models/ipcc2019/test_ch4ToAirEntericFermentation.py +1 -1
- tests/models/ipcc2019/test_co2ToAirSoilCarbonStockChangeManagementChange.py +228 -0
- tests/models/ipcc2019/test_n2OToAirInorganicFertiliserDirect.py +74 -0
- tests/models/ipcc2019/test_n2OToAirOrganicFertiliserDirect.py +74 -0
- tests/models/ipcc2019/test_organicCarbonPerHa.py +303 -1044
- tests/models/koble2014/test_residueBurnt.py +1 -2
- tests/models/koble2014/test_residueLeftOnField.py +1 -2
- tests/models/koble2014/test_residueRemoved.py +1 -2
- tests/models/koble2014/test_utils.py +52 -0
- tests/models/site/test_management.py +117 -0
- tests/models/site/test_organicCarbonPerHa.py +51 -5
- tests/models/utils/test_blank_node.py +230 -34
- tests/models/utils/test_term.py +17 -3
- {hestia_earth_models-0.57.2.dist-info → hestia_earth_models-0.59.0.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.57.2.dist-info → hestia_earth_models-0.59.0.dist-info}/top_level.txt +0 -0
|
@@ -52,7 +52,7 @@ def _should_run(cycle: dict):
|
|
|
52
52
|
N_total=N_total,
|
|
53
53
|
term_type_excreta_complete=term_type_complete)
|
|
54
54
|
|
|
55
|
-
should_run = all([N_total, term_type_complete])
|
|
55
|
+
should_run = all([N_total is not None, term_type_complete])
|
|
56
56
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
|
57
57
|
return should_run, N_total
|
|
58
58
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
from hestia_earth.schema import EmissionMethodTier
|
|
1
|
+
from hestia_earth.schema import EmissionMethodTier, TermTermType
|
|
2
2
|
|
|
3
3
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
4
4
|
from hestia_earth.models.utils.constant import Units, get_atomic_conversion
|
|
5
|
+
from hestia_earth.models.utils.completeness import _is_term_type_complete
|
|
5
6
|
from hestia_earth.models.utils.emission import _new_emission
|
|
6
7
|
from .utils import get_nh3_no3_nox_to_n, COEFF_NH3NOX_N2O, COEFF_NO3_N2O
|
|
7
8
|
from . import MODEL
|
|
8
9
|
|
|
9
10
|
REQUIREMENTS = {
|
|
10
11
|
"Cycle": {
|
|
12
|
+
"completeness.excreta": "True",
|
|
11
13
|
"emissions": [
|
|
12
14
|
{"@type": "Emission", "value": "", "term.@id": "no3ToGroundwaterExcreta"},
|
|
13
15
|
{"@type": "Emission", "value": "", "term.@id": "nh3ToAirExcreta"},
|
|
@@ -41,14 +43,16 @@ def _run(no3_n: float, nh3_n: float, nox_n: float):
|
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
def _should_run(cycle: dict):
|
|
44
|
-
nh3_n, no3_n, nox_n = get_nh3_no3_nox_to_n(cycle, NH3_TERM_ID, NO3_TERM_ID, NOX_TERM_ID)
|
|
46
|
+
nh3_n, no3_n, nox_n = get_nh3_no3_nox_to_n(cycle, NH3_TERM_ID, NO3_TERM_ID, NOX_TERM_ID, allow_none=False)
|
|
47
|
+
term_type_complete = _is_term_type_complete(cycle, TermTermType.EXCRETA)
|
|
45
48
|
|
|
46
49
|
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
|
47
50
|
no3ToGroundwaterExcreta_to_n=no3_n,
|
|
48
51
|
nh3ToAirExcreta_to_n=nh3_n,
|
|
49
|
-
noxToAirExcreta_to_n=nox_n
|
|
52
|
+
noxToAirExcreta_to_n=nox_n,
|
|
53
|
+
term_type_excreta_complete=term_type_complete)
|
|
50
54
|
|
|
51
|
-
should_run = all([no3_n, nh3_n, nox_n])
|
|
55
|
+
should_run = all([no3_n is not None, nh3_n is not None, nox_n is not None, term_type_complete])
|
|
52
56
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
|
53
57
|
return should_run, no3_n, nh3_n, nox_n
|
|
54
58
|
|
|
@@ -28,6 +28,9 @@ RETURNS = {
|
|
|
28
28
|
"methodTier": "tier 1"
|
|
29
29
|
}]
|
|
30
30
|
}
|
|
31
|
+
LOOKUPS = {
|
|
32
|
+
"crop": "N2ON_FERT"
|
|
33
|
+
}
|
|
31
34
|
TERM_ID = 'n2OToAirInorganicFertiliserDirect'
|
|
32
35
|
TIER = EmissionMethodTier.TIER_1.value
|
|
33
36
|
|
|
@@ -53,7 +56,7 @@ def _should_run(cycle: dict):
|
|
|
53
56
|
N_total=N_total,
|
|
54
57
|
term_type_fertiliser_complete=term_type_complete)
|
|
55
58
|
|
|
56
|
-
should_run = all([N_total, term_type_complete])
|
|
59
|
+
should_run = all([N_total is not None, term_type_complete])
|
|
57
60
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
|
58
61
|
return should_run, N_total
|
|
59
62
|
|
|
@@ -69,7 +69,7 @@ def _should_run(cycle: dict):
|
|
|
69
69
|
N_total=N_total,
|
|
70
70
|
term_type_fertiliser_complete=term_type_complete)
|
|
71
71
|
|
|
72
|
-
should_run = all([N_total, term_type_complete])
|
|
72
|
+
should_run = all([N_total is not None, term_type_complete])
|
|
73
73
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
|
74
74
|
return should_run, N_total
|
|
75
75
|
|
|
@@ -55,7 +55,7 @@ def _should_run(cycle: dict):
|
|
|
55
55
|
N_total=N_total,
|
|
56
56
|
term_type_fertiliser_complete=term_type_complete)
|
|
57
57
|
|
|
58
|
-
should_run = all([N_total, term_type_complete])
|
|
58
|
+
should_run = all([N_total is not None, term_type_complete])
|
|
59
59
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
|
60
60
|
return should_run, N_total
|
|
61
61
|
|
|
@@ -68,7 +68,7 @@ def _should_run(cycle: dict):
|
|
|
68
68
|
N_total=N_total,
|
|
69
69
|
term_type_fertiliser_complete=term_type_complete)
|
|
70
70
|
|
|
71
|
-
should_run = all([N_total, term_type_complete])
|
|
71
|
+
should_run = all([N_total is not None, term_type_complete])
|
|
72
72
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
|
73
73
|
return should_run, N_total
|
|
74
74
|
|
|
@@ -7,14 +7,17 @@ COEFF_NH3NOX_N2O = 0.01
|
|
|
7
7
|
COEFF_NO3_N2O = 0.0075
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def get_nh3_no3_nox_to_n(cycle: dict, nh3_term_id: str, no3_term_id: str, nox_term_id: str):
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
def get_nh3_no3_nox_to_n(cycle: dict, nh3_term_id: str, no3_term_id: str, nox_term_id: str, allow_none: bool = True):
|
|
11
|
+
default_value = 0 if allow_none else None
|
|
12
|
+
|
|
13
|
+
nh3 = find_terms_value(cycle.get('emissions', []), nh3_term_id, default=default_value)
|
|
14
|
+
nh3 = None if nh3 is None else nh3 / get_atomic_conversion(Units.KG_NH3, Units.TO_N)
|
|
15
|
+
no3 = find_terms_value(cycle.get('emissions', []), no3_term_id, default=default_value)
|
|
16
|
+
no3 = None if no3 is None else no3 / get_atomic_conversion(Units.KG_NO3, Units.TO_N)
|
|
17
|
+
nox = find_terms_value(cycle.get('emissions', []), nox_term_id, default=default_value)
|
|
18
|
+
nox = None if nox is None else nox / get_atomic_conversion(Units.KG_NOX, Units.TO_N)
|
|
19
|
+
|
|
20
|
+
return (nh3, no3, nox)
|
|
18
21
|
|
|
19
22
|
|
|
20
23
|
def get_N_N2O_excreta_coeff_from_primary_product(cycle: dict):
|
|
@@ -14,7 +14,7 @@ from . import MODEL
|
|
|
14
14
|
REQUIREMENTS = {
|
|
15
15
|
"Cycle": {
|
|
16
16
|
"completeness.animalFeed": "True",
|
|
17
|
-
"completeness.
|
|
17
|
+
"completeness.freshForage": "True",
|
|
18
18
|
"or": [
|
|
19
19
|
{
|
|
20
20
|
"animals": [{
|
|
@@ -207,7 +207,7 @@ def _get_default_values(lookup, term: dict):
|
|
|
207
207
|
|
|
208
208
|
def _should_run(cycle: dict):
|
|
209
209
|
is_animalFeed_complete = cycle.get('completeness', {}).get('animalFeed', False) is True
|
|
210
|
-
|
|
210
|
+
is_freshForage_complete = cycle.get('completeness', {}).get('freshForage', False) is True
|
|
211
211
|
|
|
212
212
|
primary_product = find_primary_product(cycle) or {}
|
|
213
213
|
term = primary_product.get('term', {})
|
|
@@ -252,11 +252,11 @@ def _should_run(cycle: dict):
|
|
|
252
252
|
|
|
253
253
|
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
|
254
254
|
term_type_animalFeed_complete=is_animalFeed_complete,
|
|
255
|
-
|
|
255
|
+
term_type_freshForage_complete=is_freshForage_complete,
|
|
256
256
|
total_feed_in_MJ=total_feed)
|
|
257
257
|
|
|
258
258
|
should_run = all([
|
|
259
|
-
is_animalFeed_complete,
|
|
259
|
+
is_animalFeed_complete, is_freshForage_complete, total_feed,
|
|
260
260
|
enteric_factor or default_values[0]
|
|
261
261
|
])
|
|
262
262
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
|
@@ -21,17 +21,24 @@ REQUIREMENTS = {
|
|
|
21
21
|
"products": [{"@type": "Product", "value": "", "term.@id": "aboveGroundCropResidueIncorporated"}],
|
|
22
22
|
"practices": [
|
|
23
23
|
{"@type": "Practice", "value": "", "term.termType": "cropResidueManagement"},
|
|
24
|
+
{"@type": "Practice", "value": "", "term.termType": "landUseManagement"},
|
|
24
25
|
{"@type": "Practice", "value": "", "term.termType": "waterRegime"}
|
|
25
26
|
]
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
LOOKUPS = {
|
|
31
|
+
"landUseManagement": [
|
|
32
|
+
"IPCC_2019_CH4_rice_SFw", "IPCC_2019_CH4_rice_SFw-min", "IPCC_2019_CH4_rice_SFw-max",
|
|
33
|
+
"IPCC_2019_CH4_rice_SFw-sd",
|
|
34
|
+
"IPCC_2019_CH4_rice_SFp", "IPCC_2019_CH4_rice_SFp-min", "IPCC_2019_CH4_rice_SFp-max",
|
|
35
|
+
"IPCC_2019_CH4_rice_SFp-sd"
|
|
36
|
+
],
|
|
30
37
|
"waterRegime": [
|
|
31
|
-
"IPCC_2019_CH4_rice_SFw", "
|
|
32
|
-
"
|
|
33
|
-
"IPCC_2019_CH4_rice_SFp", "
|
|
34
|
-
"
|
|
38
|
+
"IPCC_2019_CH4_rice_SFw", "IPCC_2019_CH4_rice_SFw-min", "IPCC_2019_CH4_rice_SFw-max",
|
|
39
|
+
"IPCC_2019_CH4_rice_SFw-sd",
|
|
40
|
+
"IPCC_2019_CH4_rice_SFp", "IPCC_2019_CH4_rice_SFp-min", "IPCC_2019_CH4_rice_SFp-max",
|
|
41
|
+
"IPCC_2019_CH4_rice_SFp-sd"
|
|
35
42
|
],
|
|
36
43
|
"organicFertiliser": ["IPCC_2019_CH4_rice_CFOA_kg_fresh_weight", "IPCC_2019_CH4_rice_CFOA_kg_dry_weight"],
|
|
37
44
|
"region-ch4ef-IPCC2019": ["CH4_ef", "CH4_ef_min", "CH4_ef_max", "CH4_ef_sd"]
|
|
@@ -66,7 +73,7 @@ def _get_CH4_ef(country: str, suffix: str = ''):
|
|
|
66
73
|
return safe_parse_float(get_table_value(lookup, 'termid', country, column_name('CH4_ef' + suffix)))
|
|
67
74
|
|
|
68
75
|
|
|
69
|
-
def
|
|
76
|
+
def _get_practice_lookup(term: dict, col: str):
|
|
70
77
|
return safe_parse_float(get_lookup_value(term, col, model=MODEL, term=TERM_ID))
|
|
71
78
|
|
|
72
79
|
|
|
@@ -99,7 +106,7 @@ def _calculate_SFo(cycle: dict, suffix: str = ''):
|
|
|
99
106
|
|
|
100
107
|
def _calculate_SF_average(practices: list, factor: str):
|
|
101
108
|
values = [
|
|
102
|
-
(
|
|
109
|
+
(_get_practice_lookup(p.get('term', {}), factor), list_sum(p.get('value', []), None)) for p in practices
|
|
103
110
|
]
|
|
104
111
|
# sum only values that are numbers
|
|
105
112
|
return list_sum([factor * percent / 100 for factor, percent in values if percent is not None])
|
|
@@ -124,7 +131,9 @@ def _get_croppingDuration(croppingDuration: dict, key: str = 'value'):
|
|
|
124
131
|
|
|
125
132
|
|
|
126
133
|
def _run(cycle: dict, croppingDuration: dict, country: str):
|
|
127
|
-
practices = filter_list_term_type(cycle.get('practices', []),
|
|
134
|
+
practices = filter_list_term_type(cycle.get('practices', []), [
|
|
135
|
+
TermTermType.WATERREGIME, TermTermType.LANDUSEMANAGEMENT
|
|
136
|
+
])
|
|
128
137
|
|
|
129
138
|
value = _calculate_factor(cycle, country, practices) * _get_croppingDuration(croppingDuration)
|
|
130
139
|
min = _calculate_factor(cycle, country, practices, '_min') * _get_croppingDuration(croppingDuration, 'min')
|