hestia-earth-models 0.64.11__py3-none-any.whl → 0.64.13__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 +1 -1
- hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsLandOccupation.py +1 -1
- hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsLandTransformation.py +1 -1
- hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsTotalLandUseEffects.py +3 -2
- hestia_earth/models/cml2001Baseline/eutrophicationPotentialExcludingFate.py +2 -2
- hestia_earth/models/cml2001Baseline/terrestrialAcidificationPotentialIncludingFateAverageEurope.py +2 -2
- hestia_earth/models/cml2001NonBaseline/eutrophicationPotentialIncludingFateAverageEurope.py +2 -2
- hestia_earth/models/cml2001NonBaseline/terrestrialAcidificationPotentialExcludingFate.py +2 -2
- hestia_earth/models/cycle/completeness/seed.py +6 -4
- hestia_earth/models/cycle/concentrateFeed.py +36 -19
- hestia_earth/models/cycle/endDate.py +10 -1
- hestia_earth/models/cycle/milkYield.py +6 -5
- hestia_earth/models/cycle/startDate.py +6 -4
- hestia_earth/models/edip2003/ozoneDepletionPotential.py +2 -2
- hestia_earth/models/emissionNotRelevant/__init__.py +3 -2
- hestia_earth/models/environmentalFootprintV3/freshwaterEcotoxicityPotentialCtue.py +2 -3
- hestia_earth/models/faostat2018/utils.py +72 -12
- hestia_earth/models/hestia/__init__.py +13 -0
- hestia_earth/models/hestia/landCover.py +727 -0
- hestia_earth/models/ipcc2013ExcludingFeedbacks/gwp100.py +2 -2
- hestia_earth/models/ipcc2013IncludingFeedbacks/gwp100.py +2 -2
- hestia_earth/models/ipcc2019/aboveGroundBiomass.py +4 -8
- hestia_earth/models/ipcc2019/animal/fatContent.py +1 -1
- hestia_earth/models/ipcc2019/animal/milkYieldPerAnimal.py +91 -0
- hestia_earth/models/ipcc2019/animal/trueProteinContent.py +1 -1
- hestia_earth/models/ipcc2019/animal/utils.py +17 -12
- hestia_earth/models/ipcc2019/belowGroundBiomass.py +4 -8
- hestia_earth/models/ipcc2019/biomass_utils.py +11 -0
- hestia_earth/models/ipcc2019/ch4ToAirEntericFermentation.py +1 -1
- hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChange.py +8 -4
- hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChange.py +7 -3
- hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +52 -6
- hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py +7 -3
- hestia_earth/models/ipcc2019/n2OToAirExcretaDirect.py +14 -9
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1_utils.py +9 -3
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2_utils.py +1 -2
- hestia_earth/models/koble2014/aboveGroundCropResidue.py +5 -1
- hestia_earth/models/lcImpactAllEffects100Years/damageToFreshwaterEcosystemsClimateChange.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToFreshwaterEcosystemsFreshwaterEcotoxicity.py +2 -3
- hestia_earth/models/lcImpactAllEffects100Years/damageToFreshwaterEcosystemsPdfYear.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealth.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthClimateChange.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthHumanToxicityCancerogenic.py +2 -3
- hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthHumanToxicityNonCancerogenic.py +2 -3
- hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthStratosphericOzoneDepletion.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToMarineEcosystemsMarineEcotoxicity.py +2 -3
- hestia_earth/models/lcImpactAllEffects100Years/damageToMarineEcosystemsPdfYear.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToTerrestrialEcosystemsClimateChange.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToTerrestrialEcosystemsPdfYear.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToTerrestrialEcosystemsTerrestrialEcotoxicity.py +2 -3
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToFreshwaterEcosystemsClimateChange.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToFreshwaterEcosystemsFreshwaterEcotoxicity.py +2 -3
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToFreshwaterEcosystemsPdfYear.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealth.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthClimateChange.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthHumanToxicityCancerogenic.py +2 -3
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthHumanToxicityNonCancerogenic.py +2 -3
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthStratosphericOzoneDepletion.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToMarineEcosystemsMarineEcotoxicity.py +2 -3
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToMarineEcosystemsPdfYear.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToTerrestrialEcosystemsClimateChange.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToTerrestrialEcosystemsPdfYear.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToTerrestrialEcosystemsTerrestrialEcotoxicity.py +2 -3
- hestia_earth/models/lcImpactCertainEffects100Years/damageToFreshwaterEcosystemsFreshwaterEcotoxicity.py +2 -3
- hestia_earth/models/lcImpactCertainEffects100Years/damageToFreshwaterEcosystemsPdfYear.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealth.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthClimateChange.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthHumanToxicityCancerogenic.py +2 -3
- hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthHumanToxicityNonCancerogenic.py +2 -3
- hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthStratosphericOzoneDepletion.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToMarineEcosystemsMarineEcotoxicity.py +2 -3
- hestia_earth/models/lcImpactCertainEffects100Years/damageToMarineEcosystemsPdfYear.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToTerrestrialEcosystemsClimateChange.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToTerrestrialEcosystemsPdfYear.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToTerrestrialEcosystemsTerrestrialEcotoxicity.py +2 -3
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToFreshwaterEcosystemsFreshwaterEcotoxicity.py +2 -3
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToFreshwaterEcosystemsPdfYear.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealth.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthClimateChange.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthHumanToxicityCancerogenic.py +2 -3
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthHumanToxicityNonCancerogenic.py +2 -3
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthStratosphericOzoneDepletion.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToMarineEcosystemsMarineEcotoxicity.py +2 -3
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToMarineEcosystemsPdfYear.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToTerrestrialEcosystemsClimateChange.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToTerrestrialEcosystemsPdfYear.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToTerrestrialEcosystemsTerrestrialEcotoxicity.py +2 -3
- hestia_earth/models/linkedImpactAssessment/emissions.py +3 -0
- hestia_earth/models/log.py +4 -3
- hestia_earth/models/mocking/search-results.json +575 -575
- hestia_earth/models/pooreNemecek2018/excretaKgN.py +4 -4
- hestia_earth/models/pooreNemecek2018/excretaKgVs.py +4 -4
- hestia_earth/models/pooreNemecek2018/no3ToGroundwaterCropResidueDecomposition.py +1 -1
- hestia_earth/models/pooreNemecek2018/no3ToGroundwaterExcreta.py +1 -1
- hestia_earth/models/pooreNemecek2018/no3ToGroundwaterInorganicFertiliser.py +1 -1
- hestia_earth/models/pooreNemecek2018/no3ToGroundwaterOrganicFertiliser.py +1 -1
- hestia_earth/models/pooreNemecek2018/{saplings.py → saplingsDepreciatedAmountPerCycle.py} +1 -1
- hestia_earth/models/pooreNemecek2018/utils.py +7 -1
- hestia_earth/models/recipe2016Egalitarian/damageToFreshwaterEcosystemsSpeciesYear.py +2 -2
- hestia_earth/models/recipe2016Egalitarian/damageToHumanHealth.py +2 -2
- hestia_earth/models/recipe2016Egalitarian/damageToMarineEcosystemsSpeciesYear.py +2 -2
- hestia_earth/models/recipe2016Egalitarian/damageToTerrestrialEcosystemsSpeciesYear.py +2 -2
- hestia_earth/models/recipe2016Egalitarian/freshwaterAquaticEcotoxicityPotential14Dcbeq.py +2 -3
- hestia_earth/models/recipe2016Egalitarian/freshwaterEutrophicationPotential.py +2 -2
- hestia_earth/models/recipe2016Egalitarian/humanCarcinogenicToxicity.py +2 -3
- hestia_earth/models/recipe2016Egalitarian/humanNonCarcinogenicToxicity.py +2 -3
- hestia_earth/models/recipe2016Egalitarian/marineAquaticEcotoxicityPotential14Dcbeq.py +2 -3
- hestia_earth/models/recipe2016Egalitarian/marineEutrophicationPotential.py +2 -2
- hestia_earth/models/recipe2016Egalitarian/ozoneDepletionPotential.py +2 -2
- hestia_earth/models/recipe2016Egalitarian/terrestrialAcidificationPotential.py +2 -2
- hestia_earth/models/recipe2016Egalitarian/terrestrialEcotoxicityPotential14Dcbeq.py +2 -3
- hestia_earth/models/recipe2016Hierarchist/damageToFreshwaterEcosystemsSpeciesYear.py +2 -2
- hestia_earth/models/recipe2016Hierarchist/damageToHumanHealth.py +2 -2
- hestia_earth/models/recipe2016Hierarchist/damageToMarineEcosystemsSpeciesYear.py +2 -2
- hestia_earth/models/recipe2016Hierarchist/damageToTerrestrialEcosystemsSpeciesYear.py +2 -2
- hestia_earth/models/recipe2016Hierarchist/freshwaterAquaticEcotoxicityPotential14Dcbeq.py +2 -3
- hestia_earth/models/recipe2016Hierarchist/freshwaterEutrophicationPotential.py +2 -2
- hestia_earth/models/recipe2016Hierarchist/humanCarcinogenicToxicity.py +2 -3
- hestia_earth/models/recipe2016Hierarchist/humanNonCarcinogenicToxicity.py +2 -3
- hestia_earth/models/recipe2016Hierarchist/marineAquaticEcotoxicityPotential14Dcbeq.py +2 -3
- hestia_earth/models/recipe2016Hierarchist/marineEutrophicationPotential.py +2 -2
- hestia_earth/models/recipe2016Hierarchist/ozoneDepletionPotential.py +2 -2
- hestia_earth/models/recipe2016Hierarchist/terrestrialAcidificationPotential.py +2 -2
- hestia_earth/models/recipe2016Hierarchist/terrestrialEcotoxicityPotential14Dcbeq.py +2 -3
- hestia_earth/models/recipe2016Individualist/damageToFreshwaterEcosystemsSpeciesYear.py +2 -2
- hestia_earth/models/recipe2016Individualist/damageToHumanHealth.py +2 -2
- hestia_earth/models/recipe2016Individualist/damageToMarineEcosystemsSpeciesYear.py +2 -2
- hestia_earth/models/recipe2016Individualist/damageToTerrestrialEcosystemsSpeciesYear.py +2 -2
- hestia_earth/models/recipe2016Individualist/freshwaterAquaticEcotoxicityPotential14Dcbeq.py +2 -3
- hestia_earth/models/recipe2016Individualist/freshwaterEutrophicationPotential.py +2 -2
- hestia_earth/models/recipe2016Individualist/humanCarcinogenicToxicity.py +2 -3
- hestia_earth/models/recipe2016Individualist/humanNonCarcinogenicToxicity.py +2 -3
- hestia_earth/models/recipe2016Individualist/marineAquaticEcotoxicityPotential14Dcbeq.py +2 -3
- hestia_earth/models/recipe2016Individualist/marineEutrophicationPotential.py +2 -2
- hestia_earth/models/recipe2016Individualist/ozoneDepletionPotential.py +2 -2
- hestia_earth/models/recipe2016Individualist/terrestrialAcidificationPotential.py +2 -2
- hestia_earth/models/recipe2016Individualist/terrestrialEcotoxicityPotential14Dcbeq.py +2 -3
- hestia_earth/models/site/management.py +142 -144
- hestia_earth/models/stehfestBouwman2006/n2OToAirCropResidueDecompositionDirect.py +1 -1
- hestia_earth/models/stehfestBouwman2006/n2OToAirExcretaDirect.py +1 -1
- hestia_earth/models/stehfestBouwman2006/n2OToAirInorganicFertiliserDirect.py +1 -1
- hestia_earth/models/stehfestBouwman2006/n2OToAirOrganicFertiliserDirect.py +1 -1
- hestia_earth/models/stehfestBouwman2006/noxToAirCropResidueDecomposition.py +1 -1
- hestia_earth/models/stehfestBouwman2006/noxToAirExcreta.py +1 -1
- hestia_earth/models/stehfestBouwman2006/noxToAirInorganicFertiliser.py +1 -1
- hestia_earth/models/stehfestBouwman2006/noxToAirOrganicFertiliser.py +1 -1
- hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirCropResidueDecomposition.py +1 -1
- hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirExcreta.py +1 -1
- hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirInorganicFertiliser.py +1 -1
- hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirOrganicFertiliser.py +1 -1
- hestia_earth/models/usetoxV2/freshwaterEcotoxicityPotentialCtue.py +2 -3
- hestia_earth/models/utils/__init__.py +4 -1
- hestia_earth/models/utils/blank_node.py +34 -14
- hestia_earth/models/utils/emission.py +1 -8
- hestia_earth/models/utils/lookup.py +2 -1
- hestia_earth/models/utils/management.py +11 -0
- hestia_earth/models/utils/pesticideAI.py +11 -17
- hestia_earth/models/utils/term.py +2 -1
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.64.11.dist-info → hestia_earth_models-0.64.13.dist-info}/METADATA +4 -4
- {hestia_earth_models-0.64.11.dist-info → hestia_earth_models-0.64.13.dist-info}/RECORD +192 -188
- {hestia_earth_models-0.64.11.dist-info → hestia_earth_models-0.64.13.dist-info}/WHEEL +1 -1
- tests/models/cycle/completeness/test_seed.py +1 -1
- tests/models/cycle/test_endDate.py +18 -2
- tests/models/cycle/test_startDate.py +21 -3
- tests/models/faostat2018/test_faostat_utils.py +84 -0
- tests/models/hestia/__init__.py +0 -0
- tests/models/hestia/test_landCover.py +210 -0
- tests/models/ipcc2019/animal/test_milkYieldPerAnimal.py +21 -0
- tests/models/ipcc2019/test_aboveGroundBiomass.py +2 -1
- tests/models/ipcc2019/test_belowGroundBiomass.py +2 -1
- tests/models/ipcc2019/test_co2ToAirAboveGroundBiomassStockChange.py +4 -3
- tests/models/ipcc2019/test_co2ToAirBelowGroundBiomassStockChange.py +3 -3
- tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py +49 -2
- tests/models/ipcc2019/test_n2OToAirExcretaDirect.py +12 -0
- tests/models/ipcc2019/test_organicCarbonPerHa.py +1 -0
- tests/models/koble2014/test_aboveGroundCropResidue.py +13 -0
- tests/models/pooreNemecek2018/test_no3ToGroundwaterCropResidueDecomposition.py +3 -2
- tests/models/pooreNemecek2018/test_no3ToGroundwaterExcreta.py +3 -2
- tests/models/pooreNemecek2018/test_no3ToGroundwaterInorganicFertiliser.py +3 -2
- tests/models/pooreNemecek2018/test_no3ToGroundwaterOrganicFertiliser.py +3 -2
- tests/models/pooreNemecek2018/{test_saplings.py → test_saplingsDepreciatedAmountPerCycle.py} +1 -1
- tests/models/site/test_management.py +18 -151
- tests/models/utils/test_blank_node.py +57 -1
- tests/models/utils/test_emission.py +1 -6
- tests/models/utils/test_site.py +33 -2
- tests/models/pooreNemecek2018/test_no3ToGroundwaterSoilFlux.py +0 -90
- tests/models/stehfestBouwman2006/test_n2OToAirSoilFlux.py +0 -41
- tests/models/stehfestBouwman2006/test_noxToAirSoilFlux.py +0 -40
- tests/models/stehfestBouwman2006GisImplementation/test_noxToAirSoilFlux.py +0 -33
- /hestia_earth/models/pooreNemecek2018/{no3ToGroundwaterSoilFlux.py → no3ToGroundwaterSoilFlux_utils.py} +0 -0
- /hestia_earth/models/stehfestBouwman2006/{n2OToAirSoilFlux.py → n2OToAirSoilFlux_utils.py} +0 -0
- /hestia_earth/models/stehfestBouwman2006/{noxToAirSoilFlux.py → noxToAirSoilFlux_utils.py} +0 -0
- /hestia_earth/models/stehfestBouwman2006GisImplementation/{noxToAirSoilFlux.py → noxToAirSoilFlux_utils.py} +0 -0
- {hestia_earth_models-0.64.11.dist-info → hestia_earth_models-0.64.13.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.64.11.dist-info → hestia_earth_models-0.64.13.dist-info}/top_level.txt +0 -0
|
@@ -20,7 +20,7 @@ def test_run_seed(mock_find_term):
|
|
|
20
20
|
|
|
21
21
|
@patch(f"{class_path}.is_plantation", return_value=False)
|
|
22
22
|
@patch(f"{class_path}.find_term_match", return_value=None)
|
|
23
|
-
def
|
|
23
|
+
def test_run_saplingsDepreciatedAmountPerCycle(mock_find_term, mock_is_plantation):
|
|
24
24
|
cycle = {}
|
|
25
25
|
|
|
26
26
|
# on cropland => not complete
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
1
3
|
from hestia_earth.models.cycle.endDate import _should_run, run
|
|
2
4
|
|
|
3
5
|
|
|
@@ -18,5 +20,19 @@ def test_should_run():
|
|
|
18
20
|
assert should_run is True
|
|
19
21
|
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
@pytest.mark.parametrize(
|
|
24
|
+
'test_name,cycle,result',
|
|
25
|
+
[
|
|
26
|
+
(
|
|
27
|
+
'with endDate only', {'endDate': '2020-01'}, '2020-01-14'
|
|
28
|
+
),
|
|
29
|
+
(
|
|
30
|
+
'with endDate same month as startDate', {'endDate': '2020-02', 'startDate': '2020-02'}, '2020-02-29'
|
|
31
|
+
),
|
|
32
|
+
(
|
|
33
|
+
'with endDate not same month as startDate', {'endDate': '2020-02', 'startDate': '2020-01'}, '2020-02-14'
|
|
34
|
+
),
|
|
35
|
+
]
|
|
36
|
+
)
|
|
37
|
+
def test_run(test_name: str, cycle: dict, result: str):
|
|
38
|
+
assert run(cycle) == result, test_name
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
1
3
|
from hestia_earth.models.cycle.startDate import _should_run_by_cycleDuration, _should_run_by_startDate, run
|
|
2
4
|
|
|
3
5
|
|
|
@@ -35,6 +37,22 @@ def test_should_run_by_startDate():
|
|
|
35
37
|
assert should_run is True
|
|
36
38
|
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
@pytest.mark.parametrize(
|
|
41
|
+
'test_name,cycle,result',
|
|
42
|
+
[
|
|
43
|
+
(
|
|
44
|
+
'with startDate only', {'startDate': '2020-01'}, '2020-01-15'
|
|
45
|
+
),
|
|
46
|
+
(
|
|
47
|
+
'with endDate and cycleDuration', {'endDate': '2020-01-01', 'cycleDuration': 365}, '2019-01-01'
|
|
48
|
+
),
|
|
49
|
+
(
|
|
50
|
+
'with endDate same month as startDate', {'endDate': '2020-02', 'startDate': '2020-02'}, '2020-02-01'
|
|
51
|
+
),
|
|
52
|
+
(
|
|
53
|
+
'with endDate not same month as startDate', {'endDate': '2020-02', 'startDate': '2020-01'}, '2020-01-15'
|
|
54
|
+
),
|
|
55
|
+
]
|
|
56
|
+
)
|
|
57
|
+
def test_run(test_name: str, cycle: dict, result: str):
|
|
58
|
+
assert run(cycle) == result, test_name
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
|
|
3
|
+
import numpy
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.faostat2018.utils import (get_sum_of_columns, MODEL, get_land_ratio,
|
|
6
|
+
get_change_in_harvested_area_for_crop)
|
|
7
|
+
from tests.utils import fixtures_path
|
|
8
|
+
|
|
9
|
+
CLASS_PATH = f"hestia_earth.models.{MODEL}.utils"
|
|
10
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/utils"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _afg_download_fixture():
|
|
14
|
+
with open(f"{fixtures_folder}/gadm-afg.csv") as f:
|
|
15
|
+
afg_lookup = numpy.recfromcsv(
|
|
16
|
+
fname=f,
|
|
17
|
+
missing_values="",
|
|
18
|
+
filling_values="",
|
|
19
|
+
delimiter=",",
|
|
20
|
+
encoding="utf-8"
|
|
21
|
+
)
|
|
22
|
+
return afg_lookup
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_get_sum_of_columns():
|
|
26
|
+
result = get_sum_of_columns(
|
|
27
|
+
lookup=_afg_download_fixture(),
|
|
28
|
+
country="GADM-AFG",
|
|
29
|
+
year=1975,
|
|
30
|
+
columns_list=["Arable land", "Permanent crops"]
|
|
31
|
+
)
|
|
32
|
+
assert result == 8050.3
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_check_sums_for_columns():
|
|
36
|
+
"""
|
|
37
|
+
Check that the values of Arable and Permanent add up to Cropland, at least for AFG
|
|
38
|
+
"""
|
|
39
|
+
for year in range(1961, 2021):
|
|
40
|
+
sum_arab_perm = get_sum_of_columns(
|
|
41
|
+
lookup=_afg_download_fixture(),
|
|
42
|
+
country="GADM-AFG",
|
|
43
|
+
year=year,
|
|
44
|
+
columns_list=["Arable land", "Permanent crops"]
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
cropland_value = get_sum_of_columns(
|
|
48
|
+
lookup=_afg_download_fixture(),
|
|
49
|
+
country="GADM-AFG",
|
|
50
|
+
year=year,
|
|
51
|
+
columns_list=["Cropland"]
|
|
52
|
+
)
|
|
53
|
+
assert sum_arab_perm == cropland_value
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@patch(f"{CLASS_PATH}.download_lookup")
|
|
57
|
+
def test_get_land_ratio(mock_lookup):
|
|
58
|
+
mock_lookup.return_value = _afg_download_fixture()
|
|
59
|
+
result = get_land_ratio(
|
|
60
|
+
country="GADM-AFG",
|
|
61
|
+
start_year=1990,
|
|
62
|
+
end_year=2010,
|
|
63
|
+
first_column="Forest land",
|
|
64
|
+
second_column="Cropland"
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
assert result == (-123.0, 0.0, -123.0)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_get_harvested_area_for_crop():
|
|
71
|
+
result = get_change_in_harvested_area_for_crop(
|
|
72
|
+
country_id="GADM-AFG",
|
|
73
|
+
start_year=1990,
|
|
74
|
+
end_year=1992,
|
|
75
|
+
crop_name="Wheat"
|
|
76
|
+
)
|
|
77
|
+
assert result == 30000.0
|
|
78
|
+
|
|
79
|
+
result = get_change_in_harvested_area_for_crop(
|
|
80
|
+
country_id="GADM-AFG",
|
|
81
|
+
start_year=2019,
|
|
82
|
+
crop_name="Wheat"
|
|
83
|
+
)
|
|
84
|
+
assert result == 2334000
|
|
File without changes
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import csv
|
|
2
|
+
import json
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pytest
|
|
5
|
+
from unittest.mock import patch
|
|
6
|
+
|
|
7
|
+
from tests.utils import fixtures_path, fake_new_management
|
|
8
|
+
from hestia_earth.models.faostat2018.utils import MODEL as FAOSTAT_MODEL
|
|
9
|
+
from hestia_earth.models.hestia.landCover import (
|
|
10
|
+
MODEL, MODEL_KEY, get_changes, _estimate_maximum_forest_change,
|
|
11
|
+
run, site_area_sum_to_100, _get_sums_of_crop_expansion
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
CLASS_PATH = f"hestia_earth.models.{MODEL}.{MODEL_KEY}"
|
|
15
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{MODEL_KEY}"
|
|
16
|
+
|
|
17
|
+
FAOSTAT_CLASS_PATH = f"hestia_earth.models.{FAOSTAT_MODEL}.utils"
|
|
18
|
+
faostat_fixtures_folder = f"{fixtures_path}/{FAOSTAT_MODEL}/utils"
|
|
19
|
+
|
|
20
|
+
BRAZIL_SITE = {
|
|
21
|
+
"@type": "Site",
|
|
22
|
+
"id": "Brazil-example",
|
|
23
|
+
"country": {
|
|
24
|
+
"name": "Brazil",
|
|
25
|
+
"type": "Term"
|
|
26
|
+
},
|
|
27
|
+
"siteType": "cropland",
|
|
28
|
+
"management": [
|
|
29
|
+
{
|
|
30
|
+
"term": {
|
|
31
|
+
"@id": "maizePlant",
|
|
32
|
+
"name": "Maize plant",
|
|
33
|
+
"type": "Term",
|
|
34
|
+
"termType": "landCover"
|
|
35
|
+
},
|
|
36
|
+
"value": 100,
|
|
37
|
+
"startDate": "2010-01-01",
|
|
38
|
+
"endDate": "2010-12-31",
|
|
39
|
+
"type": "Management"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def recfromcsv_mod(filename, **kwargs):
|
|
46
|
+
def rewrite_csv_as_tab(csv_name):
|
|
47
|
+
with open(csv_name, newline='') as fp:
|
|
48
|
+
for row in csv.reader(fp, delimiter=","):
|
|
49
|
+
yield "\t".join(row)
|
|
50
|
+
return np.recfromcsv(
|
|
51
|
+
rewrite_csv_as_tab(filename), delimiter="\t", encoding=None, **kwargs)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _download_fixture(filepath: str):
|
|
55
|
+
return recfromcsv_mod(filename=filepath)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@patch(f"{FAOSTAT_CLASS_PATH}.download_lookup")
|
|
59
|
+
def test_get_changes(mock_lookup):
|
|
60
|
+
mock_lookup.return_value = _download_fixture(f"{faostat_fixtures_folder}/gadm-afg.csv")
|
|
61
|
+
result = get_changes(
|
|
62
|
+
country_id="GADM-AFG",
|
|
63
|
+
end_year=2010
|
|
64
|
+
)
|
|
65
|
+
assert (
|
|
66
|
+
result == {
|
|
67
|
+
"Arable land": -117.0,
|
|
68
|
+
"Cropland": -123.0,
|
|
69
|
+
"Forest land": 0,
|
|
70
|
+
"Other land": 123.0,
|
|
71
|
+
"Land area": 0,
|
|
72
|
+
"Permanent crops": -6.0,
|
|
73
|
+
"Permanent meadows and pastures": 0,
|
|
74
|
+
"Total agricultural change": -123.0
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@pytest.mark.parametrize(
|
|
80
|
+
"description,inputs,expected_output",
|
|
81
|
+
[
|
|
82
|
+
(
|
|
83
|
+
"Annual cropland gain from forest",
|
|
84
|
+
{
|
|
85
|
+
"forest_change": -1000,
|
|
86
|
+
"total_cropland_change": 1000,
|
|
87
|
+
"pasture_change": 0,
|
|
88
|
+
"total_agricultural_change": 1000
|
|
89
|
+
},
|
|
90
|
+
-1000
|
|
91
|
+
),
|
|
92
|
+
(
|
|
93
|
+
"Pasture gain from forest",
|
|
94
|
+
{
|
|
95
|
+
"forest_change": -1000,
|
|
96
|
+
"total_cropland_change": 0,
|
|
97
|
+
"pasture_change": 1000,
|
|
98
|
+
"total_agricultural_change": 1000
|
|
99
|
+
},
|
|
100
|
+
-1000
|
|
101
|
+
),
|
|
102
|
+
(
|
|
103
|
+
"Brazil",
|
|
104
|
+
{
|
|
105
|
+
"forest_change": -77317,
|
|
106
|
+
"total_cropland_change": 5201,
|
|
107
|
+
"pasture_change": -8267,
|
|
108
|
+
"total_agricultural_change": -3066
|
|
109
|
+
},
|
|
110
|
+
-5201
|
|
111
|
+
),
|
|
112
|
+
(
|
|
113
|
+
"Argentina",
|
|
114
|
+
{
|
|
115
|
+
"forest_change": -4990,
|
|
116
|
+
"total_cropland_change": 11408,
|
|
117
|
+
"pasture_change": -12705,
|
|
118
|
+
"total_agricultural_change": -1297
|
|
119
|
+
},
|
|
120
|
+
-4990
|
|
121
|
+
),
|
|
122
|
+
(
|
|
123
|
+
"Madagascar",
|
|
124
|
+
{
|
|
125
|
+
"forest_change": -1131,
|
|
126
|
+
"total_cropland_change": 275,
|
|
127
|
+
"pasture_change": 4295,
|
|
128
|
+
"total_agricultural_change": 4570
|
|
129
|
+
},
|
|
130
|
+
-1131
|
|
131
|
+
),
|
|
132
|
+
(
|
|
133
|
+
"Afforestation",
|
|
134
|
+
{
|
|
135
|
+
"forest_change": 100,
|
|
136
|
+
"total_cropland_change": -1000,
|
|
137
|
+
"pasture_change": -50,
|
|
138
|
+
"total_agricultural_change": -1000
|
|
139
|
+
},
|
|
140
|
+
0
|
|
141
|
+
),
|
|
142
|
+
(
|
|
143
|
+
"Pasture gain more than forest loss",
|
|
144
|
+
{
|
|
145
|
+
"forest_change": -49,
|
|
146
|
+
"total_cropland_change": -1000,
|
|
147
|
+
"pasture_change": 50,
|
|
148
|
+
"total_agricultural_change": -950
|
|
149
|
+
},
|
|
150
|
+
-49
|
|
151
|
+
)
|
|
152
|
+
]
|
|
153
|
+
)
|
|
154
|
+
def test_estimate_maximum_forest_change(description, inputs, expected_output):
|
|
155
|
+
assert _estimate_maximum_forest_change(**inputs) == expected_output, description
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
@pytest.mark.parametrize(
|
|
159
|
+
"description,inputs,expected_result",
|
|
160
|
+
[
|
|
161
|
+
("All zeros, OK", {"a": 0, "b": 0, "c": 0.0, "d": 0.0}, True),
|
|
162
|
+
("Exactly 1, OK", {"a": 0.1, "b": 0.5, "c": 0.4, "d": 0.0}, True),
|
|
163
|
+
("Almost 1, OK", {"a": 0.1, "b": 0.5, "c": 0.4, "d": 0.01}, True),
|
|
164
|
+
("Less than 1, Fail", {"a": 0.1, "b": 0, "c": 0.0, "d": 0.65}, False),
|
|
165
|
+
("More than 1, Fail", {"a": 0.15, "b": 0.7, "c": 0.0, "d": 0.65}, False),
|
|
166
|
+
]
|
|
167
|
+
)
|
|
168
|
+
def test_check_sum_of_percentages(description, inputs, expected_result):
|
|
169
|
+
assert site_area_sum_to_100(dict_of_percentages=inputs) == expected_result
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def test_get_sums_of_crop_expansion():
|
|
173
|
+
result = _get_sums_of_crop_expansion(
|
|
174
|
+
country_id="GADM-AFG",
|
|
175
|
+
year=2010,
|
|
176
|
+
include_negatives=True
|
|
177
|
+
)
|
|
178
|
+
assert result == (753973.3, 18354.0)
|
|
179
|
+
|
|
180
|
+
result = _get_sums_of_crop_expansion(
|
|
181
|
+
country_id="GADM-AFG",
|
|
182
|
+
year=2010,
|
|
183
|
+
include_negatives=False
|
|
184
|
+
)
|
|
185
|
+
assert result == (940270.0, 28139.0)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
@pytest.mark.parametrize(
|
|
189
|
+
"subfolder",
|
|
190
|
+
[
|
|
191
|
+
"albania_example",
|
|
192
|
+
"argentina_example",
|
|
193
|
+
"armenia_example",
|
|
194
|
+
"brazil_example",
|
|
195
|
+
"zimbabwe_example",
|
|
196
|
+
"brazil_empty_example",
|
|
197
|
+
"gbr_example"
|
|
198
|
+
]
|
|
199
|
+
)
|
|
200
|
+
@patch(f"{CLASS_PATH}._new_management", side_effect=fake_new_management)
|
|
201
|
+
def test_run(mock, subfolder):
|
|
202
|
+
folder = f"{fixtures_folder}/{subfolder}"
|
|
203
|
+
with open(f"{folder}/site.jsonld", encoding='utf-8') as f:
|
|
204
|
+
site = json.load(f)
|
|
205
|
+
|
|
206
|
+
with open(f"{folder}/result.jsonld", encoding='utf-8') as f:
|
|
207
|
+
expected = json.load(f)
|
|
208
|
+
|
|
209
|
+
result = run(site)
|
|
210
|
+
assert result == expected
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
import json
|
|
3
|
+
from tests.utils import fixtures_path, fake_new_practice
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.ipcc2019 import MODEL
|
|
6
|
+
from hestia_earth.models.ipcc2019.animal.milkYieldPerAnimal import MODEL_KEY, run
|
|
7
|
+
|
|
8
|
+
class_path = f"hestia_earth.models.{MODEL}.animal.{MODEL_KEY}"
|
|
9
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/animal/{MODEL_KEY}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@patch(f"{class_path}._new_practice", side_effect=fake_new_practice)
|
|
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
|
|
@@ -45,7 +45,8 @@ PARAMS_SHOULD_RUN = [
|
|
|
45
45
|
("historical-land-cover-mix", True),
|
|
46
46
|
("historical-argentina-pasture", True),
|
|
47
47
|
("historical-brazil-maize", True),
|
|
48
|
-
("perennial-to-grassland-with-pasture-condition", True)
|
|
48
|
+
("perennial-to-grassland-with-pasture-condition", True),
|
|
49
|
+
("with-gapfilled-start-date-end-date", False) # Closes #972
|
|
49
50
|
]
|
|
50
51
|
IDS_SHOULD_RUN = [p[0] for p in PARAMS_SHOULD_RUN]
|
|
51
52
|
|
|
@@ -45,7 +45,8 @@ PARAMS_SHOULD_RUN = [
|
|
|
45
45
|
("historical-land-cover-mix", True),
|
|
46
46
|
("historical-argentina-pasture", True),
|
|
47
47
|
("historical-brazil-maize", True),
|
|
48
|
-
("perennial-to-grassland-with-pasture-condition", True)
|
|
48
|
+
("perennial-to-grassland-with-pasture-condition", True),
|
|
49
|
+
("with-gapfilled-start-date-end-date", False) # Closes #972
|
|
49
50
|
]
|
|
50
51
|
IDS_SHOULD_RUN = [p[0] for p in PARAMS_SHOULD_RUN]
|
|
51
52
|
|
|
@@ -19,9 +19,10 @@ RUN_SCENARIOS = [
|
|
|
19
19
|
("missing-measurement-dates", 3),
|
|
20
20
|
("no-biomass-measurements", 1), # Closes issue #700
|
|
21
21
|
("non-consecutive-biomass-measurements", 1), # Closes issue #827
|
|
22
|
-
("multiple-method-classifications", 5),
|
|
23
|
-
("non-soil-based-gohac-system", 3),
|
|
24
|
-
("soil-based-gohac-system", 3)
|
|
22
|
+
("multiple-method-classifications", 5), # Closes issue #764
|
|
23
|
+
("non-soil-based-gohac-system", 3), # Closes issue #848
|
|
24
|
+
("soil-based-gohac-system", 3), # Closes issue #848
|
|
25
|
+
("with-gapfilled-start-date-end-date", 1) # Closes issue #972
|
|
25
26
|
]
|
|
26
27
|
"""List of (subfolder: str, num_cycles: int)."""
|
|
27
28
|
|
|
@@ -19,9 +19,9 @@ RUN_SCENARIOS = [
|
|
|
19
19
|
("missing-measurement-dates", 3),
|
|
20
20
|
("no-biomass-measurements", 1), # Closes issue #700
|
|
21
21
|
("non-consecutive-biomass-measurements", 1), # Closes issue #827
|
|
22
|
-
("multiple-method-classifications", 5),
|
|
23
|
-
("non-soil-based-gohac-system", 3),
|
|
24
|
-
("
|
|
22
|
+
("multiple-method-classifications", 5), # Closes issue #764
|
|
23
|
+
("non-soil-based-gohac-system", 3), # Closes issue #848
|
|
24
|
+
("with-gapfilled-start-date-end-date", 1) # Closes issue #972
|
|
25
25
|
]
|
|
26
26
|
"""List of (subfolder: str, num_cycles: int)."""
|
|
27
27
|
|
|
@@ -10,8 +10,34 @@ from tests.utils import fake_new_emission, fixtures_path, order_list
|
|
|
10
10
|
|
|
11
11
|
class_path = f"hestia_earth.models.{MODEL}.co2ToAirSoilOrganicCarbonStockChange"
|
|
12
12
|
utils_path = f"hestia_earth.models.{MODEL}.co2ToAirCarbonStockChange_utils"
|
|
13
|
+
soc_utils_path = f"hestia_earth.models.{MODEL}.organicCarbonPerHa_utils"
|
|
14
|
+
term_folder = "hestia_earth.models.utils.term"
|
|
13
15
|
fixtures_folder = f"{fixtures_path}/{MODEL}/co2ToAirSoilOrganicCarbonStockChange"
|
|
14
16
|
|
|
17
|
+
|
|
18
|
+
IRRIGATED_TERM_IDS = [
|
|
19
|
+
"rainfedDeepWater",
|
|
20
|
+
"rainfedDeepWaterWaterDepth100Cm",
|
|
21
|
+
"rainfedDeepWaterWaterDepth50100Cm",
|
|
22
|
+
"irrigatedTypeUnspecified",
|
|
23
|
+
"irrigatedCenterPivotIrrigation",
|
|
24
|
+
"irrigatedContinuouslyFlooded",
|
|
25
|
+
"irrigatedDripIrrigation",
|
|
26
|
+
"irrigatedFurrowIrrigation",
|
|
27
|
+
"irrigatedLateralMoveIrrigation",
|
|
28
|
+
"irrigatedLocalizedIrrigation",
|
|
29
|
+
"irrigatedManualIrrigation",
|
|
30
|
+
"irrigatedSurfaceIrrigationMultipleDrainagePeriods",
|
|
31
|
+
"irrigatedSurfaceIrrigationSingleDrainagePeriod",
|
|
32
|
+
"irrigatedSprinklerIrrigation",
|
|
33
|
+
"irrigatedSubIrrigation",
|
|
34
|
+
"irrigatedSurfaceIrrigationDrainageRegimeUnspecified"
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
UPLAND_RICE_LAND_COVER_TERM_IDS = [
|
|
38
|
+
"ricePlantUpland"
|
|
39
|
+
]
|
|
40
|
+
|
|
15
41
|
RUN_SCENARIOS = [
|
|
16
42
|
("no-overlapping-cycles", 3),
|
|
17
43
|
("overlapping-cycles", 4),
|
|
@@ -21,7 +47,7 @@ RUN_SCENARIOS = [
|
|
|
21
47
|
("non-consecutive-organic-carbon-measurements", 1), # Closes issue #827
|
|
22
48
|
("multiple-method-classifications", 5), # Closes issue #764
|
|
23
49
|
("non-soil-based-gohac-system", 3), # Closes issue #848
|
|
24
|
-
("
|
|
50
|
+
("with-gapfilled-start-date-end-date", 1) # Closes issue #972
|
|
25
51
|
]
|
|
26
52
|
"""List of (subfolder: str, num_cycles: int)."""
|
|
27
53
|
|
|
@@ -47,7 +73,20 @@ RUN_IDS = [f"{param[0]}, cycle{param[2]}" for param in RUN_PARAMS]
|
|
|
47
73
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
|
48
74
|
@patch(f"{utils_path}.related_cycles")
|
|
49
75
|
@patch(f"{utils_path}._get_site")
|
|
50
|
-
|
|
76
|
+
@patch(f"{soc_utils_path}.get_upland_rice_land_cover_terms", return_value=UPLAND_RICE_LAND_COVER_TERM_IDS)
|
|
77
|
+
@patch(f"{soc_utils_path}.get_irrigated_terms", return_value=IRRIGATED_TERM_IDS)
|
|
78
|
+
@patch(f"{term_folder}.search")
|
|
79
|
+
def test_run(
|
|
80
|
+
search_mock,
|
|
81
|
+
get_irrigated_terms_mock,
|
|
82
|
+
get_upland_rice_land_cover_terms_mock,
|
|
83
|
+
_get_site_mock,
|
|
84
|
+
related_cycles_mock,
|
|
85
|
+
_new_emission_mock,
|
|
86
|
+
subfolder,
|
|
87
|
+
num_cycles,
|
|
88
|
+
cycle_index
|
|
89
|
+
):
|
|
51
90
|
"""
|
|
52
91
|
Test `run` function for each cycle in each scenario.
|
|
53
92
|
"""
|
|
@@ -63,6 +102,14 @@ def test_run(_get_site_mock, related_cycles_mock, _new_emission_mock, subfolder,
|
|
|
63
102
|
related_cycles_mock.return_value = cycles
|
|
64
103
|
|
|
65
104
|
result = run(cycle)
|
|
105
|
+
|
|
106
|
+
# Ensure that API calls to retrieve term IDs are properly cached.
|
|
107
|
+
get_irrigated_terms_mock.call_count <= 1
|
|
108
|
+
get_upland_rice_land_cover_terms_mock.call_count <= 1
|
|
109
|
+
|
|
110
|
+
# Ensure that the property and term utils are properly mocked.
|
|
111
|
+
search_mock.assert_not_called()
|
|
112
|
+
|
|
66
113
|
assert order_list(result) == order_list(expected)
|
|
67
114
|
|
|
68
115
|
|
|
@@ -36,3 +36,15 @@ def test_run(*args):
|
|
|
36
36
|
|
|
37
37
|
value = run(cycle)
|
|
38
38
|
assert value == expected
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
|
42
|
+
def test_run_complete_no_inputs(*args):
|
|
43
|
+
with open(f"{fixtures_folder}/complete-no-inputs/cycle.jsonld", encoding='utf-8') as f:
|
|
44
|
+
cycle = json.load(f)
|
|
45
|
+
|
|
46
|
+
with open(f"{fixtures_folder}/complete-no-inputs/result.jsonld", encoding='utf-8') as f:
|
|
47
|
+
expected = json.load(f)
|
|
48
|
+
|
|
49
|
+
value = run(cycle)
|
|
50
|
+
assert value == expected
|
|
@@ -108,6 +108,7 @@ PARAMS_SHOULD_RUN = [
|
|
|
108
108
|
("tier-1/run-with-site-type", True), # Closes issue 755
|
|
109
109
|
("tier-1/cropland-polar", False), # Closes issue 794
|
|
110
110
|
("tier-1/cropland-with-system-increasing-c-input", True), # Closes issue 851
|
|
111
|
+
("tier-1/with-gapfilled-start-date-end-date", False), # Closes issue 972
|
|
111
112
|
("tier-2/with-generalised-monthly-measurements", False), # Closes issue 600
|
|
112
113
|
("tier-2/with-incomplete-climate-data", False), # Closes issue 599
|
|
113
114
|
("tier-2/with-initial-soc", True),
|
|
@@ -47,3 +47,16 @@ def test_run_no_total(*args):
|
|
|
47
47
|
|
|
48
48
|
value = run(cycle)
|
|
49
49
|
assert value == expected
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@patch(f"{class_path}._is_term_type_incomplete", return_value=True)
|
|
53
|
+
@patch(f"{class_path}._new_product", side_effect=fake_new_product)
|
|
54
|
+
def test_run_with_leftOnField(*args):
|
|
55
|
+
with open(f"{fixtures_folder}/with-left-on-field-value/cycle.jsonld", encoding='utf-8') as f:
|
|
56
|
+
cycle = json.load(f)
|
|
57
|
+
|
|
58
|
+
with open(f"{fixtures_folder}/with-left-on-field-value/result.jsonld", encoding='utf-8') as f:
|
|
59
|
+
expected = json.load(f)
|
|
60
|
+
|
|
61
|
+
value = run(cycle)
|
|
62
|
+
assert value == expected
|
|
@@ -6,10 +6,11 @@ from hestia_earth.models.pooreNemecek2018.no3ToGroundwaterCropResidueDecompositi
|
|
|
6
6
|
|
|
7
7
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
8
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
|
+
utils_class_path = f"hestia_earth.models.{MODEL}.no3ToGroundwaterSoilFlux_utils"
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
@patch(f"
|
|
12
|
-
@patch(f"
|
|
12
|
+
@patch(f"{utils_class_path}.get_rice_paddy_terms", return_value=FLOODED_RICE_TERMS)
|
|
13
|
+
@patch(f"{utils_class_path}.get_max_rooting_depth", return_value=0.9)
|
|
13
14
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
|
14
15
|
def test_run(*args):
|
|
15
16
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
@@ -6,10 +6,11 @@ from hestia_earth.models.pooreNemecek2018.no3ToGroundwaterExcreta import MODEL,
|
|
|
6
6
|
|
|
7
7
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
8
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
|
+
utils_class_path = f"hestia_earth.models.{MODEL}.no3ToGroundwaterSoilFlux_utils"
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
@patch(f"
|
|
12
|
-
@patch(f"
|
|
12
|
+
@patch(f"{utils_class_path}.get_rice_paddy_terms", return_value=FLOODED_RICE_TERMS)
|
|
13
|
+
@patch(f"{utils_class_path}.get_max_rooting_depth", return_value=0.9)
|
|
13
14
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
|
14
15
|
def test_run(*args):
|
|
15
16
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
@@ -6,10 +6,11 @@ from hestia_earth.models.pooreNemecek2018.no3ToGroundwaterInorganicFertiliser im
|
|
|
6
6
|
|
|
7
7
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
8
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
|
+
utils_class_path = f"hestia_earth.models.{MODEL}.no3ToGroundwaterSoilFlux_utils"
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
@patch(f"
|
|
12
|
-
@patch(f"
|
|
12
|
+
@patch(f"{utils_class_path}.get_rice_paddy_terms", return_value=FLOODED_RICE_TERMS)
|
|
13
|
+
@patch(f"{utils_class_path}.get_max_rooting_depth", return_value=0.9)
|
|
13
14
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
|
14
15
|
def test_run(*args):
|
|
15
16
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
@@ -6,10 +6,11 @@ from hestia_earth.models.pooreNemecek2018.no3ToGroundwaterOrganicFertiliser impo
|
|
|
6
6
|
|
|
7
7
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
8
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
|
+
utils_class_path = f"hestia_earth.models.{MODEL}.no3ToGroundwaterSoilFlux_utils"
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
@patch(f"
|
|
12
|
-
@patch(f"
|
|
12
|
+
@patch(f"{utils_class_path}.get_rice_paddy_terms", return_value=FLOODED_RICE_TERMS)
|
|
13
|
+
@patch(f"{utils_class_path}.get_max_rooting_depth", return_value=0.9)
|
|
13
14
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
|
14
15
|
def test_run(*args):
|
|
15
16
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
tests/models/pooreNemecek2018/{test_saplings.py → test_saplingsDepreciatedAmountPerCycle.py}
RENAMED
|
@@ -2,7 +2,7 @@ from unittest.mock import patch
|
|
|
2
2
|
import json
|
|
3
3
|
from tests.utils import fixtures_path, fake_new_input
|
|
4
4
|
|
|
5
|
-
from hestia_earth.models.pooreNemecek2018.
|
|
5
|
+
from hestia_earth.models.pooreNemecek2018.saplingsDepreciatedAmountPerCycle import MODEL, TERM_ID, run, _should_run
|
|
6
6
|
|
|
7
7
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
8
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|