hestia-earth-models 0.73.6__py3-none-any.whl → 0.73.8__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/config/Cycle.json +116 -26
- hestia_earth/models/config/ImpactAssessment.json +239 -199
- hestia_earth/models/dammgen2009/noxToAirExcreta.py +11 -9
- hestia_earth/models/ecoalimV9/cycle.py +29 -39
- hestia_earth/models/ecoalimV9/impact_assessment.py +38 -40
- hestia_earth/models/ecoalimV9/utils.py +82 -16
- hestia_earth/models/ecoinventV3/__init__.py +3 -3
- hestia_earth/models/emepEea2019/n2OToAirFuelCombustionDirect.py +2 -2
- hestia_earth/models/hestia/default_emissions.py +2 -6
- hestia_earth/models/hestia/default_resourceUse.py +2 -5
- hestia_earth/models/hestia/landCover.py +3 -3
- hestia_earth/models/hestia/pastureSystem.py +1 -1
- hestia_earth/models/hestia/seed_emissions.py +7 -3
- hestia_earth/models/impact_assessment/emissions.py +3 -5
- hestia_earth/models/ipcc2019/biocharOrganicCarbonPerHa.py +9 -3
- hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChange.py +1 -5
- hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChange.py +1 -5
- hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +1 -33
- hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py +1 -5
- hestia_earth/models/ipcc2019/n2OToAirAquacultureSystemsIndirect.py +44 -0
- hestia_earth/models/ipcc2019/n2OToAirCropResidueBurningIndirect.py +43 -0
- hestia_earth/models/ipcc2019/n2OToAirCropResidueDecompositionIndirect.py +13 -70
- hestia_earth/models/ipcc2019/n2OToAirExcretaIndirect.py +13 -70
- hestia_earth/models/ipcc2019/n2OToAirFuelCombustionIndirect.py +43 -0
- hestia_earth/models/ipcc2019/n2OToAirInorganicFertiliserIndirect.py +13 -70
- hestia_earth/models/ipcc2019/n2OToAirNaturalVegetationBurningIndirect.py +43 -0
- hestia_earth/models/ipcc2019/n2OToAirOrganicFertiliserIndirect.py +13 -70
- hestia_earth/models/ipcc2019/n2OToAirOrganicSoilBurningIndirect.py +43 -0
- hestia_earth/models/ipcc2019/n2OToAirOrganicSoilCultivationIndirect.py +43 -0
- hestia_earth/models/ipcc2019/n2OToAir_indirect_emissions_utils.py +112 -0
- hestia_earth/models/ipcc2019/utils.py +0 -25
- hestia_earth/models/jarvisAndPain1994/n2ToAirExcreta.py +11 -9
- hestia_earth/models/linkedImpactAssessment/emissions.py +24 -15
- hestia_earth/models/linkedImpactAssessment/utils.py +5 -1
- hestia_earth/models/mocking/search-results.json +1284 -1284
- hestia_earth/models/utils/background_emissions.py +17 -10
- hestia_earth/models/utils/emission.py +18 -8
- hestia_earth/models/utils/impact_assessment.py +3 -3
- hestia_earth/models/utils/indicator.py +8 -1
- hestia_earth/models/utils/lookup.py +38 -21
- hestia_earth/models/utils/productivity.py +1 -1
- hestia_earth/models/version.py +1 -1
- hestia_earth/orchestrator/strategies/merge/merge_list.py +41 -54
- {hestia_earth_models-0.73.6.dist-info → hestia_earth_models-0.73.8.dist-info}/METADATA +3 -3
- {hestia_earth_models-0.73.6.dist-info → hestia_earth_models-0.73.8.dist-info}/RECORD +64 -49
- tests/models/dammgen2009/test_noxToAirExcreta.py +2 -2
- tests/models/ecoalimV9/test_cycle.py +1 -1
- tests/models/ecoalimV9/test_impact_assessment.py +1 -1
- tests/models/ecoalimV9/test_utils.py +13 -0
- tests/models/ipcc2019/test_biocharOrganicCarbonPerHa.py +2 -1
- tests/models/ipcc2019/test_n2OToAirAquacultureSystemsIndirect.py +45 -0
- tests/models/ipcc2019/test_n2OToAirCropResidueBurningIndirect.py +45 -0
- tests/models/ipcc2019/test_n2OToAirCropResidueDecompositionIndirect.py +6 -32
- tests/models/ipcc2019/test_n2OToAirExcretaIndirect.py +6 -32
- tests/models/ipcc2019/test_n2OToAirFuelCombustionIndirect.py +45 -0
- tests/models/ipcc2019/test_n2OToAirInorganicFertiliserIndirect.py +6 -32
- tests/models/ipcc2019/test_n2OToAirNaturalVegetationBurningIndirect.py +45 -0
- tests/models/ipcc2019/test_n2OToAirOrganicFertiliserIndirect.py +6 -32
- tests/models/ipcc2019/test_n2OToAirOrganicSoilBurningIndirect.py +45 -0
- tests/models/ipcc2019/test_n2OToAirOrganicSoilCultivationIndirect.py +45 -0
- tests/models/ipcc2019/test_n2OToAir_indirect_emissions_utils.py +19 -0
- {hestia_earth_models-0.73.6.dist-info → hestia_earth_models-0.73.8.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.73.6.dist-info → hestia_earth_models-0.73.8.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.73.6.dist-info → hestia_earth_models-0.73.8.dist-info}/top_level.txt +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Utilities for calculating CO2 emissions based on changes in carbon stocks (e.g., `organicCarbonPerHa`,
|
|
3
3
|
`aboveGroundBiomass` and `belowGroundBiomass`).
|
|
4
4
|
"""
|
|
5
|
-
from datetime import datetime
|
|
5
|
+
from datetime import datetime
|
|
6
6
|
from enum import Enum
|
|
7
7
|
from functools import reduce
|
|
8
8
|
from itertools import product
|
|
@@ -1506,8 +1506,6 @@ def create_run_function(
|
|
|
1506
1506
|
new_emission_func(
|
|
1507
1507
|
term_id=emission_term_id,
|
|
1508
1508
|
method_tier=_get_emission_method(total_emission),
|
|
1509
|
-
start_date=_get_emission_start_date(total_emission, cycle_start_date),
|
|
1510
|
-
end_date=_get_emission_end_date(total_emission, cycle_end_date),
|
|
1511
1509
|
**calc_descriptive_stats(
|
|
1512
1510
|
total_emission.value,
|
|
1513
1511
|
EmissionStatsDefinition.SIMULATED,
|
|
@@ -1532,33 +1530,3 @@ def get_zero_emission(year):
|
|
|
1532
1530
|
def _get_emission_method(emission: CarbonStockChangeEmission):
|
|
1533
1531
|
method = emission.method
|
|
1534
1532
|
return method if isinstance(method, EmissionMethodTier) else EmissionMethodTier.TIER_1
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
def _get_emission_start_date(emission: CarbonStockChangeEmission, cycle_start_date: str) -> str:
|
|
1538
|
-
cycle_datetime = safe_parse_date(_gapfill_datestr(cycle_start_date))
|
|
1539
|
-
emission_datetime = safe_parse_date(emission.start_date)
|
|
1540
|
-
|
|
1541
|
-
should_run = (
|
|
1542
|
-
cycle_datetime and emission_datetime
|
|
1543
|
-
and cycle_datetime < emission_datetime # If the cycle starts before the emission, add a `startDate`
|
|
1544
|
-
)
|
|
1545
|
-
|
|
1546
|
-
return (
|
|
1547
|
-
(emission_datetime + timedelta(seconds=1)).strftime(DatestrFormat.YEAR_MONTH_DAY.value) if should_run
|
|
1548
|
-
else None
|
|
1549
|
-
)
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
def _get_emission_end_date(emission: CarbonStockChangeEmission, cycle_end_date: str) -> str:
|
|
1553
|
-
cycle_datetime = safe_parse_date(_gapfill_datestr(cycle_end_date, DatestrGapfillMode.END))
|
|
1554
|
-
emission_datetime = safe_parse_date(emission.end_date)
|
|
1555
|
-
|
|
1556
|
-
should_run = (
|
|
1557
|
-
cycle_datetime and emission_datetime
|
|
1558
|
-
and cycle_datetime > emission_datetime # If the cycle ends after the emission, add an `endDate`
|
|
1559
|
-
)
|
|
1560
|
-
|
|
1561
|
-
return (
|
|
1562
|
-
emission_datetime.strftime(DatestrFormat.YEAR_MONTH_DAY.value) if should_run
|
|
1563
|
-
else None
|
|
1564
|
-
)
|
|
@@ -69,9 +69,7 @@ def _emission(
|
|
|
69
69
|
min: list[float] = None,
|
|
70
70
|
max: list[float] = None,
|
|
71
71
|
statsDefinition: str = None,
|
|
72
|
-
observations: list[int] = None
|
|
73
|
-
start_date: str,
|
|
74
|
-
end_date: str
|
|
72
|
+
observations: list[int] = None
|
|
75
73
|
) -> dict:
|
|
76
74
|
"""
|
|
77
75
|
Create an emission node based on the provided value and method tier.
|
|
@@ -99,8 +97,6 @@ def _emission(
|
|
|
99
97
|
"max": max,
|
|
100
98
|
"statsDefinition": statsDefinition,
|
|
101
99
|
"observations": observations,
|
|
102
|
-
"startDate": start_date,
|
|
103
|
-
"endDate": end_date,
|
|
104
100
|
"methodTier": method_tier.value,
|
|
105
101
|
"depth": _DEPTH_LOWER
|
|
106
102
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from hestia_earth.schema import EmissionMethodTier
|
|
2
|
+
|
|
3
|
+
from .n2OToAir_indirect_emissions_utils import run as run_emission
|
|
4
|
+
|
|
5
|
+
REQUIREMENTS = {
|
|
6
|
+
"Cycle": {
|
|
7
|
+
"completeness.cropResidue": "True",
|
|
8
|
+
"emissions": [
|
|
9
|
+
{"@type": "Emission", "value": "", "term.@id": "nh3ToSurfaceWaterAquacultureSystems"},
|
|
10
|
+
{"@type": "Emission", "value": "", "term.@id": "nh3ToAirAquacultureSystems"},
|
|
11
|
+
{"@type": "Emission", "value": "", "term.@id": "noxToAirAquacultureSystems"}
|
|
12
|
+
],
|
|
13
|
+
"optional": {
|
|
14
|
+
"site": {
|
|
15
|
+
"@type": "Site",
|
|
16
|
+
"measurements": [
|
|
17
|
+
{"@type": "Measurement", "value": "", "term.@id": "ecoClimateZone"}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
LOOKUPS = {
|
|
24
|
+
"emission": [
|
|
25
|
+
"IPCC_2019_EF4_FACTORS", "IPCC_2019_EF4_FACTORS-max", "IPCC_2019_EF4_FACTORS-min",
|
|
26
|
+
"IPCC_2019_EF5_FACTORS", "IPCC_2019_EF5_FACTORS-max", "IPCC_2019_EF5_FACTORS-min"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
RETURNS = {
|
|
30
|
+
"Emission": [{
|
|
31
|
+
"value": "",
|
|
32
|
+
"methodTier": "tier 1"
|
|
33
|
+
}]
|
|
34
|
+
}
|
|
35
|
+
TERM_ID = 'n2OToAirAquacultureSystemsIndirect'
|
|
36
|
+
TIER = EmissionMethodTier.TIER_1.value
|
|
37
|
+
_NO3_TERM_ID = 'nh3ToSurfaceWaterAquacultureSystems'
|
|
38
|
+
_NH3_TERM_ID = 'nh3ToAirAquacultureSystems'
|
|
39
|
+
_NOX_TERM_ID = 'noxToAirAquacultureSystems'
|
|
40
|
+
_EMISSION_IDS = [_NH3_TERM_ID, _NO3_TERM_ID, _NOX_TERM_ID]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def run(cycle: dict):
|
|
44
|
+
return run_emission(TERM_ID, _EMISSION_IDS, cycle)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from hestia_earth.schema import EmissionMethodTier
|
|
2
|
+
|
|
3
|
+
from .n2OToAir_indirect_emissions_utils import run as run_emission
|
|
4
|
+
|
|
5
|
+
REQUIREMENTS = {
|
|
6
|
+
"Cycle": {
|
|
7
|
+
"completeness.cropResidue": "True",
|
|
8
|
+
"emissions": [
|
|
9
|
+
{"@type": "Emission", "value": "", "term.@id": "nh3ToAirCropResidueBurning"},
|
|
10
|
+
{"@type": "Emission", "value": "", "term.@id": "noxToAirCropResidueBurning"}
|
|
11
|
+
],
|
|
12
|
+
"optional": {
|
|
13
|
+
"site": {
|
|
14
|
+
"@type": "Site",
|
|
15
|
+
"measurements": [
|
|
16
|
+
{"@type": "Measurement", "value": "", "term.@id": "ecoClimateZone"}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
LOOKUPS = {
|
|
23
|
+
"emission": [
|
|
24
|
+
"IPCC_2019_EF4_FACTORS", "IPCC_2019_EF4_FACTORS-max", "IPCC_2019_EF4_FACTORS-min",
|
|
25
|
+
"IPCC_2019_EF5_FACTORS", "IPCC_2019_EF5_FACTORS-max", "IPCC_2019_EF5_FACTORS-min"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
RETURNS = {
|
|
29
|
+
"Emission": [{
|
|
30
|
+
"value": "",
|
|
31
|
+
"methodTier": "tier 1"
|
|
32
|
+
}]
|
|
33
|
+
}
|
|
34
|
+
TERM_ID = 'n2OToAirCropResidueBurningIndirect'
|
|
35
|
+
TIER = EmissionMethodTier.TIER_1.value
|
|
36
|
+
_NO3_TERM_ID = None
|
|
37
|
+
_NH3_TERM_ID = 'nh3ToAirCropResidueBurning'
|
|
38
|
+
_NOX_TERM_ID = 'noxToAirCropResidueBurning'
|
|
39
|
+
_EMISSION_IDS = [_NH3_TERM_ID, _NO3_TERM_ID, _NOX_TERM_ID]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def run(cycle: dict):
|
|
43
|
+
return run_emission(TERM_ID, _EMISSION_IDS, cycle)
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
from hestia_earth.schema import EmissionMethodTier
|
|
1
|
+
from hestia_earth.schema import EmissionMethodTier
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from hestia_earth.models.utils.constant import Units, get_atomic_conversion
|
|
5
|
-
from hestia_earth.models.utils.completeness import _is_term_type_complete
|
|
6
|
-
from hestia_earth.models.utils.emission import _new_emission, get_nh3_no3_nox_to_n
|
|
7
|
-
from hestia_earth.models.utils.cycle import get_ecoClimateZone
|
|
8
|
-
from .utils import ecoClimate_factors, EF4_FACTORS, EF5_FACTORS
|
|
9
|
-
from . import MODEL
|
|
3
|
+
from .n2OToAir_indirect_emissions_utils import run as run_emission
|
|
10
4
|
|
|
11
5
|
REQUIREMENTS = {
|
|
12
6
|
"Cycle": {
|
|
13
|
-
"completeness.cropResidue": "True",
|
|
14
7
|
"emissions": [
|
|
15
8
|
{"@type": "Emission", "value": "", "term.@id": "no3ToGroundwaterCropResidueDecomposition"},
|
|
16
9
|
{"@type": "Emission", "value": "", "term.@id": "nh3ToAirCropResidueDecomposition"},
|
|
@@ -26,6 +19,12 @@ REQUIREMENTS = {
|
|
|
26
19
|
}
|
|
27
20
|
}
|
|
28
21
|
}
|
|
22
|
+
LOOKUPS = {
|
|
23
|
+
"emission": [
|
|
24
|
+
"IPCC_2019_EF4_FACTORS", "IPCC_2019_EF4_FACTORS-max", "IPCC_2019_EF4_FACTORS-min",
|
|
25
|
+
"IPCC_2019_EF5_FACTORS", "IPCC_2019_EF5_FACTORS-max", "IPCC_2019_EF5_FACTORS-min"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
29
28
|
RETURNS = {
|
|
30
29
|
"Emission": [{
|
|
31
30
|
"value": "",
|
|
@@ -34,67 +33,11 @@ RETURNS = {
|
|
|
34
33
|
}
|
|
35
34
|
TERM_ID = 'n2OToAirCropResidueDecompositionIndirect'
|
|
36
35
|
TIER = EmissionMethodTier.TIER_1.value
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def _emission(value: float, min: float, max: float, aggregated: bool = False):
|
|
43
|
-
emission = _new_emission(TERM_ID, MODEL)
|
|
44
|
-
emission['value'] = [value]
|
|
45
|
-
emission['min'] = [min]
|
|
46
|
-
emission['max'] = [max]
|
|
47
|
-
emission['methodTier'] = TIER
|
|
48
|
-
emission['statsDefinition'] = EmissionStatsDefinition.MODELLED.value
|
|
49
|
-
emission['methodModelDescription'] = 'Aggregated version' if aggregated else 'Disaggregated version'
|
|
50
|
-
return emission
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def _run(cycle: dict, no3: float, nh3: float, nox: float):
|
|
54
|
-
ecoClimateZone = get_ecoClimateZone(cycle)
|
|
55
|
-
|
|
56
|
-
ef4, aggregated = ecoClimate_factors(EF4_FACTORS, ecoClimateZone=ecoClimateZone)
|
|
57
|
-
ef5 = EF5_FACTORS.get('default')
|
|
58
|
-
|
|
59
|
-
debugValues(cycle, model=MODEL, term=TERM_ID,
|
|
60
|
-
ecoClimateZone=ecoClimateZone,
|
|
61
|
-
ef4_factors_used=log_as_table(ef4),
|
|
62
|
-
ef5_factors_used=log_as_table(ef5),
|
|
63
|
-
aggregated=aggregated)
|
|
64
|
-
|
|
65
|
-
value = sum([
|
|
66
|
-
no3 * ef5['value'],
|
|
67
|
-
nh3 * ef4['value'],
|
|
68
|
-
nox * ef4['value']
|
|
69
|
-
]) * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
|
70
|
-
min = sum([
|
|
71
|
-
no3 * ef5['min'],
|
|
72
|
-
nh3 * ef4['min'],
|
|
73
|
-
nox * ef4['min']
|
|
74
|
-
]) * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
|
75
|
-
max = sum([
|
|
76
|
-
no3 * ef5['max'],
|
|
77
|
-
nh3 * ef4['max'],
|
|
78
|
-
nox * ef4['max']
|
|
79
|
-
]) * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
|
80
|
-
return [_emission(value, min, max, aggregated=aggregated)]
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def _should_run(cycle: dict):
|
|
84
|
-
nh3_n, no3_n, nox_n = get_nh3_no3_nox_to_n(cycle, NH3_TERM_ID, NO3_TERM_ID, NOX_TERM_ID)
|
|
85
|
-
term_type_complete = _is_term_type_complete(cycle, TermTermType.CROPRESIDUE)
|
|
86
|
-
|
|
87
|
-
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
|
88
|
-
no3_n=no3_n,
|
|
89
|
-
nh3_n=nh3_n,
|
|
90
|
-
nox_n=nox_n,
|
|
91
|
-
term_type_cropResidue_complete=term_type_complete)
|
|
92
|
-
|
|
93
|
-
should_run = all([no3_n is not None, nh3_n is not None, nox_n is not None, term_type_complete])
|
|
94
|
-
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
|
95
|
-
return should_run, no3_n, nh3_n, nox_n
|
|
36
|
+
_NO3_TERM_ID = 'no3ToGroundwaterCropResidueDecomposition'
|
|
37
|
+
_NH3_TERM_ID = 'nh3ToAirCropResidueDecomposition'
|
|
38
|
+
_NOX_TERM_ID = 'noxToAirCropResidueDecomposition'
|
|
39
|
+
_EMISSION_IDS = [_NH3_TERM_ID, _NO3_TERM_ID, _NOX_TERM_ID]
|
|
96
40
|
|
|
97
41
|
|
|
98
42
|
def run(cycle: dict):
|
|
99
|
-
|
|
100
|
-
return _run(cycle, no3, nh3, nox) if should_run else []
|
|
43
|
+
return run_emission(TERM_ID, _EMISSION_IDS, cycle)
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
from hestia_earth.schema import EmissionMethodTier
|
|
1
|
+
from hestia_earth.schema import EmissionMethodTier
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from hestia_earth.models.utils.constant import Units, get_atomic_conversion
|
|
5
|
-
from hestia_earth.models.utils.completeness import _is_term_type_complete
|
|
6
|
-
from hestia_earth.models.utils.emission import _new_emission, get_nh3_no3_nox_to_n
|
|
7
|
-
from hestia_earth.models.utils.cycle import get_ecoClimateZone
|
|
8
|
-
from .utils import ecoClimate_factors, EF4_FACTORS, EF5_FACTORS
|
|
9
|
-
from . import MODEL
|
|
3
|
+
from .n2OToAir_indirect_emissions_utils import run as run_emission
|
|
10
4
|
|
|
11
5
|
REQUIREMENTS = {
|
|
12
6
|
"Cycle": {
|
|
13
|
-
"completeness.excreta": "True",
|
|
14
7
|
"emissions": [
|
|
15
8
|
{"@type": "Emission", "value": "", "term.@id": "no3ToGroundwaterExcreta"},
|
|
16
9
|
{"@type": "Emission", "value": "", "term.@id": "nh3ToAirExcreta"},
|
|
@@ -26,6 +19,12 @@ REQUIREMENTS = {
|
|
|
26
19
|
}
|
|
27
20
|
}
|
|
28
21
|
}
|
|
22
|
+
LOOKUPS = {
|
|
23
|
+
"emission": [
|
|
24
|
+
"IPCC_2019_EF4_FACTORS", "IPCC_2019_EF4_FACTORS-max", "IPCC_2019_EF4_FACTORS-min",
|
|
25
|
+
"IPCC_2019_EF5_FACTORS", "IPCC_2019_EF5_FACTORS-max", "IPCC_2019_EF5_FACTORS-min"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
29
28
|
RETURNS = {
|
|
30
29
|
"Emission": [{
|
|
31
30
|
"value": "",
|
|
@@ -34,67 +33,11 @@ RETURNS = {
|
|
|
34
33
|
}
|
|
35
34
|
TERM_ID = 'n2OToAirExcretaIndirect'
|
|
36
35
|
TIER = EmissionMethodTier.TIER_1.value
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def _emission(value: float, min: float, max: float, aggregated: bool = False):
|
|
43
|
-
emission = _new_emission(TERM_ID, MODEL)
|
|
44
|
-
emission['value'] = [value]
|
|
45
|
-
emission['min'] = [min]
|
|
46
|
-
emission['max'] = [max]
|
|
47
|
-
emission['methodTier'] = TIER
|
|
48
|
-
emission['statsDefinition'] = EmissionStatsDefinition.MODELLED.value
|
|
49
|
-
emission['methodModelDescription'] = 'Aggregated version' if aggregated else 'Disaggregated version'
|
|
50
|
-
return emission
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def _run(cycle: dict, no3: float, nh3: float, nox: float):
|
|
54
|
-
ecoClimateZone = get_ecoClimateZone(cycle)
|
|
55
|
-
|
|
56
|
-
ef4, aggregated = ecoClimate_factors(EF4_FACTORS, ecoClimateZone=ecoClimateZone)
|
|
57
|
-
ef5 = EF5_FACTORS.get('default')
|
|
58
|
-
|
|
59
|
-
debugValues(cycle, model=MODEL, term=TERM_ID,
|
|
60
|
-
ecoClimateZone=ecoClimateZone,
|
|
61
|
-
ef4_factors_used=log_as_table(ef4),
|
|
62
|
-
ef5_factors_used=log_as_table(ef5),
|
|
63
|
-
aggregated=aggregated)
|
|
64
|
-
|
|
65
|
-
value = sum([
|
|
66
|
-
no3 * ef5['value'],
|
|
67
|
-
nh3 * ef4['value'],
|
|
68
|
-
nox * ef4['value']
|
|
69
|
-
]) * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
|
70
|
-
min = sum([
|
|
71
|
-
no3 * ef5['min'],
|
|
72
|
-
nh3 * ef4['min'],
|
|
73
|
-
nox * ef4['min']
|
|
74
|
-
]) * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
|
75
|
-
max = sum([
|
|
76
|
-
no3 * ef5['max'],
|
|
77
|
-
nh3 * ef4['max'],
|
|
78
|
-
nox * ef4['max']
|
|
79
|
-
]) * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
|
80
|
-
return [_emission(value, min, max, aggregated=aggregated)]
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def _should_run(cycle: dict):
|
|
84
|
-
nh3_n, no3_n, nox_n = get_nh3_no3_nox_to_n(cycle, NH3_TERM_ID, NO3_TERM_ID, NOX_TERM_ID)
|
|
85
|
-
term_type_complete = _is_term_type_complete(cycle, TermTermType.EXCRETA)
|
|
86
|
-
|
|
87
|
-
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
|
88
|
-
no3_n=no3_n,
|
|
89
|
-
nh3_n=nh3_n,
|
|
90
|
-
nox_n=nox_n,
|
|
91
|
-
term_type_excreta_complete=term_type_complete)
|
|
92
|
-
|
|
93
|
-
should_run = all([no3_n is not None, nh3_n is not None, nox_n is not None, term_type_complete])
|
|
94
|
-
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
|
95
|
-
return should_run, no3_n, nh3_n, nox_n
|
|
36
|
+
_NO3_TERM_ID = 'no3ToGroundwaterExcreta'
|
|
37
|
+
_NH3_TERM_ID = 'nh3ToAirExcreta'
|
|
38
|
+
_NOX_TERM_ID = 'noxToAirExcreta'
|
|
39
|
+
_EMISSION_IDS = [_NH3_TERM_ID, _NO3_TERM_ID, _NOX_TERM_ID]
|
|
96
40
|
|
|
97
41
|
|
|
98
42
|
def run(cycle: dict):
|
|
99
|
-
|
|
100
|
-
return _run(cycle, no3, nh3, nox) if should_run else []
|
|
43
|
+
return run_emission(TERM_ID, _EMISSION_IDS, cycle)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from hestia_earth.schema import EmissionMethodTier
|
|
2
|
+
|
|
3
|
+
from .n2OToAir_indirect_emissions_utils import run as run_emission
|
|
4
|
+
|
|
5
|
+
REQUIREMENTS = {
|
|
6
|
+
"Cycle": {
|
|
7
|
+
"completeness.electricityFuel": "True",
|
|
8
|
+
"emissions": [
|
|
9
|
+
{"@type": "Emission", "value": "", "term.@id": "nh3ToAirFuelCombustion"},
|
|
10
|
+
{"@type": "Emission", "value": "", "term.@id": "noxToAirFuelCombustion"}
|
|
11
|
+
],
|
|
12
|
+
"optional": {
|
|
13
|
+
"site": {
|
|
14
|
+
"@type": "Site",
|
|
15
|
+
"measurements": [
|
|
16
|
+
{"@type": "Measurement", "value": "", "term.@id": "ecoClimateZone"}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
LOOKUPS = {
|
|
23
|
+
"emission": [
|
|
24
|
+
"IPCC_2019_EF4_FACTORS", "IPCC_2019_EF4_FACTORS-max", "IPCC_2019_EF4_FACTORS-min",
|
|
25
|
+
"IPCC_2019_EF5_FACTORS", "IPCC_2019_EF5_FACTORS-max", "IPCC_2019_EF5_FACTORS-min"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
RETURNS = {
|
|
29
|
+
"Emission": [{
|
|
30
|
+
"value": "",
|
|
31
|
+
"methodTier": "tier 1"
|
|
32
|
+
}]
|
|
33
|
+
}
|
|
34
|
+
TERM_ID = 'n2OToAirFuelCombustionIndirect'
|
|
35
|
+
TIER = EmissionMethodTier.TIER_1.value
|
|
36
|
+
_NO3_TERM_ID = None
|
|
37
|
+
_NH3_TERM_ID = 'nh3ToAirFuelCombustion'
|
|
38
|
+
_NOX_TERM_ID = 'noxToAirFuelCombustion'
|
|
39
|
+
_EMISSION_IDS = [_NH3_TERM_ID, _NO3_TERM_ID, _NOX_TERM_ID]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def run(cycle: dict):
|
|
43
|
+
return run_emission(TERM_ID, _EMISSION_IDS, cycle)
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
from hestia_earth.schema import EmissionMethodTier
|
|
1
|
+
from hestia_earth.schema import EmissionMethodTier
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from hestia_earth.models.utils.constant import Units, get_atomic_conversion
|
|
5
|
-
from hestia_earth.models.utils.completeness import _is_term_type_complete
|
|
6
|
-
from hestia_earth.models.utils.emission import _new_emission, get_nh3_no3_nox_to_n
|
|
7
|
-
from hestia_earth.models.utils.cycle import get_ecoClimateZone
|
|
8
|
-
from .utils import ecoClimate_factors, EF4_FACTORS, EF5_FACTORS
|
|
9
|
-
from . import MODEL
|
|
3
|
+
from .n2OToAir_indirect_emissions_utils import run as run_emission
|
|
10
4
|
|
|
11
5
|
REQUIREMENTS = {
|
|
12
6
|
"Cycle": {
|
|
13
|
-
"completeness.fertiliser": "True",
|
|
14
7
|
"emissions": [
|
|
15
8
|
{"@type": "Emission", "value": "", "term.@id": "no3ToGroundwaterInorganicFertiliser"},
|
|
16
9
|
{"@type": "Emission", "value": "", "term.@id": "nh3ToAirInorganicFertiliser"},
|
|
@@ -26,6 +19,12 @@ REQUIREMENTS = {
|
|
|
26
19
|
}
|
|
27
20
|
}
|
|
28
21
|
}
|
|
22
|
+
LOOKUPS = {
|
|
23
|
+
"emission": [
|
|
24
|
+
"IPCC_2019_EF4_FACTORS", "IPCC_2019_EF4_FACTORS-max", "IPCC_2019_EF4_FACTORS-min",
|
|
25
|
+
"IPCC_2019_EF5_FACTORS", "IPCC_2019_EF5_FACTORS-max", "IPCC_2019_EF5_FACTORS-min"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
29
28
|
RETURNS = {
|
|
30
29
|
"Emission": [{
|
|
31
30
|
"value": "",
|
|
@@ -34,67 +33,11 @@ RETURNS = {
|
|
|
34
33
|
}
|
|
35
34
|
TERM_ID = 'n2OToAirInorganicFertiliserIndirect'
|
|
36
35
|
TIER = EmissionMethodTier.TIER_1.value
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def _emission(value: float, min: float, max: float, aggregated: bool = False):
|
|
43
|
-
emission = _new_emission(TERM_ID, MODEL)
|
|
44
|
-
emission['value'] = [value]
|
|
45
|
-
emission['min'] = [min]
|
|
46
|
-
emission['max'] = [max]
|
|
47
|
-
emission['methodTier'] = TIER
|
|
48
|
-
emission['statsDefinition'] = EmissionStatsDefinition.MODELLED.value
|
|
49
|
-
emission['methodModelDescription'] = 'Aggregated version' if aggregated else 'Disaggregated version'
|
|
50
|
-
return emission
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def _run(cycle: dict, no3: float, nh3: float, nox: float):
|
|
54
|
-
ecoClimateZone = get_ecoClimateZone(cycle)
|
|
55
|
-
|
|
56
|
-
ef4, aggregated = ecoClimate_factors(EF4_FACTORS, ecoClimateZone=ecoClimateZone)
|
|
57
|
-
ef5 = EF5_FACTORS.get('default')
|
|
58
|
-
|
|
59
|
-
debugValues(cycle, model=MODEL, term=TERM_ID,
|
|
60
|
-
ecoClimateZone=ecoClimateZone,
|
|
61
|
-
ef4_factors_used=log_as_table(ef4),
|
|
62
|
-
ef5_factors_used=log_as_table(ef5),
|
|
63
|
-
aggregated=aggregated)
|
|
64
|
-
|
|
65
|
-
value = sum([
|
|
66
|
-
no3 * ef5['value'],
|
|
67
|
-
nh3 * ef4['value'],
|
|
68
|
-
nox * ef4['value']
|
|
69
|
-
]) * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
|
70
|
-
min = sum([
|
|
71
|
-
no3 * ef5['min'],
|
|
72
|
-
nh3 * ef4['min'],
|
|
73
|
-
nox * ef4['min']
|
|
74
|
-
]) * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
|
75
|
-
max = sum([
|
|
76
|
-
no3 * ef5['max'],
|
|
77
|
-
nh3 * ef4['max'],
|
|
78
|
-
nox * ef4['max']
|
|
79
|
-
]) * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
|
80
|
-
return [_emission(value, min, max, aggregated=aggregated)]
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def _should_run(cycle: dict):
|
|
84
|
-
nh3_n, no3_n, nox_n = get_nh3_no3_nox_to_n(cycle, NH3_TERM_ID, NO3_TERM_ID, NOX_TERM_ID)
|
|
85
|
-
term_type_complete = _is_term_type_complete(cycle, 'fertiliser')
|
|
86
|
-
|
|
87
|
-
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
|
88
|
-
no3_n=no3_n,
|
|
89
|
-
nh3_n=nh3_n,
|
|
90
|
-
nox_n=nox_n,
|
|
91
|
-
term_type_fertiliser_complete=term_type_complete)
|
|
92
|
-
|
|
93
|
-
should_run = all([no3_n is not None, nh3_n is not None, nox_n is not None, term_type_complete])
|
|
94
|
-
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
|
95
|
-
return should_run, no3_n, nh3_n, nox_n
|
|
36
|
+
_NO3_TERM_ID = 'no3ToGroundwaterInorganicFertiliser'
|
|
37
|
+
_NH3_TERM_ID = 'nh3ToAirInorganicFertiliser'
|
|
38
|
+
_NOX_TERM_ID = 'noxToAirInorganicFertiliser'
|
|
39
|
+
_EMISSION_IDS = [_NH3_TERM_ID, _NO3_TERM_ID, _NOX_TERM_ID]
|
|
96
40
|
|
|
97
41
|
|
|
98
42
|
def run(cycle: dict):
|
|
99
|
-
|
|
100
|
-
return _run(cycle, no3, nh3, nox) if should_run else []
|
|
43
|
+
return run_emission(TERM_ID, _EMISSION_IDS, cycle)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from hestia_earth.schema import EmissionMethodTier
|
|
2
|
+
|
|
3
|
+
from .n2OToAir_indirect_emissions_utils import run as run_emission
|
|
4
|
+
|
|
5
|
+
REQUIREMENTS = {
|
|
6
|
+
"Cycle": {
|
|
7
|
+
"completeness.cropResidue": "True",
|
|
8
|
+
"emissions": [
|
|
9
|
+
{"@type": "Emission", "value": "", "term.@id": "nh3ToAirNaturalVegetationBurning"},
|
|
10
|
+
{"@type": "Emission", "value": "", "term.@id": "noxToAirNaturalVegetationBurning"}
|
|
11
|
+
],
|
|
12
|
+
"optional": {
|
|
13
|
+
"site": {
|
|
14
|
+
"@type": "Site",
|
|
15
|
+
"measurements": [
|
|
16
|
+
{"@type": "Measurement", "value": "", "term.@id": "ecoClimateZone"}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
LOOKUPS = {
|
|
23
|
+
"emission": [
|
|
24
|
+
"IPCC_2019_EF4_FACTORS", "IPCC_2019_EF4_FACTORS-max", "IPCC_2019_EF4_FACTORS-min",
|
|
25
|
+
"IPCC_2019_EF5_FACTORS", "IPCC_2019_EF5_FACTORS-max", "IPCC_2019_EF5_FACTORS-min"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
RETURNS = {
|
|
29
|
+
"Emission": [{
|
|
30
|
+
"value": "",
|
|
31
|
+
"methodTier": "tier 1"
|
|
32
|
+
}]
|
|
33
|
+
}
|
|
34
|
+
TERM_ID = 'n2OToAirNaturalVegetationBurningIndirect'
|
|
35
|
+
TIER = EmissionMethodTier.TIER_1.value
|
|
36
|
+
_NO3_TERM_ID = None
|
|
37
|
+
_NH3_TERM_ID = 'nh3ToAirNaturalVegetationBurning'
|
|
38
|
+
_NOX_TERM_ID = 'noxToAirNaturalVegetationBurning'
|
|
39
|
+
_EMISSION_IDS = [_NH3_TERM_ID, _NO3_TERM_ID, _NOX_TERM_ID]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def run(cycle: dict):
|
|
43
|
+
return run_emission(TERM_ID, _EMISSION_IDS, cycle)
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
from hestia_earth.schema import EmissionMethodTier
|
|
1
|
+
from hestia_earth.schema import EmissionMethodTier
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from hestia_earth.models.utils.constant import Units, get_atomic_conversion
|
|
5
|
-
from hestia_earth.models.utils.completeness import _is_term_type_complete
|
|
6
|
-
from hestia_earth.models.utils.emission import _new_emission, get_nh3_no3_nox_to_n
|
|
7
|
-
from hestia_earth.models.utils.cycle import get_ecoClimateZone
|
|
8
|
-
from .utils import ecoClimate_factors, EF4_FACTORS, EF5_FACTORS
|
|
9
|
-
from . import MODEL
|
|
3
|
+
from .n2OToAir_indirect_emissions_utils import run as run_emission
|
|
10
4
|
|
|
11
5
|
REQUIREMENTS = {
|
|
12
6
|
"Cycle": {
|
|
13
|
-
"completeness.fertiliser": "True",
|
|
14
7
|
"emissions": [
|
|
15
8
|
{"@type": "Emission", "value": "", "term.@id": "no3ToGroundwaterOrganicFertiliser"},
|
|
16
9
|
{"@type": "Emission", "value": "", "term.@id": "nh3ToAirOrganicFertiliser"},
|
|
@@ -26,6 +19,12 @@ REQUIREMENTS = {
|
|
|
26
19
|
}
|
|
27
20
|
}
|
|
28
21
|
}
|
|
22
|
+
LOOKUPS = {
|
|
23
|
+
"emission": [
|
|
24
|
+
"IPCC_2019_EF4_FACTORS", "IPCC_2019_EF4_FACTORS-max", "IPCC_2019_EF4_FACTORS-min",
|
|
25
|
+
"IPCC_2019_EF5_FACTORS", "IPCC_2019_EF5_FACTORS-max", "IPCC_2019_EF5_FACTORS-min"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
29
28
|
RETURNS = {
|
|
30
29
|
"Emission": [{
|
|
31
30
|
"value": "",
|
|
@@ -34,67 +33,11 @@ RETURNS = {
|
|
|
34
33
|
}
|
|
35
34
|
TERM_ID = 'n2OToAirOrganicFertiliserIndirect'
|
|
36
35
|
TIER = EmissionMethodTier.TIER_1.value
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def _emission(value: float, min: float, max: float, aggregated: bool = False):
|
|
43
|
-
emission = _new_emission(TERM_ID, MODEL)
|
|
44
|
-
emission['value'] = [value]
|
|
45
|
-
emission['min'] = [min]
|
|
46
|
-
emission['max'] = [max]
|
|
47
|
-
emission['methodTier'] = TIER
|
|
48
|
-
emission['statsDefinition'] = EmissionStatsDefinition.MODELLED.value
|
|
49
|
-
emission['methodModelDescription'] = 'Aggregated version' if aggregated else 'Disaggregated version'
|
|
50
|
-
return emission
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def _run(cycle: dict, no3: float, nh3: float, nox: float):
|
|
54
|
-
ecoClimateZone = get_ecoClimateZone(cycle)
|
|
55
|
-
|
|
56
|
-
ef4, aggregated = ecoClimate_factors(EF4_FACTORS, ecoClimateZone=ecoClimateZone)
|
|
57
|
-
ef5 = EF5_FACTORS.get('default')
|
|
58
|
-
|
|
59
|
-
debugValues(cycle, model=MODEL, term=TERM_ID,
|
|
60
|
-
ecoClimateZone=ecoClimateZone,
|
|
61
|
-
ef4_factors_used=log_as_table(ef4),
|
|
62
|
-
ef5_factors_used=log_as_table(ef5),
|
|
63
|
-
aggregated=aggregated)
|
|
64
|
-
|
|
65
|
-
value = sum([
|
|
66
|
-
no3 * ef5['value'],
|
|
67
|
-
nh3 * ef4['value'],
|
|
68
|
-
nox * ef4['value']
|
|
69
|
-
]) * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
|
70
|
-
min = sum([
|
|
71
|
-
no3 * ef5['min'],
|
|
72
|
-
nh3 * ef4['min'],
|
|
73
|
-
nox * ef4['min']
|
|
74
|
-
]) * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
|
75
|
-
max = sum([
|
|
76
|
-
no3 * ef5['max'],
|
|
77
|
-
nh3 * ef4['max'],
|
|
78
|
-
nox * ef4['max']
|
|
79
|
-
]) * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
|
80
|
-
return [_emission(value, min, max, aggregated=aggregated)]
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def _should_run(cycle: dict):
|
|
84
|
-
nh3_n, no3_n, nox_n = get_nh3_no3_nox_to_n(cycle, NH3_TERM_ID, NO3_TERM_ID, NOX_TERM_ID)
|
|
85
|
-
term_type_complete = _is_term_type_complete(cycle, 'fertiliser')
|
|
86
|
-
|
|
87
|
-
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
|
88
|
-
no3_n=no3_n,
|
|
89
|
-
nh3_n=nh3_n,
|
|
90
|
-
nox_n=nox_n,
|
|
91
|
-
term_type_fertiliser_complete=term_type_complete)
|
|
92
|
-
|
|
93
|
-
should_run = all([no3_n is not None, nh3_n is not None, nox_n is not None, term_type_complete])
|
|
94
|
-
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
|
95
|
-
return should_run, no3_n, nh3_n, nox_n
|
|
36
|
+
_NO3_TERM_ID = 'no3ToGroundwaterOrganicFertiliser'
|
|
37
|
+
_NH3_TERM_ID = 'nh3ToAirOrganicFertiliser'
|
|
38
|
+
_NOX_TERM_ID = 'noxToAirOrganicFertiliser'
|
|
39
|
+
_EMISSION_IDS = [_NH3_TERM_ID, _NO3_TERM_ID, _NOX_TERM_ID]
|
|
96
40
|
|
|
97
41
|
|
|
98
42
|
def run(cycle: dict):
|
|
99
|
-
|
|
100
|
-
return _run(cycle, no3, nh3, nox) if should_run else []
|
|
43
|
+
return run_emission(TERM_ID, _EMISSION_IDS, cycle)
|