hestia-earth-models 0.73.7__py3-none-any.whl → 0.74.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/aware/scarcityWeightedWaterUse.py +7 -6
- hestia_earth/models/aware2_0/__init__.py +14 -0
- hestia_earth/models/aware2_0/scarcityWeightedWaterUse.py +115 -0
- hestia_earth/models/config/Cycle.json +121 -29
- hestia_earth/models/config/ImpactAssessment.json +240 -200
- hestia_earth/models/config/__init__.py +26 -2
- hestia_earth/models/cycle/animal/input/hestiaAggregatedData.py +2 -2
- hestia_earth/models/cycle/animal/input/properties.py +6 -5
- hestia_earth/models/cycle/animal/milkYield.py +8 -3
- hestia_earth/models/cycle/utils.py +6 -6
- hestia_earth/models/dammgen2009/noxToAirExcreta.py +11 -9
- hestia_earth/models/data/ecoinventV3/__init__.py +8 -26
- hestia_earth/models/ecoalimV9/cycle.py +51 -45
- hestia_earth/models/ecoalimV9/impact_assessment.py +63 -45
- hestia_earth/models/ecoalimV9/utils.py +21 -15
- hestia_earth/models/ecoinventV3/__init__.py +8 -140
- hestia_earth/models/ecoinventV3/cycle.py +140 -0
- hestia_earth/models/ecoinventV3/utils.py +28 -1
- hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py +8 -137
- hestia_earth/models/ecoinventV3AndEmberClimate/cycle.py +144 -0
- hestia_earth/models/emepEea2019/n2OToAirFuelCombustionDirect.py +2 -2
- hestia_earth/models/emepEea2019/utils.py +2 -3
- hestia_earth/models/environmentalFootprintV3_1/environmentalFootprintSingleOverallScore.py +5 -7
- hestia_earth/models/frischknechtEtAl2000/ionisingRadiationKbqU235Eq.py +41 -43
- hestia_earth/models/geospatialDatabase/awareWaterBasinId.py +2 -2
- hestia_earth/models/geospatialDatabase/awareWaterBasinId_v1.py +45 -0
- hestia_earth/models/hestia/default_emissions.py +7 -7
- hestia_earth/models/hestia/default_resourceUse.py +7 -6
- hestia_earth/models/hestia/landCover.py +110 -12
- hestia_earth/models/hestia/seed_emissions.py +7 -3
- hestia_earth/models/hestia/utils.py +1 -0
- hestia_earth/models/hestia/waterSalinity.py +2 -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 +25 -16
- hestia_earth/models/linkedImpactAssessment/utils.py +5 -1
- hestia_earth/models/log.py +8 -3
- hestia_earth/models/mocking/search-results.json +1670 -1666
- hestia_earth/models/utils/__init__.py +3 -0
- hestia_earth/models/utils/background_emissions.py +121 -14
- hestia_earth/models/utils/blank_node.py +1 -11
- hestia_earth/models/utils/emission.py +18 -8
- hestia_earth/models/utils/feedipedia.py +2 -2
- hestia_earth/models/utils/impact_assessment.py +4 -6
- hestia_earth/models/utils/indicator.py +8 -1
- hestia_earth/models/utils/lookup.py +30 -18
- hestia_earth/models/utils/productivity.py +1 -1
- hestia_earth/models/version.py +1 -1
- hestia_earth/orchestrator/log.py +8 -3
- hestia_earth/orchestrator/strategies/merge/merge_list.py +41 -54
- {hestia_earth_models-0.73.7.dist-info → hestia_earth_models-0.74.0.dist-info}/METADATA +3 -3
- {hestia_earth_models-0.73.7.dist-info → hestia_earth_models-0.74.0.dist-info}/RECORD +99 -75
- tests/models/aware2_0/__init__.py +0 -0
- tests/models/aware2_0/test_scarcityWeightedWaterUse.py +58 -0
- 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/ecoinventV3/__init__.py +0 -0
- tests/models/{test_ecoinventV3.py → ecoinventV3/test_cycle.py} +5 -5
- tests/models/ecoinventV3AndEmberClimate/__init__.py +0 -0
- tests/models/{test_ecoinventV3AndEmberClimate.py → ecoinventV3AndEmberClimate/test_cycle.py} +6 -4
- tests/models/environmentalFootprintV3_1/test_environmentalFootprintSingleOverallScore.py +2 -2
- tests/models/frischknechtEtAl2000/test_ionisingRadiationKbqU235Eq.py +18 -27
- tests/models/hestia/test_landCover.py +16 -6
- 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
- tests/models/site/pre_checks/test_cache_geospatialDatabase.py +4 -4
- tests/models/test_config.py +53 -7
- tests/models/utils/test_background_emissions.py +13 -0
- {hestia_earth_models-0.73.7.dist-info → hestia_earth_models-0.74.0.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.73.7.dist-info → hestia_earth_models-0.74.0.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.73.7.dist-info → hestia_earth_models-0.74.0.dist-info}/top_level.txt +0 -0
|
@@ -3,10 +3,10 @@ import json
|
|
|
3
3
|
from unittest.mock import patch
|
|
4
4
|
|
|
5
5
|
from tests.utils import fixtures_path, fake_new_emission
|
|
6
|
-
from hestia_earth.models.ecoinventV3 import MODEL, run
|
|
6
|
+
from hestia_earth.models.ecoinventV3.cycle import MODEL, run
|
|
7
7
|
|
|
8
|
-
class_path = f"hestia_earth.models.{MODEL}"
|
|
9
|
-
fixtures_folder = os.path.join(fixtures_path, MODEL)
|
|
8
|
+
class_path = f"hestia_earth.models.{MODEL}.cycle"
|
|
9
|
+
fixtures_folder = os.path.join(fixtures_path, MODEL, 'cycle')
|
|
10
10
|
|
|
11
11
|
TERMS_BY_ID = {
|
|
12
12
|
'24EpibrassinolideTgai': {
|
|
@@ -53,7 +53,7 @@ def test_run(*args):
|
|
|
53
53
|
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
54
54
|
expected = json.load(f)
|
|
55
55
|
|
|
56
|
-
result = run(
|
|
56
|
+
result = run(cycle)
|
|
57
57
|
assert result == expected
|
|
58
58
|
|
|
59
59
|
|
|
@@ -65,5 +65,5 @@ def test_run_ember(*args):
|
|
|
65
65
|
with open(f"{fixtures_folder}/ember-comparison/result.jsonld", encoding='utf-8') as f:
|
|
66
66
|
expected = json.load(f)
|
|
67
67
|
|
|
68
|
-
result = run(
|
|
68
|
+
result = run(cycle)
|
|
69
69
|
assert result == expected
|
|
File without changes
|
tests/models/{test_ecoinventV3AndEmberClimate.py → ecoinventV3AndEmberClimate/test_cycle.py}
RENAMED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import os
|
|
1
2
|
import json
|
|
2
3
|
from unittest.mock import patch
|
|
3
4
|
|
|
4
5
|
from tests.utils import fixtures_path, fake_new_emission
|
|
5
|
-
from hestia_earth.models.ecoinventV3AndEmberClimate import MODEL, run
|
|
6
|
+
from hestia_earth.models.ecoinventV3AndEmberClimate.cycle import MODEL, run
|
|
6
7
|
|
|
7
|
-
class_path = f"hestia_earth.models.{MODEL}"
|
|
8
|
-
fixtures_folder =
|
|
8
|
+
class_path = f"hestia_earth.models.{MODEL}.cycle"
|
|
9
|
+
fixtures_folder = os.path.join(fixtures_path, MODEL, 'cycle')
|
|
9
10
|
|
|
10
11
|
ELECTRICITY_TERMS = [
|
|
11
12
|
'electricityGridMarketMix',
|
|
@@ -22,5 +23,6 @@ def test_run(*args):
|
|
|
22
23
|
with open(f"{fixtures_folder}/result.jsonld", encoding="utf-8") as f:
|
|
23
24
|
expected = json.load(f)
|
|
24
25
|
|
|
25
|
-
result = run(
|
|
26
|
+
result = run(cycle)
|
|
27
|
+
print(json.dumps(result, indent=2))
|
|
26
28
|
assert result == expected
|
|
@@ -72,7 +72,7 @@ ionising_radiation_indicator_radon = {
|
|
|
72
72
|
"@type": "Indicator",
|
|
73
73
|
"term": {"@id": "ionisingRadiationKbqU235Eq", "termType": "characterisedIndicator"},
|
|
74
74
|
"value": 0.11156637927360424,
|
|
75
|
-
"
|
|
75
|
+
"key": {"@id": "radon222"},
|
|
76
76
|
"methodModel": methodModelfrischknechtEtAl2000
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -80,7 +80,7 @@ ionising_radiation_indicator_plutonium238 = {
|
|
|
80
80
|
"@type": "Indicator",
|
|
81
81
|
"term": {"@id": "ionisingRadiationKbqU235Eq", "termType": "characterisedIndicator"},
|
|
82
82
|
"value": 8.567909489437642e-13,
|
|
83
|
-
"
|
|
83
|
+
"key": {"@id": "plutonium238"},
|
|
84
84
|
"methodModel": methodModelfrischknechtEtAl2000
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -22,55 +22,48 @@ wrong_indicator = {
|
|
|
22
22
|
"termType": "emission",
|
|
23
23
|
},
|
|
24
24
|
"value": 3,
|
|
25
|
-
"
|
|
25
|
+
"key": hydrogen3_input
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
indicator_no_key = {
|
|
29
29
|
"term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
|
|
30
|
-
"value": 3
|
|
31
|
-
"inputs": [],
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
indicator_2_inputs = {
|
|
35
|
-
"term": {"@id": "ionisingCompoundsToWaterInputsProduction", "termType": "emission"},
|
|
36
|
-
"value": 3,
|
|
37
|
-
"inputs": [cesium134_input, cesium137_input],
|
|
30
|
+
"value": 3
|
|
38
31
|
}
|
|
39
32
|
|
|
40
33
|
indicator_no_unit = {
|
|
41
34
|
"term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
|
|
42
35
|
"value": 3,
|
|
43
|
-
"
|
|
36
|
+
"key": {"@id": "hydrogen3", "termType": "waste"}
|
|
44
37
|
}
|
|
45
38
|
|
|
46
39
|
indicator_wrong_unit = {
|
|
47
40
|
"term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
|
|
48
41
|
"value": 3,
|
|
49
|
-
"
|
|
42
|
+
"key": {"@id": "hydrogen3", "termType": "waste", "units": "not_a_unit"}
|
|
50
43
|
}
|
|
51
44
|
|
|
52
45
|
indicator_no_cf_input = {
|
|
53
46
|
"term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
|
|
54
47
|
"value": 3,
|
|
55
|
-
"
|
|
48
|
+
"key": no_cf_input
|
|
56
49
|
}
|
|
57
50
|
|
|
58
51
|
indicator_hydrogen3_input = {
|
|
59
52
|
"term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
|
|
60
53
|
"value": 3,
|
|
61
|
-
"
|
|
54
|
+
"key": hydrogen3_input
|
|
62
55
|
}
|
|
63
56
|
|
|
64
57
|
indicator_cesium137_water = {
|
|
65
58
|
"term": {"@id": "ionisingCompoundsToWaterInputsProduction", "termType": "emission"},
|
|
66
59
|
"value": 3,
|
|
67
|
-
"
|
|
60
|
+
"key": cesium137_input
|
|
68
61
|
}
|
|
69
62
|
|
|
70
63
|
indicator_cesium137_air = {
|
|
71
64
|
"term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
|
|
72
65
|
"value": 3,
|
|
73
|
-
"
|
|
66
|
+
"key": cesium137_input
|
|
74
67
|
}
|
|
75
68
|
|
|
76
69
|
indicator_cesium137_salt_water = {
|
|
@@ -79,7 +72,7 @@ indicator_cesium137_salt_water = {
|
|
|
79
72
|
"termType": "emission",
|
|
80
73
|
},
|
|
81
74
|
"value": 3,
|
|
82
|
-
"
|
|
75
|
+
"key": cesium137_input
|
|
83
76
|
}
|
|
84
77
|
|
|
85
78
|
indicator_uranium234_input = {
|
|
@@ -88,17 +81,16 @@ indicator_uranium234_input = {
|
|
|
88
81
|
"termType": "emission",
|
|
89
82
|
},
|
|
90
83
|
"value": 3,
|
|
91
|
-
"
|
|
84
|
+
"key": uranium234_input
|
|
92
85
|
}
|
|
93
86
|
|
|
94
87
|
|
|
95
88
|
@pytest.mark.parametrize(
|
|
96
|
-
"resources, expected,
|
|
89
|
+
"resources, expected, num_key",
|
|
97
90
|
[
|
|
98
|
-
([],
|
|
99
|
-
([wrong_indicator],
|
|
100
|
-
([
|
|
101
|
-
([indicator_2_inputs], False, 0),
|
|
91
|
+
([], False, 0),
|
|
92
|
+
([wrong_indicator], False, 0),
|
|
93
|
+
([indicator_no_key], False, 0),
|
|
102
94
|
([indicator_no_unit], False, 0),
|
|
103
95
|
([indicator_wrong_unit], False, 0),
|
|
104
96
|
([indicator_no_cf_input], True, 0),
|
|
@@ -111,8 +103,7 @@ indicator_uranium234_input = {
|
|
|
111
103
|
],
|
|
112
104
|
ids=["No emissionsResourceUse => run, empty input",
|
|
113
105
|
"Wrong indicator termid => run, empty input",
|
|
114
|
-
"Indicator no
|
|
115
|
-
"Indicator 2 inputs => no run",
|
|
106
|
+
"Indicator no key => no run",
|
|
116
107
|
"Missing unit => no run",
|
|
117
108
|
"Wrong unit => no run",
|
|
118
109
|
"Input with no cf => run, empty input",
|
|
@@ -124,7 +115,7 @@ indicator_uranium234_input = {
|
|
|
124
115
|
"3 different indicators common input => run 3 input",
|
|
125
116
|
]
|
|
126
117
|
)
|
|
127
|
-
def test_should_run(resources, expected,
|
|
118
|
+
def test_should_run(resources, expected, num_key):
|
|
128
119
|
with open(f"{fixtures_folder}/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
129
120
|
impactassessment = json.load(f)
|
|
130
121
|
|
|
@@ -132,7 +123,7 @@ def test_should_run(resources, expected, num_inputs):
|
|
|
132
123
|
|
|
133
124
|
should_run, resources_with_cf = _should_run(impactassessment)
|
|
134
125
|
assert should_run is expected
|
|
135
|
-
assert len(resources_with_cf) ==
|
|
126
|
+
assert len(resources_with_cf) == num_key
|
|
136
127
|
|
|
137
128
|
|
|
138
129
|
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
|
@@ -12,7 +12,7 @@ from hestia_earth.models.faostat2018.utils import MODEL as FAOSTAT_MODEL
|
|
|
12
12
|
from hestia_earth.models.hestia.landCover import (
|
|
13
13
|
MODEL, MODEL_KEY, _get_changes, _estimate_maximum_forest_change,
|
|
14
14
|
run, site_area_sum_to_100, _get_sums_of_crop_expansion, _get_sum_for_land_category, scale_values_to_one,
|
|
15
|
-
_get_most_common_or_alphabetically_first, _get_land_cover_lookup_suffix
|
|
15
|
+
_get_most_common_or_alphabetically_first, _get_land_cover_lookup_suffix, _get_ratio_between_land_use_types
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
CLASS_PATH = f"hestia_earth.models.{MODEL}.{MODEL_KEY}"
|
|
@@ -263,6 +263,16 @@ def test_get_land_cover_lookup_suffix(land_type: str, expected: str):
|
|
|
263
263
|
assert _get_land_cover_lookup_suffix(land_type=land_type) == expected, land_type
|
|
264
264
|
|
|
265
265
|
|
|
266
|
+
def test_get_ratio_between_land_use_types():
|
|
267
|
+
result = _get_ratio_between_land_use_types(
|
|
268
|
+
country_id="GADM-ZWE",
|
|
269
|
+
end_year=2004,
|
|
270
|
+
first_land_use_term="Arable land",
|
|
271
|
+
second_land_use_term="Permanent crops"
|
|
272
|
+
)
|
|
273
|
+
assert result == (3800.0, 58.843)
|
|
274
|
+
|
|
275
|
+
|
|
266
276
|
@pytest.mark.parametrize("subfolder", _folders)
|
|
267
277
|
@patch(f"{CLASS_PATH}._new_management", side_effect=fake_new_management)
|
|
268
278
|
def test_run(mock, subfolder: str):
|
|
@@ -303,10 +313,10 @@ def test_landCover_from_lookup_run(mock_mgmt, mock_region_lookup, caplog):
|
|
|
303
313
|
)
|
|
304
314
|
expected_message = ("site=Brazil-example, requirements=true, model=hestia, model_key=landCover, "
|
|
305
315
|
"has_management_nodes=True, land_use_type=Arable land, allowed_land_use_types=Arable land;"
|
|
306
|
-
"Permanent crops;Permanent meadows and pastures, has_no_prior_land_cover_data=True, "
|
|
307
|
-
"management_nodes=value:100_id:maizePlant_land-use-type:Arable
|
|
308
|
-
"
|
|
309
|
-
"Permanent crops:0.55;Permanent meadows and pastures:0.55;Other land:0.55,
|
|
310
|
-
"should_run_nodes=True")
|
|
316
|
+
"Permanent crops;Permanent meadows and pastures;Cropland, has_no_prior_land_cover_data=True, "
|
|
317
|
+
"management_nodes=value:100_id:maizePlant_land-use-type:Arable land"
|
|
318
|
+
"_endDate:2010-12-31_startDate:2010-01-01, landCover_from_lookups=Forest land:0.55;"
|
|
319
|
+
"Arable land:0.55;Permanent crops:0.55;Permanent meadows and pastures:0.55;Other land:0.55,"
|
|
320
|
+
" should_run_nodes=True")
|
|
311
321
|
assert expected_message in [r.msg for r in caplog.records]
|
|
312
322
|
assert result == expected
|
|
@@ -74,7 +74,8 @@ PARAMS_SHOULD_RUN = [
|
|
|
74
74
|
("no-cycles", False),
|
|
75
75
|
("with-organic-soils", False),
|
|
76
76
|
("with-relative-func-unit", False),
|
|
77
|
-
("with-site-type-forest", False)
|
|
77
|
+
("with-site-type-forest", False),
|
|
78
|
+
("with-missing-start-dates", True)
|
|
78
79
|
]
|
|
79
80
|
IDS_SHOULD_RUN = [p[0] for p in PARAMS_SHOULD_RUN]
|
|
80
81
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
import json
|
|
3
|
+
from tests.utils import fixtures_path, fake_new_emission
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.ipcc2019 import MODEL
|
|
6
|
+
from hestia_earth.models.ipcc2019.n2OToAirAquacultureSystemsIndirect import TERM_ID, run
|
|
7
|
+
|
|
8
|
+
utils_path = f"hestia_earth.models.{MODEL}.n2OToAir_indirect_emissions_utils"
|
|
9
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
13
|
+
def test_run(*args):
|
|
14
|
+
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
15
|
+
cycle = json.load(f)
|
|
16
|
+
|
|
17
|
+
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
18
|
+
expected = json.load(f)
|
|
19
|
+
|
|
20
|
+
value = run(cycle)
|
|
21
|
+
assert value == expected
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
25
|
+
def test_run_wet(*args):
|
|
26
|
+
with open(f"{fixtures_folder}/ecoClimateZone-wet/cycle.jsonld", encoding='utf-8') as f:
|
|
27
|
+
cycle = json.load(f)
|
|
28
|
+
|
|
29
|
+
with open(f"{fixtures_folder}/ecoClimateZone-wet/result.jsonld", encoding='utf-8') as f:
|
|
30
|
+
expected = json.load(f)
|
|
31
|
+
|
|
32
|
+
value = run(cycle)
|
|
33
|
+
assert value == expected
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
37
|
+
def test_run_dry(*args):
|
|
38
|
+
with open(f"{fixtures_folder}/ecoClimateZone-dry/cycle.jsonld", encoding='utf-8') as f:
|
|
39
|
+
cycle = json.load(f)
|
|
40
|
+
|
|
41
|
+
with open(f"{fixtures_folder}/ecoClimateZone-dry/result.jsonld", encoding='utf-8') as f:
|
|
42
|
+
expected = json.load(f)
|
|
43
|
+
|
|
44
|
+
value = run(cycle)
|
|
45
|
+
assert value == expected
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
import json
|
|
3
|
+
from tests.utils import fixtures_path, fake_new_emission
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.ipcc2019 import MODEL
|
|
6
|
+
from hestia_earth.models.ipcc2019.n2OToAirCropResidueBurningIndirect import TERM_ID, run
|
|
7
|
+
|
|
8
|
+
utils_path = f"hestia_earth.models.{MODEL}.n2OToAir_indirect_emissions_utils"
|
|
9
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
13
|
+
def test_run(*args):
|
|
14
|
+
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
15
|
+
cycle = json.load(f)
|
|
16
|
+
|
|
17
|
+
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
18
|
+
expected = json.load(f)
|
|
19
|
+
|
|
20
|
+
value = run(cycle)
|
|
21
|
+
assert value == expected
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
25
|
+
def test_run_wet(*args):
|
|
26
|
+
with open(f"{fixtures_folder}/ecoClimateZone-wet/cycle.jsonld", encoding='utf-8') as f:
|
|
27
|
+
cycle = json.load(f)
|
|
28
|
+
|
|
29
|
+
with open(f"{fixtures_folder}/ecoClimateZone-wet/result.jsonld", encoding='utf-8') as f:
|
|
30
|
+
expected = json.load(f)
|
|
31
|
+
|
|
32
|
+
value = run(cycle)
|
|
33
|
+
assert value == expected
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
37
|
+
def test_run_dry(*args):
|
|
38
|
+
with open(f"{fixtures_folder}/ecoClimateZone-dry/cycle.jsonld", encoding='utf-8') as f:
|
|
39
|
+
cycle = json.load(f)
|
|
40
|
+
|
|
41
|
+
with open(f"{fixtures_folder}/ecoClimateZone-dry/result.jsonld", encoding='utf-8') as f:
|
|
42
|
+
expected = json.load(f)
|
|
43
|
+
|
|
44
|
+
value = run(cycle)
|
|
45
|
+
assert value == expected
|
|
@@ -2,40 +2,14 @@ from unittest.mock import patch
|
|
|
2
2
|
import json
|
|
3
3
|
from tests.utils import fixtures_path, fake_new_emission
|
|
4
4
|
|
|
5
|
-
from hestia_earth.models.ipcc2019
|
|
6
|
-
|
|
7
|
-
)
|
|
5
|
+
from hestia_earth.models.ipcc2019 import MODEL
|
|
6
|
+
from hestia_earth.models.ipcc2019.n2OToAirCropResidueDecompositionIndirect import TERM_ID, run
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
utils_path = f"hestia_earth.models.{MODEL}.n2OToAir_indirect_emissions_utils"
|
|
10
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
11
10
|
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
# no emissions => no run
|
|
15
|
-
cycle = {'completeness': {'cropResidue': True}, 'emissions': []}
|
|
16
|
-
should_run, *args = _should_run(cycle)
|
|
17
|
-
assert not should_run
|
|
18
|
-
|
|
19
|
-
# with no3 emission => run
|
|
20
|
-
cycle['emissions'] = [
|
|
21
|
-
{
|
|
22
|
-
'term': {'@id': NO3_TERM_ID},
|
|
23
|
-
'value': [100]
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
'term': {'@id': NH3_TERM_ID},
|
|
27
|
-
'value': [100]
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
'term': {'@id': NOX_TERM_ID},
|
|
31
|
-
'value': [100]
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
should_run, *args = _should_run(cycle)
|
|
35
|
-
assert should_run is True
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
|
12
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
39
13
|
def test_run(*args):
|
|
40
14
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
41
15
|
cycle = json.load(f)
|
|
@@ -47,7 +21,7 @@ def test_run(*args):
|
|
|
47
21
|
assert value == expected
|
|
48
22
|
|
|
49
23
|
|
|
50
|
-
@patch(f"{
|
|
24
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
51
25
|
def test_run_wet(*args):
|
|
52
26
|
with open(f"{fixtures_folder}/ecoClimateZone-wet/cycle.jsonld", encoding='utf-8') as f:
|
|
53
27
|
cycle = json.load(f)
|
|
@@ -59,7 +33,7 @@ def test_run_wet(*args):
|
|
|
59
33
|
assert value == expected
|
|
60
34
|
|
|
61
35
|
|
|
62
|
-
@patch(f"{
|
|
36
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
63
37
|
def test_run_dry(*args):
|
|
64
38
|
with open(f"{fixtures_folder}/ecoClimateZone-dry/cycle.jsonld", encoding='utf-8') as f:
|
|
65
39
|
cycle = json.load(f)
|
|
@@ -2,40 +2,14 @@ from unittest.mock import patch
|
|
|
2
2
|
import json
|
|
3
3
|
from tests.utils import fixtures_path, fake_new_emission
|
|
4
4
|
|
|
5
|
-
from hestia_earth.models.ipcc2019
|
|
6
|
-
|
|
7
|
-
)
|
|
5
|
+
from hestia_earth.models.ipcc2019 import MODEL
|
|
6
|
+
from hestia_earth.models.ipcc2019.n2OToAirExcretaIndirect import TERM_ID, run
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
utils_path = f"hestia_earth.models.{MODEL}.n2OToAir_indirect_emissions_utils"
|
|
10
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
11
10
|
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
# no emissions => no run
|
|
15
|
-
cycle = {'completeness': {'excreta': True}, 'emissions': []}
|
|
16
|
-
should_run, *args = _should_run(cycle)
|
|
17
|
-
assert not should_run
|
|
18
|
-
|
|
19
|
-
# with no3 emission => run
|
|
20
|
-
cycle['emissions'] = [
|
|
21
|
-
{
|
|
22
|
-
'term': {'@id': NO3_TERM_ID},
|
|
23
|
-
'value': [100]
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
'term': {'@id': NH3_TERM_ID},
|
|
27
|
-
'value': [100]
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
'term': {'@id': NOX_TERM_ID},
|
|
31
|
-
'value': [100]
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
should_run, *args = _should_run(cycle)
|
|
35
|
-
assert should_run is True
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
|
12
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
39
13
|
def test_run(*args):
|
|
40
14
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
41
15
|
cycle = json.load(f)
|
|
@@ -47,7 +21,7 @@ def test_run(*args):
|
|
|
47
21
|
assert value == expected
|
|
48
22
|
|
|
49
23
|
|
|
50
|
-
@patch(f"{
|
|
24
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
51
25
|
def test_run_wet(*args):
|
|
52
26
|
with open(f"{fixtures_folder}/ecoClimateZone-wet/cycle.jsonld", encoding='utf-8') as f:
|
|
53
27
|
cycle = json.load(f)
|
|
@@ -59,7 +33,7 @@ def test_run_wet(*args):
|
|
|
59
33
|
assert value == expected
|
|
60
34
|
|
|
61
35
|
|
|
62
|
-
@patch(f"{
|
|
36
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
63
37
|
def test_run_dry(*args):
|
|
64
38
|
with open(f"{fixtures_folder}/ecoClimateZone-dry/cycle.jsonld", encoding='utf-8') as f:
|
|
65
39
|
cycle = json.load(f)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
import json
|
|
3
|
+
from tests.utils import fixtures_path, fake_new_emission
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.ipcc2019 import MODEL
|
|
6
|
+
from hestia_earth.models.ipcc2019.n2OToAirFuelCombustionIndirect import TERM_ID, run
|
|
7
|
+
|
|
8
|
+
utils_path = f"hestia_earth.models.{MODEL}.n2OToAir_indirect_emissions_utils"
|
|
9
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
13
|
+
def test_run(*args):
|
|
14
|
+
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
15
|
+
cycle = json.load(f)
|
|
16
|
+
|
|
17
|
+
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
18
|
+
expected = json.load(f)
|
|
19
|
+
|
|
20
|
+
value = run(cycle)
|
|
21
|
+
assert value == expected
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
25
|
+
def test_run_wet(*args):
|
|
26
|
+
with open(f"{fixtures_folder}/ecoClimateZone-wet/cycle.jsonld", encoding='utf-8') as f:
|
|
27
|
+
cycle = json.load(f)
|
|
28
|
+
|
|
29
|
+
with open(f"{fixtures_folder}/ecoClimateZone-wet/result.jsonld", encoding='utf-8') as f:
|
|
30
|
+
expected = json.load(f)
|
|
31
|
+
|
|
32
|
+
value = run(cycle)
|
|
33
|
+
assert value == expected
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
37
|
+
def test_run_dry(*args):
|
|
38
|
+
with open(f"{fixtures_folder}/ecoClimateZone-dry/cycle.jsonld", encoding='utf-8') as f:
|
|
39
|
+
cycle = json.load(f)
|
|
40
|
+
|
|
41
|
+
with open(f"{fixtures_folder}/ecoClimateZone-dry/result.jsonld", encoding='utf-8') as f:
|
|
42
|
+
expected = json.load(f)
|
|
43
|
+
|
|
44
|
+
value = run(cycle)
|
|
45
|
+
assert value == expected
|
|
@@ -2,40 +2,14 @@ from unittest.mock import patch
|
|
|
2
2
|
import json
|
|
3
3
|
from tests.utils import fixtures_path, fake_new_emission
|
|
4
4
|
|
|
5
|
-
from hestia_earth.models.ipcc2019
|
|
6
|
-
|
|
7
|
-
)
|
|
5
|
+
from hestia_earth.models.ipcc2019 import MODEL
|
|
6
|
+
from hestia_earth.models.ipcc2019.n2OToAirInorganicFertiliserIndirect import TERM_ID, run
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
utils_path = f"hestia_earth.models.{MODEL}.n2OToAir_indirect_emissions_utils"
|
|
10
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
11
10
|
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
# no emissions => no run
|
|
15
|
-
cycle = {'completeness': {'fertiliser': True}, 'emissions': []}
|
|
16
|
-
should_run, *args = _should_run(cycle)
|
|
17
|
-
assert not should_run
|
|
18
|
-
|
|
19
|
-
# with no3 emission => run
|
|
20
|
-
cycle['emissions'] = [
|
|
21
|
-
{
|
|
22
|
-
'term': {'@id': NO3_TERM_ID},
|
|
23
|
-
'value': [100]
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
'term': {'@id': NH3_TERM_ID},
|
|
27
|
-
'value': [100]
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
'term': {'@id': NOX_TERM_ID},
|
|
31
|
-
'value': [100]
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
should_run, *args = _should_run(cycle)
|
|
35
|
-
assert should_run is True
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
|
12
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
39
13
|
def test_run(*args):
|
|
40
14
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
41
15
|
cycle = json.load(f)
|
|
@@ -47,7 +21,7 @@ def test_run(*args):
|
|
|
47
21
|
assert value == expected
|
|
48
22
|
|
|
49
23
|
|
|
50
|
-
@patch(f"{
|
|
24
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
51
25
|
def test_run_wet(*args):
|
|
52
26
|
with open(f"{fixtures_folder}/ecoClimateZone-wet/cycle.jsonld", encoding='utf-8') as f:
|
|
53
27
|
cycle = json.load(f)
|
|
@@ -59,7 +33,7 @@ def test_run_wet(*args):
|
|
|
59
33
|
assert value == expected
|
|
60
34
|
|
|
61
35
|
|
|
62
|
-
@patch(f"{
|
|
36
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
63
37
|
def test_run_dry(*args):
|
|
64
38
|
with open(f"{fixtures_folder}/ecoClimateZone-dry/cycle.jsonld", encoding='utf-8') as f:
|
|
65
39
|
cycle = json.load(f)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
import json
|
|
3
|
+
from tests.utils import fixtures_path, fake_new_emission
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.ipcc2019 import MODEL
|
|
6
|
+
from hestia_earth.models.ipcc2019.n2OToAirNaturalVegetationBurningIndirect import TERM_ID, run
|
|
7
|
+
|
|
8
|
+
utils_path = f"hestia_earth.models.{MODEL}.n2OToAir_indirect_emissions_utils"
|
|
9
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
13
|
+
def test_run(*args):
|
|
14
|
+
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
15
|
+
cycle = json.load(f)
|
|
16
|
+
|
|
17
|
+
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
18
|
+
expected = json.load(f)
|
|
19
|
+
|
|
20
|
+
value = run(cycle)
|
|
21
|
+
assert value == expected
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
25
|
+
def test_run_wet(*args):
|
|
26
|
+
with open(f"{fixtures_folder}/ecoClimateZone-wet/cycle.jsonld", encoding='utf-8') as f:
|
|
27
|
+
cycle = json.load(f)
|
|
28
|
+
|
|
29
|
+
with open(f"{fixtures_folder}/ecoClimateZone-wet/result.jsonld", encoding='utf-8') as f:
|
|
30
|
+
expected = json.load(f)
|
|
31
|
+
|
|
32
|
+
value = run(cycle)
|
|
33
|
+
assert value == expected
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@patch(f"{utils_path}._new_emission", side_effect=fake_new_emission)
|
|
37
|
+
def test_run_dry(*args):
|
|
38
|
+
with open(f"{fixtures_folder}/ecoClimateZone-dry/cycle.jsonld", encoding='utf-8') as f:
|
|
39
|
+
cycle = json.load(f)
|
|
40
|
+
|
|
41
|
+
with open(f"{fixtures_folder}/ecoClimateZone-dry/result.jsonld", encoding='utf-8') as f:
|
|
42
|
+
expected = json.load(f)
|
|
43
|
+
|
|
44
|
+
value = run(cycle)
|
|
45
|
+
assert value == expected
|