hestia-earth-models 0.68.1__py3-none-any.whl → 0.69.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.
- hestia_earth/models/agribalyse2016/fuelElectricity.py +0 -5
- hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py +0 -11
- hestia_earth/models/aware/scarcityWeightedWaterUse.py +0 -4
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionFossilFuels.py +0 -18
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionMineralsAndMetals.py +0 -12
- hestia_earth/models/cml2001Baseline/resourceUseEnergyDepletionDuringCycle.py +0 -5
- hestia_earth/models/cml2001Baseline/resourceUseMineralsAndMetalsDuringCycle.py +0 -4
- hestia_earth/models/config/Cycle.json +23 -30
- hestia_earth/models/cycle/aboveGroundCropResidueTotal.py +0 -6
- hestia_earth/models/cycle/animal/input/hestiaAggregatedData.py +0 -8
- hestia_earth/models/cycle/animal/input/properties.py +0 -9
- hestia_earth/models/cycle/animal/milkYield.py +0 -6
- hestia_earth/models/cycle/animal/properties.py +0 -6
- hestia_earth/models/cycle/completeness/animalFeed.py +0 -6
- hestia_earth/models/cycle/completeness/cropResidue.py +0 -6
- hestia_earth/models/cycle/completeness/electricityFuel.py +0 -6
- hestia_earth/models/cycle/completeness/excreta.py +0 -6
- hestia_earth/models/cycle/completeness/freshForage.py +0 -6
- hestia_earth/models/cycle/completeness/material.py +0 -6
- hestia_earth/models/cycle/completeness/seed.py +0 -6
- hestia_earth/models/cycle/completeness/soilAmendment.py +0 -6
- hestia_earth/models/cycle/concentrateFeed.py +0 -6
- hestia_earth/models/cycle/cropResidueManagement.py +0 -5
- hestia_earth/models/cycle/cycleDuration.py +0 -8
- hestia_earth/models/cycle/endDate.py +0 -7
- hestia_earth/models/cycle/excretaKgMass.py +0 -5
- hestia_earth/models/cycle/excretaKgN.py +0 -5
- hestia_earth/models/cycle/excretaKgVs.py +0 -5
- hestia_earth/models/cycle/inorganicFertiliser.py +0 -6
- hestia_earth/models/cycle/input/hestiaAggregatedData.py +0 -13
- hestia_earth/models/cycle/input/properties.py +0 -9
- hestia_earth/models/cycle/input/value.py +0 -6
- hestia_earth/models/cycle/liveAnimal.py +0 -5
- hestia_earth/models/cycle/materialAndSubstrate.py +1 -6
- hestia_earth/models/cycle/milkYield.py +0 -10
- hestia_earth/models/cycle/otherSitesArea.py +0 -6
- hestia_earth/models/cycle/otherSitesUnusedDuration.py +0 -6
- hestia_earth/models/cycle/pastureSystem.py +0 -6
- hestia_earth/models/cycle/post_checks/cache.py +0 -5
- hestia_earth/models/cycle/post_checks/otherSites.py +0 -7
- hestia_earth/models/cycle/post_checks/site.py +0 -7
- hestia_earth/models/cycle/practice/value.py +0 -7
- hestia_earth/models/cycle/pre_checks/cache_sources.py +0 -5
- hestia_earth/models/cycle/pre_checks/otherSites.py +0 -7
- hestia_earth/models/cycle/pre_checks/site.py +0 -6
- hestia_earth/models/cycle/product/currency.py +0 -5
- hestia_earth/models/cycle/product/economicValueShare.py +0 -14
- hestia_earth/models/cycle/product/price.py +0 -5
- hestia_earth/models/cycle/product/primary.py +0 -5
- hestia_earth/models/cycle/product/properties.py +0 -7
- hestia_earth/models/cycle/product/revenue.py +0 -9
- hestia_earth/models/cycle/product/value.py +0 -6
- hestia_earth/models/cycle/siteArea.py +0 -6
- hestia_earth/models/cycle/siteDuration.py +0 -10
- hestia_earth/models/cycle/siteUnusedDuration.py +0 -6
- hestia_earth/models/cycle/startDate.py +0 -8
- hestia_earth/models/cycle/startDateDefinition.py +0 -6
- hestia_earth/models/cycle/transformation.py +0 -5
- hestia_earth/models/dammgen2009/noxToAirExcreta.py +2 -2
- hestia_earth/models/ecoinventV3/__init__.py +0 -15
- hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py +0 -11
- hestia_earth/models/emepEea2019/nh3ToAirExcreta.py +14 -40
- hestia_earth/models/emepEea2019/pm10ToAirAnimalHousing.py +0 -4
- hestia_earth/models/emepEea2019/pm25ToAirAnimalHousing.py +0 -4
- hestia_earth/models/emepEea2019/tspToAirAnimalHousing.py +0 -4
- hestia_earth/models/emissionNotRelevant/__init__.py +0 -5
- hestia_earth/models/environmentalFootprintV3_1/environmentalFootprintSingleOverallScore.py +0 -9
- hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandOccupation.py +0 -6
- hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandTransformation.py +0 -6
- hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexTotalLandUseEffects.py +0 -6
- hestia_earth/models/epa2014/no3ToGroundwaterExcreta.py +2 -2
- hestia_earth/models/faostat2018/product/price.py +0 -5
- hestia_earth/models/geospatialDatabase/awareWaterBasinId.py +0 -5
- hestia_earth/models/geospatialDatabase/ecoClimateZone.py +1 -20
- hestia_earth/models/geospatialDatabase/ecoregion.py +0 -7
- hestia_earth/models/geospatialDatabase/potentialEvapotranspirationAnnual.py +0 -4
- hestia_earth/models/geospatialDatabase/potentialEvapotranspirationMonthly.py +0 -4
- hestia_earth/models/geospatialDatabase/precipitationAnnual.py +0 -4
- hestia_earth/models/geospatialDatabase/precipitationMonthly.py +0 -4
- hestia_earth/models/geospatialDatabase/region.py +0 -5
- hestia_earth/models/geospatialDatabase/temperatureAnnual.py +0 -4
- hestia_earth/models/geospatialDatabase/temperatureMonthly.py +0 -4
- hestia_earth/models/haversineFormula/transport/distance.py +0 -7
- hestia_earth/models/hestia/landCover.py +31 -18
- hestia_earth/models/hestia/landTransformation100YearAverageDuringCycle.py +0 -11
- hestia_earth/models/hestia/landTransformation20YearAverageDuringCycle.py +0 -11
- hestia_earth/models/hestia/nh3ToSurfaceWaterAquacultureSystems.py +64 -0
- hestia_earth/models/hestia/residueRemoved.py +0 -4
- hestia_earth/models/hestia/resourceUse_utils.py +0 -5
- hestia_earth/models/hestia/seed_emissions.py +0 -13
- hestia_earth/models/impact_assessment/allocationMethod.py +0 -6
- hestia_earth/models/impact_assessment/emissions.py +0 -9
- hestia_earth/models/impact_assessment/irrigated.py +0 -5
- hestia_earth/models/impact_assessment/organic.py +0 -5
- hestia_earth/models/impact_assessment/post_checks/cycle.py +0 -7
- hestia_earth/models/impact_assessment/post_checks/site.py +0 -7
- hestia_earth/models/impact_assessment/pre_checks/cycle.py +0 -6
- hestia_earth/models/impact_assessment/pre_checks/site.py +0 -6
- hestia_earth/models/impact_assessment/product/economicValueShare.py +0 -6
- hestia_earth/models/impact_assessment/product/value.py +0 -5
- hestia_earth/models/ipcc2019/aboveGroundBiomass.py +9 -2
- hestia_earth/models/ipcc2019/animal/milkYieldPerAnimal.py +0 -6
- hestia_earth/models/ipcc2019/animal/pastureGrass.py +0 -10
- hestia_earth/models/ipcc2019/animal/weightAtMaturity.py +0 -4
- hestia_earth/models/ipcc2019/belowGroundBiomass.py +9 -2
- hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py +1 -1
- hestia_earth/models/ipcc2019/croppingDuration.py +0 -5
- hestia_earth/models/ipcc2019/n2OToAirExcretaDirect.py +1 -1
- hestia_earth/models/ipcc2019/no3ToGroundwaterExcreta.py +51 -15
- hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +0 -12
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py +2 -15
- hestia_earth/models/ipcc2019/{organicCarbonPerHa_tier_1_utils.py → organicCarbonPerHa_tier_1.py} +3 -15
- hestia_earth/models/ipcc2019/{organicCarbonPerHa_tier_2_utils.py → organicCarbonPerHa_tier_2.py} +3 -13
- hestia_earth/models/ipcc2019/pastureGrass.py +0 -10
- hestia_earth/models/koble2014/aboveGroundCropResidue.py +0 -9
- hestia_earth/models/koble2014/cropResidueManagement.py +0 -6
- hestia_earth/models/linkedImpactAssessment/emissions.py +0 -5
- hestia_earth/models/mocking/search-results.json +1215 -1159
- hestia_earth/models/pooreNemecek2018/ch4ToAirAquacultureSystems.py +14 -15
- hestia_earth/models/pooreNemecek2018/excretaKgN.py +12 -17
- hestia_earth/models/pooreNemecek2018/excretaKgVs.py +22 -23
- hestia_earth/models/pooreNemecek2018/n2OToAirAquacultureSystemsDirect.py +6 -9
- hestia_earth/models/pooreNemecek2018/n2ToAirAquacultureSystems.py +6 -9
- hestia_earth/models/pooreNemecek2018/nh3ToAirAquacultureSystems.py +11 -15
- hestia_earth/models/pooreNemecek2018/noxToAirAquacultureSystems.py +6 -9
- hestia_earth/models/site/defaultMethodClassification.py +0 -7
- hestia_earth/models/site/defaultMethodClassificationDescription.py +0 -7
- hestia_earth/models/site/flowingWater.py +0 -5
- hestia_earth/models/site/management.py +0 -21
- hestia_earth/models/site/measurement/value.py +0 -6
- hestia_earth/models/site/post_checks/country.py +0 -5
- hestia_earth/models/site/potentialEvapotranspirationAnnual.py +0 -3
- hestia_earth/models/site/potentialEvapotranspirationMonthly.py +0 -3
- hestia_earth/models/site/pre_checks/cache_geospatialDatabase.py +0 -5
- hestia_earth/models/site/pre_checks/cache_sources.py +0 -5
- hestia_earth/models/site/pre_checks/cache_years.py +0 -5
- hestia_earth/models/site/pre_checks/country.py +0 -5
- hestia_earth/models/site/precipitationAnnual.py +0 -3
- hestia_earth/models/site/precipitationMonthly.py +0 -3
- hestia_earth/models/site/rainfallAnnual.py +0 -3
- hestia_earth/models/site/rainfallMonthly.py +0 -3
- hestia_earth/models/site/soilMeasurement.py +0 -5
- hestia_earth/models/site/temperatureAnnual.py +0 -3
- hestia_earth/models/site/temperatureMonthly.py +0 -3
- hestia_earth/models/transformation/input/excreta.py +0 -5
- hestia_earth/models/transformation/input/max.py +0 -8
- hestia_earth/models/transformation/input/min.py +0 -8
- hestia_earth/models/transformation/input/properties.py +0 -6
- hestia_earth/models/transformation/input/sd.py +0 -8
- hestia_earth/models/transformation/input/value.py +0 -8
- hestia_earth/models/transformation/product/excreta.py +0 -7
- hestia_earth/models/utils/excretaManagement.py +37 -0
- hestia_earth/models/utils/lookup.py +2 -0
- hestia_earth/models/utils/practice.py +1 -27
- hestia_earth/models/utils/source.py +29 -9
- hestia_earth/models/version.py +1 -1
- hestia_earth/orchestrator/strategies/run/add_blank_node_if_missing.py +12 -8
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.0.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.0.dist-info}/RECORD +178 -186
- tests/models/emepEea2019/test_nh3ToAirExcreta.py +6 -17
- tests/models/hestia/test_nh3ToSurfaceWaterAquacultureSystems.py +51 -0
- tests/models/ipcc2019/test_aboveGroundBiomass.py +4 -0
- tests/models/ipcc2019/test_belowGroundBiomass.py +4 -0
- tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py +1 -1
- tests/models/ipcc2019/test_no3ToGroundwaterExcreta.py +24 -9
- tests/models/ipcc2019/test_organicCarbonPerHa.py +2 -2
- tests/models/ipcc2019/{test_organicCarbonPerHa_tier_1_utils.py → test_organicCarbonPerHa_tier_1.py} +2 -2
- tests/models/ipcc2019/{test_organicCarbonPerHa_tier_2_utils.py → test_organicCarbonPerHa_tier_2.py} +2 -2
- tests/models/pooreNemecek2018/test_ch4ToAirAquacultureSystems.py +1 -7
- tests/models/pooreNemecek2018/test_n2OToAirAquacultureSystemsDirect.py +1 -7
- tests/models/pooreNemecek2018/test_n2ToAirAquacultureSystems.py +1 -7
- tests/models/pooreNemecek2018/test_nh3ToAirAquacultureSystems.py +1 -7
- tests/models/pooreNemecek2018/test_noxToAirAquacultureSystems.py +1 -7
- tests/models/utils/test_source.py +6 -1
- tests/orchestrator/strategies/run/test_add_blank_node_if_missing.py +1 -1
- hestia_earth/models/blonkConsultants2016/__init__.py +0 -13
- hestia_earth/models/blonkConsultants2016/ch4ToAirNaturalVegetationBurning.py +0 -78
- hestia_earth/models/blonkConsultants2016/co2ToAirAboveGroundBiomassStockChangeLandUseChange.py +0 -78
- hestia_earth/models/blonkConsultants2016/n2OToAirNaturalVegetationBurningDirect.py +0 -78
- hestia_earth/models/blonkConsultants2016/utils.py +0 -30
- tests/models/blonkConsultants2016/__init__.py +0 -0
- tests/models/blonkConsultants2016/test_ch4ToAirNaturalVegetationBurning.py +0 -34
- tests/models/blonkConsultants2016/test_co2ToAirAboveGroundBiomassStockChangeLandUseChange.py +0 -36
- tests/models/blonkConsultants2016/test_n2OToAirNaturalVegetationBurningDirect.py +0 -34
- tests/models/blonkConsultants2016/test_utils.py +0 -9
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.0.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.0.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.0.dist-info}/top_level.txt +0 -0
@@ -9,28 +9,17 @@ model_utils_path = f"hestia_earth.models.{MODEL}.utils"
|
|
9
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
10
10
|
|
11
11
|
|
12
|
-
@patch(f"{class_path}.
|
13
|
-
|
14
|
-
def test_should_run(mock_get_lookup_factor, mock_excreta, *args):
|
12
|
+
@patch(f"{class_path}._is_term_type_complete")
|
13
|
+
def test_should_run(mock_is_complete, *args):
|
15
14
|
cycle = {}
|
16
15
|
|
17
|
-
# no
|
18
|
-
|
16
|
+
# no complete => no run
|
17
|
+
mock_is_complete.return_value = False
|
19
18
|
should_run, *args = _should_run(cycle)
|
20
19
|
assert not should_run
|
21
20
|
|
22
|
-
#
|
23
|
-
|
24
|
-
{
|
25
|
-
'term': {
|
26
|
-
'@id': 'excretaKgN',
|
27
|
-
'termType': 'excreta',
|
28
|
-
'units': 'kg N'
|
29
|
-
},
|
30
|
-
'value': [10]
|
31
|
-
}
|
32
|
-
]
|
33
|
-
mock_excreta.return_value = 10
|
21
|
+
# is complete => run
|
22
|
+
mock_is_complete.return_value = True
|
34
23
|
should_run, *args = _should_run(cycle)
|
35
24
|
assert should_run is True
|
36
25
|
|
@@ -0,0 +1,51 @@
|
|
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.hestia.nh3ToSurfaceWaterAquacultureSystems import MODEL, TERM_ID, run, _should_run
|
6
|
+
|
7
|
+
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
8
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
9
|
+
|
10
|
+
|
11
|
+
@patch(f"{class_path}.valid_site_type", return_value=True)
|
12
|
+
def test_should_run(mock_valid_excreta, *args):
|
13
|
+
cycle = {}
|
14
|
+
should_run, *args = _should_run(cycle)
|
15
|
+
assert not should_run
|
16
|
+
|
17
|
+
# without the right type of excreta => no run
|
18
|
+
cycle['products'] = [
|
19
|
+
{
|
20
|
+
'term': {
|
21
|
+
'@id': 'excretaSolidFishCrustaceansKgN',
|
22
|
+
'termType': 'excreta'
|
23
|
+
}
|
24
|
+
}
|
25
|
+
]
|
26
|
+
should_run, *args = _should_run(cycle)
|
27
|
+
assert not should_run
|
28
|
+
|
29
|
+
# with fish_excreta_tan => run
|
30
|
+
cycle['products'] = [
|
31
|
+
{
|
32
|
+
'term': {
|
33
|
+
'@id': 'excretaLiquidFishCrustaceansKgN',
|
34
|
+
'termType': 'excreta'
|
35
|
+
}
|
36
|
+
}
|
37
|
+
]
|
38
|
+
should_run, *args = _should_run(cycle)
|
39
|
+
assert should_run is True
|
40
|
+
|
41
|
+
|
42
|
+
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
43
|
+
def test_run(*args):
|
44
|
+
with open(f"{fixtures_folder}/cycle.jsonld", encoding="utf-8") as f:
|
45
|
+
cycle = json.load(f)
|
46
|
+
|
47
|
+
with open(f"{fixtures_folder}/result.jsonld", encoding="utf-8") as f:
|
48
|
+
expected = json.load(f)
|
49
|
+
|
50
|
+
value = run(cycle)
|
51
|
+
assert value == expected
|
@@ -97,6 +97,7 @@ PARAMS_RUN = [subfolder for subfolder, should_run in PARAMS_SHOULD_RUN if should
|
|
97
97
|
|
98
98
|
|
99
99
|
@mark.parametrize("subfolder", PARAMS_RUN)
|
100
|
+
@patch(f"{class_path}.get_source", return_value={})
|
100
101
|
@patch(f"{class_path}.calc_descriptive_stats", side_effect=_fake_calc_descriptive_stats)
|
101
102
|
@patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
|
102
103
|
@patch(f"{utils_path}._get_sample_func", return_value=sample_constant)
|
@@ -108,6 +109,7 @@ def test_run(
|
|
108
109
|
_get_sample_func_mock: MagicMock,
|
109
110
|
_new_measurement_mock: MagicMock,
|
110
111
|
_calc_descriptive_stats_mock: MagicMock,
|
112
|
+
_mock_source: MagicMock,
|
111
113
|
subfolder: str
|
112
114
|
):
|
113
115
|
folder = f"{fixtures_folder}/{subfolder}"
|
@@ -133,6 +135,7 @@ PARAMS_RUN_WITH_STATS = [
|
|
133
135
|
|
134
136
|
|
135
137
|
@mark.parametrize("subfolder", PARAMS_RUN_WITH_STATS)
|
138
|
+
@patch(f"{class_path}.get_source", return_value={})
|
136
139
|
@patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
|
137
140
|
@patch(f"{utils_path}.get_cover_crop_property_terms", return_value=COVER_CROP_PROPERTY_TERM_IDS)
|
138
141
|
@patch(f"{term_path}.search")
|
@@ -140,6 +143,7 @@ def test_run_with_stats(
|
|
140
143
|
search_mock: MagicMock,
|
141
144
|
get_cover_crop_property_terms_mock: MagicMock,
|
142
145
|
_new_measurement_mock: MagicMock,
|
146
|
+
_mock_source: MagicMock,
|
143
147
|
subfolder: str
|
144
148
|
):
|
145
149
|
folder = f"{fixtures_folder}/{subfolder}"
|
@@ -97,6 +97,7 @@ PARAMS_RUN = [subfolder for subfolder, should_run in PARAMS_SHOULD_RUN if should
|
|
97
97
|
|
98
98
|
|
99
99
|
@mark.parametrize("subfolder", PARAMS_RUN)
|
100
|
+
@patch(f"{class_path}.get_source", return_value={})
|
100
101
|
@patch(f"{class_path}.calc_descriptive_stats", side_effect=_fake_calc_descriptive_stats)
|
101
102
|
@patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
|
102
103
|
@patch(f"{utils_path}._get_sample_func", return_value=sample_constant)
|
@@ -108,6 +109,7 @@ def test_run(
|
|
108
109
|
_get_sample_func_mock: MagicMock,
|
109
110
|
_new_measurement_mock: MagicMock,
|
110
111
|
_calc_descriptive_stats_mock: MagicMock,
|
112
|
+
_mock_source: MagicMock,
|
111
113
|
subfolder: str
|
112
114
|
):
|
113
115
|
folder = f"{fixtures_folder}/{subfolder}"
|
@@ -133,6 +135,7 @@ PARAMS_RUN_WITH_STATS = [
|
|
133
135
|
|
134
136
|
|
135
137
|
@mark.parametrize("subfolder", PARAMS_RUN_WITH_STATS)
|
138
|
+
@patch(f"{class_path}.get_source", return_value={})
|
136
139
|
@patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
|
137
140
|
@patch(f"{utils_path}.get_cover_crop_property_terms", return_value=COVER_CROP_PROPERTY_TERM_IDS)
|
138
141
|
@patch(f"{term_path}.search")
|
@@ -140,6 +143,7 @@ def test_run_with_stats(
|
|
140
143
|
search_mock: MagicMock,
|
141
144
|
get_cover_crop_property_terms_mock: MagicMock,
|
142
145
|
_new_measurement_mock: MagicMock,
|
146
|
+
_mock_source: MagicMock,
|
143
147
|
subfolder: str
|
144
148
|
):
|
145
149
|
folder = f"{fixtures_folder}/{subfolder}"
|
@@ -11,7 +11,7 @@ from tests.utils import fake_new_emission, fixtures_path, order_list
|
|
11
11
|
class_path = f"hestia_earth.models.{MODEL}.co2ToAirSoilOrganicCarbonStockChange"
|
12
12
|
utils_path = f"hestia_earth.models.{MODEL}.co2ToAirCarbonStockChange_utils"
|
13
13
|
soc_utils_path = f"hestia_earth.models.{MODEL}.organicCarbonPerHa_utils"
|
14
|
-
soc_tier_1_utils_path = f"hestia_earth.models.{MODEL}.
|
14
|
+
soc_tier_1_utils_path = f"hestia_earth.models.{MODEL}.organicCarbonPerHa_tier_1"
|
15
15
|
term_path = "hestia_earth.models.utils.term"
|
16
16
|
fixtures_folder = f"{fixtures_path}/{MODEL}/co2ToAirSoilOrganicCarbonStockChange"
|
17
17
|
|
@@ -13,23 +13,26 @@ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
13
13
|
@patch(f"{class_path}.get_excreta_N_total", return_value=0)
|
14
14
|
def test_should_run(mock_N_total, mock_complete, *args):
|
15
15
|
# no N => no run
|
16
|
-
|
16
|
+
should_run, *args = _should_run({})
|
17
|
+
assert not should_run
|
17
18
|
|
18
19
|
# with N => no run
|
19
20
|
mock_N_total.return_value = 10
|
20
|
-
|
21
|
+
should_run, *args = _should_run({})
|
22
|
+
assert not should_run
|
21
23
|
|
22
24
|
# is complete => run
|
23
25
|
mock_complete.return_value = True
|
24
|
-
|
26
|
+
should_run, *args = _should_run({})
|
27
|
+
assert should_run is True
|
25
28
|
|
26
29
|
|
27
30
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
28
|
-
def
|
29
|
-
with open(f"{fixtures_folder}/ecoClimateZone-wet/cycle.jsonld", encoding='utf-8') as f:
|
31
|
+
def test_run_cropland_wet(*args):
|
32
|
+
with open(f"{fixtures_folder}/cropland/ecoClimateZone-wet/cycle.jsonld", encoding='utf-8') as f:
|
30
33
|
cycle = json.load(f)
|
31
34
|
|
32
|
-
with open(f"{fixtures_folder}/ecoClimateZone-wet/result.jsonld", encoding='utf-8') as f:
|
35
|
+
with open(f"{fixtures_folder}/cropland/ecoClimateZone-wet/result.jsonld", encoding='utf-8') as f:
|
33
36
|
expected = json.load(f)
|
34
37
|
|
35
38
|
value = run(cycle)
|
@@ -37,11 +40,23 @@ def test_run_wet(*args):
|
|
37
40
|
|
38
41
|
|
39
42
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
40
|
-
def
|
41
|
-
with open(f"{fixtures_folder}/ecoClimateZone-dry/cycle.jsonld", encoding='utf-8') as f:
|
43
|
+
def test_run_cropland_dry(*args):
|
44
|
+
with open(f"{fixtures_folder}/cropland/ecoClimateZone-dry/cycle.jsonld", encoding='utf-8') as f:
|
42
45
|
cycle = json.load(f)
|
43
46
|
|
44
|
-
with open(f"{fixtures_folder}/ecoClimateZone-dry/result.jsonld", encoding='utf-8') as f:
|
47
|
+
with open(f"{fixtures_folder}/cropland/ecoClimateZone-dry/result.jsonld", encoding='utf-8') as f:
|
48
|
+
expected = json.load(f)
|
49
|
+
|
50
|
+
value = run(cycle)
|
51
|
+
assert value == expected
|
52
|
+
|
53
|
+
|
54
|
+
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
55
|
+
def test_run_animal_housing(*args):
|
56
|
+
with open(f"{fixtures_folder}/animal housing/cycle.jsonld", encoding='utf-8') as f:
|
57
|
+
cycle = json.load(f)
|
58
|
+
|
59
|
+
with open(f"{fixtures_folder}/animal housing/result.jsonld", encoding='utf-8') as f:
|
45
60
|
expected = json.load(f)
|
46
61
|
|
47
62
|
value = run(cycle)
|
@@ -10,8 +10,8 @@ from hestia_earth.models.ipcc2019.organicCarbonPerHa_utils import sample_constan
|
|
10
10
|
from tests.utils import fake_new_measurement, fixtures_path
|
11
11
|
|
12
12
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
13
|
-
tier_1_utils_path = f"hestia_earth.models.{MODEL}.{TERM_ID}
|
14
|
-
tier_2_utils_path = f"hestia_earth.models.{MODEL}.{TERM_ID}
|
13
|
+
tier_1_utils_path = f"hestia_earth.models.{MODEL}.{TERM_ID}_tier_1"
|
14
|
+
tier_2_utils_path = f"hestia_earth.models.{MODEL}.{TERM_ID}_tier_2"
|
15
15
|
utils_path = f"hestia_earth.models.{MODEL}.{TERM_ID}_utils"
|
16
16
|
term_path = "hestia_earth.models.utils.term"
|
17
17
|
property_path = "hestia_earth.models.utils.property"
|
tests/models/ipcc2019/{test_organicCarbonPerHa_tier_1_utils.py → test_organicCarbonPerHa_tier_1.py}
RENAMED
@@ -11,7 +11,7 @@ from hestia_earth.models.ipcc2019.organicCarbonPerHa_utils import (
|
|
11
11
|
IpccCarbonInputCategory, IpccLandUseCategory, IpccManagementCategory, IpccSoilCategory, sample_constant,
|
12
12
|
sample_plus_minus_error, sample_plus_minus_uncertainty
|
13
13
|
)
|
14
|
-
from hestia_earth.models.ipcc2019.
|
14
|
+
from hestia_earth.models.ipcc2019.organicCarbonPerHa_tier_1 import (
|
15
15
|
_assign_ipcc_carbon_input_category, _assign_ipcc_land_use_category, _assign_ipcc_management_category,
|
16
16
|
_assign_ipcc_soil_category, _calc_missing_equilibrium_years, _calc_regime_start_years, _calc_soc_stocks,
|
17
17
|
_check_cropland_low_category, _check_cropland_medium_category, _get_carbon_input_kwargs, _get_sample_func,
|
@@ -20,7 +20,7 @@ from hestia_earth.models.ipcc2019.organicCarbonPerHa_tier_1_utils import (
|
|
20
20
|
|
21
21
|
from tests.utils import fixtures_path
|
22
22
|
|
23
|
-
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}
|
23
|
+
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}_tier_1"
|
24
24
|
utils_path = f"hestia_earth.models.{MODEL}.{TERM_ID}_utils"
|
25
25
|
term_path = "hestia_earth.models.utils.term"
|
26
26
|
property_path = "hestia_earth.models.utils.property"
|
tests/models/ipcc2019/{test_organicCarbonPerHa_tier_2_utils.py → test_organicCarbonPerHa_tier_2.py}
RENAMED
@@ -6,13 +6,13 @@ from pytest import mark
|
|
6
6
|
from hestia_earth.models.utils.array_builders import discrete_uniform_2d, repeat_single
|
7
7
|
|
8
8
|
from hestia_earth.models.ipcc2019.organicCarbonPerHa import MODEL, TERM_ID
|
9
|
-
from hestia_earth.models.ipcc2019.
|
9
|
+
from hestia_earth.models.ipcc2019.organicCarbonPerHa_tier_2 import (
|
10
10
|
_calc_temperature_factor_annual, _calc_water_factor_annual, _Parameter, _sample_parameter
|
11
11
|
)
|
12
12
|
|
13
13
|
from tests.utils import fixtures_path
|
14
14
|
|
15
|
-
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}
|
15
|
+
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}_tier_2"
|
16
16
|
utils_path = f"hestia_earth.models.{MODEL}.{TERM_ID}_utils"
|
17
17
|
term_path = "hestia_earth.models.utils.term"
|
18
18
|
property_path = "hestia_earth.models.utils.property"
|
@@ -11,18 +11,12 @@ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
11
11
|
|
12
12
|
@patch(f"{class_path}.valid_site_type", return_value=True)
|
13
13
|
@patch(f"{class_path}.most_relevant_measurement_value", return_value=10)
|
14
|
-
@patch(f"{class_path}.is_model_enabled", return_value=False)
|
15
14
|
@patch(F"{class_path}.find_term_match", return_value={})
|
16
|
-
def test_should_run(mock_find_term,
|
15
|
+
def test_should_run(mock_find_term, *args):
|
17
16
|
cycle = {}
|
18
17
|
should_run, *args = _should_run(cycle)
|
19
18
|
assert not should_run
|
20
19
|
|
21
|
-
# model enabled => no run
|
22
|
-
mock_is_model_enabled.return_value = True
|
23
|
-
should_run, *args = _should_run(cycle)
|
24
|
-
assert not should_run
|
25
|
-
|
26
20
|
# with kg Vs product => no run
|
27
21
|
cycle['products'] = [
|
28
22
|
{
|
@@ -9,19 +9,13 @@ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
9
|
|
10
10
|
|
11
11
|
@patch(f"{class_path}.valid_site_type", return_value=True)
|
12
|
-
@patch(f"{class_path}.is_model_enabled", return_value=False)
|
13
12
|
@patch(f"{class_path}.total_excreta", return_value=0)
|
14
13
|
@patch(f"{class_path}.total_excreta_tan", return_value=0)
|
15
|
-
def test_should_run(mock_total_excreta, mock_total_excreta_tan,
|
14
|
+
def test_should_run(mock_total_excreta, mock_total_excreta_tan, *args):
|
16
15
|
cycle = {}
|
17
16
|
should_run, *args = _should_run(cycle)
|
18
17
|
assert not should_run
|
19
18
|
|
20
|
-
# model enabled => no run
|
21
|
-
mock_is_model_enabled.return_value = True
|
22
|
-
should_run, *args = _should_run(cycle)
|
23
|
-
assert not should_run
|
24
|
-
|
25
19
|
# without neither n nor tan => no run
|
26
20
|
mock_total_excreta.return_value = 0
|
27
21
|
mock_total_excreta_tan.return_value = 0
|
@@ -9,19 +9,13 @@ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
9
|
|
10
10
|
|
11
11
|
@patch(f"{class_path}.valid_site_type", return_value=True)
|
12
|
-
@patch(f"{class_path}.is_model_enabled", return_value=False)
|
13
12
|
@patch(f"{class_path}.total_excreta", return_value=0)
|
14
13
|
@patch(f"{class_path}.total_excreta_tan", return_value=0)
|
15
|
-
def test_should_run(mock_total_excreta, mock_total_excreta_tan,
|
14
|
+
def test_should_run(mock_total_excreta, mock_total_excreta_tan, *args):
|
16
15
|
cycle = {}
|
17
16
|
should_run, *args = _should_run(cycle)
|
18
17
|
assert not should_run
|
19
18
|
|
20
|
-
# model enabled => no run
|
21
|
-
mock_is_model_enabled.return_value = True
|
22
|
-
should_run, *args = _should_run(cycle)
|
23
|
-
assert not should_run
|
24
|
-
|
25
19
|
# without neither n nor tan => no run
|
26
20
|
mock_total_excreta.return_value = 0
|
27
21
|
mock_total_excreta_tan.return_value = 0
|
@@ -9,10 +9,9 @@ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
9
|
|
10
10
|
|
11
11
|
@patch(f"{class_path}.valid_site_type", return_value=True)
|
12
|
-
@patch(f"{class_path}.is_model_enabled", return_value=False)
|
13
12
|
@patch(f"{class_path}.total_excreta_tan", return_value=0)
|
14
13
|
@patch(f"{class_path}.list_sum", return_value=0)
|
15
|
-
def test_should_run(mock_yield_of_target_species, mock_total_excreta_tan,
|
14
|
+
def test_should_run(mock_yield_of_target_species, mock_total_excreta_tan, *args):
|
16
15
|
cycle = {
|
17
16
|
'practices': [
|
18
17
|
{
|
@@ -26,11 +25,6 @@ def test_should_run(mock_yield_of_target_species, mock_total_excreta_tan, mock_i
|
|
26
25
|
should_run, *args = _should_run(cycle)
|
27
26
|
assert not should_run
|
28
27
|
|
29
|
-
# model enabled => no run
|
30
|
-
mock_is_model_enabled.return_value = True
|
31
|
-
should_run, *args = _should_run(cycle)
|
32
|
-
assert not should_run
|
33
|
-
|
34
28
|
# without neither excreta_tan nor yield_of_target_species => no run
|
35
29
|
mock_yield_of_target_species.return_value = 0
|
36
30
|
mock_total_excreta_tan.return_value = 0
|
@@ -9,19 +9,13 @@ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
9
|
|
10
10
|
|
11
11
|
@patch(f"{class_path}.valid_site_type", return_value=True)
|
12
|
-
@patch(f"{class_path}.is_model_enabled", return_value=False)
|
13
12
|
@patch(f"{class_path}.total_excreta", return_value=0)
|
14
13
|
@patch(f"{class_path}.total_excreta_tan", return_value=0)
|
15
|
-
def test_should_run(mock_total_excreta, mock_total_excreta_tan,
|
14
|
+
def test_should_run(mock_total_excreta, mock_total_excreta_tan, *args):
|
16
15
|
cycle = {}
|
17
16
|
should_run, *args = _should_run(cycle)
|
18
17
|
assert not should_run
|
19
18
|
|
20
|
-
# model enabled => no run
|
21
|
-
mock_is_model_enabled.return_value = True
|
22
|
-
should_run, *args = _should_run(cycle)
|
23
|
-
assert not should_run
|
24
|
-
|
25
19
|
# without neither n nor tan => no run
|
26
20
|
mock_total_excreta.return_value = 0
|
27
21
|
mock_total_excreta_tan.return_value = 0
|
@@ -12,7 +12,12 @@ search_results = [{
|
|
12
12
|
|
13
13
|
|
14
14
|
def test_list_sources():
|
15
|
-
|
15
|
+
sources = _list_sources()
|
16
|
+
# test `BIBLIO_TITLE`
|
17
|
+
assert 'Soil organic carbon sequestration rates in vineyard agroecosystems under different soil management practices: A meta-analysis' in sources # noqa: E501
|
18
|
+
# test `OTHER_BIBLIO_TITLES`
|
19
|
+
assert '2006 IPCC Guidelines for National Greenhouse Gas Inventories' in sources
|
20
|
+
assert 'COMMISSION DECISION of 10 June 2010 on guidelines for the calculation of land carbon stocks for the purpose of Annex V to Directive 2009/28/EC' in sources # noqa: E501
|
16
21
|
|
17
22
|
|
18
23
|
@patch(f"{class_path}.search", return_value=search_results)
|
@@ -26,7 +26,7 @@ def test_should_run(mock_node_exists, *args):
|
|
26
26
|
assert not should_run(data, model)
|
27
27
|
|
28
28
|
# node exists with added value `0` and `Emission` => run
|
29
|
-
node = {'@type': 'Emission', 'value': [0], 'added': ['value']}
|
29
|
+
node = {'@type': 'Emission', 'value': [0], 'added': ['value'], 'methodTier': 'not relevant'}
|
30
30
|
mock_node_exists.return_value = node
|
31
31
|
assert should_run(data, model) is True
|
32
32
|
|
@@ -1,13 +0,0 @@
|
|
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 = 'blonkConsultants2016'
|
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))
|
@@ -1,78 +0,0 @@
|
|
1
|
-
from hestia_earth.schema import EmissionMethodTier, CycleFunctionalUnit
|
2
|
-
|
3
|
-
from hestia_earth.models.log import logRequirements, logShouldRun
|
4
|
-
from hestia_earth.models.utils.emission import _new_emission
|
5
|
-
from hestia_earth.models.utils.cycle import land_occupation_per_ha
|
6
|
-
from .utils import get_emission_factor
|
7
|
-
from . import MODEL
|
8
|
-
|
9
|
-
REQUIREMENTS = {
|
10
|
-
"Cycle": {
|
11
|
-
"functionalUnit": "1 ha",
|
12
|
-
"or": [
|
13
|
-
{
|
14
|
-
"cycleDuration": "",
|
15
|
-
"practices": [{"@type": "Practice", "value": "", "term.@id": "longFallowRatio"}]
|
16
|
-
},
|
17
|
-
{
|
18
|
-
"@doc": "for plantations, additional properties are required",
|
19
|
-
"practices": [
|
20
|
-
{"@type": "Practice", "value": "", "term.@id": "nurseryDensity"},
|
21
|
-
{"@type": "Practice", "value": "", "term.@id": "nurseryDuration"},
|
22
|
-
{"@type": "Practice", "value": "", "term.@id": "plantationProductiveLifespan"},
|
23
|
-
{"@type": "Practice", "value": "", "term.@id": "plantationDensity"},
|
24
|
-
{"@type": "Practice", "value": "", "term.@id": "plantationLifespan"},
|
25
|
-
{"@type": "Practice", "value": "", "term.@id": "rotationDuration"}
|
26
|
-
]
|
27
|
-
}
|
28
|
-
],
|
29
|
-
"site": {
|
30
|
-
"@type": "Site",
|
31
|
-
"country": {"@type": "Term", "termType": "region"}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
LOOKUPS = {
|
36
|
-
"crop": ["isPlantation", "cropGroupingFaostatArea"],
|
37
|
-
"region-crop-cropGroupingFaostatArea-ch4forestBiomassBurning": ""
|
38
|
-
}
|
39
|
-
RETURNS = {
|
40
|
-
"Emission": [{
|
41
|
-
"value": "",
|
42
|
-
"methodTier": "tier 1"
|
43
|
-
}]
|
44
|
-
}
|
45
|
-
TERM_ID = 'ch4ToAirNaturalVegetationBurning'
|
46
|
-
TIER = EmissionMethodTier.TIER_1.value
|
47
|
-
|
48
|
-
|
49
|
-
def _emission(value: float):
|
50
|
-
emission = _new_emission(TERM_ID, MODEL)
|
51
|
-
emission['value'] = [value]
|
52
|
-
emission['methodTier'] = TIER
|
53
|
-
return emission
|
54
|
-
|
55
|
-
|
56
|
-
def _run(land_occupation: float, ch4_forest_biomass_burning: float):
|
57
|
-
value = land_occupation * ch4_forest_biomass_burning
|
58
|
-
return [_emission(value)]
|
59
|
-
|
60
|
-
|
61
|
-
def _should_run(cycle: dict):
|
62
|
-
is_1_ha_functional_unit = cycle.get('functionalUnit') == CycleFunctionalUnit._1_HA.value
|
63
|
-
land_occupation = land_occupation_per_ha(MODEL, TERM_ID, cycle)
|
64
|
-
ch4_forest_biomass_burning = get_emission_factor(TERM_ID, cycle, 'ch4forestBiomassBurning')
|
65
|
-
|
66
|
-
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
67
|
-
is_1_ha_functional_unit=is_1_ha_functional_unit,
|
68
|
-
land_occupation=land_occupation,
|
69
|
-
ch4_forest_biomass_burning=ch4_forest_biomass_burning)
|
70
|
-
|
71
|
-
should_run = all([is_1_ha_functional_unit, land_occupation, ch4_forest_biomass_burning is not None])
|
72
|
-
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
73
|
-
return should_run, land_occupation, ch4_forest_biomass_burning
|
74
|
-
|
75
|
-
|
76
|
-
def run(cycle: dict):
|
77
|
-
should_run, land_occupation, ch4_forest_biomass_burning = _should_run(cycle)
|
78
|
-
return _run(land_occupation, ch4_forest_biomass_burning) if should_run else []
|
hestia_earth/models/blonkConsultants2016/co2ToAirAboveGroundBiomassStockChangeLandUseChange.py
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
from hestia_earth.schema import EmissionMethodTier, CycleFunctionalUnit
|
2
|
-
|
3
|
-
from hestia_earth.models.log import logRequirements, logShouldRun
|
4
|
-
from hestia_earth.models.utils.emission import _new_emission
|
5
|
-
from hestia_earth.models.utils.cycle import land_occupation_per_ha
|
6
|
-
from .utils import get_emission_factor
|
7
|
-
from . import MODEL
|
8
|
-
|
9
|
-
REQUIREMENTS = {
|
10
|
-
"Cycle": {
|
11
|
-
"functionalUnit": "1 ha",
|
12
|
-
"or": [
|
13
|
-
{
|
14
|
-
"cycleDuration": "",
|
15
|
-
"practices": [{"@type": "Practice", "value": "", "term.@id": "longFallowRatio"}]
|
16
|
-
},
|
17
|
-
{
|
18
|
-
"@doc": "for plantations, additional properties are required",
|
19
|
-
"practices": [
|
20
|
-
{"@type": "Practice", "value": "", "term.@id": "nurseryDensity"},
|
21
|
-
{"@type": "Practice", "value": "", "term.@id": "nurseryDuration"},
|
22
|
-
{"@type": "Practice", "value": "", "term.@id": "plantationProductiveLifespan"},
|
23
|
-
{"@type": "Practice", "value": "", "term.@id": "plantationDensity"},
|
24
|
-
{"@type": "Practice", "value": "", "term.@id": "plantationLifespan"},
|
25
|
-
{"@type": "Practice", "value": "", "term.@id": "rotationDuration"}
|
26
|
-
]
|
27
|
-
}
|
28
|
-
],
|
29
|
-
"site": {
|
30
|
-
"@type": "Site",
|
31
|
-
"country": {"@type": "Term", "termType": "region"}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
LOOKUPS = {
|
36
|
-
"crop": ["isPlantation", "cropGroupingFaostatArea"],
|
37
|
-
"region-crop-cropGroupingFaostatArea-co2LandUseChange": ""
|
38
|
-
}
|
39
|
-
RETURNS = {
|
40
|
-
"Emission": [{
|
41
|
-
"value": "",
|
42
|
-
"methodTier": "tier 1"
|
43
|
-
}]
|
44
|
-
}
|
45
|
-
TERM_ID = 'co2ToAirAboveGroundBiomassStockChangeLandUseChange'
|
46
|
-
TIER = EmissionMethodTier.TIER_1.value
|
47
|
-
|
48
|
-
|
49
|
-
def _emission(value: float):
|
50
|
-
emission = _new_emission(TERM_ID, MODEL)
|
51
|
-
emission['value'] = [value]
|
52
|
-
emission['methodTier'] = TIER
|
53
|
-
return emission
|
54
|
-
|
55
|
-
|
56
|
-
def _run(land_occupation: float, co2_land_use_change: float):
|
57
|
-
value = land_occupation * co2_land_use_change
|
58
|
-
return [_emission(value)]
|
59
|
-
|
60
|
-
|
61
|
-
def _should_run(cycle: dict):
|
62
|
-
is_1_ha_functional_unit = cycle.get('functionalUnit') == CycleFunctionalUnit._1_HA.value
|
63
|
-
land_occupation = land_occupation_per_ha(MODEL, TERM_ID, cycle)
|
64
|
-
co2_land_use_change = get_emission_factor(TERM_ID, cycle, 'co2LandUseChange')
|
65
|
-
|
66
|
-
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
67
|
-
is_1_ha_functional_unit=is_1_ha_functional_unit,
|
68
|
-
land_occupation=land_occupation,
|
69
|
-
co2_land_use_change=co2_land_use_change)
|
70
|
-
|
71
|
-
should_run = all([is_1_ha_functional_unit, land_occupation, co2_land_use_change is not None])
|
72
|
-
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
73
|
-
return should_run, land_occupation, co2_land_use_change
|
74
|
-
|
75
|
-
|
76
|
-
def run(cycle: dict):
|
77
|
-
should_run, land_occupation, co2_land_use_change = _should_run(cycle)
|
78
|
-
return _run(land_occupation, co2_land_use_change) if should_run else []
|
@@ -1,78 +0,0 @@
|
|
1
|
-
from hestia_earth.schema import EmissionMethodTier, CycleFunctionalUnit
|
2
|
-
|
3
|
-
from hestia_earth.models.log import logRequirements, logShouldRun
|
4
|
-
from hestia_earth.models.utils.emission import _new_emission
|
5
|
-
from hestia_earth.models.utils.cycle import land_occupation_per_ha
|
6
|
-
from .utils import get_emission_factor
|
7
|
-
from . import MODEL
|
8
|
-
|
9
|
-
REQUIREMENTS = {
|
10
|
-
"Cycle": {
|
11
|
-
"functionalUnit": "1 ha",
|
12
|
-
"or": [
|
13
|
-
{
|
14
|
-
"cycleDuration": "",
|
15
|
-
"practices": [{"@type": "Practice", "value": "", "term.@id": "longFallowRatio"}]
|
16
|
-
},
|
17
|
-
{
|
18
|
-
"@doc": "for plantations, additional properties are required",
|
19
|
-
"practices": [
|
20
|
-
{"@type": "Practice", "value": "", "term.@id": "nurseryDensity"},
|
21
|
-
{"@type": "Practice", "value": "", "term.@id": "nurseryDuration"},
|
22
|
-
{"@type": "Practice", "value": "", "term.@id": "plantationProductiveLifespan"},
|
23
|
-
{"@type": "Practice", "value": "", "term.@id": "plantationDensity"},
|
24
|
-
{"@type": "Practice", "value": "", "term.@id": "plantationLifespan"},
|
25
|
-
{"@type": "Practice", "value": "", "term.@id": "rotationDuration"}
|
26
|
-
]
|
27
|
-
}
|
28
|
-
],
|
29
|
-
"site": {
|
30
|
-
"@type": "Site",
|
31
|
-
"country": {"@type": "Term", "termType": "region"}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
LOOKUPS = {
|
36
|
-
"crop": ["isPlantation", "cropGroupingFaostatArea"],
|
37
|
-
"region-crop-cropGroupingFaostatArea-n2oforestBiomassBurning": ""
|
38
|
-
}
|
39
|
-
RETURNS = {
|
40
|
-
"Emission": [{
|
41
|
-
"value": "",
|
42
|
-
"methodTier": "tier 1"
|
43
|
-
}]
|
44
|
-
}
|
45
|
-
TERM_ID = 'n2OToAirNaturalVegetationBurningDirect'
|
46
|
-
TIER = EmissionMethodTier.TIER_1.value
|
47
|
-
|
48
|
-
|
49
|
-
def _emission(value: float):
|
50
|
-
emission = _new_emission(TERM_ID, MODEL)
|
51
|
-
emission['value'] = [value]
|
52
|
-
emission['methodTier'] = TIER
|
53
|
-
return emission
|
54
|
-
|
55
|
-
|
56
|
-
def _run(land_occupation: float, n2o_forest_biomass_burning: float):
|
57
|
-
value = land_occupation * n2o_forest_biomass_burning
|
58
|
-
return [_emission(value)]
|
59
|
-
|
60
|
-
|
61
|
-
def _should_run(cycle: dict):
|
62
|
-
is_1_ha_functional_unit = cycle.get('functionalUnit') == CycleFunctionalUnit._1_HA.value
|
63
|
-
land_occupation = land_occupation_per_ha(MODEL, TERM_ID, cycle)
|
64
|
-
n2o_forest_biomass_burning = get_emission_factor(TERM_ID, cycle, 'n2oforestBiomassBurning')
|
65
|
-
|
66
|
-
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
67
|
-
is_1_ha_functional_unit=is_1_ha_functional_unit,
|
68
|
-
land_occupation=land_occupation,
|
69
|
-
n2o_forest_biomass_burning=n2o_forest_biomass_burning)
|
70
|
-
|
71
|
-
should_run = all([is_1_ha_functional_unit, land_occupation, n2o_forest_biomass_burning is not None])
|
72
|
-
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
73
|
-
return should_run, land_occupation, n2o_forest_biomass_burning
|
74
|
-
|
75
|
-
|
76
|
-
def run(cycle: dict):
|
77
|
-
should_run, land_occupation, n2o_forest_biomass_burning = _should_run(cycle)
|
78
|
-
return _run(land_occupation, n2o_forest_biomass_burning) if should_run else []
|