hestia-earth-models 0.75.1__py3-none-any.whl → 0.75.3__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 (42) hide show
  1. hestia_earth/models/config/Cycle.json +183 -16
  2. hestia_earth/models/cycle/product/economicValueShare.py +4 -4
  3. hestia_earth/models/emepEea2019/blackCarbonToAirFuelCombustion.py +33 -0
  4. hestia_earth/models/emepEea2019/ch4ToAirFuelCombustion.py +33 -0
  5. hestia_earth/models/emepEea2019/coToAirFuelCombustion.py +33 -0
  6. hestia_earth/models/emepEea2019/nmvocToAirFuelCombustion.py +33 -0
  7. hestia_earth/models/emepEea2019/pm10ToAirFuelCombustion.py +33 -0
  8. hestia_earth/models/emepEea2019/pm25ToAirFuelCombustion.py +33 -0
  9. hestia_earth/models/emepEea2019/tspToAirFuelCombustion.py +33 -0
  10. hestia_earth/models/faostat2018/seed.py +9 -8
  11. hestia_earth/models/geospatialDatabase/histosol.py +31 -11
  12. hestia_earth/models/hestia/aboveGroundCropResidueTotal.py +2 -2
  13. hestia_earth/models/hestia/management.py +5 -4
  14. hestia_earth/models/hestia/soilClassification.py +31 -13
  15. hestia_earth/models/ipcc2019/animal/pastureGrass.py +19 -11
  16. hestia_earth/models/ipcc2019/burning_utils.py +406 -4
  17. hestia_earth/models/ipcc2019/ch4ToAirExcreta.py +26 -8
  18. hestia_earth/models/ipcc2019/ch4ToAirOrganicSoilCultivation.py +8 -11
  19. hestia_earth/models/ipcc2019/co2ToAirOrganicSoilCultivation.py +9 -12
  20. hestia_earth/models/ipcc2019/emissionsToAirOrganicSoilBurning.py +516 -0
  21. hestia_earth/models/ipcc2019/n2OToAirOrganicSoilCultivationDirect.py +10 -13
  22. hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +56 -433
  23. hestia_earth/models/ipcc2019/organicSoilCultivation_utils.py +2 -2
  24. hestia_earth/models/ipcc2019/pastureGrass.py +19 -11
  25. hestia_earth/models/ipcc2019/pastureGrass_utils.py +17 -10
  26. hestia_earth/models/linkedImpactAssessment/emissions.py +1 -1
  27. hestia_earth/models/mocking/search-results.json +1 -1
  28. hestia_earth/models/pefcrGuidanceDocument2017/__init__.py +13 -0
  29. hestia_earth/models/pefcrGuidanceDocument2017/pesticideToAirPesticideApplication.py +29 -0
  30. hestia_earth/models/pefcrGuidanceDocument2017/pesticideToSoilPesticideApplication.py +29 -0
  31. hestia_earth/models/pefcrGuidanceDocument2017/pesticideToWaterPesticideApplication.py +29 -0
  32. hestia_earth/models/pefcrGuidanceDocument2017/utils.py +55 -0
  33. hestia_earth/models/pooreNemecek2018/saplingsDepreciatedAmountPerCycle.py +1 -1
  34. hestia_earth/models/utils/blank_node.py +68 -0
  35. hestia_earth/models/utils/impact_assessment.py +3 -0
  36. hestia_earth/models/version.py +1 -1
  37. hestia_earth/orchestrator/strategies/merge/merge_node.py +32 -2
  38. {hestia_earth_models-0.75.1.dist-info → hestia_earth_models-0.75.3.dist-info}/METADATA +1 -1
  39. {hestia_earth_models-0.75.1.dist-info → hestia_earth_models-0.75.3.dist-info}/RECORD +42 -29
  40. {hestia_earth_models-0.75.1.dist-info → hestia_earth_models-0.75.3.dist-info}/WHEEL +0 -0
  41. {hestia_earth_models-0.75.1.dist-info → hestia_earth_models-0.75.3.dist-info}/licenses/LICENSE +0 -0
  42. {hestia_earth_models-0.75.1.dist-info → hestia_earth_models-0.75.3.dist-info}/top_level.txt +0 -0
@@ -12,13 +12,20 @@ from hestia_earth.models.utils.emission import _new_emission
12
12
  from hestia_earth.models.utils.measurement import most_relevant_measurement_value
13
13
  from hestia_earth.models.utils.input import total_excreta
14
14
  from hestia_earth.models.utils.lookup import get_region_lookup_value
15
+ from hestia_earth.models.utils.property import get_node_property
15
16
  from . import MODEL
16
17
 
17
18
  REQUIREMENTS = {
18
19
  "Cycle": {
19
20
  "cycleDuration": "",
20
21
  "endDate": "",
21
- "practices": [{"@type": "Practice", "value": "", "term.termType": "excretaManagement"}],
22
+ "practices": [{
23
+ "@type": "Practice",
24
+ "term.termType": "excretaManagement",
25
+ "optional": {
26
+ "properties": [{"@type": "Property", "term.id": "methaneConversionFactor"}]
27
+ }
28
+ }],
22
29
  "site": {
23
30
  "@type": "Site",
24
31
  "country": {"@type": "Term", "termType": "region"},
@@ -39,6 +46,7 @@ RETURNS = {
39
46
  }
40
47
  TERM_ID = 'ch4ToAirExcreta'
41
48
  TIER = EmissionMethodTier.TIER_2.value
49
+ _CONV_FACTOR_PROP_ID = REQUIREMENTS['Cycle']['practices'][0]['optional']['properties'][0]['term.id']
42
50
 
43
51
 
44
52
  class DURATION(Enum):
@@ -110,17 +118,27 @@ def _get_ch4_conv_factor(cycle: dict):
110
118
  measurements = cycle.get('site', {}).get('measurements', [])
111
119
  ecoClimateZone = most_relevant_measurement_value(measurements, 'ecoClimateZone', end_date)
112
120
  practices = filter_list_term_type(cycle.get('practices', []), TermTermType.EXCRETAMANAGEMENT)
113
- practice_id = practices[0].get('term', {}).get('@id') if len(practices) > 0 else None
121
+ primary_practice = practices[0] if len(practices) > 0 else {}
122
+ practice_id = primary_practice.get('term', {}).get('@id')
114
123
 
115
124
  debugValues(cycle, model=MODEL, term=TERM_ID,
116
125
  duration=duration_key.value,
117
126
  ecoClimateZone=ecoClimateZone,
118
- practice_id=practice_id)
119
-
120
- return _get_excretaManagement_MCF_from_lookup(practice_id, ecoClimateZone, duration_key) if all([
121
- practice_id,
122
- ecoClimateZone is not None
123
- ]) else None
127
+ excreta_management_practice_id=practice_id)
128
+
129
+ practive_ch4_conv_factor = get_node_property(
130
+ node=primary_practice,
131
+ property=_CONV_FACTOR_PROP_ID,
132
+ find_default_property=False,
133
+ download_from_hestia=False
134
+ ).get('value')
135
+
136
+ return practive_ch4_conv_factor or (
137
+ _get_excretaManagement_MCF_from_lookup(practice_id, ecoClimateZone, duration_key) if all([
138
+ practice_id,
139
+ ecoClimateZone is not None
140
+ ]) else None
141
+ )
124
142
 
125
143
 
126
144
  def _should_run(cycle: dict):
@@ -42,7 +42,7 @@ REQUIREMENTS = {
42
42
  "site": {
43
43
  "@type": "Site",
44
44
  "measurements": [
45
- {"@type": "Measurement", "value": "", "term.@id": "histosol"},
45
+ {"@type": "Measurement", "value": "", "term.@id": "organicSoils"},
46
46
  {"@type": "Measurement", "value": "", "term.@id": "ecoClimateZone"}
47
47
  ]
48
48
  },
@@ -195,10 +195,7 @@ def _should_run(cycle: dict):
195
195
  seed = gen_seed(cycle, MODEL, TERM_ID)
196
196
  rng = np.random.default_rng(seed)
197
197
 
198
- def _get_measurement_content(term_id: str):
199
- return most_relevant_measurement_value(measurements, term_id, end_date)
200
-
201
- histosol = _get_measurement_content('histosol')
198
+ organic_soils = most_relevant_measurement_value(measurements, "organicSoils", end_date)
202
199
  eco_climate_zone = get_eco_climate_zone_value(cycle, as_enum=True)
203
200
  organic_soil_category = assign_organic_soil_category(cycle, log_id=TERM_ID)
204
201
  ditch_category = assign_ditch_category(cycle)
@@ -227,7 +224,7 @@ def _should_run(cycle: dict):
227
224
  ditch_factor=format_nd_array(ditch_factor),
228
225
  ditch_frac=format_nd_array(ditch_frac),
229
226
  land_occupation=format_float(land_occupation),
230
- histosol=format_float(histosol)
227
+ organic_soils=format_float(organic_soils)
231
228
  )
232
229
 
233
230
  should_run = all([
@@ -239,25 +236,25 @@ def _should_run(cycle: dict):
239
236
  ditch_factor,
240
237
  ditch_frac,
241
238
  land_occupation,
242
- histosol
239
+ organic_soils
243
240
  ]
244
241
  )
245
242
  ])
246
243
 
247
244
  logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
248
245
 
249
- return should_run, emission_factor, ditch_factor, ditch_frac, histosol, land_occupation
246
+ return should_run, emission_factor, ditch_factor, ditch_frac, organic_soils, land_occupation
250
247
 
251
248
 
252
249
  def _run(
253
250
  emission_factor: npt.NDArray,
254
251
  ditch_factor: npt.NDArray,
255
252
  ditch_frac: npt.NDArray,
256
- histosol: float,
253
+ organic_soils: float,
257
254
  land_occupation: float
258
255
  ):
259
- land_emission = calc_emission(TERM_ID, emission_factor, histosol, land_occupation)
260
- ditch_emission = calc_emission(TERM_ID, ditch_factor, histosol, land_occupation)
256
+ land_emission = calc_emission(TERM_ID, emission_factor, organic_soils, land_occupation)
257
+ ditch_emission = calc_emission(TERM_ID, ditch_factor, organic_soils, land_occupation)
261
258
 
262
259
  result = (ditch_emission * ditch_frac) + (land_emission * (1 - ditch_frac))
263
260
  descriptive_stats = calc_descriptive_stats(result, _STATS_DEFINITION)
@@ -39,7 +39,7 @@ REQUIREMENTS = {
39
39
  "site": {
40
40
  "@type": "Site",
41
41
  "measurements": [
42
- {"@type": "Measurement", "value": "", "term.@id": "histosol"},
42
+ {"@type": "Measurement", "value": "", "term.@id": "organicSoils"},
43
43
  {"@type": "Measurement", "value": "", "term.@id": "ecoClimateZone"}
44
44
  ]
45
45
  },
@@ -164,10 +164,7 @@ def _should_run(cycle: dict):
164
164
  seed = gen_seed(cycle, MODEL, TERM_ID)
165
165
  rng = np.random.default_rng(seed)
166
166
 
167
- def _get_measurement_content(term_id: str):
168
- return most_relevant_measurement_value(measurements, term_id, end_date)
169
-
170
- histosol = _get_measurement_content('histosol')
167
+ organic_soils = most_relevant_measurement_value(measurements, "organicSoils", end_date)
171
168
  eco_climate_zone = get_eco_climate_zone_value(cycle, as_enum=True)
172
169
  organic_soil_category = assign_organic_soil_category(cycle, log_id=TERM_ID)
173
170
 
@@ -183,7 +180,7 @@ def _should_run(cycle: dict):
183
180
  organic_soil_category=organic_soil_category,
184
181
  emission_factor=format_nd_array(emission_factor),
185
182
  land_occupation=format_float(land_occupation),
186
- histosol=format_float(histosol)
183
+ organic_soils=format_float(organic_soils)
187
184
  )
188
185
 
189
186
  should_run = all([
@@ -193,22 +190,22 @@ def _should_run(cycle: dict):
193
190
  var is not None for var in [
194
191
  emission_factor,
195
192
  land_occupation,
196
- histosol
193
+ organic_soils
197
194
  ]
198
195
  )
199
196
  ])
200
197
 
201
198
  logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
202
199
 
203
- return should_run, emission_factor, histosol, land_occupation
200
+ return should_run, emission_factor, organic_soils, land_occupation
204
201
 
205
202
 
206
- def _run(emission_factor: npt.NDArray, histosol: float, land_occupation: float):
207
- result = calc_emission(TERM_ID, emission_factor, histosol, land_occupation)
203
+ def _run(emission_factor: npt.NDArray, organic_soils: float, land_occupation: float):
204
+ result = calc_emission(TERM_ID, emission_factor, organic_soils, land_occupation)
208
205
  descriptive_stats = calc_descriptive_stats(result, _STATS_DEFINITION)
209
206
  return [_emission(descriptive_stats)]
210
207
 
211
208
 
212
209
  def run(cycle: dict):
213
- should_run, emission_factor, histosol, land_occupation = _should_run(cycle)
214
- return _run(emission_factor, histosol, land_occupation) if should_run else []
210
+ should_run, emission_factor, organic_soils, land_occupation = _should_run(cycle)
211
+ return _run(emission_factor, organic_soils, land_occupation) if should_run else []