hestia-earth-models 0.62.0__py3-none-any.whl → 0.62.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.

Potentially problematic release.


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

Files changed (58) hide show
  1. hestia_earth/models/blonkConsultants2016/utils.py +3 -2
  2. hestia_earth/models/cycle/post_checks/__init__.py +3 -2
  3. hestia_earth/models/cycle/post_checks/otherSites.py +40 -0
  4. hestia_earth/models/cycle/pre_checks/__init__.py +2 -1
  5. hestia_earth/models/cycle/pre_checks/otherSites.py +42 -0
  6. hestia_earth/models/cycle/pre_checks/site.py +1 -1
  7. hestia_earth/models/ecoinventV3AndEmberClimate/utils.py +1 -1
  8. hestia_earth/models/emepEea2019/utils.py +4 -3
  9. hestia_earth/models/geospatialDatabase/heavyWinterPrecipitation.py +1 -1
  10. hestia_earth/models/ipcc2019/animal/pastureGrass.py +6 -6
  11. hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChangeManagementChange.py +30 -4
  12. hestia_earth/models/ipcc2019/n2OToAirExcretaDirect.py +6 -2
  13. hestia_earth/models/ipcc2019/n2OToAirExcretaIndirect.py +1 -1
  14. hestia_earth/models/ipcc2019/n2OToAirInorganicFertiliserDirect.py +1 -1
  15. hestia_earth/models/ipcc2019/n2OToAirInorganicFertiliserIndirect.py +1 -1
  16. hestia_earth/models/ipcc2019/n2OToAirOrganicFertiliserIndirect.py +1 -1
  17. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1_utils.py +4 -2
  18. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2_utils.py +2 -1
  19. hestia_earth/models/ipcc2019/pastureGrass.py +3 -3
  20. hestia_earth/models/ipcc2019/pastureGrass_utils.py +41 -41
  21. hestia_earth/models/mocking/search-results.json +89 -89
  22. hestia_earth/models/schererPfister2015/utils.py +2 -2
  23. hestia_earth/models/site/brackishWater.py +1 -1
  24. hestia_earth/models/site/flowingWater.py +1 -1
  25. hestia_earth/models/site/freshWater.py +1 -1
  26. hestia_earth/models/site/management.py +29 -11
  27. hestia_earth/models/site/pre_checks/cache_sources.py +9 -13
  28. hestia_earth/models/site/salineWater.py +1 -1
  29. hestia_earth/models/stehfestBouwman2006/n2OToAirCropResidueDecompositionDirect.py +12 -2
  30. hestia_earth/models/stehfestBouwman2006/n2OToAirExcretaDirect.py +12 -2
  31. hestia_earth/models/stehfestBouwman2006/n2OToAirInorganicFertiliserDirect.py +11 -1
  32. hestia_earth/models/stehfestBouwman2006/n2OToAirOrganicFertiliserDirect.py +11 -1
  33. hestia_earth/models/stehfestBouwman2006/noxToAirCropResidueDecomposition.py +12 -2
  34. hestia_earth/models/stehfestBouwman2006/noxToAirExcreta.py +12 -2
  35. hestia_earth/models/stehfestBouwman2006/noxToAirInorganicFertiliser.py +11 -1
  36. hestia_earth/models/stehfestBouwman2006/noxToAirOrganicFertiliser.py +11 -1
  37. hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirCropResidueDecomposition.py +12 -2
  38. hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirExcreta.py +12 -2
  39. hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirInorganicFertiliser.py +11 -1
  40. hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirOrganicFertiliser.py +11 -1
  41. hestia_earth/models/utils/blank_node.py +106 -110
  42. hestia_earth/models/utils/constant.py +2 -0
  43. hestia_earth/models/utils/lookup.py +19 -6
  44. hestia_earth/models/utils/source.py +1 -1
  45. hestia_earth/models/version.py +1 -1
  46. {hestia_earth_models-0.62.0.dist-info → hestia_earth_models-0.62.1.dist-info}/METADATA +2 -2
  47. {hestia_earth_models-0.62.0.dist-info → hestia_earth_models-0.62.1.dist-info}/RECORD +58 -53
  48. tests/models/cycle/post_checks/test_otherSites.py +15 -0
  49. tests/models/cycle/pre_checks/test_otherSites.py +21 -0
  50. tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChangeManagementChange.py +5 -3
  51. tests/models/ipcc2019/test_organicCarbonPerHa.py +1 -0
  52. tests/models/site/pre_checks/test_cache_sources.py +6 -10
  53. tests/models/site/test_management.py +162 -2
  54. tests/models/utils/test_blank_node.py +0 -281
  55. tests/models/utils/test_lookup.py +10 -0
  56. {hestia_earth_models-0.62.0.dist-info → hestia_earth_models-0.62.1.dist-info}/LICENSE +0 -0
  57. {hestia_earth_models-0.62.0.dist-info → hestia_earth_models-0.62.1.dist-info}/WHEEL +0 -0
  58. {hestia_earth_models-0.62.0.dist-info → hestia_earth_models-0.62.1.dist-info}/top_level.txt +0 -0
@@ -25,20 +25,20 @@ def _get_grouping(animal: dict) -> str:
25
25
  return get_lookup_value(term, 'ipcc2019AnimalTypeGrouping', model=MODEL, model_key=MODEL_KEY)
26
26
 
27
27
 
28
- def _get_activityCoefficient(cycle: dict, animal: dict, system: dict) -> float:
28
+ def _get_activityCoefficient(cycle: dict, animal: dict, system: dict, log_node: dict) -> float:
29
29
  term = animal.get('term', {})
30
30
  term_id = term.get('@id')
31
31
  system_id = system.get('term', {}).get('@id')
32
32
  lookup = download_lookup('system-liveAnimal-activityCoefficient-ipcc2019.csv')
33
33
  activityCoefficient = safe_parse_float(get_table_value(lookup, 'termid', system_id, column_name(term_id)), 0)
34
34
 
35
- debugValues(cycle, model=MODEL, term=term_id, model_key=MODEL_KEY,
35
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
36
36
  activityCoefficient=activityCoefficient)
37
37
 
38
38
  return activityCoefficient
39
39
 
40
40
 
41
- def _calculate_NEm(cycle: dict, animal: dict) -> float:
41
+ def _calculate_NEm(cycle: dict, animal: dict, log_node: dict) -> float:
42
42
  term = animal.get('term', {})
43
43
  term_id = term.get('@id')
44
44
 
@@ -50,7 +50,7 @@ def _calculate_NEm(cycle: dict, animal: dict) -> float:
50
50
  cycleDuration = cycle.get('cycleDuration', 365)
51
51
  NEm = mjDayKgCfiNetEnergyMaintenance * pow(liveweightPerHead, 0.75) * animal_value * cycleDuration
52
52
 
53
- debugValues(cycle, model=MODEL, term=term_id, model_key=MODEL_KEY,
53
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
54
54
  mjDayKgCfiNetEnergyMaintenance=mjDayKgCfiNetEnergyMaintenance,
55
55
  liveweightPerHead=liveweightPerHead,
56
56
  NEm=NEm)
@@ -58,32 +58,32 @@ def _calculate_NEm(cycle: dict, animal: dict) -> float:
58
58
  return NEm
59
59
 
60
60
 
61
- def _calculate_NEa_cattleAndBuffalo(cycle: dict, animal: dict, system: dict, NEm: float) -> float:
61
+ def _calculate_NEa_cattleAndBuffalo(cycle: dict, animal: dict, system: dict, NEm: float, log_node: dict) -> float:
62
62
  term = animal.get('term', {})
63
63
  term_id = term.get('@id')
64
64
 
65
- activityCoefficient = _get_activityCoefficient(cycle, animal, system)
65
+ activityCoefficient = _get_activityCoefficient(cycle, animal, system, log_node)
66
66
 
67
67
  NEa = activityCoefficient * NEm
68
68
 
69
- debugValues(cycle, model=MODEL, term=term_id, model_key=MODEL_KEY,
69
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
70
70
  NEa=NEa)
71
71
 
72
72
  return NEa
73
73
 
74
74
 
75
- def _calculate_NEa_sheepAndGoat(cycle: dict, animal: dict, system: dict, _NEm: float) -> float:
75
+ def _calculate_NEa_sheepAndGoat(cycle: dict, animal: dict, system: dict, _NEm: float, log_node: dict) -> float:
76
76
  term = animal.get('term', {})
77
77
  term_id = term.get('@id')
78
78
 
79
- activityCoefficient = _get_activityCoefficient(cycle, animal, system)
79
+ activityCoefficient = _get_activityCoefficient(cycle, animal, system, log_node)
80
80
 
81
81
  liveweightPerHead = get_node_property(animal, 'liveweightPerHead', False).get('value', 0)
82
82
  animal_value = animal.get('value', 0)
83
83
  cycleDuration = cycle.get('cycleDuration', 365)
84
84
  NEa = activityCoefficient * liveweightPerHead * animal_value * cycleDuration
85
85
 
86
- debugValues(cycle, model=MODEL, term=term_id, model_key=MODEL_KEY,
86
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
87
87
  liveweightPerHead=liveweightPerHead,
88
88
  NEa=NEa)
89
89
 
@@ -96,12 +96,12 @@ _NEa_BY_GROUPING = {
96
96
  }
97
97
 
98
98
 
99
- def _calculate_NEa(cycle: dict, animal: dict, system: dict, NEm: float) -> float:
99
+ def _calculate_NEa(cycle: dict, animal: dict, system: dict, NEm: float, log_node: dict) -> float:
100
100
  grouping = _get_grouping(animal)
101
- return _NEa_BY_GROUPING.get(grouping, lambda *args: 0)(cycle, animal, system, NEm)
101
+ return _NEa_BY_GROUPING.get(grouping, lambda *args: 0)(cycle, animal, system, NEm, log_node)
102
102
 
103
103
 
104
- def _calculate_NEl_cattleAndBuffalo(cycle: dict, animal: dict) -> float:
104
+ def _calculate_NEl_cattleAndBuffalo(cycle: dict, animal: dict, log_node: dict) -> float:
105
105
  term = animal.get('term', {})
106
106
  term_id = term.get('@id')
107
107
 
@@ -112,7 +112,7 @@ def _calculate_NEl_cattleAndBuffalo(cycle: dict, animal: dict) -> float:
112
112
  cycleDuration = cycle.get('cycleDuration', 365)
113
113
  NEl = milkYield * (1.47 + (0.4 * fatContent)) * animal_value * cycleDuration
114
114
 
115
- debugValues(cycle, model=MODEL, term=term_id, model_key=MODEL_KEY,
115
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
116
116
  milkYield=milkYield,
117
117
  fatContent=fatContent,
118
118
  NEl=NEl)
@@ -120,7 +120,7 @@ def _calculate_NEl_cattleAndBuffalo(cycle: dict, animal: dict) -> float:
120
120
  return NEl
121
121
 
122
122
 
123
- def _calculate_NEl_sheepAndGoat(cycle: dict, animal: dict) -> float:
123
+ def _calculate_NEl_sheepAndGoat(cycle: dict, animal: dict, log_node: dict) -> float:
124
124
  term = animal.get('term', {})
125
125
  term_id = term.get('@id')
126
126
 
@@ -140,7 +140,7 @@ def _calculate_NEl_sheepAndGoat(cycle: dict, animal: dict) -> float:
140
140
  cycleDuration = cycle.get('cycleDuration', 365)
141
141
  NEl = milkYield * (EV_milk * fatContent/default_fatContent) * animal_value * cycleDuration
142
142
 
143
- debugValues(cycle, model=MODEL, term=term_id, model_key=MODEL_KEY,
143
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
144
144
  milkYield=milkYield,
145
145
  EV_milk=EV_milk,
146
146
  NEl=NEl)
@@ -154,19 +154,19 @@ _NEl_BY_GROUPING = {
154
154
  }
155
155
 
156
156
 
157
- def _calculate_NEl(cycle: dict, animal: dict) -> float:
157
+ def _calculate_NEl(cycle: dict, animal: dict, log_node: dict) -> float:
158
158
  grouping = _get_grouping(animal)
159
- return _NEl_BY_GROUPING.get(grouping, lambda *args: 0)(cycle, animal)
159
+ return _NEl_BY_GROUPING.get(grouping, lambda *args: 0)(cycle, animal, log_node)
160
160
 
161
161
 
162
- def _calculate_NEwork(cycle: dict, animal: dict, NEm: float) -> float:
162
+ def _calculate_NEwork(cycle: dict, animal: dict, NEm: float, log_node: dict) -> float:
163
163
  term = animal.get('term', {})
164
164
  term_id = term.get('@id')
165
165
 
166
166
  hoursWorkedPerDay = get_node_property(animal, 'hoursWorkedPerDay').get('value', 0)
167
167
  NEwork = 0.1 * NEm * hoursWorkedPerDay
168
168
 
169
- debugValues(cycle, model=MODEL, term=term_id, model_key=MODEL_KEY,
169
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
170
170
  hoursWorkedPerDay=hoursWorkedPerDay,
171
171
  NEwork=NEwork)
172
172
 
@@ -193,7 +193,7 @@ def _get_pregnancy_ratio(animal: dict) -> float:
193
193
  return _get_pregnancy_ratio_per_birth(animal, value) if ';' in value else safe_parse_float(value, 0)
194
194
 
195
195
 
196
- def _calculate_NEp(cycle: dict, animal: dict, NEm: float) -> float:
196
+ def _calculate_NEp(cycle: dict, animal: dict, NEm: float, log_node: dict) -> float:
197
197
  term = animal.get('term', {})
198
198
  term_id = term.get('@id')
199
199
 
@@ -201,7 +201,7 @@ def _calculate_NEp(cycle: dict, animal: dict, NEm: float) -> float:
201
201
  pregnancyRateTotal = get_node_property(animal, 'pregnancyRateTotal').get('value', 0)
202
202
  NEp = ratioCPregnancyNetEnergyPregnancy * pregnancyRateTotal/100 * NEm
203
203
 
204
- debugValues(cycle, model=MODEL, term=term_id, model_key=MODEL_KEY,
204
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
205
205
  ratioCPregnancyNetEnergyPregnancy=ratioCPregnancyNetEnergyPregnancy,
206
206
  pregnancyRateTotal=pregnancyRateTotal,
207
207
  NEp=NEp)
@@ -209,7 +209,7 @@ def _calculate_NEp(cycle: dict, animal: dict, NEm: float) -> float:
209
209
  return NEp
210
210
 
211
211
 
212
- def _calculate_NEg_cattleAndBuffalo(cycle: dict, animal: dict) -> float:
212
+ def _calculate_NEg_cattleAndBuffalo(cycle: dict, animal: dict, log_node: dict) -> float:
213
213
  term = animal.get('term', {})
214
214
  term_id = term.get('@id')
215
215
 
@@ -228,7 +228,7 @@ def _calculate_NEg_cattleAndBuffalo(cycle: dict, animal: dict) -> float:
228
228
  ratioCNetEnergyGrowthCattleBuffalo * weightAtMaturity > 0
229
229
  ]) else 0
230
230
 
231
- debugValues(cycle, model=MODEL, term=term_id, model_key=MODEL_KEY,
231
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
232
232
  ratioCNetEnergyGrowthCattleBuffalo=ratioCNetEnergyGrowthCattleBuffalo,
233
233
  liveweightPerHead=liveweightPerHead,
234
234
  weightAtMaturity=weightAtMaturity,
@@ -238,7 +238,7 @@ def _calculate_NEg_cattleAndBuffalo(cycle: dict, animal: dict) -> float:
238
238
  return NEg
239
239
 
240
240
 
241
- def _calculate_NEg_sheepAndGoat(cycle: dict, animal: dict) -> float:
241
+ def _calculate_NEg_sheepAndGoat(cycle: dict, animal: dict, log_node: dict) -> float:
242
242
  term = animal.get('term', {})
243
243
  term_id = term.get('@id')
244
244
 
@@ -253,7 +253,7 @@ def _calculate_NEg_sheepAndGoat(cycle: dict, animal: dict) -> float:
253
253
  cycleDuration = cycle.get('cycleDuration', 365)
254
254
  NEg = (BWf - BWi) * (MjKg_a + 0.5 * MjKg_b * (BWi + BWf)) / 365 * animal_value * cycleDuration
255
255
 
256
- debugValues(cycle, model=MODEL, term=term_id, model_key=MODEL_KEY,
256
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
257
257
  MjKg_a=MjKg_a,
258
258
  MjKg_b=MjKg_b,
259
259
  BWi=BWi,
@@ -269,9 +269,9 @@ _NEg_BY_GROUPING = {
269
269
  }
270
270
 
271
271
 
272
- def _calculate_NEg(cycle: dict, animal: dict) -> float:
272
+ def _calculate_NEg(cycle: dict, animal: dict, log_node: dict) -> float:
273
273
  grouping = _get_grouping(animal)
274
- return _NEg_BY_GROUPING.get(grouping, lambda *args: None)(cycle, animal)
274
+ return _NEg_BY_GROUPING.get(grouping, lambda *args: 0)(cycle, animal, log_node)
275
275
 
276
276
 
277
277
  def _pastureGrass_key_property_value(practice: dict, column: dict):
@@ -291,14 +291,14 @@ def calculate_REG(energy: float = 0) -> float:
291
291
  return 1.164 - (5.16/1000 * energy) + (1.308/100000 * pow(energy, 2)) - (37.4/energy) if energy > 0 else 0
292
292
 
293
293
 
294
- def _calculate_feed_meanDE(node: dict, input: dict) -> float:
294
+ def _calculate_feed_meanDE(log_node: dict, input: dict) -> float:
295
295
  term_id = input.get('term', {}).get('@id')
296
296
 
297
297
  energyContent = get_node_property_value(MODEL, input, 'energyContentHigherHeatingValue')
298
298
  energyDigestibility = get_node_property_value(MODEL, input, 'energyDigestibilityRuminants')
299
299
  meanDE = energyContent * energyDigestibility if all([energyContent, energyDigestibility]) else 0
300
300
 
301
- debugValues(node, model=MODEL, term=term_id, model_key=MODEL_KEY,
301
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
302
302
  energyContent=energyContent,
303
303
  energyDigestibility=energyDigestibility,
304
304
  meanDE=meanDE)
@@ -306,26 +306,26 @@ def _calculate_feed_meanDE(node: dict, input: dict) -> float:
306
306
  return meanDE
307
307
 
308
308
 
309
- def _calculate_NEfeed_m(node: dict, input: dict, meanDE: float) -> float:
309
+ def _calculate_NEfeed_m(log_node: dict, input: dict, meanDE: float) -> float:
310
310
  term_id = input.get('term', {}).get('@id')
311
311
 
312
312
  energyDigestibility = get_node_property_value(MODEL, input, 'energyDigestibilityRuminants', default=0)
313
313
  REm = calculate_REM(energyDigestibility * 100)
314
314
 
315
- debugValues(node, model=MODEL, term=term_id, model_key=MODEL_KEY,
315
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
316
316
  REm=REm)
317
317
 
318
318
  input_value = list_sum(input.get('value'))
319
319
  return meanDE * REm * input_value
320
320
 
321
321
 
322
- def _calculate_NEfeed_g(node: dict, input: dict, meanDE: float) -> float:
322
+ def _calculate_NEfeed_g(log_node: dict, input: dict, meanDE: float) -> float:
323
323
  term_id = input.get('term', {}).get('@id')
324
324
 
325
325
  energyDigestibility = get_node_property_value(MODEL, input, 'energyDigestibilityRuminants', default=0)
326
326
  REg = calculate_REG(energyDigestibility * 100)
327
327
 
328
- debugValues(node, model=MODEL, term=term_id, model_key=MODEL_KEY,
328
+ debugValues(log_node, model=MODEL, term=term_id, model_key=MODEL_KEY,
329
329
  REg=REg)
330
330
 
331
331
  input_value = list_sum(input.get('value'))
@@ -346,13 +346,13 @@ def calculate_NEfeed(node: dict) -> tuple:
346
346
  return (NEfeed_m, NEfeed_g)
347
347
 
348
348
 
349
- def get_animal_values(cycle: dict, animal: dict, system: dict):
350
- NEm = _calculate_NEm(cycle, animal)
351
- NEa = _calculate_NEa(cycle, animal, system, NEm)
352
- NEl = _calculate_NEl(cycle, animal)
353
- NEwork = _calculate_NEwork(cycle, animal, NEm)
354
- NEp = _calculate_NEp(cycle, animal, NEm)
355
- NEg = _calculate_NEg(cycle, animal)
349
+ def get_animal_values(cycle: dict, animal: dict, system: dict, log_node: dict):
350
+ NEm = _calculate_NEm(cycle, animal, log_node=log_node)
351
+ NEa = _calculate_NEa(cycle, animal, system, NEm, log_node=log_node)
352
+ NEl = _calculate_NEl(cycle, animal, log_node=log_node)
353
+ NEwork = _calculate_NEwork(cycle, animal, NEm, log_node=log_node)
354
+ NEp = _calculate_NEp(cycle, animal, NEm, log_node=log_node)
355
+ NEg = _calculate_NEg(cycle, animal, log_node=log_node)
356
356
 
357
357
  return (NEm, NEa, NEl, NEwork, NEp, NEg)
358
358