hestia-earth-models 0.65.3__py3-none-any.whl → 0.65.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of hestia-earth-models might be problematic. Click here for more details.

Files changed (59) hide show
  1. hestia_earth/models/agribalyse2016/fuelElectricity.py +41 -35
  2. hestia_earth/models/aware/scarcityWeightedWaterUse.py +1 -1
  3. hestia_earth/models/cache_sites.py +2 -0
  4. hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsLandOccupation.py +1 -1
  5. hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsLandTransformation.py +1 -1
  6. hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsTotalLandUseEffects.py +1 -1
  7. hestia_earth/models/cycle/completeness/__init__.py +1 -1
  8. hestia_earth/models/cycle/completeness/electricityFuel.py +4 -2
  9. hestia_earth/models/emepEea2019/nh3ToAirInorganicFertiliser.py +1 -1
  10. hestia_earth/models/geospatialDatabase/precipitationAnnual.py +2 -2
  11. hestia_earth/models/geospatialDatabase/precipitationLongTermAnnualMean.py +2 -2
  12. hestia_earth/models/geospatialDatabase/precipitationMonthly.py +2 -2
  13. hestia_earth/models/geospatialDatabase/temperatureAnnual.py +2 -2
  14. hestia_earth/models/geospatialDatabase/temperatureLongTermAnnualMean.py +2 -2
  15. hestia_earth/models/geospatialDatabase/temperatureMonthly.py +2 -2
  16. hestia_earth/models/hestia/landCover.py +31 -46
  17. hestia_earth/models/hestia/landTransformation100YearAverageDuringCycle.py +49 -0
  18. hestia_earth/models/hestia/landTransformation20YearAverageDuringCycle.py +49 -0
  19. hestia_earth/models/hestia/resourceUse_utils.py +200 -0
  20. hestia_earth/models/hestia/seed_emissions.py +37 -28
  21. hestia_earth/models/hestia/utils.py +48 -0
  22. hestia_earth/models/impact_assessment/emissions.py +20 -5
  23. hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +66 -28
  24. hestia_earth/models/ipcc2019/croppingDuration.py +5 -0
  25. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1_utils.py +26 -142
  26. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2_utils.py +3 -3
  27. hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py +8 -5
  28. hestia_earth/models/linkedImpactAssessment/freshwaterWithdrawalsInputsProduction.py +2 -1
  29. hestia_earth/models/linkedImpactAssessment/landOccupationInputsProduction.py +1 -0
  30. hestia_earth/models/linkedImpactAssessment/landTransformation100YearAverageInputsProduction.py +1 -0
  31. hestia_earth/models/linkedImpactAssessment/landTransformation20YearAverageInputsProduction.py +1 -0
  32. hestia_earth/models/linkedImpactAssessment/utils.py +25 -20
  33. hestia_earth/models/mocking/search-results.json +670 -654
  34. hestia_earth/models/pooreNemecek2018/freshwaterWithdrawalsDuringCycle.py +4 -1
  35. hestia_earth/models/schererPfister2015/nErosionSoilFlux.py +23 -14
  36. hestia_earth/models/schererPfister2015/pErosionSoilFlux.py +23 -15
  37. hestia_earth/models/schererPfister2015/utils.py +3 -5
  38. hestia_earth/models/site/management.py +2 -2
  39. hestia_earth/models/utils/__init__.py +9 -0
  40. hestia_earth/models/utils/blank_node.py +28 -0
  41. hestia_earth/models/utils/ecoClimateZone.py +1 -4
  42. hestia_earth/models/utils/fuel.py +4 -1
  43. hestia_earth/models/utils/impact_assessment.py +7 -5
  44. hestia_earth/models/utils/lookup.py +8 -2
  45. hestia_earth/models/utils/pesticideAI.py +1 -0
  46. hestia_earth/models/version.py +1 -1
  47. {hestia_earth_models-0.65.3.dist-info → hestia_earth_models-0.65.5.dist-info}/METADATA +2 -2
  48. {hestia_earth_models-0.65.3.dist-info → hestia_earth_models-0.65.5.dist-info}/RECORD +59 -53
  49. tests/models/hestia/test_landTransformation100YearAverageDuringCycle.py +30 -0
  50. tests/models/hestia/test_landTransformation20YearAverageDuringCycle.py +31 -0
  51. tests/models/ipcc2019/test_co2ToAirAboveGroundBiomassStockChange.py +3 -1
  52. tests/models/ipcc2019/test_co2ToAirBelowGroundBiomassStockChange.py +3 -1
  53. tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py +3 -1
  54. tests/models/ipcc2019/test_organicCarbonPerHa.py +3 -2
  55. tests/models/ipcc2019/test_organicCarbonPerHa_tier_1_utils.py +15 -11
  56. tests/models/utils/test_blank_node.py +22 -7
  57. {hestia_earth_models-0.65.3.dist-info → hestia_earth_models-0.65.5.dist-info}/LICENSE +0 -0
  58. {hestia_earth_models-0.65.3.dist-info → hestia_earth_models-0.65.5.dist-info}/WHEEL +0 -0
  59. {hestia_earth_models-0.65.3.dist-info → hestia_earth_models-0.65.5.dist-info}/top_level.txt +0 -0
@@ -1,43 +1,44 @@
1
- from functools import reduce
2
1
  from hestia_earth.utils.tools import non_empty_list, flatten, list_sum
3
2
 
4
- from hestia_earth.models.log import log_as_table, logRequirements, logShouldRun
5
- from hestia_earth.models.utils import sum_values, _include
3
+ from hestia_earth.models.log import log_as_table, debugValues, logRequirements, logShouldRun
4
+ from hestia_earth.models.utils import group_by, sum_values, _include
6
5
  from hestia_earth.models.utils.indicator import _new_indicator
7
6
  from hestia_earth.models.utils.impact_assessment import get_product, convert_value_from_cycle
8
7
  from hestia_earth.models.utils.input import load_impacts
9
8
  from . import MODEL
10
9
 
11
10
 
12
- def _indicator(term_id: str, value: float):
11
+ def _indicator(term_id: str, value: float, input: dict):
13
12
  indicator = _new_indicator(term_id, MODEL)
14
13
  indicator['value'] = value
14
+ indicator['inputs'] = [input]
15
15
  return indicator
16
16
 
17
17
 
18
- def _run_indicators(product: dict, term_id: str):
18
+ def _run_indicators(impact_assessment: dict, product: dict, term_id: str):
19
19
  def run(values: list):
20
+ input = values[0].get('input').get('term', {})
20
21
  indicator = values[0].get('indicator')
21
22
  values_from_cycle = non_empty_list([
22
23
  list_sum(value.get('input').get('value')) * value.get('indicator').get('value')
23
24
  for value in values
24
25
  ])
25
- value = convert_value_from_cycle(product, sum_values(values_from_cycle), model=MODEL, term_id=term_id)
26
+ value = convert_value_from_cycle(
27
+ impact_assessment, product, sum_values(values_from_cycle), model=MODEL, term_id=term_id
28
+ )
29
+
30
+ # show values per input in the logs
31
+ debugValues(impact_assessment, model=MODEL, term=term_id,
32
+ value=value,
33
+ coefficient=1,
34
+ input=input.get('@id'))
35
+
26
36
  return (
27
- _indicator(term_id, value) | _include(indicator, ['landCover', 'previousLandCover'])
37
+ _indicator(term_id, value, input) | _include(indicator, ['landCover', 'previousLandCover'])
28
38
  ) if value is not None else None
29
39
  return run
30
40
 
31
41
 
32
- def _group_indicator(group: dict, value: dict):
33
- group_key = ';'.join(non_empty_list([
34
- value.get('indicator').get('landCover', {}).get('@id'),
35
- value.get('indicator').get('previousLandCover', {}).get('@id')
36
- ]))
37
- group[group_key] = group.get(group_key, []) + [value]
38
- return group
39
-
40
-
41
42
  def _run_inputs_production(impact_assessment: dict, product: dict, term_id: str):
42
43
  cycle = impact_assessment.get('cycle', {})
43
44
 
@@ -61,11 +62,13 @@ def _run_inputs_production(impact_assessment: dict, product: dict, term_id: str)
61
62
  value
62
63
  for value in all_indicators
63
64
  if all([
64
- value.get('indicator').get('value', -1) > 0,
65
- list_sum(value.get('input').get('value', [-1]), 0) > 0
65
+ (value.get('indicator').get('value') or -1) > 0,
66
+ (list_sum(value.get('input').get('value')) or -1) > 0
66
67
  ])
67
68
  ]
68
- grouped_indicators = reduce(_group_indicator, valid_indicators, {})
69
+ grouped_indicators = group_by(valid_indicators, [
70
+ 'input.term.@id', 'indicator.landCover.@id', 'indicator.previousLandCover.@id'
71
+ ])
69
72
  has_indicators = bool(valid_indicators)
70
73
 
71
74
  logRequirements(impact_assessment, model=MODEL, term=term_id,
@@ -82,7 +85,9 @@ def _run_inputs_production(impact_assessment: dict, product: dict, term_id: str)
82
85
  should_run = all([has_indicators])
83
86
  logShouldRun(impact_assessment, MODEL, term_id, should_run)
84
87
 
85
- return non_empty_list(flatten(map(_run_indicators(product, term_id), grouped_indicators.values())))
88
+ return non_empty_list(flatten(
89
+ map(_run_indicators(impact_assessment, product, term_id), grouped_indicators.values())
90
+ ))
86
91
 
87
92
 
88
93
  def _should_run_inputs_production(impact_assessment: dict, term_id: str):