hestia-earth-models 0.72.2__py3-none-any.whl → 0.73.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 (144) hide show
  1. hestia_earth/models/{akagiEtAl2011AndIpcc2006 → akagiEtAl2011}/__init__.py +1 -1
  2. hestia_earth/models/akagiEtAl2011/ch4ToAirCropResidueBurning.py +32 -0
  3. hestia_earth/models/akagiEtAl2011/nh3ToAirCropResidueBurning.py +32 -0
  4. hestia_earth/models/akagiEtAl2011/noxToAirCropResidueBurning.py +32 -0
  5. hestia_earth/models/akagiEtAl2011/pm25ToAirCropResidueBurning.py +32 -0
  6. hestia_earth/models/akagiEtAl2011/so2ToAirCropResidueBurning.py +32 -0
  7. hestia_earth/models/akagiEtAl2011/utils.py +45 -0
  8. hestia_earth/models/aware/scarcityWeightedWaterUse.py +10 -9
  9. hestia_earth/models/cache_sites.py +8 -4
  10. hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsLandTransformation.py +14 -11
  11. hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsTotalLandUseEffects.py +1 -1
  12. hestia_earth/models/chaudharyBrooks2018/utils.py +5 -3
  13. hestia_earth/models/config/Cycle.json +48 -7
  14. hestia_earth/models/config/ImpactAssessment.json +22 -0
  15. hestia_earth/models/cycle/completeness/electricityFuel.py +1 -1
  16. hestia_earth/models/cycle/completeness/freshForage.py +1 -1
  17. hestia_earth/models/cycle/completeness/soilAmendment.py +1 -1
  18. hestia_earth/models/cycle/input/hestiaAggregatedData.py +1 -2
  19. hestia_earth/models/cycle/product/economicValueShare.py +4 -2
  20. hestia_earth/models/cycle/product/price.py +35 -10
  21. hestia_earth/models/cycle/product/revenue.py +5 -2
  22. hestia_earth/models/dammgen2009/noxToAirExcreta.py +14 -18
  23. hestia_earth/models/ecoinventV3/__init__.py +11 -6
  24. hestia_earth/models/ecoinventV3AndEmberClimate/utils.py +1 -1
  25. hestia_earth/models/emepEea2019/utils.py +2 -1
  26. hestia_earth/models/environmentalFootprintV3_1/environmentalFootprintSingleOverallScore.py +1 -1
  27. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandOccupation.py +11 -11
  28. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandTransformation.py +14 -11
  29. hestia_earth/models/faostat2018/liveweightPerHead.py +1 -1
  30. hestia_earth/models/faostat2018/product/price.py +2 -2
  31. hestia_earth/models/faostat2018/seed.py +3 -2
  32. hestia_earth/models/faostat2018/utils.py +32 -18
  33. hestia_earth/models/geospatialDatabase/altitude.py +2 -1
  34. hestia_earth/models/geospatialDatabase/drainageClass.py +2 -1
  35. hestia_earth/models/geospatialDatabase/organicCarbonPerKgSoil.py +2 -1
  36. hestia_earth/models/geospatialDatabase/totalNitrogenPerKgSoil.py +2 -1
  37. hestia_earth/models/geospatialDatabase/totalPhosphorusPerKgSoil.py +2 -1
  38. hestia_earth/models/geospatialDatabase/utils.py +7 -5
  39. hestia_earth/models/globalCropWaterModel2008/rootingDepth.py +1 -1
  40. hestia_earth/models/hestia/brackishWater.py +1 -1
  41. hestia_earth/models/hestia/default_emissions.py +105 -0
  42. hestia_earth/models/hestia/default_resourceUse.py +110 -0
  43. hestia_earth/models/hestia/excretaKgMass.py +7 -9
  44. hestia_earth/models/hestia/freshWater.py +1 -1
  45. hestia_earth/models/hestia/inorganicFertiliser.py +12 -12
  46. hestia_earth/models/hestia/landCover.py +7 -5
  47. hestia_earth/models/hestia/landTransformation100YearAverageDuringCycle.py +3 -0
  48. hestia_earth/models/hestia/landTransformation20YearAverageDuringCycle.py +3 -0
  49. hestia_earth/models/hestia/liveAnimal.py +1 -1
  50. hestia_earth/models/hestia/management.py +1 -1
  51. hestia_earth/models/hestia/netPrimaryProduction.py +1 -1
  52. hestia_earth/models/hestia/organicCarbonPerHa.py +2 -2
  53. hestia_earth/models/hestia/salineWater.py +1 -1
  54. hestia_earth/models/hestia/seed_emissions.py +35 -21
  55. hestia_earth/models/hestia/stockingDensityAnimalHousingAverage.py +1 -1
  56. hestia_earth/models/hestia/totalNitrogenPerKgSoil.py +1 -1
  57. hestia_earth/models/hestia/waterSalinity.py +3 -2
  58. hestia_earth/models/ipcc2006/aboveGroundCropResidueRemoved.py +2 -2
  59. hestia_earth/models/ipcc2006/aboveGroundCropResidueTotal.py +10 -6
  60. hestia_earth/models/ipcc2006/belowGroundCropResidue.py +12 -8
  61. hestia_earth/models/ipcc2019/animal/utils.py +1 -1
  62. hestia_earth/models/ipcc2019/belowGroundCropResidue.py +1 -1
  63. hestia_earth/models/ipcc2019/carbonContent.py +1 -1
  64. hestia_earth/models/ipcc2019/ch4ToAirAquacultureSystems.py +18 -10
  65. hestia_earth/models/ipcc2019/ch4ToAirEntericFermentation.py +6 -6
  66. hestia_earth/models/ipcc2019/ch4ToAirExcreta.py +4 -2
  67. hestia_earth/models/ipcc2019/co2ToAirUreaHydrolysis.py +1 -1
  68. hestia_earth/models/ipcc2019/croppingDuration.py +4 -2
  69. hestia_earth/models/ipcc2019/ligninContent.py +1 -1
  70. hestia_earth/models/{akagiEtAl2011AndIpcc2006 → ipcc2019}/n2OToAirCropResidueBurningDirect.py +8 -4
  71. hestia_earth/models/ipcc2019/nitrogenContent.py +1 -1
  72. hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +6 -2
  73. hestia_earth/models/ipcc2019/pastureGrass_utils.py +13 -12
  74. hestia_earth/models/ipcc2019/utils.py +6 -2
  75. hestia_earth/models/koble2014/residueBurnt.py +6 -3
  76. hestia_earth/models/koble2014/residueRemoved.py +1 -1
  77. hestia_earth/models/mocking/search-results.json +1614 -1610
  78. hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py +1 -1
  79. hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py +1 -1
  80. hestia_earth/models/pooreNemecek2018/excretaKgVs.py +1 -1
  81. hestia_earth/models/pooreNemecek2018/freshwaterWithdrawalsDuringCycle.py +44 -6
  82. hestia_earth/models/pooreNemecek2018/longFallowDuration.py +1 -1
  83. hestia_earth/models/pooreNemecek2018/nurseryDensity.py +1 -1
  84. hestia_earth/models/pooreNemecek2018/nurseryDuration.py +1 -1
  85. hestia_earth/models/pooreNemecek2018/plantationDensity.py +1 -1
  86. hestia_earth/models/pooreNemecek2018/plantationLifespan.py +1 -1
  87. hestia_earth/models/pooreNemecek2018/plantationProductiveLifespan.py +3 -1
  88. hestia_earth/models/pooreNemecek2018/saplingsDepreciatedAmountPerCycle.py +1 -1
  89. hestia_earth/models/resourceUseNotRelevant/__init__.py +65 -0
  90. hestia_earth/models/schererPfister2015/nErosionSoilFlux.py +5 -3
  91. hestia_earth/models/schererPfister2015/pErosionSoilFlux.py +5 -3
  92. hestia_earth/models/schererPfister2015/utils.py +5 -4
  93. hestia_earth/models/site/grouped_measurement.py +1 -1
  94. hestia_earth/models/stehfestBouwman2006/n2OToAirSoilFlux_utils.py +1 -1
  95. hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirSoilFlux_utils.py +3 -3
  96. hestia_earth/models/utils/background_emissions.py +15 -11
  97. hestia_earth/models/utils/blank_node.py +6 -4
  98. hestia_earth/models/utils/crop.py +1 -1
  99. hestia_earth/models/utils/cropResidue.py +16 -0
  100. hestia_earth/models/utils/cycle.py +1 -1
  101. hestia_earth/models/utils/ecoClimateZone.py +2 -2
  102. hestia_earth/models/utils/excretaManagement.py +1 -1
  103. hestia_earth/models/utils/feedipedia.py +3 -3
  104. hestia_earth/models/utils/fertiliser.py +7 -1
  105. hestia_earth/models/utils/impact_assessment.py +29 -14
  106. hestia_earth/models/utils/inorganicFertiliser.py +2 -2
  107. hestia_earth/models/utils/input.py +34 -1
  108. hestia_earth/models/utils/liveAnimal.py +2 -2
  109. hestia_earth/models/utils/lookup.py +6 -2
  110. hestia_earth/models/utils/measurement.py +4 -4
  111. hestia_earth/models/utils/productivity.py +1 -1
  112. hestia_earth/models/utils/property.py +4 -2
  113. hestia_earth/models/utils/site.py +2 -1
  114. hestia_earth/models/version.py +1 -1
  115. {hestia_earth_models-0.72.2.dist-info → hestia_earth_models-0.73.1.dist-info}/METADATA +1 -1
  116. {hestia_earth_models-0.72.2.dist-info → hestia_earth_models-0.73.1.dist-info}/RECORD +138 -127
  117. tests/models/akagiEtAl2011/test_ch4ToAirCropResidueBurning.py +33 -0
  118. tests/models/akagiEtAl2011/test_nh3ToAirCropResidueBurning.py +33 -0
  119. tests/models/{akagiEtAl2011AndIpcc2006 → akagiEtAl2011}/test_noxToAirCropResidueBurning.py +5 -17
  120. tests/models/akagiEtAl2011/test_pm25ToAirCropResidueBurning.py +33 -0
  121. tests/models/akagiEtAl2011/test_so2ToAirCropResidueBurning.py +33 -0
  122. tests/models/akagiEtAl2011/test_utils.py +18 -0
  123. tests/models/cycle/product/test_price.py +1 -11
  124. tests/models/dammgen2009/test_noxToAirExcreta.py +30 -10
  125. tests/models/geospatialDatabase/test_utils.py +2 -1
  126. tests/models/hestia/test_default_emissions.py +25 -0
  127. tests/models/hestia/test_default_resourceUse.py +26 -0
  128. tests/models/hestia/test_landCover.py +2 -2
  129. tests/models/ipcc2019/test_ch4ToAirAquacultureSystems.py +2 -2
  130. tests/models/{akagiEtAl2011AndIpcc2006/test_nh3ToAirCropResidueBurning.py → ipcc2019/test_n2OToAirCropResidueBurningDirect.py} +2 -2
  131. tests/models/pooreNemecek2018/test_freshwaterWithdrawalsDuringCycle.py +12 -0
  132. tests/models/test_resourceUseNotRelevant.py +27 -0
  133. tests/models/{akagiEtAl2011AndIpcc2006/test_utils.py → utils/test_cropResidue.py} +6 -6
  134. tests/models/utils/test_impact_assessment.py +29 -13
  135. hestia_earth/models/akagiEtAl2011AndIpcc2006/ch4ToAirCropResidueBurning.py +0 -57
  136. hestia_earth/models/akagiEtAl2011AndIpcc2006/nh3ToAirCropResidueBurning.py +0 -57
  137. hestia_earth/models/akagiEtAl2011AndIpcc2006/noxToAirCropResidueBurning.py +0 -57
  138. hestia_earth/models/akagiEtAl2011AndIpcc2006/utils.py +0 -15
  139. tests/models/akagiEtAl2011AndIpcc2006/test_ch4ToAirCropResidueBurning.py +0 -45
  140. tests/models/akagiEtAl2011AndIpcc2006/test_n2OToAirCropResidueBurningDirect.py +0 -46
  141. {hestia_earth_models-0.72.2.dist-info → hestia_earth_models-0.73.1.dist-info}/LICENSE +0 -0
  142. {hestia_earth_models-0.72.2.dist-info → hestia_earth_models-0.73.1.dist-info}/WHEEL +0 -0
  143. {hestia_earth_models-0.72.2.dist-info → hestia_earth_models-0.73.1.dist-info}/top_level.txt +0 -0
  144. /tests/models/{akagiEtAl2011AndIpcc2006 → akagiEtAl2011}/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  from typing import Optional
2
2
  from hestia_earth.schema import TermTermType
3
- from hestia_earth.utils.model import find_term_match, filter_list_term_type
3
+ from hestia_earth.utils.model import filter_list_term_type
4
4
  from hestia_earth.utils.tools import list_sum, safe_parse_date
5
5
 
6
6
  from hestia_earth.models.log import debugValues
@@ -50,7 +50,7 @@ def get_site(impact_assessment: dict) -> dict:
50
50
  return impact_assessment.get('site') or impact_assessment.get('cycle', {}).get('site') or {}
51
51
 
52
52
 
53
- def get_region_id(impact_assessment: dict) -> str:
53
+ def get_region_id(impact_assessment: dict, blank_node: dict = None) -> str:
54
54
  """
55
55
  Get the country or region @id of the ImpactAssessment.
56
56
  Note: level 1 GADM region will be returned only, even if the region is of level > 1.
@@ -59,18 +59,29 @@ def get_region_id(impact_assessment: dict) -> str:
59
59
  ----------
60
60
  impact_assessment : dict
61
61
  The `ImpactAssessment`.
62
+ blank_node : dict
63
+ If getting a value for a specific `emissionsResourceUse`, will try to get country from it.
62
64
 
63
65
  Returns
64
66
  -------
65
67
  str
66
68
  The `@id` of the `region`.
67
69
  """
68
- site = get_site(impact_assessment)
69
- term_id = site.get('region', site.get('country', impact_assessment.get('country', {}))).get('@id')
70
- return term_id if not term_id.startswith('GADM') else region_level_1_id(term_id)
71
-
72
-
73
- def get_country_id(impact_assessment: dict) -> str:
70
+ term_id: str = (
71
+ (blank_node or {}).get('region') or
72
+ (blank_node or {}).get('country') or
73
+ impact_assessment.get('country') or
74
+ get_site(impact_assessment).get('region') or
75
+ get_site(impact_assessment).get('country') or
76
+ {}
77
+ ).get('@id')
78
+ return (
79
+ term_id if not term_id.startswith('GADM-') else
80
+ region_level_1_id(term_id)
81
+ ) if term_id else None
82
+
83
+
84
+ def get_country_id(impact_assessment: dict, blank_node: dict = None) -> str:
74
85
  """
75
86
  Get the country or @id of the ImpactAssessment.
76
87
 
@@ -78,13 +89,21 @@ def get_country_id(impact_assessment: dict) -> str:
78
89
  ----------
79
90
  impact_assessment : dict
80
91
  The `ImpactAssessment`.
92
+ blank_node : dict
93
+ If getting a value for a specific `emissionsResourceUse`, will try to get country from it.
81
94
 
82
95
  Returns
83
96
  -------
84
97
  str
85
98
  The `@id` of the `country`.
86
99
  """
87
- return impact_assessment.get('country', get_site(impact_assessment).get('country', {})).get('@id')
100
+ term_id = (
101
+ (blank_node or {}).get('country') or
102
+ impact_assessment.get('country') or
103
+ get_site(impact_assessment).get('country') or
104
+ {}
105
+ ).get('@id')
106
+ return term_id if term_id else None
88
107
 
89
108
 
90
109
  def impact_emission_lookup_value(
@@ -170,7 +189,7 @@ def impact_country_value(
170
189
  lookup_col=country_id,
171
190
  blank_nodes=blank_nodes,
172
191
  grouped_key=group_key,
173
- default_no_values=None,
192
+ default_no_values=default_no_values,
174
193
  factor_value_func=_term_factor_value
175
194
  )
176
195
 
@@ -251,10 +270,6 @@ def impact_endpoint_value(model: str, term_id: str, impact: dict, lookup_col: st
251
270
  )
252
271
 
253
272
 
254
- def emission_value(impact_assessment: dict, term_id: str):
255
- return find_term_match(impact_assessment.get('emissionsResourceUse', []), term_id).get('value')
256
-
257
-
258
273
  def convert_value_from_cycle(
259
274
  log_node: dict, product: dict, value: float, default=None, model: str = None, term_id: str = None
260
275
  ):
@@ -31,12 +31,12 @@ def get_NH3_emission_factor(term_id: str, soilPh: float, temperature: float):
31
31
  soilPh_key = _get_soilPh_lookup_key(soilPh)
32
32
  temperature_key = _get_temperature_lookup_key(temperature)
33
33
  data = get_term_lookup(term_id, f"NH3_emissions_factor_{soilPh_key}")
34
- return safe_parse_float(extract_grouped_data(data, temperature_key), None)
34
+ return safe_parse_float(extract_grouped_data(data, temperature_key), default=None)
35
35
 
36
36
 
37
37
  def get_country_breakdown(model: str, term_id: str, country_id: str, col_name: str):
38
38
  value = get_region_lookup_value(BREAKDOWN_LOOKUP, country_id, col_name, model=model, term=term_id)
39
- return safe_parse_float(value, None)
39
+ return safe_parse_float(value, default=None)
40
40
 
41
41
 
42
42
  def get_cycle_inputs(cycle: dict):
@@ -4,7 +4,7 @@ from hestia_earth.utils.tools import list_sum, non_empty_list, list_average, fla
4
4
  from hestia_earth.utils.lookup import download_lookup, get_table_value, column_name
5
5
 
6
6
  from hestia_earth.models.log import logger
7
- from . import _filter_list_term_unit, _load_calculated_node
7
+ from . import _filter_list_term_unit, _load_calculated_node, group_by
8
8
  from .constant import Units
9
9
  from .blank_node import get_total_value, get_total_value_converted, get_lookup_value
10
10
  from .term import download_term
@@ -148,3 +148,36 @@ def total_excreta(inputs: list, units=Units.KG_N):
148
148
  def get_total_irrigation_m3(cycle: dict):
149
149
  irrigation_inputs = filter_list_term_type(cycle.get('inputs', []), TermTermType.WATER)
150
150
  return sum([list_average(i.get('value')) for i in irrigation_inputs if len(i.get('value', [])) > 0])
151
+
152
+
153
+ def _group_inputs(inputs: list):
154
+ grouped_inputs = group_by(inputs, ['input.term.@id'])
155
+ return [
156
+ inputs[0] | {'value': list_sum(flatten([v.get('input-value') for v in inputs]))}
157
+ for inputs in grouped_inputs.values()
158
+ ]
159
+
160
+
161
+ def _input_data(input: dict):
162
+ return {
163
+ 'input': input,
164
+ 'input-value': list_sum(input.get('value'), default=None),
165
+ 'has-linked-impact-assessment': bool(input.get('impactAssessment')),
166
+ 'is-fromCycle': input.get('fromCycle', False),
167
+ 'is-producedInCycle': input.get('producedInCycle', False)
168
+ }
169
+
170
+
171
+ def unique_background_inputs(cycle: dict):
172
+ inputs = non_empty_list(map(_input_data, cycle.get('inputs', [])))
173
+
174
+ # sum up inputs with the same id
175
+ return _group_inputs([
176
+ v for v in inputs
177
+ if all([
178
+ v.get('input-value') or -1 > 0,
179
+ not v.get('has-linked-impact-assessment'),
180
+ not v.get('is-fromCycle'),
181
+ not v.get('is-producedInCycle')
182
+ ])
183
+ ])
@@ -33,8 +33,8 @@ def get_default_digestibility(model: str, term_id: str, cycle: dict):
33
33
  lookup_col = column_name(product_id)
34
34
  value = get_table_value(lookup, 'termid', system_id, lookup_col)
35
35
  debugMissingLookup(lookup_name, 'termid', term_id, lookup_col, value, model=model, term=term_id)
36
- min = safe_parse_float(extract_grouped_data(value, 'min'), None)
37
- max = safe_parse_float(extract_grouped_data(value, 'max'), None)
36
+ min = safe_parse_float(extract_grouped_data(value, 'min'), default=None)
37
+ max = safe_parse_float(extract_grouped_data(value, 'max'), default=None)
38
38
  if min and max:
39
39
  return mean([min, max])
40
40
 
@@ -28,7 +28,7 @@ def _factor_value(model: str, term_id: str, lookup_name: str, lookup_col: str, g
28
28
  coefficient = safe_parse_float(
29
29
  extract_grouped_data(coefficient, grouped_data_key),
30
30
  default=None
31
- ) if ':' in str(coefficient) else safe_parse_float(coefficient, None)
31
+ ) if ':' in str(coefficient) else safe_parse_float(coefficient, default=None)
32
32
  if value is not None and coefficient is not None:
33
33
  if model:
34
34
  debugValues(data, model=model, term=term_id,
@@ -44,7 +44,11 @@ def _term_factor_value(model: str, term_id: str, lookup_name: str, lookup_term_i
44
44
  def get_value(data: dict):
45
45
  node_term_id = data.get('term', {}).get('@id')
46
46
  value = _node_value(data)
47
- coefficient = get_region_lookup_value(lookup_name, lookup_term_id, node_term_id, model=model, term=term_id)
47
+ # when getting data for a `region`, we can try to get the `region` on the node first, in case it is set
48
+ region_term_id = (
49
+ (data.get('region') or data.get('country') or {'@id': lookup_term_id}).get('@id')
50
+ ) if lookup_term_id.startswith('GADM-') else lookup_term_id
51
+ coefficient = get_region_lookup_value(lookup_name, region_term_id, node_term_id, model=model, term=term_id)
48
52
  coefficient = safe_parse_float(
49
53
  extract_grouped_data(coefficient, group_key) if group_key else coefficient,
50
54
  default=None
@@ -32,17 +32,17 @@ def _new_measurement(term, method=None):
32
32
  return include_method(node, term_id=method)
33
33
 
34
34
 
35
- def measurement_value(measurement: dict, is_larger_unit: bool = False) -> float:
35
+ def measurement_value(measurement: dict, is_larger_unit: bool = False, default=None) -> float:
36
36
  term = measurement.get('term', {})
37
37
  reducer = get_lookup_value(term, 'arrayTreatmentLargerUnitOfTime' if is_larger_unit else 'arrayTreatment') or 'mean'
38
38
  value = non_empty_list(measurement.get('value', []))
39
39
  is_value_valid = value is not None and isinstance(value, list) and len(value) > 0
40
- return MEASUREMENT_REDUCE.get(reducer, lambda v: v[0])(value) if is_value_valid else 0
40
+ return MEASUREMENT_REDUCE.get(reducer, lambda v: v[0])(value) if is_value_valid else default
41
41
 
42
42
 
43
43
  def most_relevant_measurement_value(measurements: list, term_id: str, date: str, default=None):
44
44
  measurement = most_relevant_blank_node_by_id(measurements, term_id, date)
45
- return measurement_value(measurement) if measurement else default
45
+ return measurement_value(measurement, default=default) if measurement else default
46
46
 
47
47
 
48
48
  def _group_measurement_key(measurement: dict, include_dates: bool = True):
@@ -167,7 +167,7 @@ def most_relevant_measurement_value_by_depth_and_date(
167
167
 
168
168
  def depth_distance(depth_string):
169
169
  split = depth_string.split('_')
170
- upper, lower = safe_parse_float(split[0]), safe_parse_float(split[2]) # "a_to_b"
170
+ upper, lower = safe_parse_float(split[0], default=0), safe_parse_float(split[2], default=0) # "a_to_b"
171
171
  return abs(upper - depth_upper) + abs(lower - depth_lower)
172
172
 
173
173
  nearest_key = min(grouped_measurements.keys(), key=depth_distance)
@@ -17,5 +17,5 @@ PRODUCTIVITY_KEY = {
17
17
 
18
18
 
19
19
  def get_productivity(country: dict, default: PRODUCTIVITY = PRODUCTIVITY.HIGH):
20
- hdi = safe_parse_float(get_lookup_value(country, 'hdi'), None)
20
+ hdi = safe_parse_float(get_lookup_value(country, 'hdi'), default=None)
21
21
  return next((key for key in PRODUCTIVITY_KEY if hdi and PRODUCTIVITY_KEY[key](hdi)), default)
@@ -132,9 +132,11 @@ def get_node_property_value_converted(model: str, node: dict, prop_id: str, defa
132
132
 
133
133
  def _get_nitrogen_content(node: dict):
134
134
  return safe_parse_float(
135
- get_node_property(node, 'nitrogenContent').get('value', 0)) if node else 0
135
+ get_node_property(node, 'nitrogenContent').get('value', 0), default=0
136
+ ) if node else 0
136
137
 
137
138
 
138
139
  def _get_nitrogen_tan_content(node: dict):
139
140
  return safe_parse_float(
140
- get_node_property(node, 'totalAmmoniacalNitrogenContentAsN').get('value', 0)) if node else 0
141
+ get_node_property(node, 'totalAmmoniacalNitrogenContentAsN').get('value', 0), default=0
142
+ ) if node else 0
@@ -1,5 +1,5 @@
1
1
  from typing import Optional
2
-
2
+ from functools import lru_cache
3
3
  from hestia_earth.schema import SchemaType, SiteSiteType, TermTermType
4
4
  from hestia_earth.utils.api import find_related
5
5
  from hestia_earth.utils.tools import non_empty_list, flatten, safe_parse_date
@@ -130,6 +130,7 @@ def region_factor(model: str, region_id: str, term_id: str, termType: TermTermTy
130
130
  return get_region_lookup_value(f"region-{termType.value}.csv", region_id, term_id, model=model, term=term_id)
131
131
 
132
132
 
133
+ @lru_cache()
133
134
  def get_land_cover_term_id(site_type: str):
134
135
  land_cover_terms = get_land_cover_siteTypes()
135
136
  term = next((
@@ -1 +1 @@
1
- VERSION = '0.72.2'
1
+ VERSION = '0.73.1'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hestia-earth-models
3
- Version: 0.72.2
3
+ Version: 0.73.1
4
4
  Summary: HESTIA's set of modules for filling gaps in the activity data using external datasets (e.g. populating soil properties with a geospatial dataset using provided coordinates) and internal lookups (e.g. populating machinery use from fuel use). Includes rules for when gaps should be filled versus not (e.g. never gap fill yield, gap fill crop residue if yield provided etc.).
5
5
  Home-page: https://gitlab.com/hestia-earth/hestia-engine-models
6
6
  Author: HESTIA Team