hestia-earth-models 0.48.0__py3-none-any.whl → 0.49.0__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 (20) hide show
  1. hestia_earth/models/agribalyse2016/fuelElectricity.py +33 -18
  2. hestia_earth/models/blonkConsultants2016/{co2ToAirSoilCarbonStockChangeManagementChange.py → co2ToAirAboveGroundBiomassStockChangeLandUseChange.py} +1 -1
  3. hestia_earth/models/faostat2018/product/price.py +1 -1
  4. hestia_earth/models/haversineFormula/transport/distance.py +27 -8
  5. hestia_earth/models/impact_assessment/freshwaterWithdrawalsDuringCycle.py +5 -1
  6. hestia_earth/models/impact_assessment/product/economicValueShare.py +2 -1
  7. hestia_earth/models/ipcc2006/belowGroundCropResidue.py +1 -1
  8. hestia_earth/models/mocking/search-results.json +63 -63
  9. hestia_earth/models/site/cationExchangeCapacityPerKgSoil.py +11 -6
  10. hestia_earth/models/site/organicCarbonPerHa.py +32 -15
  11. hestia_earth/models/version.py +1 -1
  12. {hestia_earth_models-0.48.0.dist-info → hestia_earth_models-0.49.0.dist-info}/METADATA +7 -7
  13. {hestia_earth_models-0.48.0.dist-info → hestia_earth_models-0.49.0.dist-info}/RECORD +20 -20
  14. {hestia_earth_models-0.48.0.dist-info → hestia_earth_models-0.49.0.dist-info}/WHEEL +1 -1
  15. tests/models/blonkConsultants2016/{test_co2ToAirSoilCarbonStockChangeManagementChange.py → test_co2ToAirAboveGroundBiomassStockChangeLandUseChange.py} +1 -1
  16. tests/models/faostat2018/product/test_price.py +7 -1
  17. tests/models/site/test_cationExchangeCapacityPerKgSoil.py +6 -4
  18. tests/models/site/test_organicCarbonPerHa.py +6 -4
  19. {hestia_earth_models-0.48.0.dist-info → hestia_earth_models-0.49.0.dist-info}/LICENSE +0 -0
  20. {hestia_earth_models-0.48.0.dist-info → hestia_earth_models-0.49.0.dist-info}/top_level.txt +0 -0
@@ -3,6 +3,7 @@ Fuel and Electricity
3
3
 
4
4
  This model calculates fuel and electricity data from the number of hours each machine is operated for using.
5
5
  """
6
+ from functools import reduce
6
7
  from hestia_earth.schema import InputStatsDefinition, TermTermType
7
8
  from hestia_earth.utils.model import filter_list_term_type
8
9
  from hestia_earth.utils.tools import flatten, list_sum, non_empty_list
@@ -44,34 +45,49 @@ def _input(term_id: str, value: float, operation: dict):
44
45
  return input
45
46
 
46
47
 
48
+ def _operation_input(operation: dict):
49
+ input = operation.get('input', {})
50
+ return _input(input.get('id'), input.get('value') * operation.get('value'), operation.get('term', {}))
51
+
52
+
47
53
  def _run_operation(cycle: dict):
48
- def exec(operation: dict):
49
- input = operation.get('input', {})
50
- input_term = input.get('term', {})
51
- input_term_id = input_term.get('@id')
52
- coefficient = input.get('value')
53
- value = list_sum(operation.get('value', []))
54
+ def exec(operations: list):
55
+ input_term_id = operations[0].get('input').get('id')
56
+ values_logs = ';'.join([
57
+ f"id:{p.get('term').get('@id')}_value:{p.get('value')}_coefficient:{p.get('input').get('value')}"
58
+ for p in operations
59
+ ])
54
60
 
55
61
  debugValues(cycle, model=MODEL, term=input_term_id,
56
- operation=operation.get('@id'),
57
- value=value,
58
- coefficient=coefficient)
59
- logShouldRun(cycle, MODEL, input_term_id, True, model_key=MODEL_KEY, operation=operation.get('@id'))
62
+ values=values_logs)
63
+
64
+ logShouldRun(cycle, MODEL, input_term_id, True, model_key=MODEL_KEY)
60
65
 
61
- return _input(input_term.get('@id'), coefficient * value, operation.get('term', {}))
66
+ return list(map(_operation_input, operations))
62
67
  return exec
63
68
 
64
69
 
70
+ def _group_operations(operations: list):
71
+ def grouper(group: dict, operation: dict):
72
+ input_term_id = operation.get('input').get('id')
73
+ group[input_term_id] = group.get(input_term_id, [])
74
+ group[input_term_id].append(operation)
75
+ return group
76
+
77
+ return reduce(grouper, operations, {})
78
+
79
+
65
80
  def _should_run_operation(cycle: dict):
66
81
  def exec(practice: dict):
67
82
  term = practice.get('term', {})
68
83
  term_id = term.get('@id')
69
- value = list_sum(practice.get('value', []))
84
+ values = practice.get('value', [])
85
+ value = list_sum(values) if all([not isinstance(v, str) for v in values]) else 0 # str allowed for Practice
70
86
  has_value = value > 0
71
87
 
72
88
  coeffs = get_lookup_value(term, LOOKUPS['operation'], model=MODEL, model_key=MODEL_KEY)
73
89
  values = non_empty_list(coeffs.split(';')) if coeffs else []
74
- inputs = [{'term': {'@id': c.split(':')[0]}, 'value': float(c.split(':')[1])} for c in values]
90
+ inputs = [{'id': c.split(':')[0], 'value': float(c.split(':')[1])} for c in values]
75
91
  has_lookup_value = len(inputs) > 0
76
92
 
77
93
  logRequirements(cycle, model=MODEL, term=term_id, model_key=MODEL_KEY,
@@ -80,10 +96,7 @@ def _should_run_operation(cycle: dict):
80
96
 
81
97
  should_run = all([has_value, has_lookup_value])
82
98
  logShouldRun(cycle, MODEL, term_id, should_run, model_key=MODEL_KEY)
83
- return [{
84
- **practice,
85
- 'input': input
86
- } for input in inputs] if should_run else []
99
+ return [{'term': term, 'value': value, 'input': input} for input in inputs] if should_run else []
87
100
  return exec
88
101
 
89
102
 
@@ -105,4 +118,6 @@ def _should_run(cycle: dict):
105
118
 
106
119
  def run(cycle: dict):
107
120
  should_run, operations = _should_run(cycle)
108
- return list(map(_run_operation(cycle), operations)) if should_run else []
121
+ # group operations by input to show logs as table
122
+ grouped_operations = _group_operations(operations)
123
+ return flatten(map(_run_operation(cycle), grouped_operations.values())) if should_run else []
@@ -49,7 +49,7 @@ RETURNS = {
49
49
  "statsDefinition": "modelled"
50
50
  }]
51
51
  }
52
- TERM_ID = 'co2ToAirSoilCarbonStockChangeManagementChange'
52
+ TERM_ID = 'co2ToAirAboveGroundBiomassStockChangeLandUseChange'
53
53
  TIER = EmissionMethodTier.TIER_1.value
54
54
 
55
55
 
@@ -67,7 +67,7 @@ def _lookup_data(
67
67
  data = get_table_value(lookup, 'termid', country_id, column_name(grouping))
68
68
  debugMissingLookup(lookup_name, 'termid', country_id, grouping, data,
69
69
  model=MODEL, term=term_id, key=MODEL_KEY)
70
- price = extract_grouped_data(data, str(year)) if year else extract_grouped_data(data, 'Average_price_per_tonne')
70
+ price = extract_grouped_data(data, str(year)) or extract_grouped_data(data, 'Average_price_per_tonne')
71
71
  return safe_parse_float(price, None)
72
72
 
73
73
 
@@ -74,18 +74,37 @@ def _run_input(cycle: dict, site_country: dict):
74
74
  return exec
75
75
 
76
76
 
77
- def _should_run_input(site_country: str):
77
+ def _should_run_input(site_country_id: str):
78
78
  def exec(input: dict):
79
- input_country = input.get('country', {}).get('@id')
79
+ input_country = input.get('country', {}) or {}
80
+ input_country_id = input_country.get('@id')
81
+ input_country = download_hestia(input_country_id)
80
82
  has_transports = len(input.get('transport', [])) > 0
81
- should_run = all([has_transports, input_country, input_country != site_country])
83
+ should_run = input_country and all([
84
+ input_country.get('latitude'), input_country.get('latitude'),
85
+ has_transports, input_country_id != site_country_id
86
+ ])
82
87
  return should_run
83
88
  return exec
84
89
 
85
90
 
86
- def run(cycle: dict):
87
- site_country = cycle.get('site', {}).get('country', {}).get('@id')
88
- inputs = list(filter(_should_run_input(site_country), cycle.get('inputs', [])))
91
+ def _should_run(cycle: dict):
92
+ country = cycle.get('site', {}).get('country', {})
93
+ country_id = cycle.get('site', {}).get('country', {}).get('@id')
94
+ inputs = list(filter(_should_run_input(country_id), cycle.get('inputs', [])))
89
95
  # download full term to get coordinates only if there is anything to run
90
- site_country = download_hestia(site_country) if len(inputs) > 0 else site_country
91
- return non_empty_list(map(_run_input(cycle, site_country), inputs))
96
+ country = download_hestia(country_id) if len(inputs) > 0 else {}
97
+
98
+ # can only run if the site country has centroid coordinates
99
+ logRequirements(cycle, model=MODEL, term=None, key=MODEL_KEY,
100
+ latitude=country.get('latitude'),
101
+ longitude=country.get('latitude'),
102
+ has_inputs_transport=len(inputs) > 0)
103
+ should_run = all([country.get('latitude'), country.get('latitude'), len(inputs) > 0])
104
+ logShouldRun(cycle, MODEL, None, should_run, key=MODEL_KEY)
105
+ return should_run, country, inputs
106
+
107
+
108
+ def run(cycle: dict):
109
+ should_run, country, inputs = _should_run(cycle)
110
+ return non_empty_list(map(_run_input(cycle, country), inputs)) if should_run else []
@@ -36,7 +36,11 @@ RETURNS = {
36
36
  }
37
37
  LOOKUPS = {
38
38
  "crop": "cropGroupingFAO",
39
- "region": ["Conveyancing_Efficiency_Annual_crops", "Conveyancing_Efficiency_Permanent_crops"]
39
+ "region": [
40
+ "Conveyancing_Efficiency_Annual_crops",
41
+ "Conveyancing_Efficiency_Permanent_crops",
42
+ "Conveyancing_Efficiency_Perennial_crops"
43
+ ]
40
44
  }
41
45
  TERM_ID = 'freshwaterWithdrawalsDuringCycle'
42
46
 
@@ -26,7 +26,8 @@ MODEL_KEY = 'economicValueShare'
26
26
 
27
27
 
28
28
  def _run(impact: dict, product: dict):
29
- return {**impact.get('product'), MODEL_KEY: product.get(MODEL_KEY, 100)}
29
+ value = product.get(MODEL_KEY)
30
+ return {**impact.get('product'), MODEL_KEY: value} if value is not None else None
30
31
 
31
32
 
32
33
  def _should_run(impact: dict):
@@ -22,7 +22,7 @@ REQUIREMENTS = {
22
22
  }
23
23
  }
24
24
  LOOKUPS = {
25
- "crop": ["Crop_residue_intercept", "Crop_residue_slope", "Ratio_Abv_to_Below_Grou_crop_residue"]
25
+ "crop": ["Crop_residue_intercept", "Crop_residue_slope", "IPCC_2019_Ratio_BGRes_AGRes"]
26
26
  }
27
27
  RETURNS = {
28
28
  "Product": [{
@@ -20,67 +20,67 @@
20
20
  "results": [
21
21
  {
22
22
  "@type": "Term",
23
- "@id": "n2OToAirCropResidueDecompositionIndirect"
23
+ "@id": "pToDrainageWaterSoilFlux"
24
24
  },
25
25
  {
26
26
  "@type": "Term",
27
- "@id": "dichlorodifluoromethaneToAirInputsProduction"
27
+ "@id": "nh3ToAirOrganicSoilCultivation"
28
28
  },
29
29
  {
30
30
  "@type": "Term",
31
- "@id": "co2ToAirBelowGroundBiomassStockChangeManagementChange"
31
+ "@id": "n2ToAirWasteTreatment"
32
32
  },
33
33
  {
34
34
  "@type": "Term",
35
- "@id": "codToWaterIndustrialProcesses"
35
+ "@id": "nToSurfaceWaterSoilFlux"
36
36
  },
37
37
  {
38
38
  "@type": "Term",
39
- "@id": "po43ToGroundwaterInorganicFertiliser"
39
+ "@id": "no3ToGroundwaterInorganicFertiliser"
40
40
  },
41
41
  {
42
42
  "@type": "Term",
43
- "@id": "bod5ToWaterInputsProduction"
43
+ "@id": "noToAirExcreta"
44
44
  },
45
45
  {
46
46
  "@type": "Term",
47
- "@id": "nh4ToGroundwaterExcreta"
47
+ "@id": "nh3ToAirCropResidueDecomposition"
48
48
  },
49
49
  {
50
50
  "@type": "Term",
51
- "@id": "n2OToAirDiminishingSoilCarbonStocksLandUseChangeDirect"
51
+ "@id": "bromochlorodifluoromethaneToAirInputsProduction"
52
52
  },
53
53
  {
54
54
  "@type": "Term",
55
- "@id": "nToSurfaceWaterSoilFlux"
55
+ "@id": "n2OToAirDiminishingSoilCarbonStocksLandUseChangeDirect"
56
56
  },
57
57
  {
58
58
  "@type": "Term",
59
- "@id": "no3ToGroundwaterInorganicFertiliser"
59
+ "@id": "po43ToGroundwaterInorganicFertiliser"
60
60
  },
61
61
  {
62
62
  "@type": "Term",
63
- "@id": "noToAirExcreta"
63
+ "@id": "bod5ToWaterInputsProduction"
64
64
  },
65
65
  {
66
66
  "@type": "Term",
67
- "@id": "nh3ToAirCropResidueDecomposition"
67
+ "@id": "nh4ToGroundwaterExcreta"
68
68
  },
69
69
  {
70
70
  "@type": "Term",
71
- "@id": "bromochlorodifluoromethaneToAirInputsProduction"
71
+ "@id": "n2OToAirCropResidueDecompositionIndirect"
72
72
  },
73
73
  {
74
74
  "@type": "Term",
75
- "@id": "pToDrainageWaterSoilFlux"
75
+ "@id": "dichlorodifluoromethaneToAirInputsProduction"
76
76
  },
77
77
  {
78
78
  "@type": "Term",
79
- "@id": "nh3ToAirOrganicSoilCultivation"
79
+ "@id": "co2ToAirBelowGroundBiomassStockChangeManagementChange"
80
80
  },
81
81
  {
82
82
  "@type": "Term",
83
- "@id": "n2ToAirWasteTreatment"
83
+ "@id": "codToWaterIndustrialProcesses"
84
84
  },
85
85
  {
86
86
  "@type": "Term",
@@ -114,18 +114,6 @@
114
114
  "@type": "Term",
115
115
  "@id": "chlorodifluoromethaneToAirInputsProduction"
116
116
  },
117
- {
118
- "@type": "Term",
119
- "@id": "nh4ToSurfaceWaterAquacultureSystems"
120
- },
121
- {
122
- "@type": "Term",
123
- "@id": "ch4ToAirSoilFlux"
124
- },
125
- {
126
- "@type": "Term",
127
- "@id": "no3ToGroundwaterWasteTreatment"
128
- },
129
117
  {
130
118
  "@type": "Term",
131
119
  "@id": "noToAirOrganicFertiliser"
@@ -172,7 +160,15 @@
172
160
  },
173
161
  {
174
162
  "@type": "Term",
175
- "@id": "noxToAirOrganicFertiliser"
163
+ "@id": "nh4ToSurfaceWaterAquacultureSystems"
164
+ },
165
+ {
166
+ "@type": "Term",
167
+ "@id": "ch4ToAirSoilFlux"
168
+ },
169
+ {
170
+ "@type": "Term",
171
+ "@id": "no3ToGroundwaterWasteTreatment"
176
172
  },
177
173
  {
178
174
  "@type": "Term",
@@ -192,12 +188,16 @@
192
188
  },
193
189
  {
194
190
  "@type": "Term",
195
- "@id": "nToSurfaceWaterInputsProduction"
191
+ "@id": "noxToAirOrganicFertiliser"
196
192
  },
197
193
  {
198
194
  "@type": "Term",
199
195
  "@id": "no3ToGroundwaterSoilFlux"
200
196
  },
197
+ {
198
+ "@type": "Term",
199
+ "@id": "nToSurfaceWaterInputsProduction"
200
+ },
201
201
  {
202
202
  "@type": "Term",
203
203
  "@id": "n2OToAirOrganicSoilCultivationIndirect"
@@ -288,35 +288,35 @@
288
288
  },
289
289
  {
290
290
  "@type": "Term",
291
- "@id": "nToSurfaceWaterAquacultureSystems"
291
+ "@id": "pesticideToWaterInputsProduction"
292
292
  },
293
293
  {
294
294
  "@type": "Term",
295
- "@id": "noToAirSoilFlux"
295
+ "@id": "co2ToAirAboveGroundBiomassStockChangeLandUseChange"
296
296
  },
297
297
  {
298
298
  "@type": "Term",
299
- "@id": "co2ToAirSoilFlux"
299
+ "@id": "nToSurfaceWaterAquacultureSystems"
300
300
  },
301
301
  {
302
302
  "@type": "Term",
303
- "@id": "n2OToAirFuelCombustionDirect"
303
+ "@id": "noToAirSoilFlux"
304
304
  },
305
305
  {
306
306
  "@type": "Term",
307
- "@id": "pToSurfaceWaterSoilFlux"
307
+ "@id": "co2ToAirSoilFlux"
308
308
  },
309
309
  {
310
310
  "@type": "Term",
311
- "@id": "noToAirWasteTreatment"
311
+ "@id": "n2OToAirFuelCombustionDirect"
312
312
  },
313
313
  {
314
314
  "@type": "Term",
315
- "@id": "co2ToAirAboveGroundBiomassStockChangeLandUseChange"
315
+ "@id": "pToSurfaceWaterSoilFlux"
316
316
  },
317
317
  {
318
318
  "@type": "Term",
319
- "@id": "pesticideToWaterInputsProduction"
319
+ "@id": "noToAirWasteTreatment"
320
320
  },
321
321
  {
322
322
  "@type": "Term",
@@ -414,6 +414,14 @@
414
414
  "@type": "Term",
415
415
  "@id": "codToWaterInputsProduction"
416
416
  },
417
+ {
418
+ "@type": "Term",
419
+ "@id": "ch4ToAirAquacultureSystems"
420
+ },
421
+ {
422
+ "@type": "Term",
423
+ "@id": "co2ToAirLimeHydrolysis"
424
+ },
417
425
  {
418
426
  "@type": "Term",
419
427
  "@id": "nh3ToAirCropResidueBurning"
@@ -442,14 +450,6 @@
442
450
  "@type": "Term",
443
451
  "@id": "pm25ToAirFuelCombustion"
444
452
  },
445
- {
446
- "@type": "Term",
447
- "@id": "ch4ToAirAquacultureSystems"
448
- },
449
- {
450
- "@type": "Term",
451
- "@id": "co2ToAirLimeHydrolysis"
452
- },
453
453
  {
454
454
  "@type": "Term",
455
455
  "@id": "nErosionInputsProduction"
@@ -576,23 +576,19 @@
576
576
  },
577
577
  {
578
578
  "@type": "Term",
579
- "@id": "po43ToSurfaceWaterAquacultureSystems"
580
- },
581
- {
582
- "@type": "Term",
583
- "@id": "n2ToAirInorganicFertiliser"
579
+ "@id": "nh4ToGroundwaterSoilFlux"
584
580
  },
585
581
  {
586
582
  "@type": "Term",
587
- "@id": "hexaneToAirInputsProduction"
583
+ "@id": "po43ToSurfaceWaterAquacultureSystems"
588
584
  },
589
585
  {
590
586
  "@type": "Term",
591
- "@id": "nh4ToSurfaceWaterInputsProduction"
587
+ "@id": "n2ToAirInorganicFertiliser"
592
588
  },
593
589
  {
594
590
  "@type": "Term",
595
- "@id": "nh4ToGroundwaterSoilFlux"
591
+ "@id": "hexaneToAirInputsProduction"
596
592
  },
597
593
  {
598
594
  "@type": "Term",
@@ -666,6 +662,14 @@
666
662
  "@type": "Term",
667
663
  "@id": "nmvocToAirSilageFeeding"
668
664
  },
665
+ {
666
+ "@type": "Term",
667
+ "@id": "nh4ToSurfaceWaterInputsProduction"
668
+ },
669
+ {
670
+ "@type": "Term",
671
+ "@id": "pm25ToAirCropResidueBurning"
672
+ },
669
673
  {
670
674
  "@type": "Term",
671
675
  "@id": "noxToAirInputsProduction"
@@ -678,6 +682,10 @@
678
682
  "@type": "Term",
679
683
  "@id": "ch4ToAirEntericFermentation"
680
684
  },
685
+ {
686
+ "@type": "Term",
687
+ "@id": "no3ToGroundwaterOrganicFertiliser"
688
+ },
681
689
  {
682
690
  "@type": "Term",
683
691
  "@id": "ch4ToAirInputsProductionFossil"
@@ -698,14 +706,6 @@
698
706
  "@type": "Term",
699
707
  "@id": "no3ToGroundwaterInputsProduction"
700
708
  },
701
- {
702
- "@type": "Term",
703
- "@id": "pm25ToAirCropResidueBurning"
704
- },
705
- {
706
- "@type": "Term",
707
- "@id": "no3ToGroundwaterOrganicFertiliser"
708
- },
709
709
  {
710
710
  "@type": "Term",
711
711
  "@id": "pToGroundwaterInputsProduction"
@@ -1164,7 +1164,7 @@
1164
1164
  "@type": "Term",
1165
1165
  "name": "Generic crop, seed",
1166
1166
  "@id": "genericCropSeed",
1167
- "_score": 27.97878
1167
+ "_score": 27.980534
1168
1168
  }
1169
1169
  ]
1170
1170
  },
@@ -55,7 +55,7 @@ def _run(measurements: list):
55
55
  return measurement(value, depthUpper=depthUpper, depthLower=depthLower)
56
56
 
57
57
 
58
- def _should_run(site: dict, measurements: list):
58
+ def _should_run_measurements(site: dict, measurements: list):
59
59
  clayContent = find_term_match(measurements, 'clayContent', None)
60
60
  soilPh = find_term_match(measurements, 'soilPh', None)
61
61
  organicCarbonPerKgSoil = find_term_match(measurements, 'organicCarbonPerKgSoil', None)
@@ -72,12 +72,17 @@ def _should_run(site: dict, measurements: list):
72
72
  **depth_logs)
73
73
 
74
74
  should_run = all([clayContent is not None, soilPh is not None, organicCarbonPerKgSoil is not None])
75
- logShouldRun(site, MODEL, TERM_ID, should_run)
76
75
  return should_run
77
76
 
78
77
 
78
+ def _should_run(site: dict):
79
+ grouped_measurements = list(group_measurements_by_depth(site.get('measurements', [])).values())
80
+ values = [(measurements, _should_run_measurements(site, measurements)) for measurements in grouped_measurements]
81
+ should_run = any([_should_run for measurements, _should_run in values])
82
+ logShouldRun(site, MODEL, TERM_ID, should_run)
83
+ return should_run, [measurements for measurements, _should_run in values if _should_run]
84
+
85
+
79
86
  def run(site: dict):
80
- grouped_measurements = list(group_measurements_by_depth(site.get('measurements', []), include_dates=False).values())
81
- return [
82
- _run(measurements) for measurements in grouped_measurements if _should_run(site, measurements)
83
- ]
87
+ should_run, values = _should_run(site)
88
+ return list(map(_run, values)) if should_run else []
@@ -2,7 +2,9 @@ from hestia_earth.schema import MeasurementStatsDefinition, MeasurementMethodCla
2
2
  from hestia_earth.utils.model import find_term_match
3
3
 
4
4
  from hestia_earth.models.log import logRequirements, logShouldRun
5
- from hestia_earth.models.utils.measurement import _new_measurement, group_measurements_by_depth, measurement_value
5
+ from hestia_earth.models.utils.measurement import (
6
+ _new_measurement, group_measurements_by_depth, _group_measurement_key, measurement_value
7
+ )
6
8
  from . import MODEL
7
9
 
8
10
  REQUIREMENTS = {
@@ -51,7 +53,7 @@ def _run(measurements: list):
51
53
  return measurement(value, depthUpper, depthLower)
52
54
 
53
55
 
54
- def _should_run(site: dict, measurements: list):
56
+ def _should_run_measurements(site: dict, measurements: list):
55
57
  soilBulkDensity = find_term_match(measurements, 'soilBulkDensity', None)
56
58
  has_soilBulkDensity_depthLower = (soilBulkDensity or {}).get('depthLower') is not None
57
59
  has_soilBulkDensity_depthUpper = (soilBulkDensity or {}).get('depthUpper') is not None
@@ -59,24 +61,39 @@ def _should_run(site: dict, measurements: list):
59
61
  has_organicCarbonPerKgSoil_depthLower = (organicCarbonPerKgSoil or {}).get('depthLower') is not None
60
62
  has_organicCarbonPerKgSoil_depthUpper = (organicCarbonPerKgSoil or {}).get('depthUpper') is not None
61
63
 
64
+ depth_logs = {
65
+ _group_measurement_key(measurements[0], include_dates=False): ';'.join([
66
+ '_'.join([
67
+ 'id:soilBulkDensity',
68
+ f"hasDepthLower:{has_soilBulkDensity_depthLower}",
69
+ f"hasDepthUpper:{has_soilBulkDensity_depthUpper}"
70
+ ]),
71
+ '_'.join([
72
+ 'id:organicCarbonPerKgSoil',
73
+ f"hasDepthLower:{has_organicCarbonPerKgSoil_depthLower}",
74
+ f"hasDepthUpper:{has_organicCarbonPerKgSoil_depthUpper}"
75
+ ])
76
+ ])
77
+ } if len(measurements) > 0 else {}
78
+
62
79
  logRequirements(site, model=MODEL, term=TERM_ID,
63
- has_soilBulkDensity=soilBulkDensity is not None,
64
- has_soilBulkDensity_depthLower=has_soilBulkDensity_depthLower,
65
- has_soilBulkDensity_depthUpper=has_soilBulkDensity_depthUpper,
66
- has_organicCarbonPerKgSoil=organicCarbonPerKgSoil is not None,
67
- has_organicCarbonPerKgSoil_depthLower=has_organicCarbonPerKgSoil_depthLower,
68
- has_organicCarbonPerKgSoil_depthUpper=has_organicCarbonPerKgSoil_depthUpper)
80
+ **depth_logs)
69
81
 
70
82
  should_run = all([
71
- soilBulkDensity is not None, has_soilBulkDensity_depthLower, has_soilBulkDensity_depthUpper,
72
- organicCarbonPerKgSoil is not None, has_organicCarbonPerKgSoil_depthLower, has_organicCarbonPerKgSoil_depthUpper
83
+ has_soilBulkDensity_depthLower, has_soilBulkDensity_depthUpper,
84
+ has_organicCarbonPerKgSoil_depthLower, has_organicCarbonPerKgSoil_depthUpper
73
85
  ])
74
- logShouldRun(site, MODEL, TERM_ID, should_run)
75
86
  return should_run
76
87
 
77
88
 
78
- def run(site: dict):
89
+ def _should_run(site: dict):
79
90
  grouped_measurements = list(group_measurements_by_depth(site.get('measurements', [])).values())
80
- return [
81
- _run(measurements) for measurements in grouped_measurements if _should_run(site, measurements)
82
- ]
91
+ values = [(measurements, _should_run_measurements(site, measurements)) for measurements in grouped_measurements]
92
+ should_run = any([_should_run for measurements, _should_run in values])
93
+ logShouldRun(site, MODEL, TERM_ID, should_run)
94
+ return should_run, [measurements for measurements, _should_run in values if _should_run]
95
+
96
+
97
+ def run(site: dict):
98
+ should_run, values = _should_run(site)
99
+ return list(map(_run, values)) if should_run else []
@@ -1 +1 @@
1
- VERSION = '0.48.0'
1
+ VERSION = '0.49.0'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hestia-earth-models
3
- Version: 0.48.0
3
+ Version: 0.49.0
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
@@ -11,13 +11,13 @@ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
11
11
  Classifier: Programming Language :: Python :: 3.6
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
- Requires-Dist: hestia-earth.schema (==22.*)
15
- Requires-Dist: hestia-earth.utils (>=0.11.1)
16
- Requires-Dist: python-dateutil (>=2.8.1)
17
- Requires-Dist: CurrencyConverter (==0.16.8)
18
- Requires-Dist: haversine (>=2.7.0)
14
+ Requires-Dist: hestia-earth.schema ==22.*
15
+ Requires-Dist: hestia-earth.utils >=0.11.1
16
+ Requires-Dist: python-dateutil >=2.8.1
17
+ Requires-Dist: CurrencyConverter ==0.16.8
18
+ Requires-Dist: haversine >=2.7.0
19
19
  Provides-Extra: spatial
20
- Requires-Dist: hestia-earth.earth-engine (>=0.2.0) ; extra == 'spatial'
20
+ Requires-Dist: hestia-earth.earth-engine >=0.2.0 ; extra == 'spatial'
21
21
 
22
22
  # Hestia Engine Models
23
23
 
@@ -2,9 +2,9 @@ hestia_earth/__init__.py,sha256=G-d438vPx7m_ks5e9XTtM3u7LDRO5dSSukibukWmyPM,56
2
2
  hestia_earth/models/__init__.py,sha256=qEFeq3yuf3lQKVseALmL8aPM8fpCS54B_5pry00M3hk,76
3
3
  hestia_earth/models/log.py,sha256=rOgKa-gSrcS-Y1gO9eJXJaA3ofxcQW_45hGly2Lf00Y,2444
4
4
  hestia_earth/models/requirements.py,sha256=znNZJAhwX2iYiKcAQXPftY7z_1MsNa0QxCXkXyHm_U0,17363
5
- hestia_earth/models/version.py,sha256=exHQD27mo4QXwRDD7owDzwLLB3TxEzaIkoQPYz1xUQo,19
5
+ hestia_earth/models/version.py,sha256=zgraak42T6rmaFGxWnUUUn4Zle6ivFt4DV9V53AgWbQ,19
6
6
  hestia_earth/models/agribalyse2016/__init__.py,sha256=WvK0qCQbnYtg9oZxrACd1wGormZyXibPtpCnIQeDqbw,415
7
- hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=4_6KTvKBFQPESvekql69odXsrr0McvpTaNoHyYNo6qc,3852
7
+ hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=Vs0cRIUObtxpcvQfh9zPF5FjDdhUf2GhT0KCZzThG24,4460
8
8
  hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=rxU6nflJ5QisQTjEGsCSbAF9fYfSOtez3cGaRJVKo14,3303
9
9
  hestia_earth/models/akagiEtAl2011AndIpcc2006/__init__.py,sha256=WK7xQwUPX48JGqZeb2S2EKdtXuxMjY7HYyUFHItUqUo,425
10
10
  hestia_earth/models/akagiEtAl2011AndIpcc2006/ch4ToAirCropResidueBurning.py,sha256=JUTkKB9EclLu7OkVQm2tTZpZF5vTTZl4HogaH_S4qrs,1779
@@ -16,7 +16,7 @@ hestia_earth/models/aware/__init__.py,sha256=F8XRo9nRiX-fHAqyeMARYtFmJWRPs-hnIaC
16
16
  hestia_earth/models/aware/scarcityWeightedWaterUse.py,sha256=NOGWGMVg4qxaubriihR_24UHQNCi_UAdH4opaPMy5b4,4520
17
17
  hestia_earth/models/blonkConsultants2016/__init__.py,sha256=jJhYkwblgQZRg3QOERBZfl4Nw9szPn-Mljz7KMWlXXM,421
18
18
  hestia_earth/models/blonkConsultants2016/ch4ToAirNaturalVegetationBurning.py,sha256=wklXERaNrkdCmpphbpj_59XYKZfP8QAQ-AAUkfSttuU,3324
19
- hestia_earth/models/blonkConsultants2016/co2ToAirSoilCarbonStockChangeManagementChange.py,sha256=k-zh-HCOIISnmGOXw4czpD2k0DQwAg_trQ_gGVJhKCU,3260
19
+ hestia_earth/models/blonkConsultants2016/co2ToAirAboveGroundBiomassStockChangeLandUseChange.py,sha256=FnEDkJ2DR7XHrZGySqwo-CtJkavz554leLz_PD_8IXk,3265
20
20
  hestia_earth/models/blonkConsultants2016/landTransformationFromForest20YearAverageDuringCycle.py,sha256=HsyiHyuZQKKCh0Uoc8krVW5zwsc9G2hNxTCbp5jj9Co,3695
21
21
  hestia_earth/models/blonkConsultants2016/n2OToAirNaturalVegetationBurningDirect.py,sha256=ai9BXRbMw_XbRTnmAlGVs5IMrebYYE7UFnrw0FJkCqs,3453
22
22
  hestia_earth/models/blonkConsultants2016/utils.py,sha256=tbXCP5585AyIVLRc-nSFfrCiTZToXgP8riJe1Hk7rp0,1479
@@ -114,7 +114,7 @@ hestia_earth/models/faostat2018/readyToCookWeightPerHead.py,sha256=gLRPMjbtXyHrn
114
114
  hestia_earth/models/faostat2018/seed.py,sha256=AqxT1bIPxrij3nYaA3rc9bHVKOP-sciVlUXKomD6rwc,2811
115
115
  hestia_earth/models/faostat2018/utils.py,sha256=Uc8KXYIwwS0YJjA16jm3_v1DHQaIQg8_YZpBCU92EDY,3250
116
116
  hestia_earth/models/faostat2018/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
117
- hestia_earth/models/faostat2018/product/price.py,sha256=gLcLXtgReJrszsY3X80Z62znthb-y-IHWOfvF6mkWIA,8068
117
+ hestia_earth/models/faostat2018/product/price.py,sha256=vE3rtICxjYqnQdYiUNuR0gyjbVjDuCGqrARUT1HILEA,8058
118
118
  hestia_earth/models/geospatialDatabase/__init__.py,sha256=2Eh6-hjX812Uuf8nxYnC50uXE6uv_8ofFK8iVMwihXA,419
119
119
  hestia_earth/models/geospatialDatabase/aware.py,sha256=LE2Pwp6urX_QV0DlAn6S4NcKwcg0Y_J8lTfr_LzKlBA,1363
120
120
  hestia_earth/models/geospatialDatabase/clayContent.py,sha256=SAlHW1TMhOz9S4iUASlC9htuSlydINgk22hXW-v4UDU,2286
@@ -148,7 +148,7 @@ hestia_earth/models/globalCropWaterModel2008/__init__.py,sha256=vQxexzFCl2Uv2RiI
148
148
  hestia_earth/models/globalCropWaterModel2008/rootingDepth.py,sha256=k6UeqX-JyXKdB6qcEzKUl2UzSOlX8sH1nnPf9LhtKWY,4254
149
149
  hestia_earth/models/haversineFormula/__init__.py,sha256=o155nR-XI67iCSBVNYIu4sPRIF3C2Y1NnUZ6lfpi0Do,417
150
150
  hestia_earth/models/haversineFormula/transport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
151
- hestia_earth/models/haversineFormula/transport/distance.py,sha256=KNq5_UgxcPiNe_O-oyE-EbqX_UZ03Pk7aIKOZh-2SQ4,3299
151
+ hestia_earth/models/haversineFormula/transport/distance.py,sha256=pii20EpXzxbAW7FASXvHSA_kyKULR-Limx2AdKj8gc0,4139
152
152
  hestia_earth/models/hyde32/__init__.py,sha256=hSOwDiK0M0NfmQbW_J7O_SZa8IsJMgITSHSVMsDS4KI,407
153
153
  hestia_earth/models/hyde32/landTransformationFromCropland100YearAverageDuringCycle.py,sha256=Ww_BrjgPV6WK6L2VeZkhnoE_I-HQFRLDcVn82fk15fo,2402
154
154
  hestia_earth/models/hyde32/landTransformationFromCropland20YearAverageDuringCycle.py,sha256=yr_qmy_fcHk6-he-h90rUlI-LpV6P7DeD3WbdE3MoJw,2398
@@ -161,7 +161,7 @@ hestia_earth/models/hyde32/landTransformationFromPermanentPasture20YearAverageDu
161
161
  hestia_earth/models/hyde32/utils.py,sha256=j9QavyBZIQ-ZCNjdPLWjOjg2LrxcNlanQ1wPnT0IKX8,3098
162
162
  hestia_earth/models/impact_assessment/__init__.py,sha256=B6UO8z3NR6JjIycyT7adZbnNKcBC49qnF2bOhVcufy4,355
163
163
  hestia_earth/models/impact_assessment/emissions.py,sha256=XcHTqyPAZeCz7qPTD8VvccmYMYROqBGrR0zJNpZtmvM,3413
164
- hestia_earth/models/impact_assessment/freshwaterWithdrawalsDuringCycle.py,sha256=9CavXee24bRHBlVOINLDBH4zzQZqHRu15J_06oDzGRc,3879
164
+ hestia_earth/models/impact_assessment/freshwaterWithdrawalsDuringCycle.py,sha256=ljh9vou6jJzNjWCtdLsvozx2S1K9cQvWVxifk6mMWso,3952
165
165
  hestia_earth/models/impact_assessment/freshwaterWithdrawalsInputsProduction.py,sha256=DSLX_aEWaUFcFZRD46bG5lIQ4TtAtIqH-sMkVCJH2Dg,990
166
166
  hestia_earth/models/impact_assessment/irrigated.py,sha256=0lFUPRUwQze283F6aCsqiBJ2pbFNPvApcbppwbSF2SE,749
167
167
  hestia_earth/models/impact_assessment/landOccupationInputsProduction.py,sha256=SggB_4tpiKNeb6TIQWBm-X9VwG4pzLoyHdK8JroRIsE,576
@@ -182,12 +182,12 @@ hestia_earth/models/impact_assessment/pre_checks/__init__.py,sha256=3FV6tLVLlXzV
182
182
  hestia_earth/models/impact_assessment/pre_checks/cycle.py,sha256=drOQaHY5V_LLRH8txgFOp006VGbnftGHJLznNe3tC88,1079
183
183
  hestia_earth/models/impact_assessment/pre_checks/site.py,sha256=4xLy_GIYJZpCpKbiR4BEfKNEU1YyPJnMLq4yTgyJVnY,929
184
184
  hestia_earth/models/impact_assessment/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
185
- hestia_earth/models/impact_assessment/product/economicValueShare.py,sha256=z3EUHmN-SkGhPIJ_mtMs0EUDlHmvCVHa7UDxEVLgv1E,1426
185
+ hestia_earth/models/impact_assessment/product/economicValueShare.py,sha256=EFVAQ6ZDC_jPRMA3K3lVVLR6Ow3nzMeG6zhNlwICef8,1470
186
186
  hestia_earth/models/impact_assessment/product/value.py,sha256=opBfdXZ8GfTxdMkr_XeOFb3gZ4slGpUNE9RXHH1QUHw,1332
187
187
  hestia_earth/models/ipcc2006/__init__.py,sha256=ReUFPLqIyp16QEOGaiHmz41QbuwYBQYDKVtw6KuRDIA,409
188
188
  hestia_earth/models/ipcc2006/aboveGroundCropResidueRemoved.py,sha256=PAAHVduJgUH3taVvhzWCFJ9shpIHHPNvS-TqITc95oM,2879
189
189
  hestia_earth/models/ipcc2006/aboveGroundCropResidueTotal.py,sha256=gIKxz6fQmgkejkgQyu1m4Z_sVe3NzJ9H5CfGS4zOHfc,3565
190
- hestia_earth/models/ipcc2006/belowGroundCropResidue.py,sha256=5Tx3XLhzp59XabaMNWr2gIyBJ7SlsyUwSPoLSm2Mrpw,4281
190
+ hestia_earth/models/ipcc2006/belowGroundCropResidue.py,sha256=LE70lRsJeoe9qFWfVGHbnL-__nbDzzvRO9CzqRrySbE,4272
191
191
  hestia_earth/models/ipcc2006/co2ToAirOrganicSoilCultivation.py,sha256=3t2t9S5Pkw1JdKVrIhaRkcqNyaiUqiuTmw9z23Leplo,3146
192
192
  hestia_earth/models/ipcc2006/n2OToAirCropResidueDecompositionIndirect.py,sha256=9Xf6g-fMuMpB-xRm2YlYb8VpvZH-c283wLZPK2ZSJrY,2438
193
193
  hestia_earth/models/ipcc2006/n2OToAirExcretaDirect.py,sha256=-h5bG6XU5AzEFLSSFeSSU1OZHcxw2h4cZibK4hd2u4Q,2131
@@ -318,7 +318,7 @@ hestia_earth/models/lcImpactCertainEffectsInfinite/damageToTerrestrialEcosystems
318
318
  hestia_earth/models/linkedImpactAssessment/__init__.py,sha256=x6xsPu-Rwh-7HKsvHuKmgM1YML6fQy2z9Hsy9_BeO2Y,3565
319
319
  hestia_earth/models/mocking/__init__.py,sha256=Y39V6yj_3M1q8v9ShCHwPeJOstypOVIvb_FldMEbF7g,766
320
320
  hestia_earth/models/mocking/mock_search.py,sha256=ysPhzvMGvsHKqQXKRFi8ZqohcnyKutBlNqT_j0OH8L4,1983
321
- hestia_earth/models/mocking/search-results.json,sha256=0MClGUYinHbYklCNhse1T-cW37AseYRY40RSNBMmOwU,31895
321
+ hestia_earth/models/mocking/search-results.json,sha256=qhzP5fQTl3cosYM2N_fl_ki1gyTX9Eod9aXwR0VeAvg,31896
322
322
  hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
323
323
  hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=cJa-2eFuBM0pBAH6tMHUFlpBLhU92rYZzol-JkyDduM,2210
324
324
  hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=txjMrM6Q2g5Qsq6HhAL-IpMMLOj37wlWD2KnovyEWvw,2205
@@ -405,10 +405,10 @@ hestia_earth/models/schererPfister2015/pToGroundwaterSoilFlux.py,sha256=Gt3YdTCu
405
405
  hestia_earth/models/schererPfister2015/pToSurfaceWaterSoilFlux.py,sha256=bzgtCAtX0D5cRqoL24Ukg2IDr00Up7Ji4m1QQ9fJ-9w,2741
406
406
  hestia_earth/models/schererPfister2015/utils.py,sha256=LEvz9guqto0kuF5rXcQjgYsD3CvEmORvJQqRA1f7uMI,3130
407
407
  hestia_earth/models/site/__init__.py,sha256=aVuLLhq0OQVm-_MZoq4JAKMidqexUWJBg_7mmojmDzc,405
408
- hestia_earth/models/site/cationExchangeCapacityPerKgSoil.py,sha256=wEcycTmazTrCzXKoqBVhpKW_4cUmp3wWlxDBDSW1GKg,3406
408
+ hestia_earth/models/site/cationExchangeCapacityPerKgSoil.py,sha256=kQWABi_TWOYKgAkBnMEc0O1VgNOSbJuNkLaeNFMzeEI,3693
409
409
  hestia_earth/models/site/flowingWater.py,sha256=ZPeXd2tNYgG24kYOGQZM9lrUzCi9nZsabvHJsaH0hy4,1796
410
410
  hestia_earth/models/site/netPrimaryProduction.py,sha256=mwoQcjYkCbHxzZ8PhFN7RtjwKa5igqkICpNVJq08lYc,1901
411
- hestia_earth/models/site/organicCarbonPerHa.py,sha256=_duLpVHx-rx0f1I5IzreDp9LulC0JULrX63bm2W_tcM,3905
411
+ hestia_earth/models/site/organicCarbonPerHa.py,sha256=jj8zB_TyWB97Eo1eZLw-4RDM4HOY_bMGvB45OHEhXYU,4293
412
412
  hestia_earth/models/site/organicCarbonPerKgSoil.py,sha256=zY9QUho9jhaQK-X0x_DszZOoj-Ol8NzNcASk-Ix_qEk,1870
413
413
  hestia_earth/models/site/organicCarbonPerM3Soil.py,sha256=r-rDBLr-h10__csvlWreoe2MVBpMT5MMmokZVLRJ7Iw,1870
414
414
  hestia_earth/models/site/organicMatterPerKgSoil.py,sha256=VXXLt9lBWkNR8xY4tGOi9DmiaRBKydbevwJ_HL2JNf0,1870
@@ -503,7 +503,7 @@ tests/models/aware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
503
503
  tests/models/aware/test_scarcityWeightedWaterUse.py,sha256=JmwOQFxcFm45IKn_aJU1K6o8Cp5w_wllcRDAhwbXMj0,2278
504
504
  tests/models/blonkConsultants2016/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
505
505
  tests/models/blonkConsultants2016/test_ch4ToAirNaturalVegetationBurning.py,sha256=T4FjcMHaIK5Pp6ZnYKiRUxX_FuK23NWY0TeN7z0fjUc,1155
506
- tests/models/blonkConsultants2016/test_co2ToAirSoilCarbonStockChangeManagementChange.py,sha256=Y9zJT-My5pvHrwfB54ViSsgV-bMc-wEZpX71PE7Lg40,1176
506
+ tests/models/blonkConsultants2016/test_co2ToAirAboveGroundBiomassStockChangeLandUseChange.py,sha256=70j3jG0dALAnowIQb0AKqP6FmI_utjt7Jd8Jdim_hY4,1181
507
507
  tests/models/blonkConsultants2016/test_landTransformationFromForest20YearAverageDuringCycle.py,sha256=0VrYyvnKnfTpElwHLKp2YxXXTQIbv5q8x10NCaZjzTs,1198
508
508
  tests/models/blonkConsultants2016/test_n2OToAirNaturalVegetationBurningDirect.py,sha256=JBDTKbPaP-enQLi7281NRDjgO_HtkWuQzREN3kyO5qU,1180
509
509
  tests/models/blonkConsultants2016/test_utils.py,sha256=9OYZVBui1pauU-ipisUGzQc9johzMYDkXhqYpCWROnU,456
@@ -593,7 +593,7 @@ tests/models/faostat2018/test_liveweightPerHead.py,sha256=KrjbvyWmnGS-Wy_B5ZSNbo
593
593
  tests/models/faostat2018/test_readyToCookWeightPerHead.py,sha256=pMDcONs0WUvANcJ6_OPF7TBwMF45JGMxFRPNPtHLqVI,1570
594
594
  tests/models/faostat2018/test_seed.py,sha256=tUXoNVveX0m0ed9UXB4zXxIZsPxktXyUXlbWuUKG0sQ,1705
595
595
  tests/models/faostat2018/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
596
- tests/models/faostat2018/product/test_price.py,sha256=65K4IwMoAz2giPolZhKWMQifXjYYZr4jSZXfY9g4spk,3543
596
+ tests/models/faostat2018/product/test_price.py,sha256=kVGebepabR8vMrfmVMz1Scq56mg2EDwYwzUE1v7USWY,3860
597
597
  tests/models/geospatialDatabase/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
598
598
  tests/models/geospatialDatabase/test_aware.py,sha256=tbBBvXrOqdO0cMPJTa02UfhlwfosH8iNoJLzZNFs1NU,857
599
599
  tests/models/geospatialDatabase/test_clayContent.py,sha256=56QuhOUDBwHhVrzjFmDifr6bHgtQExDENlQ1fNi4VQw,1030
@@ -875,10 +875,10 @@ tests/models/schererPfister2015/test_pToDrainageWaterSoilFlux.py,sha256=57MVRyiE
875
875
  tests/models/schererPfister2015/test_pToGroundwaterSoilFlux.py,sha256=lOTL-ue6hEbQsKIss6VsN7bJME5UCB3pTbqbLtMp9rk,1064
876
876
  tests/models/schererPfister2015/test_pToSurfaceWaterSoilFlux.py,sha256=1VJo9q-Kb2OboK2RMp3-bkP6lXfkFbqMz1ACJC75FWw,1441
877
877
  tests/models/site/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
878
- tests/models/site/test_cationExchangeCapacityPerKgSoil.py,sha256=FOtllJ_E4Ld4MngPn__CsQXXeHhZ5fNB-ruSd8DUgFQ,963
878
+ tests/models/site/test_cationExchangeCapacityPerKgSoil.py,sha256=ZbIt-mQohYE-8xd4zoqDTVj3VC-Dg9wnOTY4ppULsCY,1023
879
879
  tests/models/site/test_flowingWater.py,sha256=q7ktHV7sffIUBf0SgIhbkL_U_c7RTHYv6oWhXY4A6io,1274
880
880
  tests/models/site/test_netPrimaryProduction.py,sha256=FaC5TEwHnR56_QrXkIB5u3mgSLOcSmBRbL8vzqaZwk0,1056
881
- tests/models/site/test_organicCarbonPerHa.py,sha256=m392fH_aEt_tI6dVhAzOVHKpeuztNgP5p6yNiLTs4Mw,983
881
+ tests/models/site/test_organicCarbonPerHa.py,sha256=l9I_-c7y3-dlSceqd7LY4CKTGr3TamRw0vtHnWC31YE,1043
882
882
  tests/models/site/test_organicCarbonPerKgSoil.py,sha256=fqPe2JbrZwwMK497Qnb2WPx4-n2vda4PW-S3tQa_CGI,1035
883
883
  tests/models/site/test_organicCarbonPerM3Soil.py,sha256=8fOwtcBAFH1fSduIXXtYOdL83oYAVxC4f6BAZpY5X_w,1035
884
884
  tests/models/site/test_organicMatterPerKgSoil.py,sha256=EvZ6HknxjUjhdmdYostB9eCc_WowpRWpmssWM2vT_NU,1035
@@ -942,8 +942,8 @@ tests/models/utils/test_site.py,sha256=cSKrkLeerymMLZAwCnbQce38NwgxXojQHAVm9DPUT
942
942
  tests/models/utils/test_term.py,sha256=-Wn2C1jyOLfkvhcKmKWT-Jms7yqLwx5ok91gYJNcGWc,2028
943
943
  tests/models/webbEtAl2012AndSintermannEtAl2012/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
944
944
  tests/models/webbEtAl2012AndSintermannEtAl2012/test_nh3ToAirOrganicFertiliser.py,sha256=qi2FNXS5Af2WDtm7nq_FsprH3BfCF0XxnE0XHmC4aIY,2244
945
- hestia_earth_models-0.48.0.dist-info/LICENSE,sha256=EFSZhfUdZCTsCIYdHzTGewMKfRfp7X9t1s2aaKxm8O0,1154
946
- hestia_earth_models-0.48.0.dist-info/METADATA,sha256=qr3vGbnvtSxfruXQTcGowRr_gfINmTxglKJWJ3_lSsQ,3190
947
- hestia_earth_models-0.48.0.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
948
- hestia_earth_models-0.48.0.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
949
- hestia_earth_models-0.48.0.dist-info/RECORD,,
945
+ hestia_earth_models-0.49.0.dist-info/LICENSE,sha256=EFSZhfUdZCTsCIYdHzTGewMKfRfp7X9t1s2aaKxm8O0,1154
946
+ hestia_earth_models-0.49.0.dist-info/METADATA,sha256=9XuW6DCH40QIwXn3LgZNRC9zOwkFzSSoMn98MFaLIec,3178
947
+ hestia_earth_models-0.49.0.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
948
+ hestia_earth_models-0.49.0.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
949
+ hestia_earth_models-0.49.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.0)
2
+ Generator: bdist_wheel (0.41.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -2,7 +2,7 @@ from unittest.mock import patch
2
2
  import json
3
3
  from tests.utils import fixtures_path, fake_new_emission
4
4
 
5
- from hestia_earth.models.blonkConsultants2016.co2ToAirSoilCarbonStockChangeManagementChange import (
5
+ from hestia_earth.models.blonkConsultants2016.co2ToAirAboveGroundBiomassStockChangeLandUseChange import (
6
6
  MODEL, TERM_ID, run, _should_run
7
7
  )
8
8
 
@@ -2,7 +2,7 @@ import json
2
2
  from unittest.mock import patch
3
3
  from tests.utils import fixtures_path
4
4
 
5
- from hestia_earth.models.faostat2018.product.price import MODEL, MODEL_KEY, run, _should_run
5
+ from hestia_earth.models.faostat2018.product.price import MODEL, MODEL_KEY, run, _should_run, _lookup_data
6
6
 
7
7
  class_path = f"hestia_earth.models.{MODEL}.product.{MODEL_KEY}"
8
8
  fixtures_folder = f"{fixtures_path}/{MODEL}/product/{MODEL_KEY}"
@@ -18,6 +18,12 @@ def test_should_run():
18
18
  assert should_run is True
19
19
 
20
20
 
21
+ def test_lookup_data():
22
+ assert _lookup_data('cocoaSeedDehulled', 'Cocoa beans', 'GADM-GHA', 2000, term_type='crop') == 412.9
23
+ # average price per tonne as year value is missing
24
+ assert _lookup_data('cocoaSeedDehulled', 'Cocoa beans', 'GADM-GHA', 2012, term_type='crop') == 844.0047619047618
25
+
26
+
21
27
  @patch(f"{class_path}.download_hestia", return_value={})
22
28
  def test_run_crop(*args):
23
29
  with open(f"{fixtures_folder}/crop/cycle.jsonld", encoding='utf-8') as f:
@@ -2,21 +2,23 @@ from unittest.mock import patch
2
2
  import json
3
3
  from tests.utils import fixtures_path, fake_new_measurement
4
4
 
5
- from hestia_earth.models.site.cationExchangeCapacityPerKgSoil import MODEL, TERM_ID, run, _should_run
5
+ from hestia_earth.models.site.cationExchangeCapacityPerKgSoil import (
6
+ MODEL, TERM_ID, run, _should_run_measurements
7
+ )
6
8
 
7
9
  class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
8
10
  fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
9
11
 
10
12
 
11
13
  @patch(f"{class_path}.find_term_match")
12
- def test_should_run(mock_find):
14
+ def test_should_run_measurements(mock_find):
13
15
  # no measurement => no run
14
16
  mock_find.return_value = None
15
- assert not _should_run({}, [])
17
+ assert not _should_run_measurements({}, [])
16
18
 
17
19
  # with measurement => run
18
20
  mock_find.return_value = {'value': [10]}
19
- assert _should_run({}, []) is True
21
+ assert _should_run_measurements({}, []) is True
20
22
 
21
23
 
22
24
  @patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
@@ -2,21 +2,23 @@ from unittest.mock import patch
2
2
  import json
3
3
  from tests.utils import fixtures_path, fake_new_measurement
4
4
 
5
- from hestia_earth.models.site.organicCarbonPerHa import MODEL, TERM_ID, run, _should_run
5
+ from hestia_earth.models.site.organicCarbonPerHa import (
6
+ MODEL, TERM_ID, run, _should_run_measurements
7
+ )
6
8
 
7
9
  class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
8
10
  fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
9
11
 
10
12
 
11
13
  @patch(f"{class_path}.find_term_match")
12
- def test_should_run(mock_find):
14
+ def test_should_run_measurements(mock_find):
13
15
  # no measurement => no run
14
16
  mock_find.return_value = {}
15
- assert not _should_run({}, [])
17
+ assert not _should_run_measurements({}, [])
16
18
 
17
19
  # with measurement => run
18
20
  mock_find.return_value = {'value': [10], 'depthUpper': 0, 'depthLower': 10}
19
- assert _should_run({}, []) is True
21
+ assert _should_run_measurements({}, []) is True
20
22
 
21
23
 
22
24
  @patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)