hestia-earth-models 0.75.2__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 (27) hide show
  1. hestia_earth/models/config/Cycle.json +168 -16
  2. hestia_earth/models/emepEea2019/blackCarbonToAirFuelCombustion.py +33 -0
  3. hestia_earth/models/emepEea2019/ch4ToAirFuelCombustion.py +33 -0
  4. hestia_earth/models/emepEea2019/coToAirFuelCombustion.py +33 -0
  5. hestia_earth/models/emepEea2019/nmvocToAirFuelCombustion.py +33 -0
  6. hestia_earth/models/emepEea2019/pm10ToAirFuelCombustion.py +33 -0
  7. hestia_earth/models/emepEea2019/pm25ToAirFuelCombustion.py +33 -0
  8. hestia_earth/models/emepEea2019/tspToAirFuelCombustion.py +33 -0
  9. hestia_earth/models/faostat2018/seed.py +9 -8
  10. hestia_earth/models/hestia/management.py +5 -4
  11. hestia_earth/models/ipcc2019/animal/pastureGrass.py +16 -10
  12. hestia_earth/models/ipcc2019/pastureGrass.py +16 -10
  13. hestia_earth/models/ipcc2019/pastureGrass_utils.py +17 -10
  14. hestia_earth/models/linkedImpactAssessment/emissions.py +1 -1
  15. hestia_earth/models/mocking/search-results.json +1 -1
  16. hestia_earth/models/pefcrGuidanceDocument2017/__init__.py +13 -0
  17. hestia_earth/models/pefcrGuidanceDocument2017/pesticideToAirPesticideApplication.py +29 -0
  18. hestia_earth/models/pefcrGuidanceDocument2017/pesticideToSoilPesticideApplication.py +29 -0
  19. hestia_earth/models/pefcrGuidanceDocument2017/pesticideToWaterPesticideApplication.py +29 -0
  20. hestia_earth/models/pefcrGuidanceDocument2017/utils.py +55 -0
  21. hestia_earth/models/pooreNemecek2018/saplingsDepreciatedAmountPerCycle.py +1 -1
  22. hestia_earth/models/version.py +1 -1
  23. {hestia_earth_models-0.75.2.dist-info → hestia_earth_models-0.75.3.dist-info}/METADATA +1 -1
  24. {hestia_earth_models-0.75.2.dist-info → hestia_earth_models-0.75.3.dist-info}/RECORD +27 -15
  25. {hestia_earth_models-0.75.2.dist-info → hestia_earth_models-0.75.3.dist-info}/WHEEL +0 -0
  26. {hestia_earth_models-0.75.2.dist-info → hestia_earth_models-0.75.3.dist-info}/licenses/LICENSE +0 -0
  27. {hestia_earth_models-0.75.2.dist-info → hestia_earth_models-0.75.3.dist-info}/top_level.txt +0 -0
@@ -755,22 +755,24 @@
755
755
  "mergeStrategy": "list",
756
756
  "stage": 2
757
757
  },
758
- {
759
- "key": "inputs",
760
- "model": "ipcc2019",
761
- "value": "pastureGrass",
762
- "runStrategy": "always",
763
- "mergeStrategy": "list",
764
- "stage": 2
765
- },
766
- {
767
- "key": "animals",
768
- "model": "ipcc2019",
769
- "value": "animal.pastureGrass",
770
- "runStrategy": "always",
771
- "mergeStrategy": "list",
772
- "stage": 2
773
- },
758
+ [
759
+ {
760
+ "key": "inputs",
761
+ "model": "ipcc2019",
762
+ "value": "pastureGrass",
763
+ "runStrategy": "always",
764
+ "mergeStrategy": "list",
765
+ "stage": 2
766
+ },
767
+ {
768
+ "key": "animals",
769
+ "model": "ipcc2019",
770
+ "value": "animal.pastureGrass",
771
+ "runStrategy": "always",
772
+ "mergeStrategy": "list",
773
+ "stage": 2
774
+ }
775
+ ],
774
776
  [
775
777
  {
776
778
  "key": "products",
@@ -1368,6 +1370,51 @@
1368
1370
  "replaceThreshold": ["value", 0.01]
1369
1371
  },
1370
1372
  "stage": 2
1373
+ },
1374
+ {
1375
+ "key": "emissions",
1376
+ "model": "pefcrGuidanceDocument2017",
1377
+ "value": "pesticideToAirPesticideApplication",
1378
+ "runStrategy": "add_blank_node_if_missing",
1379
+ "runArgs": {
1380
+ "runNonMeasured": true,
1381
+ "runNonAddedTerm": true
1382
+ },
1383
+ "mergeStrategy": "list",
1384
+ "mergeArgs": {
1385
+ "replaceThreshold": ["value", 0.01]
1386
+ },
1387
+ "stage": 2
1388
+ },
1389
+ {
1390
+ "key": "emissions",
1391
+ "model": "pefcrGuidanceDocument2017",
1392
+ "value": "pesticideToSoilPesticideApplication",
1393
+ "runStrategy": "add_blank_node_if_missing",
1394
+ "runArgs": {
1395
+ "runNonMeasured": true,
1396
+ "runNonAddedTerm": true
1397
+ },
1398
+ "mergeStrategy": "list",
1399
+ "mergeArgs": {
1400
+ "replaceThreshold": ["value", 0.01]
1401
+ },
1402
+ "stage": 2
1403
+ },
1404
+ {
1405
+ "key": "emissions",
1406
+ "model": "pefcrGuidanceDocument2017",
1407
+ "value": "pesticideToWaterPesticideApplication",
1408
+ "runStrategy": "add_blank_node_if_missing",
1409
+ "runArgs": {
1410
+ "runNonMeasured": true,
1411
+ "runNonAddedTerm": true
1412
+ },
1413
+ "mergeStrategy": "list",
1414
+ "mergeArgs": {
1415
+ "replaceThreshold": ["value", 0.01]
1416
+ },
1417
+ "stage": 2
1371
1418
  }
1372
1419
  ],
1373
1420
  [
@@ -1846,6 +1893,111 @@
1846
1893
  },
1847
1894
  "stage": 2
1848
1895
  },
1896
+ {
1897
+ "key": "emissions",
1898
+ "model": "emepEea2019",
1899
+ "value": "coToAirFuelCombustion",
1900
+ "runStrategy": "add_blank_node_if_missing",
1901
+ "runArgs": {
1902
+ "runNonMeasured": true,
1903
+ "runNonAddedTerm": true
1904
+ },
1905
+ "mergeStrategy": "list",
1906
+ "mergeArgs": {
1907
+ "replaceThreshold": ["value", 0.01]
1908
+ },
1909
+ "stage": 2
1910
+ },
1911
+ {
1912
+ "key": "emissions",
1913
+ "model": "emepEea2019",
1914
+ "value": "blackCarbonToAirFuelCombustion",
1915
+ "runStrategy": "add_blank_node_if_missing",
1916
+ "runArgs": {
1917
+ "runNonMeasured": true,
1918
+ "runNonAddedTerm": true
1919
+ },
1920
+ "mergeStrategy": "list",
1921
+ "mergeArgs": {
1922
+ "replaceThreshold": ["value", 0.01]
1923
+ },
1924
+ "stage": 2
1925
+ },
1926
+ {
1927
+ "key": "emissions",
1928
+ "model": "emepEea2019",
1929
+ "value": "nmvocToAirFuelCombustion",
1930
+ "runStrategy": "add_blank_node_if_missing",
1931
+ "runArgs": {
1932
+ "runNonMeasured": true,
1933
+ "runNonAddedTerm": true
1934
+ },
1935
+ "mergeStrategy": "list",
1936
+ "mergeArgs": {
1937
+ "replaceThreshold": ["value", 0.01]
1938
+ },
1939
+ "stage": 2
1940
+ },
1941
+ {
1942
+ "key": "emissions",
1943
+ "model": "emepEea2019",
1944
+ "value": "pm10ToAirFuelCombustion",
1945
+ "runStrategy": "add_blank_node_if_missing",
1946
+ "runArgs": {
1947
+ "runNonMeasured": true,
1948
+ "runNonAddedTerm": true
1949
+ },
1950
+ "mergeStrategy": "list",
1951
+ "mergeArgs": {
1952
+ "replaceThreshold": ["value", 0.01]
1953
+ },
1954
+ "stage": 2
1955
+ },
1956
+ {
1957
+ "key": "emissions",
1958
+ "model": "emepEea2019",
1959
+ "value": "pm25ToAirFuelCombustion",
1960
+ "runStrategy": "add_blank_node_if_missing",
1961
+ "runArgs": {
1962
+ "runNonMeasured": true,
1963
+ "runNonAddedTerm": true
1964
+ },
1965
+ "mergeStrategy": "list",
1966
+ "mergeArgs": {
1967
+ "replaceThreshold": ["value", 0.01]
1968
+ },
1969
+ "stage": 2
1970
+ },
1971
+ {
1972
+ "key": "emissions",
1973
+ "model": "emepEea2019",
1974
+ "value": "tspToAirFuelCombustion",
1975
+ "runStrategy": "add_blank_node_if_missing",
1976
+ "runArgs": {
1977
+ "runNonMeasured": true,
1978
+ "runNonAddedTerm": true
1979
+ },
1980
+ "mergeStrategy": "list",
1981
+ "mergeArgs": {
1982
+ "replaceThreshold": ["value", 0.01]
1983
+ },
1984
+ "stage": 2
1985
+ },
1986
+ {
1987
+ "key": "emissions",
1988
+ "model": "emepEea2019",
1989
+ "value": "ch4ToAirFuelCombustion",
1990
+ "runStrategy": "add_blank_node_if_missing",
1991
+ "runArgs": {
1992
+ "runNonMeasured": true,
1993
+ "runNonAddedTerm": true
1994
+ },
1995
+ "mergeStrategy": "list",
1996
+ "mergeArgs": {
1997
+ "replaceThreshold": ["value", 0.01]
1998
+ },
1999
+ "stage": 2
2000
+ },
1849
2001
  {
1850
2002
  "key": "emissions",
1851
2003
  "model": "ipcc2019",
@@ -0,0 +1,33 @@
1
+ from hestia_earth.schema import EmissionMethodTier
2
+
3
+ from .fuelCombustion_utils import run as run_fuelCombustion
4
+
5
+ REQUIREMENTS = {
6
+ "Cycle": {
7
+ "or": {
8
+ "inputs": [
9
+ {"@type": "Input", "value": "", "term.termType": "fuel", "optional": {
10
+ "operation": ""
11
+ }}
12
+ ],
13
+ "completeness.electricityFuel": "True"
14
+ }
15
+ }
16
+ }
17
+ RETURNS = {
18
+ "Emission": [{
19
+ "value": "",
20
+ "inputs": "",
21
+ "operation": "",
22
+ "methodTier": "tier 1"
23
+ }]
24
+ }
25
+ LOOKUPS = {
26
+ "fuel": "blackCarbonToAirFuelCombustionEmepEea2019",
27
+ "operation": "blackCarbonToAirFuelCombustionEmepEea2019"
28
+ }
29
+ TERM_ID = 'blackCarbonToAirFuelCombustion'
30
+ TIER = EmissionMethodTier.TIER_1.value
31
+
32
+
33
+ def run(cycle: dict): return run_fuelCombustion(cycle, term_id=TERM_ID)
@@ -0,0 +1,33 @@
1
+ from hestia_earth.schema import EmissionMethodTier
2
+
3
+ from .fuelCombustion_utils import run as run_fuelCombustion
4
+
5
+ REQUIREMENTS = {
6
+ "Cycle": {
7
+ "or": {
8
+ "inputs": [
9
+ {"@type": "Input", "value": "", "term.termType": "fuel", "optional": {
10
+ "operation": ""
11
+ }}
12
+ ],
13
+ "completeness.electricityFuel": "True"
14
+ }
15
+ }
16
+ }
17
+ RETURNS = {
18
+ "Emission": [{
19
+ "value": "",
20
+ "inputs": "",
21
+ "operation": "",
22
+ "methodTier": "tier 1"
23
+ }]
24
+ }
25
+ LOOKUPS = {
26
+ "fuel": "ch4ToAirFuelCombustionEmepEea2019",
27
+ "operation": "ch4ToAirFuelCombustionEmepEea2019"
28
+ }
29
+ TERM_ID = 'ch4ToAirFuelCombustion'
30
+ TIER = EmissionMethodTier.TIER_1.value
31
+
32
+
33
+ def run(cycle: dict): return run_fuelCombustion(cycle, term_id=TERM_ID)
@@ -0,0 +1,33 @@
1
+ from hestia_earth.schema import EmissionMethodTier
2
+
3
+ from .fuelCombustion_utils import run as run_fuelCombustion
4
+
5
+ REQUIREMENTS = {
6
+ "Cycle": {
7
+ "or": {
8
+ "inputs": [
9
+ {"@type": "Input", "value": "", "term.termType": "fuel", "optional": {
10
+ "operation": ""
11
+ }}
12
+ ],
13
+ "completeness.electricityFuel": "True"
14
+ }
15
+ }
16
+ }
17
+ RETURNS = {
18
+ "Emission": [{
19
+ "value": "",
20
+ "inputs": "",
21
+ "operation": "",
22
+ "methodTier": "tier 1"
23
+ }]
24
+ }
25
+ LOOKUPS = {
26
+ "fuel": "coToAirFuelCombustionEmepEea2019",
27
+ "operation": "coToAirFuelCombustionEmepEea2019"
28
+ }
29
+ TERM_ID = 'coToAirFuelCombustion'
30
+ TIER = EmissionMethodTier.TIER_1.value
31
+
32
+
33
+ def run(cycle: dict): return run_fuelCombustion(cycle, term_id=TERM_ID)
@@ -0,0 +1,33 @@
1
+ from hestia_earth.schema import EmissionMethodTier
2
+
3
+ from .fuelCombustion_utils import run as run_fuelCombustion
4
+
5
+ REQUIREMENTS = {
6
+ "Cycle": {
7
+ "or": {
8
+ "inputs": [
9
+ {"@type": "Input", "value": "", "term.termType": "fuel", "optional": {
10
+ "operation": ""
11
+ }}
12
+ ],
13
+ "completeness.electricityFuel": "True"
14
+ }
15
+ }
16
+ }
17
+ RETURNS = {
18
+ "Emission": [{
19
+ "value": "",
20
+ "inputs": "",
21
+ "operation": "",
22
+ "methodTier": "tier 1"
23
+ }]
24
+ }
25
+ LOOKUPS = {
26
+ "fuel": "nmvocToAirFuelCombustionEmepEea2019",
27
+ "operation": "nmvocToAirFuelCombustionEmepEea2019"
28
+ }
29
+ TERM_ID = 'nmvocToAirFuelCombustion'
30
+ TIER = EmissionMethodTier.TIER_1.value
31
+
32
+
33
+ def run(cycle: dict): return run_fuelCombustion(cycle, term_id=TERM_ID)
@@ -0,0 +1,33 @@
1
+ from hestia_earth.schema import EmissionMethodTier
2
+
3
+ from .fuelCombustion_utils import run as run_fuelCombustion
4
+
5
+ REQUIREMENTS = {
6
+ "Cycle": {
7
+ "or": {
8
+ "inputs": [
9
+ {"@type": "Input", "value": "", "term.termType": "fuel", "optional": {
10
+ "operation": ""
11
+ }}
12
+ ],
13
+ "completeness.electricityFuel": "True"
14
+ }
15
+ }
16
+ }
17
+ RETURNS = {
18
+ "Emission": [{
19
+ "value": "",
20
+ "inputs": "",
21
+ "operation": "",
22
+ "methodTier": "tier 1"
23
+ }]
24
+ }
25
+ LOOKUPS = {
26
+ "fuel": "pm10ToAirFuelCombustionEmepEea2019",
27
+ "operation": "pm10ToAirFuelCombustionEmepEea2019"
28
+ }
29
+ TERM_ID = 'pm10ToAirFuelCombustion'
30
+ TIER = EmissionMethodTier.TIER_1.value
31
+
32
+
33
+ def run(cycle: dict): return run_fuelCombustion(cycle, term_id=TERM_ID)
@@ -0,0 +1,33 @@
1
+ from hestia_earth.schema import EmissionMethodTier
2
+
3
+ from .fuelCombustion_utils import run as run_fuelCombustion
4
+
5
+ REQUIREMENTS = {
6
+ "Cycle": {
7
+ "or": {
8
+ "inputs": [
9
+ {"@type": "Input", "value": "", "term.termType": "fuel", "optional": {
10
+ "operation": ""
11
+ }}
12
+ ],
13
+ "completeness.electricityFuel": "True"
14
+ }
15
+ }
16
+ }
17
+ RETURNS = {
18
+ "Emission": [{
19
+ "value": "",
20
+ "inputs": "",
21
+ "operation": "",
22
+ "methodTier": "tier 1"
23
+ }]
24
+ }
25
+ LOOKUPS = {
26
+ "fuel": "pm25ToAirFuelCombustionEmepEea2019",
27
+ "operation": "pm25ToAirFuelCombustionEmepEea2019"
28
+ }
29
+ TERM_ID = 'pm25ToAirFuelCombustion'
30
+ TIER = EmissionMethodTier.TIER_1.value
31
+
32
+
33
+ def run(cycle: dict): return run_fuelCombustion(cycle, term_id=TERM_ID)
@@ -0,0 +1,33 @@
1
+ from hestia_earth.schema import EmissionMethodTier
2
+
3
+ from .fuelCombustion_utils import run as run_fuelCombustion
4
+
5
+ REQUIREMENTS = {
6
+ "Cycle": {
7
+ "or": {
8
+ "inputs": [
9
+ {"@type": "Input", "value": "", "term.termType": "fuel", "optional": {
10
+ "operation": ""
11
+ }}
12
+ ],
13
+ "completeness.electricityFuel": "True"
14
+ }
15
+ }
16
+ }
17
+ RETURNS = {
18
+ "Emission": [{
19
+ "value": "",
20
+ "inputs": "",
21
+ "operation": "",
22
+ "methodTier": "tier 1"
23
+ }]
24
+ }
25
+ LOOKUPS = {
26
+ "fuel": "tspToAirFuelCombustionEmepEea2019",
27
+ "operation": "tspToAirFuelCombustionEmepEea2019"
28
+ }
29
+ TERM_ID = 'tspToAirFuelCombustion'
30
+ TIER = EmissionMethodTier.TIER_1.value
31
+
32
+
33
+ def run(cycle: dict): return run_fuelCombustion(cycle, term_id=TERM_ID)
@@ -15,7 +15,7 @@ REQUIREMENTS = {
15
15
  "term.termType": "crop",
16
16
  "value": "> 0"
17
17
  }],
18
- "completeness.other": "False"
18
+ "completeness.seed": "False"
19
19
  }
20
20
  }
21
21
  LOOKUPS = {
@@ -34,17 +34,18 @@ TERM_ID = 'seed'
34
34
  def _run_product(product: dict):
35
35
  term = product.get('term', {})
36
36
  product_value = list_sum(product.get('value', []))
37
- value = safe_parse_float(
38
- get_lookup_value(term, LOOKUPS['crop'][0], model=MODEL, term=TERM_ID), default=0) * product_value
39
- sd = safe_parse_float(get_lookup_value(term, LOOKUPS['crop'][1], model=MODEL, term=TERM_ID), default=0)
40
- return value, sd
37
+ value, sd = [
38
+ safe_parse_float(get_lookup_value(term, lookup, model=MODEL, term=TERM_ID), default=0)
39
+ for lookup in LOOKUPS['crop']
40
+ ]
41
+ return value * product_value, sd
41
42
 
42
43
 
43
44
  def _run(products: list):
44
45
  values = list(map(_run_product, products))
45
46
  total_value = list_sum([value for value, _ in values])
46
47
  # TODO: we only fill-in sd for single values as the total value is complicated to calculate
47
- total_sd = values[0][1] if len(values) == 1 else 0
48
+ total_sd = values[0][1] if len(values) == 1 else None
48
49
  return [
49
50
  _new_input(term=TERM_ID, model=MODEL, value=total_value, sd=total_sd)
50
51
  ] if total_value > 0 else []
@@ -53,8 +54,8 @@ def _run(products: list):
53
54
  def _should_run_product(product: dict):
54
55
  term = product.get('term', {})
55
56
  product_value = list_sum(product.get('value', []))
56
- has_all_lookups = all([get_lookup_value(term, col, model=MODEL, term=TERM_ID) for col in LOOKUPS['crop']])
57
- return all([has_all_lookups, product_value > 0])
57
+ has_lookup = get_lookup_value(term, LOOKUPS['crop'][0], model=MODEL, term=TERM_ID)
58
+ return all([has_lookup, product_value > 0])
58
59
 
59
60
 
60
61
  def _should_run(cycle: dict):
@@ -206,7 +206,7 @@ def _get_relevant_items(cycle: dict, item_name: str, term_types: List[TermTermTy
206
206
 
207
207
 
208
208
  def _input_gap_fill_term_id(input: dict):
209
- return get_lookup_value(input.get('term'), 'inputGapFillManagementTermId')
209
+ return get_lookup_value(input.get('term'), 'inputGapFillManagementTermId', skip_debug=True)
210
210
 
211
211
 
212
212
  def _input_value_valid(input: dict):
@@ -242,9 +242,10 @@ def _cycle_has_existing_non_cover_land_cover_nodes(cycle: dict) -> bool:
242
242
  # blankNodesGroup = Cover crops lookup, return True, else False
243
243
  return any([
244
244
  practice for practice in cycle.get("practices", [])
245
- if practice.get("term", {}).get("termType") == TermTermType.LANDCOVER.value
246
- and not any(prop for prop in practice.get("properties", [])
247
- if _is_cover_crop(prop.get("term", {}).get("@id")))
245
+ if practice.get("term", {}).get("termType") == TermTermType.LANDCOVER.value and not any(
246
+ prop for prop in practice.get("properties", [])
247
+ if _is_cover_crop(prop.get("term", {}).get("@id"))
248
+ )
248
249
  ])
249
250
 
250
251
 
@@ -11,6 +11,7 @@ from hestia_earth.models.utils.property import get_node_property
11
11
  from hestia_earth.models.utils.cycle import get_animals_by_period
12
12
  from .. import MODEL
13
13
  from ..pastureGrass_utils import (
14
+ has_cycle_inputs_feed,
14
15
  practice_input_id,
15
16
  should_run_practice,
16
17
  calculate_meanDE,
@@ -79,7 +80,11 @@ REQUIREMENTS = {
79
80
  "properties": [{
80
81
  "@type": "Property",
81
82
  "value": "",
82
- "term.@id": ["neutralDetergentFibreContent", "energyContentHigherHeatingValue"]
83
+ "term.@id": [
84
+ "neutralDetergentFibreContent",
85
+ "energyContentHigherHeatingValue",
86
+ "energyDigestibilityRuminants"
87
+ ]
83
88
  }]
84
89
  }
85
90
  }],
@@ -274,10 +279,8 @@ def _should_run(cycle: dict, animals: list, practices: dict):
274
279
  freshForage_incomplete = _is_term_type_incomplete(cycle, 'freshForage')
275
280
  all_animals_have_value = all([a.get('value', 0) > 0 for a in animals])
276
281
 
277
- no_cycle_inputs_feed = all([not input.get('isAnimalFeed', False) for input in cycle.get('inputs', [])])
278
-
279
- meanDE = calculate_meanDE(practices)
280
- meanECHHV = calculate_meanECHHV(practices)
282
+ meanDE = calculate_meanDE(cycle, practices)
283
+ meanECHHV = calculate_meanECHHV(cycle, practices)
281
284
  REM = calculate_REM(meanDE)
282
285
  REG = calculate_REG(meanDE)
283
286
 
@@ -288,7 +291,6 @@ def _should_run(cycle: dict, animals: list, practices: dict):
288
291
  animalFeed_complete,
289
292
  animalPopulation_complete,
290
293
  freshForage_incomplete,
291
- no_cycle_inputs_feed,
292
294
  all_animals_have_value,
293
295
  has_practice_termType_system,
294
296
  has_practice_pastureGrass_with_landCover_key,
@@ -302,12 +304,11 @@ def _should_run(cycle: dict, animals: list, practices: dict):
302
304
  term_type_animalFeed_complete=animalFeed_complete,
303
305
  term_type_animalPopulation_complete=animalPopulation_complete,
304
306
  term_type_freshForage_incomplete=freshForage_incomplete,
305
- no_cycle_inputs_feed=no_cycle_inputs_feed,
306
307
  all_animals_have_value=all_animals_have_value,
307
308
  has_practice_termType_system=has_practice_termType_system,
308
309
  has_practice_pastureGrass_with_landCover_key=has_practice_pastureGrass_with_landCover_key,
309
- grass_MeanDE=calculate_meanDE(practices, term=term_id),
310
- grass_MeanECHHV=calculate_meanECHHV(practices, term=term_id),
310
+ grass_MeanDE=calculate_meanDE(cycle, practices, term=term_id),
311
+ grass_MeanECHHV=calculate_meanECHHV(cycle, practices, term=term_id),
311
312
  grass_REM=REM,
312
313
  grass_REG=REG)
313
314
 
@@ -316,8 +317,13 @@ def _should_run(cycle: dict, animals: list, practices: dict):
316
317
  return should_run, meanDE, meanECHHV, REM, REG, systems
317
318
 
318
319
 
319
- def run(cycle: dict):
320
+ def _run(cycle: dict):
320
321
  animals = get_animals_by_period(cycle)
321
322
  practices = list(filter(should_run_practice(cycle), cycle.get('practices', [])))
322
323
  should_run, meanDE, meanECHHV, REM, REG, systems = _should_run(cycle, animals, practices)
323
324
  return list(map(_run_animal(cycle, meanDE, meanECHHV, REM, REG, systems, practices), animals)) if should_run else []
325
+
326
+
327
+ def run(cycle: dict):
328
+ # determines if this model or animal model should run
329
+ return _run(cycle) if not has_cycle_inputs_feed(cycle) else []
@@ -10,6 +10,7 @@ from hestia_earth.models.utils.completeness import _is_term_type_complete, _is_t
10
10
  from hestia_earth.models.utils.cycle import get_animals_by_period
11
11
  from . import MODEL
12
12
  from .pastureGrass_utils import (
13
+ has_cycle_inputs_feed,
13
14
  practice_input_id,
14
15
  should_run_practice,
15
16
  calculate_meanDE,
@@ -56,7 +57,11 @@ REQUIREMENTS = {
56
57
  "properties": [{
57
58
  "@type": "Property",
58
59
  "value": "",
59
- "term.@id": ["neutralDetergentFibreContent", "energyContentHigherHeatingValue"]
60
+ "term.@id": [
61
+ "neutralDetergentFibreContent",
62
+ "energyContentHigherHeatingValue",
63
+ "energyDigestibilityRuminants"
64
+ ]
60
65
  }]
61
66
  }
62
67
  }],
@@ -227,10 +232,8 @@ def _should_run(cycle: dict, practices: dict):
227
232
  freshForage_incomplete = _is_term_type_incomplete(cycle, 'freshForage')
228
233
  all_animals_have_value = all([a.get('value', 0) > 0 for a in cycle.get('animals', [])])
229
234
 
230
- has_cycle_inputs_feed = any([i.get('isAnimalFeed', False) for i in cycle.get('inputs', [])])
231
-
232
- meanDE = calculate_meanDE(practices)
233
- meanECHHV = calculate_meanECHHV(practices)
235
+ meanDE = calculate_meanDE(cycle, practices)
236
+ meanECHHV = calculate_meanECHHV(cycle, practices)
234
237
  REM = calculate_REM(meanDE)
235
238
  REG = calculate_REG(meanDE)
236
239
 
@@ -241,7 +244,6 @@ def _should_run(cycle: dict, practices: dict):
241
244
  animalFeed_complete,
242
245
  animalPopulation_complete,
243
246
  freshForage_incomplete,
244
- has_cycle_inputs_feed,
245
247
  all_animals_have_value,
246
248
  has_practice_termType_system,
247
249
  has_practice_pastureGrass_with_landCover_key,
@@ -254,12 +256,11 @@ def _should_run(cycle: dict, practices: dict):
254
256
  term_type_animalFeed_complete=animalFeed_complete,
255
257
  term_type_animalPopulation_complete=animalPopulation_complete,
256
258
  term_type_freshForage_incomplete=freshForage_incomplete,
257
- has_cycle_inputs_feed=has_cycle_inputs_feed,
258
259
  all_animals_have_value=all_animals_have_value,
259
260
  has_practice_termType_system=has_practice_termType_system,
260
261
  has_practice_pastureGrass_with_landCover_key=has_practice_pastureGrass_with_landCover_key,
261
- grass_MeanDE=calculate_meanDE(practices, term=term_id),
262
- grass_MeanECHHV=calculate_meanECHHV(practices, term=term_id),
262
+ grass_MeanDE=calculate_meanDE(cycle, practices, term=term_id),
263
+ grass_MeanECHHV=calculate_meanECHHV(cycle, practices, term=term_id),
263
264
  grass_REM=REM,
264
265
  grass_REG=REG)
265
266
 
@@ -268,9 +269,14 @@ def _should_run(cycle: dict, practices: dict):
268
269
  return should_run, meanDE, meanECHHV, REM, REG, systems
269
270
 
270
271
 
271
- def run(cycle: dict):
272
+ def _run(cycle: dict):
272
273
  practices = list(filter(should_run_practice(cycle), cycle.get('practices', [])))
273
274
  should_run, meanDE, meanECHHV, REM, REG, systems = _should_run(cycle, practices)
274
275
  return non_empty_list(
275
276
  map(_run_practice(cycle, meanDE, meanECHHV, REM, REG, systems), practices)
276
277
  ) if should_run else []
278
+
279
+
280
+ def run(cycle: dict):
281
+ # determines if this model or animal model should run
282
+ return _run(cycle) if has_cycle_inputs_feed(cycle) else []