hestia-earth-models 0.68.1__py3-none-any.whl → 0.69.1__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 +1202 -1146
- 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/pooreNemecek2018/utils.py +2 -2
- 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.1.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/RECORD +179 -187
- 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.1.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Product Properties
|
3
|
-
|
4
|
-
This model handles the following case:
|
5
|
-
- when the `dryMatter` property is set, the model recalculates the other properties based on the data from feedipedia;
|
6
|
-
- when the `min` and `max` are set, the model averages the `value`.
|
7
|
-
"""
|
8
1
|
from hestia_earth.utils.model import find_term_match
|
9
2
|
|
10
3
|
from hestia_earth.models.utils.feedipedia import rescale_properties_from_dryMatter
|
@@ -1,12 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Product Revenue
|
3
|
-
|
4
|
-
This model calculates the revenue of each product by multiplying the yield with the revenue.
|
5
|
-
|
6
|
-
In the case the product `value` is `0`, the `revenue` will be set to `0`.
|
7
|
-
|
8
|
-
In the case the product `price` is `0`, the `revenue` will be set to `0`.
|
9
|
-
"""
|
10
1
|
from hestia_earth.utils.tools import list_sum, non_empty_list
|
11
2
|
|
12
3
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
@@ -1,9 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Product Value
|
3
|
-
|
4
|
-
This model calculates the `value` of the [Product](https://hestia.earth/schema/Product)
|
5
|
-
by taking an average from the `min` and `max` values.
|
6
|
-
"""
|
7
1
|
from hestia_earth.utils.tools import non_empty_list, list_average
|
8
2
|
|
9
3
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
@@ -1,9 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Site Area
|
3
|
-
|
4
|
-
For animal production cycles, use the `stockingDensityAnimalHousingAverage` to calculate the average area required
|
5
|
-
for all animals.
|
6
|
-
"""
|
7
1
|
from hestia_earth.schema import TermTermType, SiteSiteType
|
8
2
|
from hestia_earth.utils.model import filter_list_term_type, find_term_match
|
9
3
|
from hestia_earth.utils.tools import list_sum
|
@@ -1,13 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Site duration
|
3
|
-
|
4
|
-
This model calculates the `siteDuration` on the `Cycle` to the same value as `cycleDuration`
|
5
|
-
when only a single `Site` is present.
|
6
|
-
|
7
|
-
Note: on `crop` production cycles:
|
8
|
-
* For temporary crops, gap fill only when `startDateDefinition` = `harvest of previous crop`.
|
9
|
-
* For permanent crops, no restriction applies.
|
10
|
-
"""
|
11
1
|
from hestia_earth.schema import TermTermType, CycleStartDateDefinition
|
12
2
|
from hestia_earth.utils.model import find_primary_product
|
13
3
|
|
@@ -1,9 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Site Unused Duration
|
3
|
-
|
4
|
-
This model sets the [Cycle siteUnusedDuration](https://hestia.earth/schema/Cycle#siteUnusedDuration) based on
|
5
|
-
the `siteDuration` and the `longFallowRatio` practice.
|
6
|
-
"""
|
7
1
|
from hestia_earth.schema import SiteSiteType
|
8
2
|
from hestia_earth.utils.tools import list_sum
|
9
3
|
|
@@ -1,11 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Start Date
|
3
|
-
|
4
|
-
This model sets the [Cycle startDate](https://hestia.earth/schema/Cycle#startDate) based on:
|
5
|
-
* the `cycleDuration` and the `endDate` if it has been provided to a day precision (e.g., `2000-01-01`);
|
6
|
-
* if no `cycleDuration` is provided, and the `startDate` is set to month precision (e.g., `2000-01`),
|
7
|
-
assumed it started on the 15th of the month.
|
8
|
-
"""
|
9
1
|
from datetime import timedelta
|
10
2
|
from hestia_earth.utils.date import is_in_days, is_in_months
|
11
3
|
from hestia_earth.utils.tools import safe_parse_date
|
@@ -1,9 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Start Date Definition
|
3
|
-
|
4
|
-
This model sets the [Cycle startDateDefinition](https://hestia.earth/schema/Cycle#startDateDefinition)
|
5
|
-
based on the result of the `cycleDuration` gap-filling model.
|
6
|
-
"""
|
7
1
|
from hestia_earth.schema import TermTermType, CycleStartDateDefinition
|
8
2
|
from hestia_earth.utils.model import find_primary_product
|
9
3
|
|
@@ -35,7 +35,7 @@ def _emission(value: float):
|
|
35
35
|
|
36
36
|
|
37
37
|
def _run(excretaKgN: float, NO_N_EF: float):
|
38
|
-
value = NO_N_EF * excretaKgN * get_atomic_conversion(Units.KG_NOX, Units.TO_N)
|
38
|
+
value = (NO_N_EF or 0) * (excretaKgN or 0) * get_atomic_conversion(Units.KG_NOX, Units.TO_N)
|
39
39
|
return [_emission(value)]
|
40
40
|
|
41
41
|
|
@@ -47,7 +47,7 @@ def _should_run(cycle: dict):
|
|
47
47
|
excretaKgN=excretaKgN,
|
48
48
|
NO_N_EF=NO_N_EF)
|
49
49
|
|
50
|
-
should_run = all([excretaKgN, NO_N_EF])
|
50
|
+
should_run = all([excretaKgN is not None, NO_N_EF is not None])
|
51
51
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
52
52
|
return should_run, excretaKgN, NO_N_EF
|
53
53
|
|
@@ -1,18 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
ecoinvent v3
|
3
|
-
|
4
|
-
This model calculates background emissions related to the production of Inputs from the ecoinvent database, version 3.
|
5
|
-
|
6
|
-
Note: to use the `ecoinventV3` model locally or in the
|
7
|
-
[HESTIA Community Edition](https://gitlab.com/hestia-earth/hestia-community-edition) you need a valid ecoinvent license.
|
8
|
-
Please contact us at community@hestia.earth for instructions to download the required file to run the model.
|
9
|
-
|
10
|
-
**Pesticide Brand Name**
|
11
|
-
|
12
|
-
For `Input` with a [Pesticide Brand Name](https://hestia.earth/glossary?pesticideBrandBane) term, you can override the
|
13
|
-
default list of [Pesticide Active Ingredient](https://hestia.earth/glossary?pesticideAI) by specifying the list of
|
14
|
-
[properties](https://hestia.earth/schema/Input#properties) manually.
|
15
|
-
"""
|
16
1
|
from functools import reduce
|
17
2
|
from hestia_earth.schema import EmissionMethodTier
|
18
3
|
from hestia_earth.utils.tools import flatten, list_sum
|
@@ -1,14 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
ecoinvent v3 and Ember Climate
|
3
|
-
|
4
|
-
This model calculates background emissions related to the production of Inputs from the ecoinvent database, version 3,
|
5
|
-
and using the percentage of production for each energy source from
|
6
|
-
[Ember](https://ember-climate.org/data-catalogue/yearly-electricity-data/).
|
7
|
-
|
8
|
-
Note: to use the `ecoinventV3AndEmberClimate` model locally or in the
|
9
|
-
[Hestia Community Edition](https://gitlab.com/hestia-earth/hestia-community-edition) you need a valid ecoinvent license.
|
10
|
-
Please contact us at community@hestia.earth for instructions to download the required file to run the model.
|
11
|
-
"""
|
12
1
|
from functools import reduce
|
13
2
|
from hestia_earth.utils.tools import list_sum, flatten
|
14
3
|
from hestia_earth.schema import EmissionMethodTier
|
@@ -1,18 +1,16 @@
|
|
1
1
|
from hestia_earth.schema import EmissionMethodTier, TermTermType
|
2
|
-
from hestia_earth.utils.lookup import column_name, download_lookup, get_table_value
|
3
|
-
from hestia_earth.utils.model import filter_list_term_type
|
4
|
-
from hestia_earth.utils.tools import safe_parse_float, list_sum
|
5
2
|
|
6
|
-
from hestia_earth.models.log import logRequirements,
|
7
|
-
from hestia_earth.models.utils import _filter_list_term_unit
|
3
|
+
from hestia_earth.models.log import logRequirements, logShouldRun
|
8
4
|
from hestia_earth.models.utils.constant import Units, get_atomic_conversion
|
9
5
|
from hestia_earth.models.utils.completeness import _is_term_type_complete
|
10
6
|
from hestia_earth.models.utils.input import total_excreta_tan
|
7
|
+
from hestia_earth.models.utils.excretaManagement import get_excreta_inputs_with_factor
|
11
8
|
from . import MODEL
|
12
9
|
from .utils import _emission
|
13
10
|
|
14
11
|
REQUIREMENTS = {
|
15
12
|
"Cycle": {
|
13
|
+
"completeness.excreta": "True",
|
16
14
|
"inputs": [{
|
17
15
|
"@type": "Input",
|
18
16
|
"value": "",
|
@@ -28,7 +26,7 @@ REQUIREMENTS = {
|
|
28
26
|
}
|
29
27
|
}
|
30
28
|
LOOKUPS = {
|
31
|
-
"excretaManagement-excreta-NH3_EF_2019": "
|
29
|
+
"excretaManagement-excreta-NH3_EF_2019": ""
|
32
30
|
}
|
33
31
|
RETURNS = {
|
34
32
|
"Emission": [{
|
@@ -40,50 +38,26 @@ TERM_ID = 'nh3ToAirExcreta'
|
|
40
38
|
TIER = EmissionMethodTier.TIER_2.value
|
41
39
|
|
42
40
|
|
43
|
-
def
|
44
|
-
|
45
|
-
lookup_name = f"{list(LOOKUPS.keys())[0]}.csv"
|
46
|
-
value = get_table_value(download_lookup(lookup_name), 'termid', term_id, column_name(input_term_id))
|
47
|
-
debugMissingLookup(lookup_name, 'termid', term_id, input_term_id, value, model=MODEL, term=TERM_ID)
|
48
|
-
return safe_parse_float(value, None)
|
49
|
-
|
50
|
-
|
51
|
-
def _run(excreta_EF_product: float):
|
52
|
-
value = excreta_EF_product * get_atomic_conversion(Units.KG_NH3, Units.TO_N)
|
41
|
+
def _run(excreta_EF_input: float):
|
42
|
+
value = excreta_EF_input * get_atomic_conversion(Units.KG_NH3, Units.TO_N)
|
53
43
|
return [_emission(value=value, tier=TIER, term_id=TERM_ID)]
|
54
44
|
|
55
45
|
|
56
46
|
def _should_run(cycle: dict):
|
57
47
|
excreta_complete = _is_term_type_complete(cycle, TermTermType.EXCRETA)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
# total of excreta including the NH3 factor
|
63
|
-
excreta = filter_list_term_type(cycle.get('inputs', []), TermTermType.EXCRETA)
|
64
|
-
excreta = _filter_list_term_unit(excreta, Units.KG_N)
|
65
|
-
excreta_values = [
|
66
|
-
(i.get('term', {}).get('@id'), total_excreta_tan([i]), _get_nh3_factor(practice_id, i)) for i in excreta
|
67
|
-
]
|
68
|
-
excreta_logs = log_as_table([
|
69
|
-
{'id': id, 'value': v, 'EF': ef} for id, v, ef in excreta_values
|
70
|
-
])
|
71
|
-
excreta_EF_products = [v * f for id, v, f in excreta_values if v is not None and f is not None]
|
72
|
-
has_excreta_EF_products = len(excreta_EF_products) > 0
|
73
|
-
excreta_EF_product = list_sum(excreta_EF_products, 0)
|
48
|
+
excreta_EF_input = get_excreta_inputs_with_factor(
|
49
|
+
cycle, f"{list(LOOKUPS.keys())[0]}.csv", excreta_convertion_func=total_excreta_tan, model=MODEL, term=TERM_ID
|
50
|
+
)
|
74
51
|
|
75
52
|
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
76
53
|
term_type_excreta_complete=excreta_complete,
|
77
|
-
|
78
|
-
excreta=excreta_logs,
|
79
|
-
excreta_EF_product=excreta_EF_product,
|
80
|
-
has_excreta_EF_products=has_excreta_EF_products)
|
54
|
+
excreta_EF_input=excreta_EF_input)
|
81
55
|
|
82
|
-
should_run = excreta_complete
|
56
|
+
should_run = all([excreta_complete, excreta_EF_input >= 0])
|
83
57
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
84
|
-
return should_run,
|
58
|
+
return should_run, excreta_EF_input
|
85
59
|
|
86
60
|
|
87
61
|
def run(cycle: dict):
|
88
|
-
should_run,
|
89
|
-
return _run(
|
62
|
+
should_run, excreta_EF_input = _should_run(cycle)
|
63
|
+
return _run(excreta_EF_input) if should_run else []
|
@@ -1,7 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
When `otherSites` are provided, `otherSitesDuration` must be set as well so we know the length of time the animals
|
3
|
-
spend on each Site.
|
4
|
-
"""
|
5
1
|
from hestia_earth.schema import EmissionMethodTier
|
6
2
|
|
7
3
|
from .utils import _emission, get_live_animal_emission_value, should_run_animal
|
@@ -1,7 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
When `otherSites` are provided, `otherSitesDuration` must be set as well so we know the length of time the animals
|
3
|
-
spend on each Site.
|
4
|
-
"""
|
5
1
|
from hestia_earth.schema import EmissionMethodTier
|
6
2
|
|
7
3
|
from .utils import _emission, get_live_animal_emission_value, should_run_animal
|
@@ -1,7 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
When `otherSites` are provided, `otherSitesDuration` must be set as well so we know the length of time the animals
|
3
|
-
spend on each Site.
|
4
|
-
"""
|
5
1
|
from hestia_earth.schema import EmissionMethodTier
|
6
2
|
|
7
3
|
from .utils import _emission, get_live_animal_emission_value, should_run_animal
|
@@ -1,12 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
The inputs and outputs from the life cycle inventory are aggregated in 16 midpoint
|
3
|
-
characterised impact categories. These impact categories are then normalised (i.e., the results are divided by
|
4
|
-
the overall inventory of a reference unit, e.g., the entire world, to convert the characterised impact categories in
|
5
|
-
relative shares of the impacts of the analysed system) and weighted (i.e., each impact category is multiplied by
|
6
|
-
a weighting factor to reflect their perceived relative importance). The weighted impact categories can then be
|
7
|
-
summed to obtain the EF single overall score. The number and the name of the impact categories is the same
|
8
|
-
in EF3.0 and EF3.1.
|
9
|
-
"""
|
10
1
|
from typing import List, Optional, Tuple
|
11
2
|
|
12
3
|
from hestia_earth.schema import TermTermType
|
@@ -1,9 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Characterises [soilQualityIndexLandOccupation](https://hestia.earth/term/soilQualityIndexLandOccupation)
|
3
|
-
based on an updated [LANCA model (De Laurentiis et al. 2019)](
|
4
|
-
http://publications.jrc.ec.europa.eu/repository/handle/JRC113865) and on the LANCA (Regionalised) Characterisation
|
5
|
-
Factors version 2.5 (Horn and Meier, 2018).
|
6
|
-
"""
|
7
1
|
from typing import Tuple
|
8
2
|
|
9
3
|
from hestia_earth.schema import TermTermType
|
@@ -1,9 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Characterises [soilQualityIndexLandTransformation](https://hestia.earth/term/soilQualityIndexLandTransformation)
|
3
|
-
based on an updated [LANCA model (De Laurentiis et al. 2019)](
|
4
|
-
http://publications.jrc.ec.europa.eu/repository/handle/JRC113865) and on the LANCA (Regionalised) Characterisation
|
5
|
-
Factors version 2.5 (Horn and Meier, 2018).
|
6
|
-
"""
|
7
1
|
from typing import List, Tuple
|
8
2
|
|
9
3
|
from hestia_earth.schema import TermTermType
|
@@ -1,9 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Characterises [soilQualityIndexTotalLandUseEffects](https://hestia.earth/term/soilQualityIndexTotalLandUseEffects)
|
3
|
-
based on an updated [LANCA model (De Laurentiis et al. 2019)](
|
4
|
-
http://publications.jrc.ec.europa.eu/repository/handle/JRC113865) and on the LANCA (Regionalised) Characterisation
|
5
|
-
Factors version 2.5 (Horn and Meier, 2018).
|
6
|
-
"""
|
7
1
|
from hestia_earth.schema import TermTermType
|
8
2
|
from hestia_earth.utils.model import find_term_match, filter_list_term_type
|
9
3
|
from hestia_earth.utils.tools import list_sum
|
@@ -17,14 +17,14 @@ REQUIREMENTS = {
|
|
17
17
|
RETURNS = {
|
18
18
|
"Emission": [{
|
19
19
|
"value": "",
|
20
|
-
"methodTier": "tier
|
20
|
+
"methodTier": "tier 1"
|
21
21
|
}]
|
22
22
|
}
|
23
23
|
LOOKUPS = {
|
24
24
|
"excretaManagement": "EF_NO3-N"
|
25
25
|
}
|
26
26
|
TERM_ID = 'no3ToGroundwaterExcreta'
|
27
|
-
TIER = EmissionMethodTier.
|
27
|
+
TIER = EmissionMethodTier.TIER_1.value
|
28
28
|
|
29
29
|
|
30
30
|
def _emission(value: float):
|
@@ -1,8 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Product Price
|
3
|
-
|
4
|
-
Calculates the price of `crop` and `liveAnimal` using FAOSTAT data.
|
5
|
-
"""
|
6
1
|
from hestia_earth.schema import TermTermType
|
7
2
|
from hestia_earth.utils.lookup import extract_grouped_data
|
8
3
|
from hestia_earth.utils.tools import non_empty_list, safe_parse_float, safe_parse_date
|
@@ -1,8 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Aware Water Basin ID
|
3
|
-
|
4
|
-
This model calculates the the [AWARE](https://wulca-waterlca.org/) water basin identifier.
|
5
|
-
"""
|
6
1
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
7
2
|
from .utils import download, has_geospatial_data, should_download
|
8
3
|
from . import MODEL
|
@@ -1,22 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
They approximataely map to the [IPCC (2019) Climate Zones](https://www.ipcc-nggip.iges.or.jp/public/2019rf/pdf/4_Volume4/19R_V4_Ch03_Land%20Representation.pdf). # noqa: E501
|
3
|
-
Data are derived from [Hiederer et al. (2010) Biofuels: A new methodology to estimate GHG emissions from global land use change, European Commission Joint Research Centre](https://ec.europa.eu/jrc/en/publication/eur-scientific-and-technical-research-reports/biofuels-new-methodology-estimate-ghg-emissions-due-global-land-use-change-methodology). # noqa: E501
|
4
|
-
|
5
|
-
| Value | Climate Zone |
|
6
|
-
|-------|----------------------|
|
7
|
-
| 1 | Warm Temperate Moist |
|
8
|
-
| 2 | Warm Temperate Dry |
|
9
|
-
| 3 | Cool Temperate Moist |
|
10
|
-
| 4 | Cool Temperate Dry |
|
11
|
-
| 5 | Polar Moist |
|
12
|
-
| 6 | Polar Dry |
|
13
|
-
| 7 | Boreal Moist |
|
14
|
-
| 8 | Boreal Dry |
|
15
|
-
| 9 | Tropical Montane |
|
16
|
-
| 10 | Tropical Wet |
|
17
|
-
| 11 | Tropical Moist |
|
18
|
-
| 12 | Tropical Dry |
|
19
|
-
"""
|
20
1
|
from hestia_earth.schema import MeasurementMethodClassification
|
21
2
|
from hestia_earth.utils.lookup import download_lookup, _get_single_table_value, column_name
|
22
3
|
|
@@ -51,7 +32,7 @@ EE_PARAMS = {
|
|
51
32
|
'ee_type': 'raster',
|
52
33
|
'reducer': 'mode'
|
53
34
|
}
|
54
|
-
BIBLIO_TITLE = 'Biofuels:
|
35
|
+
BIBLIO_TITLE = 'Biofuels: a new methodology to estimate GHG emissions from global land use change'
|
55
36
|
|
56
37
|
|
57
38
|
def _measurement(site: dict, value: int):
|
@@ -1,10 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Ecoregion
|
3
|
-
|
4
|
-
Ecoregions represent the original distribution of distinct assemblages of species and communities.
|
5
|
-
There are 867 terrestrial ecoregions as
|
6
|
-
[defined by WWF](https://www.worldwildlife.org/publications/terrestrial-ecoregions-of-the-world).
|
7
|
-
"""
|
8
1
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
9
2
|
from .utils import download, has_geospatial_data, should_download
|
10
3
|
from . import MODEL
|
@@ -1,7 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Must be associated with at least 1 `Cycle` that has an
|
3
|
-
[endDate](https://hestia.earth/schema/Cycle#endDate) after `1958` and before `2021`.
|
4
|
-
"""
|
5
1
|
from hestia_earth.schema import MeasurementMethodClassification
|
6
2
|
from hestia_earth.utils.tools import non_empty_list
|
7
3
|
|
@@ -1,7 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Must be associated with at least 1 `Cycle` that has an
|
3
|
-
[endDate](https://hestia.earth/schema/Cycle#endDate) after `1979-01-01` and before `2020-06-01`.
|
4
|
-
"""
|
5
1
|
from hestia_earth.schema import MeasurementMethodClassification
|
6
2
|
from hestia_earth.utils.tools import flatten, non_empty_list
|
7
3
|
|
@@ -1,7 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Must be associated with at least 1 `Cycle` that has an
|
3
|
-
[endDate](https://hestia.earth/schema/Cycle#endDate) after `1979-01-01` and before `2020-06-01`.
|
4
|
-
"""
|
5
1
|
from hestia_earth.schema import MeasurementMethodClassification
|
6
2
|
from hestia_earth.utils.tools import non_empty_list
|
7
3
|
|
@@ -1,7 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Must be associated with at least 1 `Cycle` that has an
|
3
|
-
[endDate](https://hestia.earth/schema/Cycle#endDate) after `1979-01-01` and before `2020-06-01`.
|
4
|
-
"""
|
5
1
|
from hestia_earth.schema import MeasurementMethodClassification
|
6
2
|
from hestia_earth.utils.tools import flatten, non_empty_list
|
7
3
|
|
@@ -1,7 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Must be associated with at least 1 `Cycle` that has an
|
3
|
-
[endDate](https://hestia.earth/schema/Cycle#endDate) after `1979-01-01` and before `2020-06-01`.
|
4
|
-
"""
|
5
1
|
from hestia_earth.schema import MeasurementMethodClassification
|
6
2
|
from hestia_earth.utils.tools import non_empty_list
|
7
3
|
|
@@ -1,7 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Must be associated with at least 1 `Cycle` that has an
|
3
|
-
[endDate](https://hestia.earth/schema/Cycle#endDate) after `1979-01-01` and before `2020-06-01`.
|
4
|
-
"""
|
5
1
|
from hestia_earth.schema import MeasurementMethodClassification
|
6
2
|
from hestia_earth.utils.tools import flatten, non_empty_list
|
7
3
|
|
@@ -1,10 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Transport Value
|
3
|
-
|
4
|
-
This model calculates the `distance` of the [Transport](https://hestia.earth/schema/Transport) linked to the
|
5
|
-
[Inputs of the Cycle](https://hestia.earth/schema/Cycle#inputs) by calculating the distance between the
|
6
|
-
country of the Cycle and the country of origin of the Input (which must be different).
|
7
|
-
"""
|
8
1
|
from haversine import haversine
|
9
2
|
from hestia_earth.utils.api import download_hestia
|
10
3
|
from hestia_earth.utils.tools import non_empty_list
|
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
Land Cover
|
3
|
-
|
4
|
-
This model calculates historic land use change over a twenty-year period,
|
5
|
-
extending the functionality of the Blonk model.
|
6
|
-
"""
|
1
|
+
import functools
|
7
2
|
import math
|
8
3
|
from collections import defaultdict
|
9
4
|
from datetime import datetime, timedelta
|
@@ -103,6 +98,26 @@ OUTPUT_SIGNIFICANT_DIGITS = 3
|
|
103
98
|
_LOOKUP_EXPANSION = "region-crop-cropGroupingFaostatProduction-areaHarvestedUpTo20YearExpansion.csv"
|
104
99
|
|
105
100
|
|
101
|
+
def _get_lookup_with_cache(lookup_term, column):
|
102
|
+
"""Wrapper to get_lookup_value which pulls out the immutable parts of the term to allow caching."""
|
103
|
+
@functools.cache
|
104
|
+
def _get_immutable_lookup(term_id: str, term_type: str, col: str):
|
105
|
+
new_term = {"@id": term_id, "termType": term_type} if term_type and term_id else {}
|
106
|
+
return get_lookup_value(
|
107
|
+
lookup_term=new_term,
|
108
|
+
column=col,
|
109
|
+
skip_debug=False,
|
110
|
+
model=MODEL,
|
111
|
+
term=new_term
|
112
|
+
)
|
113
|
+
|
114
|
+
return _get_immutable_lookup(
|
115
|
+
term_id=lookup_term.get("@id"),
|
116
|
+
term_type=lookup_term.get("termType"),
|
117
|
+
col=column
|
118
|
+
)
|
119
|
+
|
120
|
+
|
106
121
|
def _management(term_id: str, value: float, start_date: str, end_date: str):
|
107
122
|
node = _new_management(term_id, MODEL)
|
108
123
|
node['value'] = value
|
@@ -140,10 +155,13 @@ def site_area_sum_to_100(dict_of_percentages: dict):
|
|
140
155
|
)
|
141
156
|
|
142
157
|
|
143
|
-
def _should_group_landCover(
|
158
|
+
def _should_group_landCover(management_node: dict):
|
144
159
|
return any(
|
145
|
-
bool(
|
146
|
-
|
160
|
+
bool(_get_lookup_with_cache(
|
161
|
+
lookup_term=prop.get("term", {}),
|
162
|
+
column="CALCULATE_TOTAL_LAND_COVER_SHARE_SEPARATELY"
|
163
|
+
))
|
164
|
+
for prop in management_node.get("properties", [])
|
147
165
|
)
|
148
166
|
|
149
167
|
|
@@ -391,7 +409,7 @@ def _get_shares_of_expansion(
|
|
391
409
|
|
392
410
|
def _get_faostat_name(term: dict) -> str:
|
393
411
|
"""For landCover terms, find the cropGroupingFaostatArea name for the landCover id."""
|
394
|
-
return
|
412
|
+
return _get_lookup_with_cache(term, "cropGroupingFaostatArea")
|
395
413
|
|
396
414
|
|
397
415
|
def _get_complete_faostat_to_crop_mapping() -> dict:
|
@@ -515,7 +533,7 @@ def _get_sums_of_crop_expansion(country_id: str, year: int, include_negatives: b
|
|
515
533
|
lookup = download_lookup(_LOOKUP_EXPANSION.replace('region', f"{country_id}")) or download_lookup(_LOOKUP_EXPANSION)
|
516
534
|
columns = lookup_columns(lookup)
|
517
535
|
values = {
|
518
|
-
name:
|
536
|
+
name: get_region_lookup_value(lookup_name=_LOOKUP_EXPANSION, term_id=country_id, column=name, model=MODEL)
|
519
537
|
for name in columns if name != "termid"
|
520
538
|
}
|
521
539
|
|
@@ -729,13 +747,8 @@ def _should_run_historical_land_use_change_single_crop(
|
|
729
747
|
return should_run, capped_site_area
|
730
748
|
|
731
749
|
|
732
|
-
def _get_land_use_term_from_node(node: dict)
|
733
|
-
return
|
734
|
-
lookup_term=node.get("term", {}),
|
735
|
-
column=LOOKUPS.get("landCover")[1],
|
736
|
-
model=MODEL,
|
737
|
-
term=node.get("term", {})
|
738
|
-
)
|
750
|
+
def _get_land_use_term_from_node(node: dict):
|
751
|
+
return _get_lookup_with_cache(lookup_term=node.get("term", {}), column=LOOKUPS.get("landCover")[1])
|
739
752
|
|
740
753
|
|
741
754
|
def _collect_land_use_types(nodes: list) -> list:
|
@@ -1,14 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Creates an [emissionsResourceUse](https://hestia.earth/schema/Emission) for every landCover land transformation.
|
3
|
-
contained within the [ImpactAssesment.cycle](https://hestia.earth/schema/ImpactAssessment#cycle), averaged over the last
|
4
|
-
100 years.
|
5
|
-
|
6
|
-
It does this by multiplying the land occupation during the cycle by the
|
7
|
-
[Site](https://hestia.earth/schema/Site) area 100 years ago and dividing by 100.
|
8
|
-
|
9
|
-
Land transformation from [land type] 100 years =
|
10
|
-
(Land occupation, during Cycle * Site Percentage Area 100 years ago [land type] / 100) / 100
|
11
|
-
"""
|
12
1
|
from .resourceUse_utils import run_resource_use
|
13
2
|
|
14
3
|
REQUIREMENTS = {
|
@@ -1,14 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Creates an [emissionsResourceUse](https://hestia.earth/schema/Emission) for every landCover land transformation.
|
3
|
-
contained within the [ImpactAssesment.cycle](https://hestia.earth/schema/ImpactAssessment#cycle), averaged over the last
|
4
|
-
20 years.
|
5
|
-
|
6
|
-
It does this by multiplying the land occupation during the cycle by the
|
7
|
-
[Site](https://hestia.earth/schema/Site) area 20 years ago and dividing by 20.
|
8
|
-
|
9
|
-
Land transformation from [land type] 20 years =
|
10
|
-
(Land occupation, during Cycle * Site Percentage Area 20 years ago [land type] / 100) / 20
|
11
|
-
"""
|
12
1
|
from .resourceUse_utils import run_resource_use
|
13
2
|
|
14
3
|
REQUIREMENTS = {
|