hestia-earth-models 0.74.1__py3-none-any.whl → 0.74.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 (40) hide show
  1. hestia_earth/models/config/Cycle.json +23 -0
  2. hestia_earth/models/config/ImpactAssessment.json +1 -1
  3. hestia_earth/models/cycle/aboveGroundCropResidueTotal.py +50 -0
  4. hestia_earth/models/cycle/completeness/freshForage.py +2 -2
  5. hestia_earth/models/emepEea2019/co2ToAirFuelCombustion.py +2 -27
  6. hestia_earth/models/emepEea2019/fuelCombustion_utils.py +107 -0
  7. hestia_earth/models/emepEea2019/n2OToAirFuelCombustionDirect.py +2 -27
  8. hestia_earth/models/emepEea2019/nh3ToAirFuelCombustion.py +33 -0
  9. hestia_earth/models/emepEea2019/noxToAirFuelCombustion.py +2 -27
  10. hestia_earth/models/emepEea2019/so2ToAirFuelCombustion.py +2 -27
  11. hestia_earth/models/emepEea2019/utils.py +1 -73
  12. hestia_earth/models/hestia/landCover.py +6 -5
  13. hestia_earth/models/hestia/landOccupationDuringCycle.py +264 -0
  14. hestia_earth/models/hestia/management.py +109 -68
  15. hestia_earth/models/hestia/utils.py +0 -1
  16. hestia_earth/models/ipcc2006/aboveGroundCropResidueTotal.py +20 -11
  17. hestia_earth/models/ipcc2019/aboveGroundCropResidueTotal.py +37 -28
  18. hestia_earth/models/ipcc2019/animal/pastureGrass.py +15 -8
  19. hestia_earth/models/ipcc2019/animal/utils.py +2 -2
  20. hestia_earth/models/ipcc2019/pastureGrass.py +7 -2
  21. hestia_earth/models/mocking/search-results.json +1566 -1562
  22. hestia_earth/models/utils/cropResidue.py +5 -0
  23. hestia_earth/models/version.py +1 -1
  24. {hestia_earth_models-0.74.1.dist-info → hestia_earth_models-0.74.3.dist-info}/METADATA +1 -1
  25. {hestia_earth_models-0.74.1.dist-info → hestia_earth_models-0.74.3.dist-info}/RECORD +40 -33
  26. tests/models/cycle/test_aboveGroundCropResidueTotal.py +20 -0
  27. tests/models/emepEea2019/test_co2ToAirFuelCombustion.py +2 -1
  28. tests/models/emepEea2019/test_n2OToAirFuelCombustionDirect.py +2 -1
  29. tests/models/emepEea2019/test_nh3ToAirFuelCombustion.py +34 -0
  30. tests/models/emepEea2019/test_noxToAirFuelCombustion.py +2 -1
  31. tests/models/emepEea2019/test_so2ToAirFuelCombustion.py +2 -1
  32. tests/models/environmentalFootprintV3_1/test_scarcityWeightedWaterUse.py +0 -1
  33. tests/models/hestia/test_landCover.py +1 -1
  34. tests/models/hestia/test_landOccupationDuringCycle.py +68 -0
  35. tests/models/hestia/test_management.py +29 -1
  36. tests/models/ipcc2006/test_aboveGroundCropResidueTotal.py +9 -6
  37. tests/models/ipcc2019/test_aboveGroundCropResidueTotal.py +16 -42
  38. {hestia_earth_models-0.74.1.dist-info → hestia_earth_models-0.74.3.dist-info}/LICENSE +0 -0
  39. {hestia_earth_models-0.74.1.dist-info → hestia_earth_models-0.74.3.dist-info}/WHEEL +0 -0
  40. {hestia_earth_models-0.74.1.dist-info → hestia_earth_models-0.74.3.dist-info}/top_level.txt +0 -0
@@ -188,7 +188,9 @@ def calculate_NEwool(cycle: dict, animal: dict, products: list, total_weight: fl
188
188
  return total_energy * animal_weight/total_weight
189
189
 
190
190
 
191
- def _run_practice(animal: dict, values: dict, meanDE: float, meanECHHV: float, REM: float, REG: float, NEwool: float):
191
+ def _run_practice(
192
+ cycle: dict, animal: dict, values: dict, meanDE: float, meanECHHV: float, REM: float, REG: float, NEwool: float
193
+ ):
192
194
  NEm_feed, NEg_feed, log_feed = calculate_NEfeed(animal)
193
195
 
194
196
  def run(practice: dict):
@@ -225,7 +227,7 @@ def _run_practice(animal: dict, values: dict, meanDE: float, meanECHHV: float, R
225
227
  ])
226
228
  has_positive_feed_values = all([NEm_feed >= 0, NEg_feed >= 0])
227
229
 
228
- logRequirements(animal, model=MODEL, term=input_term_id, model_key=MODEL_KEY,
230
+ logRequirements(cycle, model=MODEL, term=input_term_id, animalId=animal.get('animalId'), model_key=MODEL_KEY,
229
231
  feed_logs=log_as_table(log_feed),
230
232
  has_positive_feed_values=has_positive_feed_values,
231
233
  animal_logs=logs,
@@ -233,7 +235,7 @@ def _run_practice(animal: dict, values: dict, meanDE: float, meanECHHV: float, R
233
235
  animal_properties=animal_properties)
234
236
 
235
237
  should_run = all([has_positive_feed_values])
236
- logShouldRun(animal, MODEL, input_term_id, should_run, model_key=MODEL_KEY)
238
+ logShouldRun(cycle, MODEL, input_term_id, should_run, animalId=animal.get('animalId'), model_key=MODEL_KEY)
237
239
 
238
240
  return _input(input_term_id, value) if should_run else None
239
241
 
@@ -254,7 +256,7 @@ def _run_animal(cycle: dict, meanDE: float, meanECHHV: float, REM: float, REG: f
254
256
  animal_values = get_animal_values(cycle, animal, systems)
255
257
 
256
258
  inputs = non_empty_list(map(
257
- _run_practice(animal, animal_values, meanDE, meanECHHV, REM, REG, NEwool),
259
+ _run_practice(cycle, animal, animal_values, meanDE, meanECHHV, REM, REG, NEwool),
258
260
  practices
259
261
  ))
260
262
  return animal | {
@@ -278,32 +280,37 @@ def _should_run(cycle: dict, animals: list, practices: dict):
278
280
  REM = calculate_REM(meanDE)
279
281
  REG = calculate_REG(meanDE)
280
282
 
283
+ has_practice_termType_system = len(systems) > 0
284
+ has_practice_pastureGrass_with_landCover_key = len(practices) > 0
285
+
281
286
  should_run = all([
282
287
  animalFeed_complete,
283
288
  animalPopulation_complete,
284
289
  freshForage_incomplete,
285
290
  no_cycle_inputs_feed,
286
291
  all_animals_have_value,
287
- len(systems) > 0,
288
- len(practices) > 0,
292
+ has_practice_termType_system,
293
+ has_practice_pastureGrass_with_landCover_key,
289
294
  meanDE > 0,
290
295
  meanECHHV > 0
291
296
  ])
292
297
 
293
298
  for term_id in [MODEL_KEY] + [practice_input_id(p) for p in practices]:
294
299
  for animal in animals:
295
- logRequirements(animal, model=MODEL, term=term_id, model_key=MODEL_KEY,
300
+ logRequirements(cycle, model=MODEL, term=term_id, animalId=animal.get('animalId'), model_key=MODEL_KEY,
296
301
  term_type_animalFeed_complete=animalFeed_complete,
297
302
  term_type_animalPopulation_complete=animalPopulation_complete,
298
303
  term_type_freshForage_incomplete=freshForage_incomplete,
299
304
  no_cycle_inputs_feed=no_cycle_inputs_feed,
300
305
  all_animals_have_value=all_animals_have_value,
306
+ has_practice_termType_system=has_practice_termType_system,
307
+ has_practice_pastureGrass_with_landCover_key=has_practice_pastureGrass_with_landCover_key,
301
308
  grass_MeanDE=calculate_meanDE(practices, term=term_id),
302
309
  grass_MeanECHHV=calculate_meanECHHV(practices, term=term_id),
303
310
  grass_REM=REM,
304
311
  grass_REG=REG)
305
312
 
306
- logShouldRun(animal, MODEL, term_id, should_run, model_key=MODEL_KEY)
313
+ logShouldRun(cycle, MODEL, term_id, should_run, animalId=animal.get('animalId'), model_key=MODEL_KEY)
307
314
 
308
315
  return should_run, meanDE, meanECHHV, REM, REG, systems
309
316
 
@@ -62,7 +62,7 @@ def should_run_by_productivity_lookup(
62
62
  practice = value.get('practice')
63
63
  animal_term_id = animal.get('term').get('@id')
64
64
 
65
- logRequirements(cycle, model=MODEL, term=animal_term_id, property=term_id,
65
+ logRequirements(cycle, model=MODEL, term=animal_term_id, animalId=animal.get('animalId'), property=term_id,
66
66
  country_id=country_id,
67
67
  **({
68
68
  lookup_col.replace('-', '_'): lookup_value
@@ -75,7 +75,7 @@ def should_run_by_productivity_lookup(
75
75
  not practice_column or bool(practice),
76
76
  lookup_value is not None
77
77
  ])
78
- logShouldRun(cycle, MODEL, animal_term_id, should_run, property=term_id)
78
+ logShouldRun(cycle, MODEL, animal_term_id, should_run, animalId=animal.get('animalId'), property=term_id)
79
79
 
80
80
  return should_run
81
81
 
@@ -233,14 +233,17 @@ def _should_run(cycle: dict, practices: dict):
233
233
  REM = calculate_REM(meanDE)
234
234
  REG = calculate_REG(meanDE)
235
235
 
236
+ has_practice_termType_system = len(systems) > 0
237
+ has_practice_pastureGrass_with_landCover_key = len(practices) > 0
238
+
236
239
  should_run = all([
237
240
  animalFeed_complete,
238
241
  animalPopulation_complete,
239
242
  freshForage_incomplete,
240
243
  has_cycle_inputs_feed,
241
244
  all_animals_have_value,
242
- len(systems) > 0,
243
- len(practices) > 0,
245
+ has_practice_termType_system,
246
+ has_practice_pastureGrass_with_landCover_key,
244
247
  meanDE > 0,
245
248
  meanECHHV > 0
246
249
  ])
@@ -252,6 +255,8 @@ def _should_run(cycle: dict, practices: dict):
252
255
  term_type_freshForage_incomplete=freshForage_incomplete,
253
256
  has_cycle_inputs_feed=has_cycle_inputs_feed,
254
257
  all_animals_have_value=all_animals_have_value,
258
+ has_practice_termType_system=has_practice_termType_system,
259
+ has_practice_pastureGrass_with_landCover_key=has_practice_pastureGrass_with_landCover_key,
255
260
  grass_MeanDE=calculate_meanDE(practices, term=term_id),
256
261
  grass_MeanECHHV=calculate_meanECHHV(practices, term=term_id),
257
262
  grass_REM=REM,