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.
Files changed (189) hide show
  1. hestia_earth/models/agribalyse2016/fuelElectricity.py +0 -5
  2. hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py +0 -11
  3. hestia_earth/models/aware/scarcityWeightedWaterUse.py +0 -4
  4. hestia_earth/models/cml2001Baseline/abioticResourceDepletionFossilFuels.py +0 -18
  5. hestia_earth/models/cml2001Baseline/abioticResourceDepletionMineralsAndMetals.py +0 -12
  6. hestia_earth/models/cml2001Baseline/resourceUseEnergyDepletionDuringCycle.py +0 -5
  7. hestia_earth/models/cml2001Baseline/resourceUseMineralsAndMetalsDuringCycle.py +0 -4
  8. hestia_earth/models/config/Cycle.json +23 -30
  9. hestia_earth/models/cycle/aboveGroundCropResidueTotal.py +0 -6
  10. hestia_earth/models/cycle/animal/input/hestiaAggregatedData.py +0 -8
  11. hestia_earth/models/cycle/animal/input/properties.py +0 -9
  12. hestia_earth/models/cycle/animal/milkYield.py +0 -6
  13. hestia_earth/models/cycle/animal/properties.py +0 -6
  14. hestia_earth/models/cycle/completeness/animalFeed.py +0 -6
  15. hestia_earth/models/cycle/completeness/cropResidue.py +0 -6
  16. hestia_earth/models/cycle/completeness/electricityFuel.py +0 -6
  17. hestia_earth/models/cycle/completeness/excreta.py +0 -6
  18. hestia_earth/models/cycle/completeness/freshForage.py +0 -6
  19. hestia_earth/models/cycle/completeness/material.py +0 -6
  20. hestia_earth/models/cycle/completeness/seed.py +0 -6
  21. hestia_earth/models/cycle/completeness/soilAmendment.py +0 -6
  22. hestia_earth/models/cycle/concentrateFeed.py +0 -6
  23. hestia_earth/models/cycle/cropResidueManagement.py +0 -5
  24. hestia_earth/models/cycle/cycleDuration.py +0 -8
  25. hestia_earth/models/cycle/endDate.py +0 -7
  26. hestia_earth/models/cycle/excretaKgMass.py +0 -5
  27. hestia_earth/models/cycle/excretaKgN.py +0 -5
  28. hestia_earth/models/cycle/excretaKgVs.py +0 -5
  29. hestia_earth/models/cycle/inorganicFertiliser.py +0 -6
  30. hestia_earth/models/cycle/input/hestiaAggregatedData.py +0 -13
  31. hestia_earth/models/cycle/input/properties.py +0 -9
  32. hestia_earth/models/cycle/input/value.py +0 -6
  33. hestia_earth/models/cycle/liveAnimal.py +0 -5
  34. hestia_earth/models/cycle/materialAndSubstrate.py +1 -6
  35. hestia_earth/models/cycle/milkYield.py +0 -10
  36. hestia_earth/models/cycle/otherSitesArea.py +0 -6
  37. hestia_earth/models/cycle/otherSitesUnusedDuration.py +0 -6
  38. hestia_earth/models/cycle/pastureSystem.py +0 -6
  39. hestia_earth/models/cycle/post_checks/cache.py +0 -5
  40. hestia_earth/models/cycle/post_checks/otherSites.py +0 -7
  41. hestia_earth/models/cycle/post_checks/site.py +0 -7
  42. hestia_earth/models/cycle/practice/value.py +0 -7
  43. hestia_earth/models/cycle/pre_checks/cache_sources.py +0 -5
  44. hestia_earth/models/cycle/pre_checks/otherSites.py +0 -7
  45. hestia_earth/models/cycle/pre_checks/site.py +0 -6
  46. hestia_earth/models/cycle/product/currency.py +0 -5
  47. hestia_earth/models/cycle/product/economicValueShare.py +0 -14
  48. hestia_earth/models/cycle/product/price.py +0 -5
  49. hestia_earth/models/cycle/product/primary.py +0 -5
  50. hestia_earth/models/cycle/product/properties.py +0 -7
  51. hestia_earth/models/cycle/product/revenue.py +0 -9
  52. hestia_earth/models/cycle/product/value.py +0 -6
  53. hestia_earth/models/cycle/siteArea.py +0 -6
  54. hestia_earth/models/cycle/siteDuration.py +0 -10
  55. hestia_earth/models/cycle/siteUnusedDuration.py +0 -6
  56. hestia_earth/models/cycle/startDate.py +0 -8
  57. hestia_earth/models/cycle/startDateDefinition.py +0 -6
  58. hestia_earth/models/cycle/transformation.py +0 -5
  59. hestia_earth/models/dammgen2009/noxToAirExcreta.py +2 -2
  60. hestia_earth/models/ecoinventV3/__init__.py +0 -15
  61. hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py +0 -11
  62. hestia_earth/models/emepEea2019/nh3ToAirExcreta.py +14 -40
  63. hestia_earth/models/emepEea2019/pm10ToAirAnimalHousing.py +0 -4
  64. hestia_earth/models/emepEea2019/pm25ToAirAnimalHousing.py +0 -4
  65. hestia_earth/models/emepEea2019/tspToAirAnimalHousing.py +0 -4
  66. hestia_earth/models/emissionNotRelevant/__init__.py +0 -5
  67. hestia_earth/models/environmentalFootprintV3_1/environmentalFootprintSingleOverallScore.py +0 -9
  68. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandOccupation.py +0 -6
  69. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandTransformation.py +0 -6
  70. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexTotalLandUseEffects.py +0 -6
  71. hestia_earth/models/epa2014/no3ToGroundwaterExcreta.py +2 -2
  72. hestia_earth/models/faostat2018/product/price.py +0 -5
  73. hestia_earth/models/geospatialDatabase/awareWaterBasinId.py +0 -5
  74. hestia_earth/models/geospatialDatabase/ecoClimateZone.py +1 -20
  75. hestia_earth/models/geospatialDatabase/ecoregion.py +0 -7
  76. hestia_earth/models/geospatialDatabase/potentialEvapotranspirationAnnual.py +0 -4
  77. hestia_earth/models/geospatialDatabase/potentialEvapotranspirationMonthly.py +0 -4
  78. hestia_earth/models/geospatialDatabase/precipitationAnnual.py +0 -4
  79. hestia_earth/models/geospatialDatabase/precipitationMonthly.py +0 -4
  80. hestia_earth/models/geospatialDatabase/region.py +0 -5
  81. hestia_earth/models/geospatialDatabase/temperatureAnnual.py +0 -4
  82. hestia_earth/models/geospatialDatabase/temperatureMonthly.py +0 -4
  83. hestia_earth/models/haversineFormula/transport/distance.py +0 -7
  84. hestia_earth/models/hestia/landCover.py +31 -18
  85. hestia_earth/models/hestia/landTransformation100YearAverageDuringCycle.py +0 -11
  86. hestia_earth/models/hestia/landTransformation20YearAverageDuringCycle.py +0 -11
  87. hestia_earth/models/hestia/nh3ToSurfaceWaterAquacultureSystems.py +64 -0
  88. hestia_earth/models/hestia/residueRemoved.py +0 -4
  89. hestia_earth/models/hestia/resourceUse_utils.py +0 -5
  90. hestia_earth/models/hestia/seed_emissions.py +0 -13
  91. hestia_earth/models/impact_assessment/allocationMethod.py +0 -6
  92. hestia_earth/models/impact_assessment/emissions.py +0 -9
  93. hestia_earth/models/impact_assessment/irrigated.py +0 -5
  94. hestia_earth/models/impact_assessment/organic.py +0 -5
  95. hestia_earth/models/impact_assessment/post_checks/cycle.py +0 -7
  96. hestia_earth/models/impact_assessment/post_checks/site.py +0 -7
  97. hestia_earth/models/impact_assessment/pre_checks/cycle.py +0 -6
  98. hestia_earth/models/impact_assessment/pre_checks/site.py +0 -6
  99. hestia_earth/models/impact_assessment/product/economicValueShare.py +0 -6
  100. hestia_earth/models/impact_assessment/product/value.py +0 -5
  101. hestia_earth/models/ipcc2019/aboveGroundBiomass.py +9 -2
  102. hestia_earth/models/ipcc2019/animal/milkYieldPerAnimal.py +0 -6
  103. hestia_earth/models/ipcc2019/animal/pastureGrass.py +0 -10
  104. hestia_earth/models/ipcc2019/animal/weightAtMaturity.py +0 -4
  105. hestia_earth/models/ipcc2019/belowGroundBiomass.py +9 -2
  106. hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py +1 -1
  107. hestia_earth/models/ipcc2019/croppingDuration.py +0 -5
  108. hestia_earth/models/ipcc2019/n2OToAirExcretaDirect.py +1 -1
  109. hestia_earth/models/ipcc2019/no3ToGroundwaterExcreta.py +51 -15
  110. hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +0 -12
  111. hestia_earth/models/ipcc2019/organicCarbonPerHa.py +2 -15
  112. hestia_earth/models/ipcc2019/{organicCarbonPerHa_tier_1_utils.py → organicCarbonPerHa_tier_1.py} +3 -15
  113. hestia_earth/models/ipcc2019/{organicCarbonPerHa_tier_2_utils.py → organicCarbonPerHa_tier_2.py} +3 -13
  114. hestia_earth/models/ipcc2019/pastureGrass.py +0 -10
  115. hestia_earth/models/koble2014/aboveGroundCropResidue.py +0 -9
  116. hestia_earth/models/koble2014/cropResidueManagement.py +0 -6
  117. hestia_earth/models/linkedImpactAssessment/emissions.py +0 -5
  118. hestia_earth/models/mocking/search-results.json +1202 -1146
  119. hestia_earth/models/pooreNemecek2018/ch4ToAirAquacultureSystems.py +14 -15
  120. hestia_earth/models/pooreNemecek2018/excretaKgN.py +12 -17
  121. hestia_earth/models/pooreNemecek2018/excretaKgVs.py +22 -23
  122. hestia_earth/models/pooreNemecek2018/n2OToAirAquacultureSystemsDirect.py +6 -9
  123. hestia_earth/models/pooreNemecek2018/n2ToAirAquacultureSystems.py +6 -9
  124. hestia_earth/models/pooreNemecek2018/nh3ToAirAquacultureSystems.py +11 -15
  125. hestia_earth/models/pooreNemecek2018/noxToAirAquacultureSystems.py +6 -9
  126. hestia_earth/models/pooreNemecek2018/utils.py +2 -2
  127. hestia_earth/models/site/defaultMethodClassification.py +0 -7
  128. hestia_earth/models/site/defaultMethodClassificationDescription.py +0 -7
  129. hestia_earth/models/site/flowingWater.py +0 -5
  130. hestia_earth/models/site/management.py +0 -21
  131. hestia_earth/models/site/measurement/value.py +0 -6
  132. hestia_earth/models/site/post_checks/country.py +0 -5
  133. hestia_earth/models/site/potentialEvapotranspirationAnnual.py +0 -3
  134. hestia_earth/models/site/potentialEvapotranspirationMonthly.py +0 -3
  135. hestia_earth/models/site/pre_checks/cache_geospatialDatabase.py +0 -5
  136. hestia_earth/models/site/pre_checks/cache_sources.py +0 -5
  137. hestia_earth/models/site/pre_checks/cache_years.py +0 -5
  138. hestia_earth/models/site/pre_checks/country.py +0 -5
  139. hestia_earth/models/site/precipitationAnnual.py +0 -3
  140. hestia_earth/models/site/precipitationMonthly.py +0 -3
  141. hestia_earth/models/site/rainfallAnnual.py +0 -3
  142. hestia_earth/models/site/rainfallMonthly.py +0 -3
  143. hestia_earth/models/site/soilMeasurement.py +0 -5
  144. hestia_earth/models/site/temperatureAnnual.py +0 -3
  145. hestia_earth/models/site/temperatureMonthly.py +0 -3
  146. hestia_earth/models/transformation/input/excreta.py +0 -5
  147. hestia_earth/models/transformation/input/max.py +0 -8
  148. hestia_earth/models/transformation/input/min.py +0 -8
  149. hestia_earth/models/transformation/input/properties.py +0 -6
  150. hestia_earth/models/transformation/input/sd.py +0 -8
  151. hestia_earth/models/transformation/input/value.py +0 -8
  152. hestia_earth/models/transformation/product/excreta.py +0 -7
  153. hestia_earth/models/utils/excretaManagement.py +37 -0
  154. hestia_earth/models/utils/lookup.py +2 -0
  155. hestia_earth/models/utils/practice.py +1 -27
  156. hestia_earth/models/utils/source.py +29 -9
  157. hestia_earth/models/version.py +1 -1
  158. hestia_earth/orchestrator/strategies/run/add_blank_node_if_missing.py +12 -8
  159. {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/METADATA +2 -2
  160. {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/RECORD +179 -187
  161. tests/models/emepEea2019/test_nh3ToAirExcreta.py +6 -17
  162. tests/models/hestia/test_nh3ToSurfaceWaterAquacultureSystems.py +51 -0
  163. tests/models/ipcc2019/test_aboveGroundBiomass.py +4 -0
  164. tests/models/ipcc2019/test_belowGroundBiomass.py +4 -0
  165. tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py +1 -1
  166. tests/models/ipcc2019/test_no3ToGroundwaterExcreta.py +24 -9
  167. tests/models/ipcc2019/test_organicCarbonPerHa.py +2 -2
  168. tests/models/ipcc2019/{test_organicCarbonPerHa_tier_1_utils.py → test_organicCarbonPerHa_tier_1.py} +2 -2
  169. tests/models/ipcc2019/{test_organicCarbonPerHa_tier_2_utils.py → test_organicCarbonPerHa_tier_2.py} +2 -2
  170. tests/models/pooreNemecek2018/test_ch4ToAirAquacultureSystems.py +1 -7
  171. tests/models/pooreNemecek2018/test_n2OToAirAquacultureSystemsDirect.py +1 -7
  172. tests/models/pooreNemecek2018/test_n2ToAirAquacultureSystems.py +1 -7
  173. tests/models/pooreNemecek2018/test_nh3ToAirAquacultureSystems.py +1 -7
  174. tests/models/pooreNemecek2018/test_noxToAirAquacultureSystems.py +1 -7
  175. tests/models/utils/test_source.py +6 -1
  176. tests/orchestrator/strategies/run/test_add_blank_node_if_missing.py +1 -1
  177. hestia_earth/models/blonkConsultants2016/__init__.py +0 -13
  178. hestia_earth/models/blonkConsultants2016/ch4ToAirNaturalVegetationBurning.py +0 -78
  179. hestia_earth/models/blonkConsultants2016/co2ToAirAboveGroundBiomassStockChangeLandUseChange.py +0 -78
  180. hestia_earth/models/blonkConsultants2016/n2OToAirNaturalVegetationBurningDirect.py +0 -78
  181. hestia_earth/models/blonkConsultants2016/utils.py +0 -30
  182. tests/models/blonkConsultants2016/__init__.py +0 -0
  183. tests/models/blonkConsultants2016/test_ch4ToAirNaturalVegetationBurning.py +0 -34
  184. tests/models/blonkConsultants2016/test_co2ToAirAboveGroundBiomassStockChangeLandUseChange.py +0 -36
  185. tests/models/blonkConsultants2016/test_n2OToAirNaturalVegetationBurningDirect.py +0 -34
  186. tests/models/blonkConsultants2016/test_utils.py +0 -9
  187. {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/LICENSE +0 -0
  188. {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/WHEEL +0 -0
  189. {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,64 @@
1
+ from hestia_earth.schema import TermTermType, EmissionMethodTier
2
+ from hestia_earth.models.utils.emission import _new_emission
3
+ from hestia_earth.utils.model import filter_list_term_type
4
+ from hestia_earth.models.utils.aquacultureManagement import valid_site_type
5
+ from hestia_earth.models.utils.input import total_excreta_tan
6
+ from . import MODEL
7
+
8
+
9
+ REQUIREMENTS = {
10
+ "Cycle": {
11
+ "products": [{
12
+ "@type": "Product",
13
+ "term.termType": "excreta",
14
+ "term.@id": "excretaLiquidFishCrustaceansKgN"
15
+ }]
16
+ }
17
+ }
18
+
19
+ RETURNS = {
20
+ "Emission": [{
21
+ "value": "",
22
+ "methodTier": "tier 1"
23
+ }]
24
+ }
25
+
26
+ TIER = EmissionMethodTier.TIER_1.value
27
+ TERM_ID = 'nh3ToSurfaceWaterAquacultureSystems'
28
+ _EXCRETA_TERM_ID = 'excretaLiquidFishCrustaceansKgN'
29
+
30
+
31
+ def _emission(value: float):
32
+ emission = _new_emission(TERM_ID, MODEL)
33
+ emission['value'] = [round(value, 7)]
34
+ emission['methodTier'] = TIER
35
+ return emission
36
+
37
+
38
+ def _run(excreta_products: list):
39
+ value = total_excreta_tan(excreta_products)
40
+ return [_emission(value)]
41
+
42
+
43
+ def _valid_excreta(cycle: dict):
44
+ excreta_products = filter_list_term_type(cycle.get('products', []), TermTermType.EXCRETA.value)
45
+ valid_excreta_products = [
46
+ product for product in excreta_products if all([
47
+ product.get('term', {}).get('@id') == _EXCRETA_TERM_ID
48
+ ])
49
+ ]
50
+ return valid_excreta_products
51
+
52
+
53
+ def _should_run(cycle: dict):
54
+ valid_excreta_products = _valid_excreta(cycle)
55
+ should_run = all([
56
+ valid_site_type(cycle),
57
+ bool(valid_excreta_products),
58
+ ])
59
+ return should_run, valid_excreta_products
60
+
61
+
62
+ def run(cycle: dict):
63
+ should_run, valid_excreta_products = _should_run(cycle)
64
+ return _run(valid_excreta_products) if should_run else []
@@ -1,7 +1,3 @@
1
- """
2
- This model will gap-fill the value for `residueRemoved` when the only provided data is the incorporated residue.
3
- We are assuming that anything that was not incorporated must have been removed.
4
- """
5
1
  from hestia_earth.schema import TermTermType
6
2
  from hestia_earth.utils.model import filter_list_term_type
7
3
  from hestia_earth.utils.tools import list_sum
@@ -1,8 +1,3 @@
1
- """
2
- Resource Use
3
-
4
- Provides common code for land transformation models.
5
- """
6
1
  from datetime import datetime
7
2
  from dateutil.relativedelta import relativedelta
8
3
  from hestia_earth.schema import TermTermType
@@ -1,16 +1,3 @@
1
- """
2
- Seed Emissions
3
-
4
- This model uses the `emissions` recalculated from the current `Cycle` to estimate the `emissions` associated with
5
- producing the `Input` with `termType` = `seed`.
6
-
7
- These are the steps:
8
-
9
- 1. Recalculate all emissions for the Cycle of interest;
10
- 2. Group Cycle emissions based on their `inputProductionGroupId` lookup value and sum them up;
11
- 3. Divide the sum of each emission group by the average crop yield (from FAOSTAT) to get emissions per kg of product;
12
- 4. Multiply by `seed.value` to get total background `emissions` from seed production per ha.
13
- """
14
1
  from functools import reduce
15
2
  from hestia_earth.schema import TermTermType, EmissionMethodTier, SiteSiteType
16
3
  from hestia_earth.utils.lookup import (
@@ -1,9 +1,3 @@
1
- """
2
- Allocation Method
3
-
4
- If any of the impact `emissionsResourceUse`, `impacts`, or `endpoints`, have been modified by the calculations,
5
- the `allocationMethod` will be set to `economic`.
6
- """
7
1
  from hestia_earth.schema import ImpactAssessmentAllocationMethod
8
2
 
9
3
  from hestia_earth.models.log import logShouldRun, logRequirements
@@ -1,12 +1,3 @@
1
- """
2
- Emissions
3
-
4
- Creates an [Indicator](https://hestia.earth/schema/Indicator) for every [Emission](https://hestia.earth/schema/Emission)
5
- contained within the [ImpactAssesment.cycle](https://hestia.earth/schema/ImpactAssessment#cycle).
6
- It does this by dividing the Emission amount by the Product amount, and applying an allocation between co-products.
7
- Note: for any Emission in the system boundary that does not exist in the Cycle, it will log the model as failed,
8
- so that we know the Emission is missing.
9
- """
10
1
  from hestia_earth.utils.tools import list_sum
11
2
  from hestia_earth.utils.emission import cycle_emissions_in_system_boundary
12
3
 
@@ -1,8 +1,3 @@
1
- """
2
- Irrigated
3
-
4
- Detects if the [Cycle](https://hestia.earth/schema/ImpactAssessment#cycle) was irrigated.
5
- """
6
1
  from hestia_earth.models.log import logger
7
2
  from hestia_earth.models.utils.cycle import is_irrigated
8
3
  from . import MODEL
@@ -1,8 +1,3 @@
1
- """
2
- Organic
3
-
4
- Detects if the [Cycle](https://hestia.earth/schema/ImpactAssessment#cycle) has an organic label.
5
- """
6
1
  from hestia_earth.models.log import logger
7
2
  from hestia_earth.models.utils.cycle import is_organic
8
3
  from . import MODEL
@@ -1,10 +1,3 @@
1
- """
2
- Post Checks Cycle
3
-
4
- This model is run only if the [pre model](../pre_checks/cycle.md) has been run before.
5
- This model will restore the `impactAssessment.cycle` as a "linked node"
6
- (i.e. it will be set with only `@type`, `@id` and `name` keys).
7
- """
8
1
  from hestia_earth.utils.model import linked_node
9
2
 
10
3
  REQUIREMENTS = {
@@ -1,10 +1,3 @@
1
- """
2
- Post Checks Site
3
-
4
- This model is run only if the [pre model](../pre_checks/site.md) has been run before.
5
- This model will restore the `impactAssessment.site` as a "linked node"
6
- (i.e. it will be set with only `@type`, `@id` and `name` keys).
7
- """
8
1
  from hestia_earth.utils.model import linked_node
9
2
 
10
3
  REQUIREMENTS = {
@@ -1,9 +1,3 @@
1
- """
2
- Pre Checks Cycle
3
-
4
- Some ImpactAssessment models need a full version of the linked [Cycle](https://hestia.earth/schema/Cycle) to run.
5
- This model will fetch the complete version of the [Cycle](https://hestia.earth/schema/Cycle) and include it.
6
- """
7
1
  from hestia_earth.schema import SchemaType
8
2
 
9
3
  from hestia_earth.models.utils import _load_calculated_node
@@ -1,9 +1,3 @@
1
- """
2
- Pre Checks Site
3
-
4
- Some ImpactAssessment models need a full version of the linked [Site](https://hestia.earth/schema/Site) to run.
5
- This model will fetch the complete version of the [Site](https://hestia.earth/schema/Site) and include it.
6
- """
7
1
  from hestia_earth.schema import SchemaType
8
2
 
9
3
  from hestia_earth.models.utils import _load_calculated_node
@@ -1,9 +1,3 @@
1
- """
2
- Product Economic Value Share
3
-
4
- Returns the [economicValueShare](https://hestia.earth/schema/Product#economicValueShare) of the Product
5
- linked to the Cycle.
6
- """
7
1
  from hestia_earth.models.log import logShouldRun
8
2
  from hestia_earth.models.utils.product import find_by_product
9
3
  from .. import MODEL
@@ -1,8 +1,3 @@
1
- """
2
- Product Value
3
-
4
- Returns the [value](https://hestia.earth/schema/Product#value) of the Product linked to the Cycle.
5
- """
6
1
  from hestia_earth.models.log import logShouldRun
7
2
  from hestia_earth.models.utils.product import find_by_product
8
3
  from .. import MODEL
@@ -18,6 +18,7 @@ from hestia_earth.models.utils.array_builders import gen_seed
18
18
  from hestia_earth.models.utils.blank_node import group_nodes_by_year
19
19
  from hestia_earth.models.utils.descriptive_stats import calc_descriptive_stats
20
20
  from hestia_earth.models.utils.ecoClimateZone import EcoClimateZone, get_eco_climate_zone_value
21
+ from hestia_earth.models.utils.source import get_source
21
22
  from hestia_earth.models.utils.measurement import _new_measurement
22
23
 
23
24
  from . import MODEL
@@ -87,6 +88,11 @@ RETURNS = {
87
88
  }]
88
89
  }
89
90
  TERM_ID = 'aboveGroundBiomass'
91
+ BIBLIO_TITLE = '2019 Refinement to the 2006 IPCC Guidelines for National Greenhouse Gas Inventories'
92
+ OTHER_BIBLIO_TITLES = [
93
+ '2006 IPCC Guidelines for National Greenhouse Gas Inventories',
94
+ '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' # noqa: E501
95
+ ]
90
96
 
91
97
  _ITERATIONS = 10000
92
98
  _METHOD_CLASSIFICATION = MeasurementMethodClassification.TIER_1_MODEL.value
@@ -131,7 +137,7 @@ def run(site: dict) -> list[dict]:
131
137
  `aboveGroundBiomass`
132
138
  """
133
139
  should_run, inventory, kwargs = _should_run(site)
134
- return _run(inventory, iterations=_ITERATIONS, **kwargs) if should_run else []
140
+ return _run(site, inventory, iterations=_ITERATIONS, **kwargs) if should_run else []
135
141
 
136
142
 
137
143
  def _should_run(site: dict) -> tuple[bool, dict, dict]:
@@ -407,6 +413,7 @@ the `dict` keys.
407
413
 
408
414
 
409
415
  def _run(
416
+ site: dict,
410
417
  inventory: dict,
411
418
  *,
412
419
  eco_climate_zone: EcoClimateZone,
@@ -501,7 +508,7 @@ def _run(
501
508
  axis=1, # Calculate stats rowwise.
502
509
  decimals=6 # Round values to the nearest milligram.
503
510
  )
504
- return [_measurement(timestamps, **descriptive_stats)]
511
+ return [_measurement(timestamps, **descriptive_stats) | get_source(site, BIBLIO_TITLE, OTHER_BIBLIO_TITLES)]
505
512
 
506
513
 
507
514
  def _build_col_name(biomass_category: BiomassCategory) -> str:
@@ -1,9 +1,3 @@
1
- """
2
- Milk Yield Per Animal
3
-
4
- This model gap-fills the practice "Milk yield per X, raw" for live animals added to the animal node,
5
- taking values from a lookup file.
6
- """
7
1
  from hestia_earth.models.log import logRequirements, logShouldRun
8
2
  from hestia_earth.models.utils.blank_node import merge_blank_nodes, get_lookup_value
9
3
  from hestia_earth.models.utils.practice import _new_practice
@@ -1,13 +1,3 @@
1
- """
2
- Animal Pasture Grass
3
-
4
- This model estimates the energetic requirements of ruminants and can be used to estimate the amount of grass they graze.
5
- Source:
6
- [IPCC 2019, Vol.4, Chapter 10](https://www.ipcc-nggip.iges.or.jp/public/2019rf/pdf/4_Volume4/19R_V4_Ch10_Livestock.pdf).
7
-
8
- This version of the model will run at the Animal Blank Node level, if none of the Cycle Input are given as feed
9
- (see https://www.hestia.earth/schema/Input#isAnimalFeed).
10
- """
11
1
  from hestia_earth.schema import TermTermType
12
2
  from hestia_earth.utils.model import filter_list_term_type
13
3
  from hestia_earth.utils.tools import list_sum, non_empty_list
@@ -1,7 +1,3 @@
1
- """
2
- Note: when the `liveweightPerHead` property is provided, this model will only work if the returned value is
3
- greater than or equal to `liveweightPerHead` value.
4
- """
5
1
  from hestia_earth.utils.model import find_term_match
6
2
 
7
3
  from hestia_earth.models.log import logRequirements, logShouldRun
@@ -18,6 +18,7 @@ from hestia_earth.models.utils.array_builders import gen_seed
18
18
  from hestia_earth.models.utils.blank_node import group_nodes_by_year
19
19
  from hestia_earth.models.utils.descriptive_stats import calc_descriptive_stats
20
20
  from hestia_earth.models.utils.ecoClimateZone import EcoClimateZone, get_eco_climate_zone_value
21
+ from hestia_earth.models.utils.source import get_source
21
22
  from hestia_earth.models.utils.measurement import _new_measurement
22
23
 
23
24
  from . import MODEL
@@ -76,6 +77,11 @@ RETURNS = {
76
77
  }]
77
78
  }
78
79
  TERM_ID = 'belowGroundBiomass'
80
+ BIBLIO_TITLE = '2019 Refinement to the 2006 IPCC Guidelines for National Greenhouse Gas Inventories'
81
+ OTHER_BIBLIO_TITLES = [
82
+ '2006 IPCC Guidelines for National Greenhouse Gas Inventories',
83
+ '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' # noqa: E501
84
+ ]
79
85
 
80
86
  _ITERATIONS = 10000
81
87
  _DEPTH_UPPER = 0
@@ -128,7 +134,7 @@ def run(site: dict) -> list[dict]:
128
134
  `aboveGroundBiomass`
129
135
  """
130
136
  should_run, inventory, kwargs = _should_run(site)
131
- return _run(inventory, iterations=_ITERATIONS, **kwargs) if should_run else []
137
+ return _run(site, inventory, iterations=_ITERATIONS, **kwargs) if should_run else []
132
138
 
133
139
 
134
140
  def _should_run(site: dict) -> tuple[bool, dict, dict]:
@@ -394,6 +400,7 @@ the `dict` keys.
394
400
 
395
401
 
396
402
  def _run(
403
+ site: dict,
397
404
  inventory: dict,
398
405
  *,
399
406
  eco_climate_zone: EcoClimateZone,
@@ -484,7 +491,7 @@ def _run(
484
491
  axis=1, # Calculate stats rowwise.
485
492
  decimals=6 # Round values to the nearest milligram.
486
493
  )
487
- return [_measurement(timestamps, **descriptive_stats)]
494
+ return [_measurement(timestamps, **descriptive_stats) | get_source(site, BIBLIO_TITLE, OTHER_BIBLIO_TITLES)]
488
495
 
489
496
 
490
497
  def _build_col_name(biomass_category: BiomassCategory) -> str:
@@ -4,7 +4,7 @@ from hestia_earth.models.log import logRequirements, logShouldRun
4
4
  from hestia_earth.models.utils.blank_node import cumulative_nodes_term_match
5
5
  from hestia_earth.models.utils.emission import _new_emission
6
6
 
7
- from .organicCarbonPerHa_tier_1_utils import _assign_ipcc_land_use_category, get_valid_management_nodes
7
+ from .organicCarbonPerHa_tier_1 import _assign_ipcc_land_use_category, get_valid_management_nodes
8
8
  from .co2ToAirCarbonStockChange_utils import create_run_function, create_should_run_function
9
9
  from . import MODEL
10
10
 
@@ -1,8 +1,3 @@
1
- """
2
- `croppingDuration` can be added by the uploader for all crops, however the model `IPCC (2019)` will only run for
3
- `riceGrainInHusk` or `ricePlantFlooded`.
4
- The model will only run for rice crops as this is the only crop which requires the value for emission recalculations.
5
- """
6
1
  from hestia_earth.schema import PracticeStatsDefinition
7
2
  from hestia_earth.utils.tools import safe_parse_float
8
3
 
@@ -56,7 +56,7 @@ def _should_run(cycle: dict):
56
56
  N2O_N_EF=N2O_N_EF,
57
57
  term_type_excreta_complete=term_type_complete)
58
58
 
59
- should_run = all([N_total, N2O_N_EF]) or all([not N_total, term_type_complete])
59
+ should_run = all([N_total is not None, N2O_N_EF is not None]) or all([not N_total, term_type_complete])
60
60
  logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
61
61
  return should_run, N_total, N2O_N_EF
62
62
 
@@ -1,36 +1,47 @@
1
- from hestia_earth.schema import EmissionMethodTier, EmissionStatsDefinition, TermTermType
1
+ from hestia_earth.schema import EmissionMethodTier, EmissionStatsDefinition, TermTermType, SiteSiteType
2
2
 
3
3
  from hestia_earth.models.log import logRequirements, logShouldRun
4
4
  from hestia_earth.models.utils.constant import Units, get_atomic_conversion
5
5
  from hestia_earth.models.utils.completeness import _is_term_type_complete
6
6
  from hestia_earth.models.utils.emission import _new_emission
7
7
  from hestia_earth.models.utils.cycle import get_excreta_N_total, get_ecoClimateZone
8
+ from hestia_earth.models.utils.input import total_excreta
9
+ from hestia_earth.models.utils.excretaManagement import get_excreta_inputs_with_factor
8
10
  from .utils import get_FracLEACH_H
9
11
  from . import MODEL
10
12
 
11
13
  REQUIREMENTS = {
12
14
  "Cycle": {
13
15
  "completeness.excreta": "True",
14
- "completeness.water": "True",
15
16
  "inputs": [
16
17
  {
17
18
  "@type": "Input",
18
19
  "value": "",
19
20
  "term.termType": "excreta",
20
- "optional": {
21
- "properties": [{"@type": "Property", "value": "", "term.@id": "nitrogenContent"}]
22
- }
21
+ "properties": [
22
+ {"@type": "Property", "value": "", "term.@id": "nitrogenContent"},
23
+ {"@type": "Property", "value": "", "term.@id": "totalAmmoniacalNitrogenContentAsN"}
24
+ ]
23
25
  }
24
26
  ],
25
27
  "site": {
26
28
  "@type": "Site",
27
- "measurements": [{"@type": "Measurement", "value": "", "term.@id": "ecoClimateZone"}]
29
+ "optional": {
30
+ "measurements": [{"@type": "Measurement", "value": "", "term.@id": "ecoClimateZone"}]
31
+ }
28
32
  },
29
33
  "optional": {
30
- "practices": [{"@type": "Practice", "value": "", "term.termType": "waterRegime"}]
34
+ "completeness.water": "True",
35
+ "practices": [
36
+ {"@type": "Practice", "value": "", "term.termType": "waterRegime"},
37
+ {"@type": "Practice", "value": "", "term.termType": "excretaManagement"}
38
+ ]
31
39
  }
32
40
  }
33
41
  }
42
+ LOOKUPS = {
43
+ "excretaManagement-excreta-NO3_EF_2019": ""
44
+ }
34
45
  RETURNS = {
35
46
  "Emission": [{
36
47
  "value": "",
@@ -45,12 +56,13 @@ TERM_ID = 'no3ToGroundwaterExcreta'
45
56
  TIER = EmissionMethodTier.TIER_1.value
46
57
 
47
58
 
48
- def _emission(value: float, sd: float, min: float, max: float):
59
+ def _emission(value: float, sd: float = None, min: float = None, max: float = None):
49
60
  emission = _new_emission(TERM_ID, MODEL)
50
61
  emission['value'] = [value]
51
- emission['sd'] = [sd]
52
- emission['min'] = [min]
53
- emission['max'] = [max]
62
+ if sd is not None:
63
+ emission['sd'] = [sd]
64
+ emission['min'] = [min]
65
+ emission['max'] = [max]
54
66
  emission['methodTier'] = TIER
55
67
  emission['statsDefinition'] = EmissionStatsDefinition.MODELLED.value
56
68
  return emission
@@ -68,21 +80,45 @@ def _run(cycle: dict):
68
80
  )]
69
81
 
70
82
 
83
+ def _run_with_excreta_managemen(excreta_EF_input: float):
84
+ value = excreta_EF_input * get_atomic_conversion(Units.KG_NO3, Units.TO_N)
85
+ return [_emission(value)]
86
+
87
+
88
+ def _should_run_with_excreta_management(cycle: dict):
89
+ site_type = cycle.get('site', {}).get('siteType')
90
+ return site_type not in [SiteSiteType.CROPLAND.value, SiteSiteType.PERMANENT_PASTURE.value]
91
+
92
+
71
93
  def _should_run(cycle: dict):
72
94
  N_excreta = get_excreta_N_total(cycle)
73
95
  ecoClimateZone = get_ecoClimateZone(cycle)
74
96
  excreta_complete = _is_term_type_complete(cycle, TermTermType.EXCRETA)
75
97
  water_complete = _is_term_type_complete(cycle, TermTermType.WATER)
76
98
 
99
+ use_excreta_management = _should_run_with_excreta_management(cycle)
100
+ excreta_EF_input = get_excreta_inputs_with_factor(
101
+ cycle, f"{list(LOOKUPS.keys())[0]}.csv", excreta_convertion_func=total_excreta, model=MODEL, term=TERM_ID
102
+ ) if use_excreta_management else None
103
+
77
104
  logRequirements(cycle, model=MODEL, term=TERM_ID,
78
105
  N_excreta=N_excreta,
79
106
  ecoClimateZone=ecoClimateZone,
80
107
  term_type_excreta_complete=excreta_complete,
81
- term_type_water_complete=water_complete)
108
+ term_type_water_complete=water_complete,
109
+ excreta_EF_input=excreta_EF_input)
82
110
 
83
- should_run = all([N_excreta is not None, ecoClimateZone, excreta_complete, water_complete])
111
+ should_run = excreta_complete and (
112
+ all([excreta_EF_input >= 0]) if use_excreta_management else
113
+ all([water_complete, N_excreta is not None, ecoClimateZone])
114
+ )
84
115
  logShouldRun(cycle, MODEL, TERM_ID, should_run)
85
- return should_run
116
+ return should_run, excreta_EF_input
86
117
 
87
118
 
88
- def run(cycle: dict): return _run(cycle) if _should_run(cycle) else []
119
+ def run(cycle: dict):
120
+ should_run, excreta_EF_input = _should_run(cycle)
121
+ return (
122
+ _run_with_excreta_managemen(excreta_EF_input) if _should_run_with_excreta_management(cycle) else
123
+ _run(cycle)
124
+ ) if should_run else []
@@ -1,15 +1,3 @@
1
- """
2
- Non-CO2 emissions, to air, natural vegetation burning
3
-
4
- This model returns the amounts of non-CO2 emissions from natural vegetation burning:
5
- 1. [CH4, to air, natural vegetation burning](https://www.hestia.earth/term/ch4ToAirNaturalVegetationBurning);
6
- 2. [CO, to air, natural vegetation burning](https://www.hestia.earth/term/coToAirNaturalVegetationBurning);
7
- 3. [N2O, to air, natural vegetation burning](https://www.hestia.earth/term/n2OToAirNaturalVegetationBurningDirect);
8
- 4. [NOx, to air, natural vegetation burning](https://www.hestia.earth/term/noxToAirNaturalVegetationBurning).
9
-
10
- For now, the V1 version of this model only calculates emissions from forests burning, as we have no reliable way of
11
- recording savannah grassland and woodland fire regimes using the HESTIA glossary.
12
- """
13
1
  from enum import Enum
14
2
  from functools import lru_cache, reduce
15
3
  from itertools import product
@@ -1,16 +1,3 @@
1
- """
2
- The IPCC model for estimating soil organic carbon stock changes in the 0 - 30cm depth interval due to management
3
- changes. This model will attempt to run the Tier 2 methodology and return results. If the Tier 2 methodology cannot be
4
- run, it will attempt to run the Tier 1 methodology and return the results.
5
-
6
- Both tier methodologies are run as Monte Carlo simulations with 10000 iterations, allowing the model to calculate a
7
- `value` (mean), `sd`, `min`, `max` for each year of the model result.
8
-
9
- The requirements in this file are for the Tier 1 methodology only, as it has simpler requirements. The requirements for
10
- the Tier 2 methodology can be found in the
11
- [HESTIA SOC wiki](https://gitlab.com/hestia-earth/hestia-engine-models/-/wikis/Soil-organic-carbon-modelling)
12
- alongside data recommendations, examples and explanations for both tiers.
13
- """
14
1
  from functools import reduce
15
2
  from pydash.objects import merge
16
3
  from types import ModuleType
@@ -18,8 +5,8 @@ from types import ModuleType
18
5
  from hestia_earth.models.log import log_as_table, logRequirements, logShouldRun
19
6
 
20
7
  from .organicCarbonPerHa_utils import format_bool, format_bool_list, format_enum, format_number, format_number_list
21
- from . import organicCarbonPerHa_tier_1_utils as tier_1
22
- from . import organicCarbonPerHa_tier_2_utils as tier_2
8
+ from . import organicCarbonPerHa_tier_1 as tier_1
9
+ from . import organicCarbonPerHa_tier_2 as tier_2
23
10
  from . import MODEL # noqa
24
11
 
25
12
  REQUIREMENTS = {
@@ -1,15 +1,3 @@
1
- """
2
- The IPCC Tier 1 methodology for estimating soil organic carbon stock changes in the 0 - 30cm depth interval due to
3
- management changes.
4
-
5
- The model cannot not run on Sites with polar moist (ecoClimateZone 5) or polar dry (ecoClimateZone 6).
6
-
7
- More information on this model, including data requirements **and** recommendations, and examples can be found in the
8
- [HESTIA SOC wiki](https://gitlab.com/hestia-earth/hestia-engine-models/-/wikis/Soil-organic-carbon-modelling).
9
-
10
- Source: [IPCC 2019, Vol. 4, Chapter 2](https://www.ipcc-nggip.iges.or.jp/public/2019rf/vol4.html).
11
- """
12
-
13
1
  from enum import Enum
14
2
  from functools import reduce
15
3
  from numpy import empty_like, random, vstack
@@ -56,7 +44,7 @@ _LOOKUPS = {
56
44
  "usdaSoilType": "IPCC_SOIL_CATEGORY"
57
45
  }
58
46
 
59
- _TERM_ID = 'organicCarbonPerHa'
47
+ TERM_ID = 'organicCarbonPerHa'
60
48
  _METHOD_CLASSIFICATION = MeasurementMethodClassification.TIER_1_MODEL.value
61
49
 
62
50
  _CLAY_CONTENT_TERM_ID = "clayContent"
@@ -120,7 +108,7 @@ def _measurement(
120
108
  dict
121
109
  A valid HESTIA `Measurement` node, see: https://www.hestia.earth/schema/Measurement.
122
110
  """
123
- measurement = _new_measurement(_TERM_ID) | descriptive_stats_dict
111
+ measurement = _new_measurement(TERM_ID) | descriptive_stats_dict
124
112
  measurement["dates"] = [f"{year}-12-31" for year in timestamps]
125
113
  measurement["depthUpper"] = DEPTH_UPPER
126
114
  measurement["depthLower"] = DEPTH_LOWER
@@ -556,7 +544,7 @@ def should_run(site: dict) -> tuple[bool, dict, dict]:
556
544
  )
557
545
 
558
546
  kwargs = {
559
- "seed": gen_seed(site, MODEL, _TERM_ID),
547
+ "seed": gen_seed(site, MODEL, TERM_ID),
560
548
  "eco_climate_zone": eco_climate_zone,
561
549
  "ipcc_soil_category": ipcc_soil_category,
562
550
  }
@@ -1,13 +1,3 @@
1
- """
2
- The IPCC Tier 2 methodology for estimating soil organic carbon stock changes in the 0 - 30cm depth interval due to
3
- management changes.
4
-
5
- More information on this model, including data requirements **and** recommendations, and examples can be found in the
6
- [HESTIA SOC wiki](https://gitlab.com/hestia-earth/hestia-engine-models/-/wikis/Soil-organic-carbon-modelling).
7
-
8
- Source: [IPCC 2019, Vol. 4, Chapter 5](https://www.ipcc-nggip.iges.or.jp/public/2019rf/vol4.html).
9
- """
10
-
11
1
  from enum import Enum
12
2
  from numpy import array, empty, exp, minimum, random, where, vstack
13
3
  from numpy.typing import NDArray
@@ -49,7 +39,7 @@ _LOOKUPS = {
49
39
  "tillage": "IPCC_TILLAGE_MANAGEMENT_CATEGORY"
50
40
  }
51
41
 
52
- _TERM_ID = 'organicCarbonPerHa'
42
+ TERM_ID = 'organicCarbonPerHa'
53
43
  _METHOD_CLASSIFICATION = MeasurementMethodClassification.TIER_2_MODEL.value
54
44
 
55
45
  _RUN_IN_PERIOD = 5
@@ -134,7 +124,7 @@ def _measurement(
134
124
  dict
135
125
  A valid HESTIA `Measurement` node, see: https://www.hestia.earth/schema/Measurement.
136
126
  """
137
- measurement = _new_measurement(_TERM_ID) | descriptive_stats_dict
127
+ measurement = _new_measurement(TERM_ID) | descriptive_stats_dict
138
128
  measurement["dates"] = [f"{year}-12-31" for year in timestamps]
139
129
  measurement["depthUpper"] = DEPTH_UPPER
140
130
  measurement["depthLower"] = DEPTH_LOWER
@@ -413,7 +403,7 @@ def should_run(site: dict) -> tuple[bool, dict, dict]:
413
403
  _compile_inventory(cycles, measurement_nodes)
414
404
  if should_compile_inventory else ({}, {})
415
405
  )
416
- kwargs["seed"] = gen_seed(site, MODEL, _TERM_ID)
406
+ kwargs["seed"] = gen_seed(site, MODEL, TERM_ID)
417
407
 
418
408
  valid_years = [year for year, group in inventory.items() if group.get(_InventoryKey.SHOULD_RUN)]
419
409
 
@@ -1,13 +1,3 @@
1
- """
2
- Cycle Pasture Grass
3
-
4
- This model estimates the energetic requirements of ruminants and can be used to estimate the amount of grass they graze.
5
- Source:
6
- [IPCC 2019, Vol.4, Chapter 10](https://www.ipcc-nggip.iges.or.jp/public/2019rf/pdf/4_Volume4/19R_V4_Ch10_Livestock.pdf).
7
-
8
- This version of the model will run at the Cycle level, if at least one Cycle Input is given as feed
9
- (see https://www.hestia.earth/schema/Input#isAnimalFeed).
10
- """
11
1
  from hestia_earth.schema import TermTermType
12
2
  from hestia_earth.utils.model import filter_list_term_type
13
3
  from hestia_earth.utils.tools import list_sum, non_empty_list
@@ -1,12 +1,3 @@
1
- """
2
- Above Ground Crop Residue
3
-
4
- This model returns the amounts and destinations of above ground crop residue, working in the following order:
5
- 1. [Above ground crop residue, removed](https://hestia.earth/term/aboveGroundCropResidueRemoved);
6
- 2. [Above ground crop residue, incorporated](https://hestia.earth/term/aboveGroundCropResidueIncorporated);
7
- 3. [Above ground crop residue, burnt](https://hestia.earth/term/aboveGroundCropResidueBurnt);
8
- 4. [Above ground crop residue, left on field](https://hestia.earth/term/aboveGroundCropResidueLeftOnField).
9
- """
10
1
  from functools import reduce
11
2
  from hestia_earth.utils.model import find_term_match
12
3
  from hestia_earth.utils.tools import flatten, list_sum, list_average