hestia-earth-models 0.62.3__py3-none-any.whl → 0.62.5__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 (38) hide show
  1. hestia_earth/models/emepEea2019/co2ToAirFuelCombustion.py +2 -10
  2. hestia_earth/models/emepEea2019/n2OToAirFuelCombustionDirect.py +2 -10
  3. hestia_earth/models/emepEea2019/nh3ToAirExcreta.py +2 -9
  4. hestia_earth/models/emepEea2019/nh3ToAirInorganicFertiliser.py +2 -9
  5. hestia_earth/models/emepEea2019/noxToAirFuelCombustion.py +2 -10
  6. hestia_earth/models/emepEea2019/pm10ToAirAnimalHousing.py +57 -0
  7. hestia_earth/models/emepEea2019/pm25ToAirAnimalHousing.py +57 -0
  8. hestia_earth/models/emepEea2019/so2ToAirFuelCombustion.py +2 -10
  9. hestia_earth/models/emepEea2019/tspToAirAnimalHousing.py +57 -0
  10. hestia_earth/models/emepEea2019/utils.py +60 -1
  11. hestia_earth/models/faostat2018/liveweightPerHead.py +1 -1
  12. hestia_earth/models/ipcc2019/animal/pastureGrass.py +2 -2
  13. hestia_earth/models/ipcc2019/pastureGrass.py +2 -2
  14. hestia_earth/models/ipcc2019/pastureGrass_utils.py +1 -10
  15. hestia_earth/models/log.py +1 -1
  16. hestia_earth/models/mocking/search-results.json +145 -1
  17. hestia_earth/models/site/management.py +63 -35
  18. hestia_earth/models/utils/cycle.py +10 -1
  19. hestia_earth/models/utils/site.py +7 -0
  20. hestia_earth/models/utils/term.py +21 -1
  21. hestia_earth/models/version.py +1 -1
  22. {hestia_earth_models-0.62.3.dist-info → hestia_earth_models-0.62.5.dist-info}/METADATA +1 -1
  23. {hestia_earth_models-0.62.3.dist-info → hestia_earth_models-0.62.5.dist-info}/RECORD +38 -32
  24. tests/models/emepEea2019/test_co2ToAirFuelCombustion.py +3 -2
  25. tests/models/emepEea2019/test_n2OToAirFuelCombustionDirect.py +3 -2
  26. tests/models/emepEea2019/test_nh3ToAirExcreta.py +2 -1
  27. tests/models/emepEea2019/test_nh3ToAirInorganicFertiliser.py +4 -3
  28. tests/models/emepEea2019/test_noxToAirFuelCombustion.py +3 -2
  29. tests/models/emepEea2019/test_pm10ToAirAnimalHousing.py +21 -0
  30. tests/models/emepEea2019/test_pm25ToAirAnimalHousing.py +21 -0
  31. tests/models/emepEea2019/test_so2ToAirFuelCombustion.py +3 -2
  32. tests/models/emepEea2019/test_tspToAirAnimalHousing.py +21 -0
  33. tests/models/emepEea2019/test_utils.py +198 -1
  34. tests/models/faostat2018/test_liveweightPerHead.py +9 -0
  35. tests/models/site/test_management.py +55 -7
  36. {hestia_earth_models-0.62.3.dist-info → hestia_earth_models-0.62.5.dist-info}/LICENSE +0 -0
  37. {hestia_earth_models-0.62.3.dist-info → hestia_earth_models-0.62.5.dist-info}/WHEEL +0 -0
  38. {hestia_earth_models-0.62.3.dist-info → hestia_earth_models-0.62.5.dist-info}/top_level.txt +0 -0
@@ -2,8 +2,7 @@ from hestia_earth.schema import EmissionMethodTier
2
2
  from hestia_earth.utils.tools import list_sum
3
3
 
4
4
  from hestia_earth.models.log import logRequirements, logShouldRun
5
- from hestia_earth.models.utils.emission import _new_emission
6
- from .utils import get_fuel_values
5
+ from .utils import get_fuel_values, _emission
7
6
  from . import MODEL
8
7
 
9
8
  REQUIREMENTS = {
@@ -32,16 +31,9 @@ TERM_ID = 'co2ToAirFuelCombustion'
32
31
  TIER = EmissionMethodTier.TIER_1.value
33
32
 
34
33
 
35
- def _emission(value: float):
36
- emission = _new_emission(TERM_ID, MODEL)
37
- emission['value'] = [value]
38
- emission['methodTier'] = TIER
39
- return emission
40
-
41
-
42
34
  def _run(fuel_values: list):
43
35
  value = list_sum(fuel_values)
44
- return [_emission(value)]
36
+ return [_emission(value=value, tier=TIER, term_id=TERM_ID)]
45
37
 
46
38
 
47
39
  def _should_run(cycle: dict):
@@ -2,8 +2,7 @@ from hestia_earth.schema import EmissionMethodTier
2
2
  from hestia_earth.utils.tools import list_sum
3
3
 
4
4
  from hestia_earth.models.log import logRequirements, logShouldRun
5
- from hestia_earth.models.utils.emission import _new_emission
6
- from .utils import get_fuel_values
5
+ from .utils import get_fuel_values, _emission
7
6
  from . import MODEL
8
7
 
9
8
  REQUIREMENTS = {
@@ -32,16 +31,9 @@ TERM_ID = 'n2OToAirFuelCombustionDirect'
32
31
  TIER = EmissionMethodTier.TIER_1.value
33
32
 
34
33
 
35
- def _emission(value: float):
36
- emission = _new_emission(TERM_ID, MODEL)
37
- emission['value'] = [value]
38
- emission['methodTier'] = TIER
39
- return emission
40
-
41
-
42
34
  def _run(fuel_values: list):
43
35
  value = list_sum(fuel_values)
44
- return [_emission(value)]
36
+ return [_emission(value=value, tier=TIER, term_id=TERM_ID)]
45
37
 
46
38
 
47
39
  def _should_run(cycle: dict):
@@ -7,9 +7,9 @@ from hestia_earth.models.log import logRequirements, debugMissingLookup, logShou
7
7
  from hestia_earth.models.utils import _filter_list_term_unit
8
8
  from hestia_earth.models.utils.constant import Units, get_atomic_conversion
9
9
  from hestia_earth.models.utils.completeness import _is_term_type_complete
10
- from hestia_earth.models.utils.emission import _new_emission
11
10
  from hestia_earth.models.utils.input import total_excreta_tan
12
11
  from . import MODEL
12
+ from .utils import _emission
13
13
 
14
14
  REQUIREMENTS = {
15
15
  "Cycle": {
@@ -40,13 +40,6 @@ TERM_ID = 'nh3ToAirExcreta'
40
40
  TIER = EmissionMethodTier.TIER_2.value
41
41
 
42
42
 
43
- def _emission(value: float):
44
- emission = _new_emission(TERM_ID, MODEL)
45
- emission['value'] = [value]
46
- emission['methodTier'] = TIER
47
- return emission
48
-
49
-
50
43
  def _get_nh3_factor(term_id: str, input: dict):
51
44
  input_term_id = input.get('term', {}).get('@id')
52
45
  lookup_name = f"{list(LOOKUPS.keys())[0]}.csv"
@@ -57,7 +50,7 @@ def _get_nh3_factor(term_id: str, input: dict):
57
50
 
58
51
  def _run(excreta_EF_product: float):
59
52
  value = excreta_EF_product * get_atomic_conversion(Units.KG_NH3, Units.TO_N)
60
- return [_emission(value)]
53
+ return [_emission(value=value, tier=TIER, term_id=TERM_ID)]
61
54
 
62
55
 
63
56
  def _should_run(cycle: dict):
@@ -10,7 +10,7 @@ from hestia_earth.models.utils.inorganicFertiliser import (
10
10
  get_NH3_emission_factor, get_terms, get_term_lookup, get_country_breakdown, get_cycle_inputs
11
11
  )
12
12
  from hestia_earth.models.utils.constant import Units
13
- from hestia_earth.models.utils.emission import _new_emission
13
+ from .utils import _emission
14
14
  from hestia_earth.models.utils.measurement import most_relevant_measurement_value
15
15
  from . import MODEL
16
16
 
@@ -58,13 +58,6 @@ TIER = EmissionMethodTier.TIER_2.value
58
58
  UNSPECIFIED_TERM_ID = 'inorganicNitrogenFertiliserUnspecifiedKgN'
59
59
 
60
60
 
61
- def _emission(value: float):
62
- emission = _new_emission(TERM_ID, MODEL)
63
- emission['value'] = [value]
64
- emission['methodTier'] = TIER
65
- return emission
66
-
67
-
68
61
  def _input_with_factor(soilPh: float, temperature: float):
69
62
  def get_value(input: dict):
70
63
  term_id = input.get('term', {}).get('@id')
@@ -151,4 +144,4 @@ def _should_run(cycle: dict):
151
144
  def run(cycle: dict):
152
145
  should_run, N_inputs_with_factor = _should_run(cycle)
153
146
  value = list_sum([i.get('value') * i.get('factor') for i in N_inputs_with_factor]) if should_run else None
154
- return [_emission(value)] if value is not None else []
147
+ return [_emission(value=value, tier=TIER, term_id=TERM_ID)] if value is not None else []
@@ -2,8 +2,7 @@ from hestia_earth.schema import EmissionMethodTier
2
2
  from hestia_earth.utils.tools import list_sum
3
3
 
4
4
  from hestia_earth.models.log import logRequirements, logShouldRun
5
- from hestia_earth.models.utils.emission import _new_emission
6
- from .utils import get_fuel_values
5
+ from .utils import get_fuel_values, _emission
7
6
  from . import MODEL
8
7
 
9
8
  REQUIREMENTS = {
@@ -32,16 +31,9 @@ TERM_ID = 'noxToAirFuelCombustion'
32
31
  TIER = EmissionMethodTier.TIER_1.value
33
32
 
34
33
 
35
- def _emission(value: float):
36
- emission = _new_emission(TERM_ID, MODEL)
37
- emission['value'] = [value]
38
- emission['methodTier'] = TIER
39
- return emission
40
-
41
-
42
34
  def _run(fuel_values: list):
43
35
  value = list_sum(fuel_values)
44
- return [_emission(value)]
36
+ return [_emission(value=value, tier=TIER, term_id=TERM_ID)]
45
37
 
46
38
 
47
39
  def _should_run(cycle: dict):
@@ -0,0 +1,57 @@
1
+ """
2
+ When `otherSites` are provided, `otherSitesDuration` must be set as well so we know the length of time the animals
3
+ spend on each Site.
4
+ """
5
+ from hestia_earth.schema import EmissionMethodTier
6
+
7
+ from .utils import _emission, get_live_animal_emission_value, should_run_animal
8
+ from . import MODEL
9
+
10
+ REQUIREMENTS = {
11
+ "Cycle": {
12
+ "completeness.animalPopulation": "True",
13
+ "site": {"@type": "Site"},
14
+ "siteDuration": "",
15
+ "animals": [
16
+ {
17
+ "@type": "Animal",
18
+ "term.termType": "liveAnimal",
19
+ "value": "",
20
+ "referencePeriod": "average"
21
+ }
22
+ ],
23
+ "optional": {
24
+ "otherSites": [{"@type": "Site"}],
25
+ "otherSitesDuration": ""
26
+ }
27
+ }
28
+ }
29
+ RETURNS = {
30
+ "Emission": [{
31
+ "value": "",
32
+ "methodTier": "tier 1"
33
+ }]
34
+ }
35
+ LOOKUPS = {
36
+ "liveAnimal": "pm10ToAirEea2019",
37
+ "operation": "pm10ToAirAnimalHousingEmepEea2019"
38
+ }
39
+ TERM_ID = 'pm10ToAirAnimalHousing'
40
+ TIER = EmissionMethodTier.TIER_1.value
41
+
42
+
43
+ def _run(animals: list[dict], total_duration: float):
44
+ return [
45
+ _emission(
46
+ value=get_live_animal_emission_value(animals, total_duration, lookup_col=LOOKUPS["liveAnimal"]),
47
+ tier=TIER,
48
+ term_id=TERM_ID
49
+ )
50
+ ]
51
+
52
+
53
+ def run(cycle: dict):
54
+ should_run, animals, total_duration = should_run_animal(
55
+ cycle=cycle, model=MODEL, term=TERM_ID, tier=TIER
56
+ )
57
+ return _run(animals, total_duration) if should_run else []
@@ -0,0 +1,57 @@
1
+ """
2
+ When `otherSites` are provided, `otherSitesDuration` must be set as well so we know the length of time the animals
3
+ spend on each Site.
4
+ """
5
+ from hestia_earth.schema import EmissionMethodTier
6
+
7
+ from .utils import _emission, get_live_animal_emission_value, should_run_animal
8
+ from . import MODEL
9
+
10
+ REQUIREMENTS = {
11
+ "Cycle": {
12
+ "completeness.animalPopulation": "True",
13
+ "site": {"@type": "Site"},
14
+ "siteDuration": "",
15
+ "animals": [
16
+ {
17
+ "@type": "Animal",
18
+ "term.termType": "liveAnimal",
19
+ "value": "",
20
+ "referencePeriod": "average"
21
+ }
22
+ ],
23
+ "optional": {
24
+ "otherSites": [{"@type": "Site"}],
25
+ "otherSitesDuration": ""
26
+ }
27
+ }
28
+ }
29
+ RETURNS = {
30
+ "Emission": [{
31
+ "value": "",
32
+ "methodTier": "tier 1"
33
+ }]
34
+ }
35
+ LOOKUPS = {
36
+ "liveAnimal": "pm25ToAirEea2019",
37
+ "operation": "pm25ToAirAnimalHousingEmepEea2019"
38
+ }
39
+ TERM_ID = 'pm25ToAirAnimalHousing'
40
+ TIER = EmissionMethodTier.TIER_1.value
41
+
42
+
43
+ def _run(animals: list[dict], total_duration: float):
44
+ return [
45
+ _emission(
46
+ value=get_live_animal_emission_value(animals, total_duration, lookup_col=LOOKUPS["liveAnimal"]),
47
+ tier=TIER,
48
+ term_id=TERM_ID
49
+ )
50
+ ]
51
+
52
+
53
+ def run(cycle: dict):
54
+ should_run, animals, total_duration = should_run_animal(
55
+ cycle=cycle, model=MODEL, term=TERM_ID, tier=TIER
56
+ )
57
+ return _run(animals, total_duration) if should_run else []
@@ -2,8 +2,7 @@ from hestia_earth.schema import EmissionMethodTier
2
2
  from hestia_earth.utils.tools import list_sum
3
3
 
4
4
  from hestia_earth.models.log import logRequirements, logShouldRun
5
- from hestia_earth.models.utils.emission import _new_emission
6
- from .utils import get_fuel_values
5
+ from .utils import get_fuel_values, _emission
7
6
  from . import MODEL
8
7
 
9
8
  REQUIREMENTS = {
@@ -32,16 +31,9 @@ TERM_ID = 'so2ToAirFuelCombustion'
32
31
  TIER = EmissionMethodTier.TIER_1.value
33
32
 
34
33
 
35
- def _emission(value: float):
36
- emission = _new_emission(TERM_ID, MODEL)
37
- emission['value'] = [value]
38
- emission['methodTier'] = TIER
39
- return emission
40
-
41
-
42
34
  def _run(fuel_values: list):
43
35
  value = list_sum(fuel_values)
44
- return [_emission(value)]
36
+ return [_emission(value=value, tier=TIER, term_id=TERM_ID)]
45
37
 
46
38
 
47
39
  def _should_run(cycle: dict):
@@ -0,0 +1,57 @@
1
+ """
2
+ When `otherSites` are provided, `otherSitesDuration` must be set as well so we know the length of time the animals
3
+ spend on each Site.
4
+ """
5
+ from hestia_earth.schema import EmissionMethodTier
6
+
7
+ from .utils import _emission, get_live_animal_emission_value, should_run_animal
8
+ from . import MODEL
9
+
10
+ REQUIREMENTS = {
11
+ "Cycle": {
12
+ "completeness.animalPopulation": "True",
13
+ "site": {"@type": "Site"},
14
+ "siteDuration": "",
15
+ "animals": [
16
+ {
17
+ "@type": "Animal",
18
+ "term.termType": "liveAnimal",
19
+ "value": "",
20
+ "referencePeriod": "average"
21
+ }
22
+ ],
23
+ "optional": {
24
+ "otherSites": [{"@type": "Site"}],
25
+ "otherSitesDuration": ""
26
+ }
27
+ }
28
+ }
29
+ RETURNS = {
30
+ "Emission": [{
31
+ "value": "",
32
+ "methodTier": "tier 1"
33
+ }]
34
+ }
35
+ LOOKUPS = {
36
+ "liveAnimal": "tspToAirEea2019",
37
+ "operation": "tspToAirAnimalHousingEmepEea2019"
38
+ }
39
+ TERM_ID = 'tspToAirAnimalHousing'
40
+ TIER = EmissionMethodTier.TIER_1.value
41
+
42
+
43
+ def _run(animals: list[dict], total_duration: float):
44
+ return [
45
+ _emission(
46
+ value=get_live_animal_emission_value(animals, total_duration, lookup_col=LOOKUPS["liveAnimal"]),
47
+ tier=TIER,
48
+ term_id=TERM_ID
49
+ )
50
+ ]
51
+
52
+
53
+ def run(cycle: dict):
54
+ should_run, animals, total_duration = should_run_animal(
55
+ cycle=cycle, model=MODEL, term=TERM_ID, tier=TIER
56
+ )
57
+ return _run(animals, total_duration) if should_run else []
@@ -1,13 +1,23 @@
1
- from hestia_earth.schema import TermTermType
1
+ from hestia_earth.schema import TermTermType, SiteSiteType
2
2
  from hestia_earth.utils.model import filter_list_term_type
3
3
  from hestia_earth.utils.lookup import extract_grouped_data
4
4
  from hestia_earth.utils.tools import list_sum, safe_parse_float, non_empty_list
5
5
 
6
+ from hestia_earth.models.log import logRequirements, logShouldRun
6
7
  from hestia_earth.models.utils.completeness import _is_term_type_complete
7
8
  from hestia_earth.models.utils.term import get_lookup_value
9
+ from hestia_earth.models.utils.cycle import get_animals_by_period
10
+ from hestia_earth.models.utils.emission import _new_emission
8
11
  from . import MODEL
9
12
 
10
13
 
14
+ def _emission(value: float, tier: str, term_id: str):
15
+ emission = _new_emission(term_id, MODEL)
16
+ emission['value'] = [value]
17
+ emission['methodTier'] = tier
18
+ return emission
19
+
20
+
11
21
  def _get_fuel_input_value(term_id: str, lookup_col: str):
12
22
  def get_value(input: dict):
13
23
  input_term = input.get('term', {})
@@ -33,3 +43,52 @@ def get_fuel_values(term_id: str, cycle: dict, lookup_col: str):
33
43
  len(values) == 0,
34
44
  _is_term_type_complete(cycle, 'electricityFuel')
35
45
  ]) else values
46
+
47
+
48
+ def _get_emissions_factor(animal: dict, lookup_col: str) -> float:
49
+ return safe_parse_float(
50
+ get_lookup_value(animal.get("term", {}), lookup_col, model=MODEL, term=animal.get("term", ""))
51
+ )
52
+
53
+
54
+ def _duration_in_housing(cycle: dict) -> int:
55
+ other_sites = cycle.get("otherSites", [])
56
+ other_durations = cycle.get("otherSitesDuration", [])
57
+ return list_sum([
58
+ cycle.get("siteDuration", cycle.get("cycleDuration", 0))
59
+ if cycle.get("site", {}).get("siteType", "") == SiteSiteType.ANIMAL_HOUSING.value else 0
60
+ ] + ([
61
+ other_durations[x]
62
+ for x in range(len(other_sites))
63
+ if other_sites[x].get("siteType", "") == SiteSiteType.ANIMAL_HOUSING.value
64
+ ] if len(other_sites) == len(other_durations) else []))
65
+
66
+
67
+ def get_live_animal_emission_value(animals: list[dict], duration: float, lookup_col: str) -> float:
68
+ return list_sum([
69
+ animal.get('value') * _get_emissions_factor(animal=animal, lookup_col=lookup_col)
70
+ for animal in animals
71
+ ]) * duration / 365
72
+
73
+
74
+ def should_run_animal(cycle: dict, model: str, term: str, tier: str) -> tuple[list, bool]:
75
+ term_type_animalPopulation_complete = _is_term_type_complete(cycle=cycle, term="animalPopulation")
76
+
77
+ # models will be set as not relevant is primary `siteType` does not match, so check only `otherSites`.
78
+
79
+ total_duration = _duration_in_housing(cycle)
80
+
81
+ has_other_sites_and_duration = len(cycle.get("otherSites", [])) == len(cycle.get("otherSitesDuration", []))
82
+
83
+ animals = get_animals_by_period(cycle)
84
+ has_animals = len(animals) > 0
85
+
86
+ logRequirements(cycle, model=model, term=term,
87
+ term_type_animalPopulation_complete=term_type_animalPopulation_complete,
88
+ has_animals=has_animals,
89
+ has_other_sites_and_duration=has_other_sites_and_duration,
90
+ number_of_days_in_animal_housing=total_duration)
91
+
92
+ should_run = all([term_type_animalPopulation_complete, has_animals, has_other_sites_and_duration])
93
+ logShouldRun(cycle, model, term, should_run, methodTier=tier)
94
+ return should_run, animals, total_duration
@@ -77,7 +77,7 @@ def _run_liveAnimal(cycle: dict, product: dict, year: int, country_id: str):
77
77
  product_id = product.get('term', {}).get('@id')
78
78
  animal_product_id = get_liveAnimal_to_animalProduct_id(product_id, LOOKUPS['liveAnimal'][0], term=TERM_ID)
79
79
 
80
- animal_product_term = download_hestia(animal_product_id)
80
+ animal_product_term = download_hestia(animal_product_id) if animal_product_id else {}
81
81
  kg_liveweight, groupingFAO = _product_value({**product, 'term': animal_product_term}, year, country_id)
82
82
 
83
83
  logRequirements(cycle, model=MODEL, term=product_id, property=TERM_ID,
@@ -18,6 +18,7 @@ from hestia_earth.models.utils.input import _new_input
18
18
  from hestia_earth.models.utils.term import get_wool_terms, get_lookup_value
19
19
  from hestia_earth.models.utils.completeness import _is_term_type_complete, _is_term_type_incomplete
20
20
  from hestia_earth.models.utils.property import get_node_property
21
+ from hestia_earth.models.utils.cycle import get_animals_by_period
21
22
  from .. import MODEL
22
23
  from ..pastureGrass_utils import (
23
24
  practice_input_id,
@@ -29,7 +30,6 @@ from ..pastureGrass_utils import (
29
30
  calculate_NEfeed,
30
31
  calculate_GE,
31
32
  product_wool_energy,
32
- get_animals,
33
33
  get_animal_values
34
34
  )
35
35
 
@@ -308,7 +308,7 @@ def _should_run(cycle: dict, animals: list, practices: dict):
308
308
 
309
309
 
310
310
  def run(cycle: dict):
311
- animals = get_animals(cycle)
311
+ animals = get_animals_by_period(cycle)
312
312
  practices = list(filter(should_run_practice(cycle), cycle.get('practices', [])))
313
313
  should_run, meanDE, meanECHHV, system = _should_run(cycle, animals, practices)
314
314
  return list(map(_run_animal(cycle, meanDE, meanECHHV, system, practices), animals)) if should_run else []
@@ -17,6 +17,7 @@ from hestia_earth.models.utils.blank_node import lookups_logs, properties_logs
17
17
  from hestia_earth.models.utils.input import _new_input
18
18
  from hestia_earth.models.utils.term import get_wool_terms
19
19
  from hestia_earth.models.utils.completeness import _is_term_type_complete, _is_term_type_incomplete
20
+ from hestia_earth.models.utils.cycle import get_animals_by_period
20
21
  from . import MODEL
21
22
  from .pastureGrass_utils import (
22
23
  practice_input_id,
@@ -28,7 +29,6 @@ from .pastureGrass_utils import (
28
29
  calculate_NEfeed,
29
30
  calculate_GE,
30
31
  product_wool_energy,
31
- get_animals,
32
32
  get_animal_values
33
33
  )
34
34
 
@@ -164,7 +164,7 @@ def calculate_NEwool(cycle: dict) -> float:
164
164
 
165
165
 
166
166
  def _run_practice(cycle: dict, meanDE: float, meanECHHV: float, system: dict):
167
- animals = get_animals(cycle)
167
+ animals = get_animals_by_period(cycle)
168
168
  REM = calculate_REM(meanDE)
169
169
  REG = calculate_REG(meanDE)
170
170
  NEwool = calculate_NEwool(cycle)
@@ -1,4 +1,4 @@
1
- from hestia_earth.schema import TermTermType, AnimalReferencePeriod
1
+ from hestia_earth.schema import TermTermType
2
2
  from hestia_earth.utils.api import download_hestia
3
3
  from hestia_earth.utils.lookup import download_lookup, get_table_value, column_name, extract_grouped_data
4
4
  from hestia_earth.utils.tools import list_sum, safe_parse_float
@@ -341,12 +341,3 @@ def should_run_practice(cycle: dict):
341
341
  return all([len(value) > 0, term_id == MODEL_KEY, key_term_type in KEY_TERM_TYPES])
342
342
 
343
343
  return should_run
344
-
345
-
346
- def get_animals(cycle: dict):
347
- return [
348
- a for a in cycle.get('animals', []) if all([
349
- a.get('value'),
350
- a.get('referencePeriod') == AnimalReferencePeriod.AVERAGE.value
351
- ])
352
- ]
@@ -63,7 +63,7 @@ def logShouldRun(log_node: dict, model: str, term: Union[str, None], should_run:
63
63
 
64
64
 
65
65
  def debugMissingLookup(lookup_name: str, row: str, row_value: str, col: str, value, **kwargs):
66
- if value is None:
66
+ if value is None or value == '':
67
67
  extra = (', ' + _join_args(**kwargs)) if len(kwargs.keys()) > 0 else ''
68
68
  logger.warn('Missing lookup=%s, %s=%s, column=%s' + extra, lookup_name, row, row_value, col)
69
69
 
@@ -1486,7 +1486,7 @@
1486
1486
  "@type": "Term",
1487
1487
  "name": "Generic crop, seed",
1488
1488
  "@id": "genericCropSeed",
1489
- "_score": 25.968466
1489
+ "_score": 26.312824
1490
1490
  }
1491
1491
  ]
1492
1492
  },
@@ -1636,6 +1636,150 @@
1636
1636
  }
1637
1637
  ]
1638
1638
  },
1639
+ {
1640
+ "name": "get_land_cover_siteTypes",
1641
+ "query": {
1642
+ "bool": {
1643
+ "must": [
1644
+ {
1645
+ "match": {
1646
+ "@type": "Term"
1647
+ }
1648
+ },
1649
+ {
1650
+ "match": {
1651
+ "termType": "landCover"
1652
+ }
1653
+ }
1654
+ ],
1655
+ "should": [
1656
+ {
1657
+ "match": {
1658
+ "name": "agri-food processor"
1659
+ }
1660
+ },
1661
+ {
1662
+ "match": {
1663
+ "name": "animal housing"
1664
+ }
1665
+ },
1666
+ {
1667
+ "match": {
1668
+ "name": "cropland"
1669
+ }
1670
+ },
1671
+ {
1672
+ "match": {
1673
+ "name": "food retailer"
1674
+ }
1675
+ },
1676
+ {
1677
+ "match": {
1678
+ "name": "forest"
1679
+ }
1680
+ },
1681
+ {
1682
+ "match": {
1683
+ "name": "glass or high accessible cover"
1684
+ }
1685
+ },
1686
+ {
1687
+ "match": {
1688
+ "name": "lake"
1689
+ }
1690
+ },
1691
+ {
1692
+ "match": {
1693
+ "name": "other natural vegetation"
1694
+ }
1695
+ },
1696
+ {
1697
+ "match": {
1698
+ "name": "permanent pasture"
1699
+ }
1700
+ },
1701
+ {
1702
+ "match": {
1703
+ "name": "pond"
1704
+ }
1705
+ },
1706
+ {
1707
+ "match": {
1708
+ "name": "river or stream"
1709
+ }
1710
+ },
1711
+ {
1712
+ "match": {
1713
+ "name": "sea or ocean"
1714
+ }
1715
+ }
1716
+ ],
1717
+ "minimum_should_match": 1
1718
+ }
1719
+ },
1720
+ "results": [
1721
+ {
1722
+ "@type": "Term",
1723
+ "name": "Glass or high accessible cover",
1724
+ "@id": "glassOrHighAccessibleCover",
1725
+ "_score": 59.49422
1726
+ },
1727
+ {
1728
+ "@type": "Term",
1729
+ "name": "River or stream",
1730
+ "@id": "riverOrStream",
1731
+ "_score": 50.673336
1732
+ },
1733
+ {
1734
+ "@type": "Term",
1735
+ "name": "Other natural vegetation",
1736
+ "@id": "otherNaturalVegetation",
1737
+ "_score": 40.97334
1738
+ },
1739
+ {
1740
+ "@type": "Term",
1741
+ "name": "Natural forest",
1742
+ "@id": "naturalForest",
1743
+ "_score": 31.583748
1744
+ },
1745
+ {
1746
+ "@type": "Term",
1747
+ "name": "Permanent pasture",
1748
+ "@id": "permanentPasture",
1749
+ "_score": 28.25857
1750
+ },
1751
+ {
1752
+ "@type": "Term",
1753
+ "name": "Animal housing",
1754
+ "@id": "animalHousing",
1755
+ "_score": 27.218006
1756
+ },
1757
+ {
1758
+ "@type": "Term",
1759
+ "name": "Root or tuber crop plant",
1760
+ "@id": "rootOrTuberCropPlant",
1761
+ "_score": 25.098145
1762
+ },
1763
+ {
1764
+ "@type": "Term",
1765
+ "name": "High intensity grazing pasture",
1766
+ "@id": "highIntensityGrazingPasture",
1767
+ "_score": 23.833916
1768
+ },
1769
+ {
1770
+ "@type": "Term",
1771
+ "name": "Permanent cropland",
1772
+ "@id": "permanentCropland",
1773
+ "_score": 20.639563
1774
+ },
1775
+ {
1776
+ "@type": "Term",
1777
+ "name": "Forest",
1778
+ "@id": "forest",
1779
+ "_score": 20.246805
1780
+ }
1781
+ ]
1782
+ },
1639
1783
  {
1640
1784
  "name": "get_liquid_fuel_terms",
1641
1785
  "query": {