hestia-earth-models 0.67.0__py3-none-any.whl → 0.68.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. hestia_earth/models/aware/scarcityWeightedWaterUse.py +5 -6
  2. hestia_earth/models/blonkConsultants2016/ch4ToAirNaturalVegetationBurning.py +1 -1
  3. hestia_earth/models/blonkConsultants2016/co2ToAirAboveGroundBiomassStockChangeLandUseChange.py +1 -1
  4. hestia_earth/models/blonkConsultants2016/n2OToAirNaturalVegetationBurningDirect.py +1 -1
  5. hestia_earth/models/blonkConsultants2016/utils.py +9 -9
  6. hestia_earth/models/cache_sites.py +26 -14
  7. hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsLandOccupation.py +2 -2
  8. hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsLandTransformation.py +2 -2
  9. hestia_earth/models/chaudharyBrooks2018/utils.py +13 -8
  10. hestia_earth/models/cml2001Baseline/abioticResourceDepletionFossilFuels.py +2 -3
  11. hestia_earth/models/cml2001Baseline/abioticResourceDepletionMineralsAndMetals.py +1 -1
  12. hestia_earth/models/cml2001Baseline/resourceUseEnergyDepletionDuringCycle.py +5 -10
  13. hestia_earth/models/config/Cycle.json +15 -0
  14. hestia_earth/models/config/ImpactAssessment.json +14 -1
  15. hestia_earth/models/config/Site.json +8 -0
  16. hestia_earth/models/cycle/completeness/freshForage.py +7 -3
  17. hestia_earth/models/cycle/excretaKgMass.py +2 -2
  18. hestia_earth/models/cycle/inorganicFertiliser.py +67 -17
  19. hestia_earth/models/cycle/materialAndSubstrate.py +3 -2
  20. hestia_earth/models/cycle/pastureGrass.py +3 -3
  21. hestia_earth/models/dammgen2009/noxToAirExcreta.py +1 -1
  22. hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py +1 -1
  23. hestia_earth/models/ecoinventV3AndEmberClimate/utils.py +2 -6
  24. hestia_earth/models/emissionNotRelevant/__init__.py +4 -4
  25. hestia_earth/models/environmentalFootprintV3_1/environmentalFootprintSingleOverallScore.py +60 -46
  26. hestia_earth/models/environmentalFootprintV3_1/photochemicalOzoneCreationPotentialHumanHealthNmvocEq.py +36 -0
  27. hestia_earth/models/environmentalFootprintV3_1/scarcityWeightedWaterUse.py +2 -2
  28. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandOccupation.py +9 -8
  29. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandTransformation.py +45 -34
  30. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexTotalLandUseEffects.py +24 -21
  31. hestia_earth/models/faostat2018/coldCarcassWeightPerHead.py +2 -2
  32. hestia_earth/models/faostat2018/coldDressedCarcassWeightPerHead.py +2 -2
  33. hestia_earth/models/faostat2018/liveweightPerHead.py +7 -8
  34. hestia_earth/models/faostat2018/product/price.py +34 -28
  35. hestia_earth/models/faostat2018/readyToCookWeightPerHead.py +2 -2
  36. hestia_earth/models/faostat2018/utils.py +15 -27
  37. hestia_earth/models/frischknechtEtAl2000/ionisingRadiationKbqU235Eq.py +16 -9
  38. hestia_earth/models/geospatialDatabase/altitude.py +60 -0
  39. hestia_earth/models/geospatialDatabase/croppingIntensity.py +1 -1
  40. hestia_earth/models/geospatialDatabase/ecoClimateZone.py +2 -2
  41. hestia_earth/models/geospatialDatabase/longFallowRatio.py +1 -1
  42. hestia_earth/models/geospatialDatabase/utils.py +4 -1
  43. hestia_earth/models/globalCropWaterModel2008/rootingDepth.py +2 -3
  44. hestia_earth/models/haversineFormula/transport/distance.py +3 -3
  45. hestia_earth/models/hestia/landCover.py +72 -45
  46. hestia_earth/models/hestia/landTransformation100YearAverageDuringCycle.py +1 -1
  47. hestia_earth/models/hestia/landTransformation20YearAverageDuringCycle.py +1 -1
  48. hestia_earth/models/hestia/seed_emissions.py +11 -7
  49. hestia_earth/models/impact_assessment/__init__.py +3 -3
  50. hestia_earth/models/ipcc2019/aboveGroundBiomass.py +1 -1
  51. hestia_earth/models/ipcc2019/animal/fatContent.py +1 -1
  52. hestia_earth/models/ipcc2019/animal/hoursWorkedPerDay.py +1 -1
  53. hestia_earth/models/ipcc2019/animal/liveweightGain.py +1 -1
  54. hestia_earth/models/ipcc2019/animal/liveweightPerHead.py +1 -1
  55. hestia_earth/models/ipcc2019/animal/milkYieldPerAnimal.py +1 -1
  56. hestia_earth/models/ipcc2019/animal/pastureGrass.py +1 -1
  57. hestia_earth/models/ipcc2019/animal/pregnancyRateTotal.py +1 -1
  58. hestia_earth/models/ipcc2019/animal/trueProteinContent.py +1 -1
  59. hestia_earth/models/ipcc2019/animal/utils.py +5 -7
  60. hestia_earth/models/ipcc2019/animal/weightAtMaturity.py +1 -1
  61. hestia_earth/models/ipcc2019/belowGroundBiomass.py +1 -1
  62. hestia_earth/models/ipcc2019/ch4ToAirEntericFermentation.py +2 -2
  63. hestia_earth/models/ipcc2019/ch4ToAirExcreta.py +6 -7
  64. hestia_earth/models/ipcc2019/ch4ToAirFloodedRice.py +5 -3
  65. hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +1 -1
  66. hestia_earth/models/ipcc2019/croppingDuration.py +3 -6
  67. hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +947 -0
  68. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1_utils.py +4 -4
  69. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2_utils.py +1 -1
  70. hestia_earth/models/ipcc2019/pastureGrass.py +1 -1
  71. hestia_earth/models/koble2014/residueBurnt.py +5 -7
  72. hestia_earth/models/koble2014/residueRemoved.py +5 -7
  73. hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthWaterStress.py +2 -2
  74. hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthWaterStress.py +2 -2
  75. hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthWaterStress.py +2 -2
  76. hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthWaterStress.py +2 -2
  77. hestia_earth/models/log.py +1 -1
  78. hestia_earth/models/mocking/search-results.json +3477 -1045
  79. hestia_earth/models/site/management.py +1 -1
  80. hestia_earth/models/site/post_checks/__init__.py +3 -2
  81. hestia_earth/models/site/post_checks/country.py +9 -0
  82. hestia_earth/models/site/pre_checks/__init__.py +3 -2
  83. hestia_earth/models/site/pre_checks/country.py +9 -0
  84. hestia_earth/models/utils/__init__.py +1 -16
  85. hestia_earth/models/utils/blank_node.py +89 -36
  86. hestia_earth/models/utils/completeness.py +3 -2
  87. hestia_earth/models/utils/cycle.py +5 -4
  88. hestia_earth/models/utils/ecoClimateZone.py +2 -2
  89. hestia_earth/models/utils/emission.py +5 -5
  90. hestia_earth/models/utils/feedipedia.py +6 -6
  91. hestia_earth/models/utils/impact_assessment.py +6 -6
  92. hestia_earth/models/utils/indicator.py +9 -7
  93. hestia_earth/models/utils/inorganicFertiliser.py +4 -6
  94. hestia_earth/models/utils/input.py +6 -5
  95. hestia_earth/models/utils/lookup.py +35 -105
  96. hestia_earth/models/utils/management.py +4 -4
  97. hestia_earth/models/utils/measurement.py +6 -7
  98. hestia_earth/models/utils/method.py +20 -0
  99. hestia_earth/models/utils/practice.py +4 -5
  100. hestia_earth/models/utils/product.py +4 -5
  101. hestia_earth/models/utils/property.py +12 -22
  102. hestia_earth/models/utils/site.py +14 -8
  103. hestia_earth/models/utils/term.py +27 -1
  104. hestia_earth/models/version.py +1 -1
  105. hestia_earth/orchestrator/log.py +0 -11
  106. hestia_earth/orchestrator/models/__init__.py +17 -4
  107. hestia_earth/orchestrator/strategies/run/add_blank_node_if_missing.py +2 -20
  108. {hestia_earth_models-0.67.0.dist-info → hestia_earth_models-0.68.0.dist-info}/METADATA +2 -2
  109. {hestia_earth_models-0.67.0.dist-info → hestia_earth_models-0.68.0.dist-info}/RECORD +159 -151
  110. tests/models/cml2001Baseline/test_abioticResourceDepletionFossilFuels.py +3 -3
  111. tests/models/cml2001Baseline/test_resourceUseEnergyDepletionDuringCycle.py +68 -35
  112. tests/models/cycle/test_coldCarcassWeightPerHead.py +1 -1
  113. tests/models/cycle/test_coldDressedCarcassWeightPerHead.py +1 -1
  114. tests/models/cycle/test_concentrateFeed.py +1 -1
  115. tests/models/cycle/test_energyContentLowerHeatingValue.py +1 -1
  116. tests/models/cycle/test_excretaKgMass.py +1 -1
  117. tests/models/cycle/test_feedConversionRatio.py +3 -3
  118. tests/models/cycle/test_pastureGrass.py +1 -1
  119. tests/models/cycle/test_readyToCookWeightPerHead.py +1 -1
  120. tests/models/environmentalFootprintV3_1/test_environmentalFootprintSingleOverallScore.py +38 -8
  121. tests/models/environmentalFootprintV3_1/test_photochemicalOzoneCreationPotentialHumanHealthNmvocEq.py +30 -0
  122. tests/models/environmentalFootprintV3_1/test_soilQualityIndexLandTransformation.py +65 -36
  123. tests/models/environmentalFootprintV3_1/test_soilQualityIndexTotalLandUseEffects.py +30 -7
  124. tests/models/faostat2018/product/test_price.py +27 -14
  125. tests/models/faostat2018/test_faostat_utils.py +4 -24
  126. tests/models/faostat2018/test_liveweightPerHead.py +9 -9
  127. tests/models/globalCropWaterModel2008/test_rootingDepth.py +7 -3
  128. tests/models/haversineFormula/transport/test_distance.py +1 -1
  129. tests/models/hestia/test_landCover.py +53 -5
  130. tests/models/ipcc2019/animal/test_pastureGrass.py +5 -3
  131. tests/models/ipcc2019/test_aboveGroundCropResidueTotal.py +4 -4
  132. tests/models/ipcc2019/test_belowGroundCropResidue.py +4 -4
  133. tests/models/ipcc2019/test_ch4ToAirEntericFermentation.py +10 -10
  134. tests/models/ipcc2019/test_croppingDuration.py +1 -1
  135. tests/models/ipcc2019/test_nonCo2EmissionsToAirNaturalVegetationBurning.py +83 -0
  136. tests/models/ipcc2019/test_organicCarbonPerHa.py +12 -12
  137. tests/models/ipcc2019/test_pastureGrass.py +5 -3
  138. tests/models/pooreNemecek2018/test_excretaKgN.py +5 -5
  139. tests/models/pooreNemecek2018/test_excretaKgVs.py +2 -2
  140. tests/models/site/post_checks/test_country.py +6 -0
  141. tests/models/site/pre_checks/test_cache_geospatialDatabase.py +1 -1
  142. tests/models/site/pre_checks/test_country.py +12 -0
  143. tests/models/site/test_management.py +1 -4
  144. tests/models/test_ecoinventV3.py +7 -3
  145. tests/models/utils/test_blank_node.py +17 -177
  146. tests/models/utils/test_dataCompleteness.py +5 -5
  147. tests/models/utils/test_emission.py +2 -2
  148. tests/models/utils/test_indicator.py +2 -2
  149. tests/models/utils/test_input.py +2 -2
  150. tests/models/utils/test_measurement.py +2 -4
  151. tests/models/utils/test_practice.py +4 -2
  152. tests/models/utils/test_product.py +2 -2
  153. tests/models/utils/test_property.py +4 -2
  154. tests/models/utils/test_site.py +7 -0
  155. tests/orchestrator/models/test_transformations.py +4 -1
  156. tests/orchestrator/strategies/run/test_add_blank_node_if_missing.py +4 -9
  157. hestia_earth/models/environmentalFootprintV3_1/utils.py +0 -17
  158. tests/models/utils/test_lookup.py +0 -10
  159. {hestia_earth_models-0.67.0.dist-info → hestia_earth_models-0.68.0.dist-info}/LICENSE +0 -0
  160. {hestia_earth_models-0.67.0.dist-info → hestia_earth_models-0.68.0.dist-info}/WHEEL +0 -0
  161. {hestia_earth_models-0.67.0.dist-info → hestia_earth_models-0.68.0.dist-info}/top_level.txt +0 -0
@@ -17,7 +17,7 @@ def fake_rounded_indicator(value: float):
17
17
  return indicator
18
18
 
19
19
 
20
- def fake_download_hestia(filename, column_name):
20
+ def fake_get_terms(filename, column_name):
21
21
  data = {
22
22
  'fuel.csv': ["lignite", "conventionalCrudeOil", "naturalGas", "coalTar"],
23
23
  'electricity.csv': ['electricityGridMarketMix', 'electricityGridHardCoal', 'electricityProducedOnSiteHardCoal',
@@ -105,7 +105,7 @@ good_nuclear_indicator_mj = {
105
105
  "good nuclear fuel use indicator in mj",
106
106
  ]
107
107
  )
108
- @patch(f"{class_path}.get_all_non_renewable_terms", side_effect=fake_download_hestia)
108
+ @patch(f"{class_path}.get_all_non_renewable_terms", side_effect=fake_get_terms)
109
109
  def test_should_run(mock_get_all_non_renewable_terms, resources, expected, num_inputs):
110
110
  with open(f"{fixtures_folder}/impactassessment.jsonld", encoding='utf-8') as f:
111
111
  impactassessment = json.load(f)
@@ -117,7 +117,7 @@ def test_should_run(mock_get_all_non_renewable_terms, resources, expected, num_i
117
117
  assert len(resources) == num_inputs
118
118
 
119
119
 
120
- @patch(f"{class_path}.get_all_non_renewable_terms", side_effect=fake_download_hestia)
120
+ @patch(f"{class_path}.get_all_non_renewable_terms", side_effect=fake_get_terms)
121
121
  @patch(f"{class_path}._indicator", side_effect=fake_rounded_indicator)
122
122
  def test_run(*args):
123
123
  with open(f"{fixtures_folder}/impactassessment.jsonld", encoding='utf-8') as f:
@@ -9,38 +9,72 @@ from tests.utils import fixtures_path, fake_new_indicator
9
9
  class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
10
10
  fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
11
11
 
12
- diesel_input = {"term": {"termType": "fuel", "units": "kg", "@id": "diesel"}, "value": 2}
13
- diesel_input_in_mj = {"term": {"termType": "fuel", "units": "MJ", "@id": "diesel"}, "value": 111}
14
- diesel_input_wrong_unit = {"term": {"termType": "fuel", "units": "foobedoos", "@id": "diesel"}, "value": 2}
15
- diesel_input_no_unit = {"term": {"termType": "fuel", "@id": "diesel"}, "value": 2}
16
- diesel_input_with_properties = {"term": {"termType": "fuel", "units": "kg", "@id": "diesel"},
17
- "value": 2,
18
- "properties": [{"term": {"@id": "energyContentHigherHeatingValue", }, "value": 70}]
19
- }
20
- diesel_input_with_properties2 = {"term": {"termType": "fuel", "units": "kg", "@id": "diesel"},
21
- "value": 2,
22
- "properties": [{"term": {"@id": "energyContentHigherHeatingValue", }, "value": 4}]
23
- }
24
-
25
- electricity_input = {"term": {"termType": "electricity", "units": "kWh", "@id": "electricityGridOil"}, "value": 30}
26
-
27
- input_coal_tar_kg = {"term": {"@id": "coalTar", "termType": "fuel", "units": "kg",
28
- "name": "Coal tar unknown energy Content"},
29
- "value": 5}
30
-
31
- input_crude_oil_kg_property = {"term": {"@id": "conventionalCrudeOil", "termType": "fuel", "units": "kg"},
32
- "value": 5,
33
- "properties": [{"@type": "Property", "value": 45.8,
34
- "term": {"@type": "Term", "@id": "energyContentHigherHeatingValue",
35
- "units": "MJ / kg"}, }]}
36
-
37
- input_crude_oil_kg_no_property = {"term": {"@id": "conventionalCrudeOil", "termType": "fuel", "units": "kg"},
38
- "value": 5}
39
-
40
- input_natural_gas_m3 = {"term": {"@id": "naturalGas", "termType": "fuel", "units": "m3"}, "value": 5}
41
-
42
- input_nuclear_fuel_kwh = {"term": {"@id": "electricityGridNuclear", "termType": "electricity", "units": "kWh"},
43
- "value": 1.3889}
12
+ diesel_input = {
13
+ "term": {"termType": "fuel", "units": "kg", "@id": "diesel"},
14
+ "value": 2,
15
+ "properties": [{"term": {"@id": "energyContentLowerHeatingValue", }, "value": 70}]
16
+ }
17
+ diesel_input_in_mj = {
18
+ "term": {"termType": "fuel", "units": "MJ", "@id": "diesel"},
19
+ "value": 111
20
+ }
21
+ diesel_input_wrong_unit = {
22
+ "term": {"termType": "fuel", "units": "foobedoos", "@id": "diesel"},
23
+ "value": 2
24
+ }
25
+ diesel_input_no_unit = {
26
+ "term": {"termType": "fuel", "@id": "diesel"},
27
+ "value": 2
28
+ }
29
+ diesel_input_with_properties = {
30
+ "term": {"termType": "fuel", "units": "kg", "@id": "diesel"},
31
+ "value": 2,
32
+ "properties": [{"term": {"@id": "energyContentLowerHeatingValue", }, "value": 70}]
33
+ }
34
+ diesel_input_with_properties2 = {
35
+ "term": {"termType": "fuel", "units": "kg", "@id": "diesel"},
36
+ "value": 2,
37
+ "properties": [{"term": {"@id": "energyContentLowerHeatingValue", }, "value": 4}]
38
+ }
39
+
40
+ electricity_input = {
41
+ "term": {"termType": "electricity", "units": "kWh", "@id": "electricityGridOil"},
42
+ "value": 30
43
+ }
44
+
45
+ input_coal_tar_kg = {
46
+ "term": {"@id": "coalTar", "termType": "fuel", "units": "kg", "name": "Coal tar unknown energy Content"},
47
+ "value": 5
48
+ }
49
+
50
+ input_crude_oil_kg_property = {
51
+ "term": {"@id": "conventionalCrudeOil", "termType": "fuel", "units": "kg"},
52
+ "value": 5,
53
+ "properties": [{
54
+ "@type": "Property",
55
+ "value": 45.8,
56
+ "term": {"@type": "Term", "@id": "energyContentLowerHeatingValue", "units": "MJ / kg"},
57
+ }]
58
+ }
59
+
60
+ input_natural_gas_m3 = {
61
+ "term": {"@id": "naturalGas", "termType": "fuel", "units": "m3"},
62
+ "value": 5,
63
+ "properties": [{
64
+ "@type": "Property",
65
+ "value": 45.8,
66
+ "term": {"@type": "Term", "@id": "energyContentLowerHeatingValue", "units": "MJ / kg"},
67
+ }, {
68
+ "@type": "Property",
69
+ "value": 45.8,
70
+ "term": {"@type": "Term", "@id": "density", "units": "kg / m3"},
71
+ }]
72
+ }
73
+
74
+ input_nuclear_fuel_kwh = {
75
+ "term": {"@id": "electricityGridNuclear", "termType": "electricity", "units": "kWh"},
76
+ "value": 1.3889
77
+ }
44
78
 
45
79
 
46
80
  @pytest.mark.parametrize(
@@ -57,7 +91,6 @@ input_nuclear_fuel_kwh = {"term": {"@id": "electricityGridNuclear", "termType":
57
91
  ([electricity_input], True, 1),
58
92
  ([electricity_input, electricity_input, electricity_input], True, 1),
59
93
  ([input_crude_oil_kg_property], True, 1),
60
- ([input_crude_oil_kg_no_property], True, 1),
61
94
  ([input_natural_gas_m3], True, 1),
62
95
  ([input_nuclear_fuel_kwh], True, 1),
63
96
  ([input_coal_tar_kg], False, 0),
@@ -74,13 +107,13 @@ input_nuclear_fuel_kwh = {"term": {"@id": "electricityGridNuclear", "termType":
74
107
  "good electric input => run",
75
108
  "multiple good merg-able electric inputs => run",
76
109
  "good fuel with input property",
77
- "good fuel with no input property",
78
110
  "good fuel in m^3",
79
111
  "good nuclear fuel use indicator in kWh",
80
112
  "bad indicator input in kg no property to convert to mj"
81
113
  ]
82
114
  )
83
- def test_should_run(inputs, expected, num_inputs):
115
+ @patch('hestia_earth.models.utils.property.download_term', return_value={})
116
+ def test_should_run(mock_download, inputs, expected, num_inputs):
84
117
  with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
85
118
  cycle = json.load(f)
86
119
 
@@ -34,7 +34,7 @@ def test_should_run():
34
34
  assert should_run is True
35
35
 
36
36
 
37
- @patch("hestia_earth.models.utils.property.download_hestia", return_value={'units': '%'})
37
+ @patch("hestia_earth.models.utils.property.download_term", return_value={'units': '%'})
38
38
  @patch(f"{class_path}._new_property", side_effect=fake_new_property)
39
39
  def test_run(*args):
40
40
  with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
@@ -34,7 +34,7 @@ def test_should_run():
34
34
  assert should_run is True
35
35
 
36
36
 
37
- @patch("hestia_earth.models.utils.property.download_hestia", return_value={'units': '%'})
37
+ @patch("hestia_earth.models.utils.property.download_term", return_value={'units': '%'})
38
38
  @patch(f"{class_path}._new_property", side_effect=fake_new_property)
39
39
  def test_run(*args):
40
40
  with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
@@ -37,7 +37,7 @@ def test_should_run(mock_primary_product, *args):
37
37
  assert should_run is True
38
38
 
39
39
 
40
- @patch('hestia_earth.models.utils.property.download_hestia', return_value={}) # make sure default props are not loaded
40
+ @patch('hestia_earth.models.utils.property.download_term', return_value={}) # make sure default props are not loaded
41
41
  @patch(f"{class_path}.get_energy_digestibility_terms", return_value=ED_TERM_IDS)
42
42
  @patch(f"{class_path}.get_digestible_energy_terms", return_value=DE_TERM_IDS)
43
43
  @patch(f"{class_path}._new_property", side_effect=fake_new_property)
@@ -24,7 +24,7 @@ def test_should_run_input():
24
24
  assert _should_run_input({})(input) is True
25
25
 
26
26
 
27
- @patch("hestia_earth.models.utils.property.download_hestia", return_value={'units': '%'})
27
+ @patch("hestia_earth.models.utils.property.download_term", return_value={'units': '%'})
28
28
  @patch(f"{class_path}.get_wood_fuel_terms", return_value=['woodPellets', 'woodFuel'])
29
29
  @patch(f"{class_path}._new_property", side_effect=fake_new_property)
30
30
  def test_run(*args):
@@ -84,7 +84,7 @@ def test_should_run():
84
84
  assert should_run is True
85
85
 
86
86
 
87
- @patch(f"{class_path}.download_hestia", side_effect=lambda id, *args: TERMS[id])
87
+ @patch(f"{class_path}.download_term", side_effect=lambda id, *args: TERMS[id])
88
88
  @patch(f"{class_path}._new_product", side_effect=fake_new_product)
89
89
  def test_run(*args):
90
90
  with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
@@ -14,7 +14,7 @@ TERMS_BY_ID = {
14
14
  }
15
15
 
16
16
 
17
- def fake_download_hestia(term_id: str, *args): return TERMS_BY_ID[term_id]
17
+ def fake_download_term(term_id: str, *args): return TERMS_BY_ID[term_id]
18
18
 
19
19
 
20
20
  @patch(f"{class_path}.get_total_value_converted_with_min_ratio", return_value=10)
@@ -37,7 +37,7 @@ def test_should_run(*args):
37
37
  assert should_run is True
38
38
 
39
39
 
40
- @patch("hestia_earth.models.utils.property.download_hestia", side_effect=fake_download_hestia)
40
+ @patch("hestia_earth.models.utils.property.download_term", side_effect=fake_download_term)
41
41
  @patch(f"{class_path}.is_run_required", return_value=True)
42
42
  @patch(f"{class_path}._new_practice", side_effect=fake_new_practice)
43
43
  def test_run(*args):
@@ -51,7 +51,7 @@ def test_run(*args):
51
51
  assert value == expected
52
52
 
53
53
 
54
- @patch("hestia_earth.models.utils.property.download_hestia", side_effect=fake_download_hestia)
54
+ @patch("hestia_earth.models.utils.property.download_term", side_effect=fake_download_term)
55
55
  @patch(f"{class_path}.is_run_required", return_value=True)
56
56
  @patch(f"{class_path}._new_practice", side_effect=fake_new_practice)
57
57
  def test_run_with_carcass(*args):
@@ -18,7 +18,7 @@ def test_should_run():
18
18
  assert _should_run(cycle) is True
19
19
 
20
20
 
21
- @patch(f"{class_path}.download_hestia", return_value={'@type': 'Term', '@id': KEY_TERM_ID})
21
+ @patch(f"{class_path}.download_term", return_value={'@type': 'Term', '@id': KEY_TERM_ID})
22
22
  @patch(f"{class_path}._new_practice", side_effect=fake_new_practice)
23
23
  def test_run(*args):
24
24
  with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
@@ -34,7 +34,7 @@ def test_should_run():
34
34
  assert should_run is True
35
35
 
36
36
 
37
- @patch("hestia_earth.models.utils.property.download_hestia", return_value={'units': '%'})
37
+ @patch("hestia_earth.models.utils.property.download_term", return_value={'units': '%'})
38
38
  @patch(f"{class_path}._new_property", side_effect=fake_new_property)
39
39
  def test_run(*args):
40
40
  with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
@@ -18,31 +18,55 @@ def fake_rounded_indicator(value: float):
18
18
  return indicator
19
19
 
20
20
 
21
+ methodModelEFV31 = {"@type": "Term", "@id": "environmentalFootprintV3-1"}
22
+ methodModelFantkeEtAl2016 = {"@type": "Term", "@id": "fantkeEtAl2016"}
23
+
21
24
  ozone_indicator = {"@type": "Indicator",
22
25
  "term": {"@id": "ozoneDepletionPotential", "termType": "characterisedIndicator"},
23
- "value": 0}
26
+ "value": 0,
27
+ "methodModel": {"@type": "Term", "@id": "edip2003"}}
24
28
 
29
+ other_valid_ozone_indicator = {"@type": "Indicator",
30
+ "term": {"@id": "ozoneDepletionPotential", "termType": "characterisedIndicator"},
31
+ "value": 0,
32
+ "methodModel": {"@type": "Term", "@id": "recipe2016Hierarchist"}}
25
33
  acid_indicator = {
26
34
  "@type": "Indicator",
27
35
  "term": {"@id": "terrestrialAcidificationPotentialAccumulatedExceedance", "termType": "characterisedIndicator"},
28
- "value": 0.000420443840380047}
36
+ "value": 0.000420443840380047,
37
+ "methodModel": {"@type": "Term", "@id": "poschEtAl2008"}
38
+ }
29
39
 
30
40
  bad_indicator_id = {"@type": "Indicator",
31
41
  "term": {"@id": "no_a_real_id", "termType": "characterisedIndicator"},
32
- "value": 0.000420443840380047}
42
+ "value": 0.000420443840380047,
43
+ "methodModel": methodModelEFV31
44
+ }
33
45
 
34
46
  not_pef_indicator = {"@type": "Indicator",
35
47
  "term": {"@id": "gwpStar", "termType": "characterisedIndicator"},
36
- "value": 0.000420443840380047}
48
+ "value": 0.000420443840380047,
49
+ "methodModel": methodModelEFV31
50
+ }
37
51
 
38
52
  bad_indicator_no_val = {"@type": "Indicator",
39
53
  "term": {"@id": "damageToHumanHealthParticulateMatterFormation",
40
- "termType": "characterisedIndicator"}}
54
+ "termType": "characterisedIndicator"},
55
+ "methodModel": methodModelFantkeEtAl2016
56
+ }
41
57
 
42
58
  bad_indicator_bad_val = {"@type": "Indicator",
43
59
  "term": {"@id": "damageToHumanHealthParticulateMatterFormation",
44
60
  "termType": "characterisedIndicator"},
45
- "value": None}
61
+ "value": None,
62
+ "methodModel": methodModelFantkeEtAl2016
63
+ }
64
+
65
+ bad_indicator_no_method_model = {
66
+ "@type": "Indicator",
67
+ "term": {"@id": "terrestrialAcidificationPotentialAccumulatedExceedance", "termType": "characterisedIndicator"},
68
+ "value": 0.000420443840380047
69
+ }
46
70
 
47
71
 
48
72
  @mark.parametrize(
@@ -53,10 +77,13 @@ bad_indicator_bad_val = {"@type": "Indicator",
53
77
  ([not_pef_indicator], False, 0),
54
78
  ([bad_indicator_no_val], False, 0),
55
79
  ([bad_indicator_bad_val], False, 0),
80
+ ([bad_indicator_no_method_model], False, 0),
81
+ ([other_valid_ozone_indicator], False, 0),
56
82
  ([ozone_indicator], True, 1),
57
83
  ([ozone_indicator, ozone_indicator], False, 2),
58
84
  ([ozone_indicator, acid_indicator], True, 2),
59
- ([bad_indicator_no_val, acid_indicator], False, 1)
85
+ ([ozone_indicator, other_valid_ozone_indicator], True, 1),
86
+ ([bad_indicator_no_val, acid_indicator], False, 1),
60
87
  ],
61
88
  ids=[
62
89
  "No indicators => no run",
@@ -64,9 +91,12 @@ bad_indicator_bad_val = {"@type": "Indicator",
64
91
  "not_pef_indicator => no run",
65
92
  "bad_indicator_no_val => no run",
66
93
  "bad_indicator_bad_val => no run",
67
- "ozone_indicator => run",
94
+ "bad_indicator_no_method_model => no run",
95
+ "ozone_indicator not pef=> no run",
96
+ "ozone_indicator pef => run",
68
97
  "2 ozone_indicator => no run",
69
98
  "2 good indicators => run",
99
+ "2 ozone_indicator different methodModel => run with 1",
70
100
  "one bad one good indicator => no run",
71
101
  ]
72
102
  )
@@ -0,0 +1,30 @@
1
+ import json
2
+ from unittest.mock import patch
3
+
4
+ from hestia_earth.models.environmentalFootprintV3_1 import MODEL_FOLDER
5
+ from hestia_earth.models.environmentalFootprintV3_1.photochemicalOzoneCreationPotentialHumanHealthNmvocEq import (
6
+ TERM_ID,
7
+ run,
8
+ )
9
+ from tests.utils import fixtures_path, fake_new_indicator
10
+
11
+ class_path = f"hestia_earth.models.{MODEL_FOLDER}.{TERM_ID}"
12
+ fixtures_folder = f"{fixtures_path}/{MODEL_FOLDER}/{TERM_ID}"
13
+
14
+
15
+ @patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
16
+ def test_run(*args):
17
+ with open(
18
+ f"{fixtures_path}/impact_assessment/emissions/impact-assessment.jsonld",
19
+ encoding="utf-8",
20
+ ) as f:
21
+ impact = json.load(f)
22
+ with open(f"{fixtures_folder}/emissions.jsonld", encoding="utf-8") as f:
23
+ emissions = json.load(f)
24
+
25
+ with open(f"{fixtures_folder}/result.jsonld", encoding="utf-8") as f:
26
+ expected = json.load(f)
27
+
28
+ impact["emissionsResourceUse"] = emissions
29
+ value = run(impact)
30
+ assert value == expected
@@ -22,91 +22,120 @@ def fake_rounded_indicator(value: float):
22
22
  crop_land = {"@id": "cropland", "termType": "landCover"}
23
23
  sea_land_cover = {"@id": "seaOrOcean", "termType": "landCover"}
24
24
  forest = {"@id": "forest", "termType": "landCover"}
25
- indicator = {
25
+
26
+ indicator_inputs_production = {
26
27
  "@id": "landTransformation20YearAverageInputsProduction",
27
28
  "termType": "resourceUse",
28
29
  "units": "m2 / year"
29
30
  }
31
+
32
+ indicator_during_cycle = {
33
+ "@id": "landTransformation20YearAverageDuringCycle",
34
+ "termType": "resourceUse",
35
+ "units": "m2 / year"
36
+ }
37
+
30
38
  wrong_indicator = {"term": {"@id": "NOT_VALID_INDICATOR_ID", "termType": "resourceUse", "units": "m2 / year"},
31
39
  "value": 0.5, "landCover": crop_land, "previousLandCover": forest}
32
40
 
33
41
  indicator_no_land_cover = {
34
- "term": indicator,
42
+ "term": indicator_during_cycle,
35
43
  "previousLandCover": forest,
36
44
  "value": 0.5}
37
45
 
38
46
  indicator_no_previous_land_cover = {
39
- "term": indicator,
47
+ "term": indicator_during_cycle,
40
48
  "landCover": crop_land,
41
49
  "value": 0.5}
42
50
 
43
51
  indicator_bad_area_value = {
44
- "term": indicator,
52
+ "term": indicator_during_cycle,
45
53
  "value": -10,
46
54
  "previousLandCover": forest,
47
55
  "landCover": crop_land}
48
56
 
57
+ indicator_zero_area_value = {
58
+ "term": indicator_during_cycle,
59
+ "value": 0,
60
+ "previousLandCover": forest,
61
+ "landCover": crop_land}
62
+
49
63
  inputs_production_indicator_from_forest_to_no_cf = {
50
- "term": indicator,
64
+ "term": indicator_inputs_production,
65
+ "value": 0.5,
66
+ "previousLandCover": forest,
67
+ "landCover": sea_land_cover}
68
+
69
+ during_cycle_indicator_from_forest_to_no_cf = {
70
+ "term": indicator_during_cycle,
51
71
  "value": 0.5,
52
72
  "previousLandCover": forest,
53
73
  "landCover": sea_land_cover}
54
74
 
55
75
  good_inputs_production_indicator_from_forest_to_cropland = {
56
- "term": indicator,
76
+ "term": indicator_inputs_production,
57
77
  "value": 0.5,
58
78
  "previousLandCover": forest,
59
79
  "landCover": crop_land}
60
80
 
61
81
  good_inputs_production_indicator_from_forest_to_forest = {
62
- "term": indicator,
82
+ "term": indicator_inputs_production,
63
83
  "value": 0.5,
64
84
  "previousLandCover": forest,
65
85
  "landCover": forest}
66
86
 
67
87
  good_during_cycle_indicator_from_forest_to_cropland = {
68
- "term": indicator | {'@id': 'landTransformation20YearAverageDuringCycle'},
88
+ "term": indicator_during_cycle,
69
89
  "value": 0.5,
70
90
  "previousLandCover": forest,
71
91
  "landCover": crop_land}
72
92
 
73
93
  good_during_cycle_indicator_from_forest_to_forest = {
74
- "term": indicator | {'@id': 'landTransformation20YearAverageDuringCycle'},
94
+ "term": indicator_during_cycle,
75
95
  "value": 0.5,
76
96
  "previousLandCover": forest,
77
97
  "landCover": forest}
78
98
 
79
99
 
80
100
  @mark.parametrize(
81
- "resources, expected, num_inputs",
101
+ "test_name, resources, expected, num_inputs",
82
102
  [
83
- ([], False, 0),
84
- ([wrong_indicator], False, 0),
85
- ([indicator_no_land_cover], False, 0),
86
- ([indicator_no_previous_land_cover], False, 0),
87
- ([indicator_bad_area_value], False, 0),
88
- ([good_during_cycle_indicator_from_forest_to_cropland], True, 1),
89
- ([good_during_cycle_indicator_from_forest_to_forest], True, 1),
90
- ([good_inputs_production_indicator_from_forest_to_cropland], True, 1),
91
- ([good_inputs_production_indicator_from_forest_to_forest], True, 1),
92
- ([inputs_production_indicator_from_forest_to_no_cf], True, 0), # todo check
93
- ([good_inputs_production_indicator_from_forest_to_cropland,
94
- good_during_cycle_indicator_from_forest_to_cropland], True, 2)
95
- ],
96
- ids=["No emissionsResourceUse => no run, 0 dict",
97
- "Wrong indicator termid => no run, 0 dict",
98
- "Indicator no landcover terms => no run",
99
- "Indicator no previousLandCover terms => no run",
100
- "Bad m2 / year value => no run",
101
- "One good during cycle transformation => run, 1 dict",
102
- "One 0 during cycle transformation => run, 1 dict",
103
- "One good inputs production transformation => run, 1 dict",
104
- "One 0 inputs production transformation => run, 1 dict",
105
- "One good from transformation and One with no CF (ocean) => run, 2 dict", # todo
106
- "Multiple good indicators => run, 2 dict",
107
- ]
103
+ ("No emissionsResourceUse => no run, 0 dict", [], False, 0),
104
+ ("Wrong indicator termid => no run, 0 dict", [wrong_indicator], False, 0),
105
+ ("Indicator no landcover terms => no run", [indicator_no_land_cover], False, 0),
106
+ ("Indicator no previousLandCover terms => no run", [indicator_no_previous_land_cover], False, 0),
107
+ ("Bad m2 / year area value => no run", [indicator_bad_area_value], False, 0),
108
+ ("One good and one Bad m2 / year area value => no run", [
109
+ good_during_cycle_indicator_from_forest_to_cropland,
110
+ indicator_bad_area_value], False, 1),
111
+ ("One 0 m2 / year area value => filter and run, 0 dict", [indicator_zero_area_value], True, 1),
112
+ ("One good during cycle transformation => run, 1 dict", [good_during_cycle_indicator_from_forest_to_cropland
113
+ ], True, 1),
114
+ ("One 0 during cycle transformation => run, 1 dict", [good_during_cycle_indicator_from_forest_to_forest
115
+ ], True, 1),
116
+ ("Only one good inputs production transformation => no run", [
117
+ good_inputs_production_indicator_from_forest_to_cropland], False, 1),
118
+ ("Good during cycle AND inputs production transformation => run, 2 dict", [
119
+ good_during_cycle_indicator_from_forest_to_cropland,
120
+ good_inputs_production_indicator_from_forest_to_cropland], True, 2),
121
+ ("One 0 inputs production transformation => no run", [
122
+ good_inputs_production_indicator_from_forest_to_forest], False, 1),
123
+ ("Good during cycle AND inputs production 0 transformation => run, 2 dict", [
124
+ good_during_cycle_indicator_from_forest_to_cropland,
125
+ good_inputs_production_indicator_from_forest_to_forest], True, 2),
126
+ ("One transformation with no CF (ocean) => run, 0 dict", [during_cycle_indicator_from_forest_to_no_cf
127
+ ], True, 0),
128
+ ("One good from transformation and One with no CF (ocean) => run, 1 dict", [
129
+ good_inputs_production_indicator_from_forest_to_cropland,
130
+ during_cycle_indicator_from_forest_to_no_cf], True, 1),
131
+ ("Multiple good indicators => run, 2 dict", [good_inputs_production_indicator_from_forest_to_cropland,
132
+ good_during_cycle_indicator_from_forest_to_cropland], True, 2),
133
+ ("One good, one wrong indicator => filter and run, 1 dict", [
134
+ good_during_cycle_indicator_from_forest_to_cropland,
135
+ wrong_indicator], True, 1),
136
+ ]
108
137
  )
109
- def test_should_run(resources: list, expected: bool, num_inputs: int):
138
+ def test_should_run(test_name: str, resources: list, expected: bool, num_inputs: int):
110
139
  with open(f"{fixtures_folder}/multipleTransformations/impact-assessment.jsonld", encoding='utf-8') as f:
111
140
  impact = json.load(f)
112
141
 
@@ -10,14 +10,37 @@ from tests.utils import fixtures_path, fake_new_indicator
10
10
  class_path = f"hestia_earth.models.{MODEL_FOLDER}.{TERM_ID}"
11
11
  fixtures_folder = f"{fixtures_path}/{MODEL_FOLDER}/{TERM_ID}"
12
12
 
13
- transform_indicator = {'term': {'@id': 'soilQualityIndexLandTransformation'}, 'value': 10}
14
- occupation_indicator = {'term': {'@id': 'soilQualityIndexLandOccupation'}, 'value': 10}
15
- missing_value_indicator = {'term': {'@id': 'soilQualityIndexLandOccupation'}}
16
- bad_value_indicator = {'term': {'@id': 'soilQualityIndexLandOccupation'}, 'value': "42"}
13
+ transform_indicator = {
14
+ "term": {
15
+ "@id": "soilQualityIndexLandTransformation",
16
+ "termType": "characterisedIndicator",
17
+ },
18
+ "value": 10,
19
+ }
20
+ occupation_indicator = {
21
+ "term": {
22
+ "@id": "soilQualityIndexLandOccupation",
23
+ "termType": "characterisedIndicator",
24
+ },
25
+ "value": 10,
26
+ }
27
+ missing_value_indicator = {
28
+ "term": {
29
+ "@id": "soilQualityIndexLandOccupation",
30
+ "termType": "characterisedIndicator",
31
+ }
32
+ }
33
+ bad_value_indicator = {
34
+ "term": {
35
+ "@id": "soilQualityIndexLandOccupation",
36
+ "termType": "characterisedIndicator",
37
+ },
38
+ "value": "42",
39
+ }
17
40
 
18
41
 
19
42
  @mark.parametrize(
20
- "emissions_resource_use, expected, num_expected",
43
+ "impacts, expected, num_expected",
21
44
  [
22
45
  ([], False, 0),
23
46
  ([transform_indicator], False, 1),
@@ -32,11 +55,11 @@ bad_value_indicator = {'term': {'@id': 'soilQualityIndexLandOccupation'}, 'value
32
55
  ids=["Empty", "missing obligatory occupation", "duplicate entry", "no value in entry", "bad value in entry",
33
56
  "correct assessment", "just occupation", "multiple occupations and transformations"]
34
57
  )
35
- def test_should_run(emissions_resource_use, expected, num_expected):
58
+ def test_should_run(impacts, expected, num_expected):
36
59
  with open(f"{fixtures_folder}/impactassessment.jsonld", encoding='utf-8') as f:
37
60
  impactassessment = json.load(f)
38
61
 
39
- impactassessment['emissionsResourceUse'] = emissions_resource_use
62
+ impactassessment['impacts'] = impacts
40
63
 
41
64
  should_run, indicators = _should_run(impactassessment)
42
65
  assert should_run is expected