hestia-earth-models 0.64.10__py3-none-any.whl → 0.64.12__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 (71) hide show
  1. hestia_earth/models/cml2001Baseline/eutrophicationPotentialExcludingFate.py +2 -2
  2. hestia_earth/models/cml2001Baseline/terrestrialAcidificationPotentialIncludingFateAverageEurope.py +2 -2
  3. hestia_earth/models/cml2001NonBaseline/eutrophicationPotentialIncludingFateAverageEurope.py +2 -2
  4. hestia_earth/models/cml2001NonBaseline/terrestrialAcidificationPotentialExcludingFate.py +2 -2
  5. hestia_earth/models/cycle/completeness/cropResidue.py +15 -10
  6. hestia_earth/models/cycle/completeness/freshForage.py +60 -0
  7. hestia_earth/models/cycle/concentrateFeed.py +31 -19
  8. hestia_earth/models/edip2003/ozoneDepletionPotential.py +2 -2
  9. hestia_earth/models/fantkeEtAl2016/damageToHumanHealthParticulateMatterFormation.py +7 -17
  10. hestia_earth/models/faostat2018/utils.py +72 -12
  11. hestia_earth/models/hestia/__init__.py +13 -0
  12. hestia_earth/models/hestia/landCover.py +725 -0
  13. hestia_earth/models/ipcc2013ExcludingFeedbacks/gwp100.py +2 -2
  14. hestia_earth/models/ipcc2013IncludingFeedbacks/gwp100.py +2 -2
  15. hestia_earth/models/ipcc2019/animal/fatContent.py +1 -1
  16. hestia_earth/models/ipcc2019/animal/milkYieldPerAnimal.py +91 -0
  17. hestia_earth/models/ipcc2019/animal/trueProteinContent.py +1 -1
  18. hestia_earth/models/ipcc2019/animal/utils.py +17 -12
  19. hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChange.py +8 -4
  20. hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChange.py +7 -3
  21. hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +45 -3
  22. hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py +7 -3
  23. hestia_earth/models/ipcc2021/gwp100.py +2 -2
  24. hestia_earth/models/lcImpactAllEffects100Years/damageToFreshwaterEcosystemsClimateChange.py +2 -2
  25. hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthClimateChange.py +2 -2
  26. hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthStratosphericOzoneDepletion.py +2 -2
  27. hestia_earth/models/lcImpactAllEffects100Years/damageToTerrestrialEcosystemsClimateChange.py +2 -2
  28. hestia_earth/models/lcImpactAllEffectsInfinite/damageToFreshwaterEcosystemsClimateChange.py +2 -2
  29. hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthClimateChange.py +2 -2
  30. hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthStratosphericOzoneDepletion.py +2 -2
  31. hestia_earth/models/lcImpactAllEffectsInfinite/damageToTerrestrialEcosystemsClimateChange.py +2 -2
  32. hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthClimateChange.py +2 -2
  33. hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthStratosphericOzoneDepletion.py +2 -2
  34. hestia_earth/models/lcImpactCertainEffects100Years/damageToTerrestrialEcosystemsClimateChange.py +2 -2
  35. hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthClimateChange.py +2 -2
  36. hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthStratosphericOzoneDepletion.py +2 -2
  37. hestia_earth/models/lcImpactCertainEffectsInfinite/damageToTerrestrialEcosystemsClimateChange.py +2 -2
  38. hestia_earth/models/mocking/search-results.json +335 -335
  39. hestia_earth/models/recipe2016Egalitarian/ecosystemDamageOzoneFormation.py +2 -2
  40. hestia_earth/models/recipe2016Egalitarian/freshwaterEutrophicationPotential.py +2 -2
  41. hestia_earth/models/recipe2016Egalitarian/humanDamageOzoneFormation.py +2 -2
  42. hestia_earth/models/recipe2016Egalitarian/marineEutrophicationPotential.py +2 -2
  43. hestia_earth/models/recipe2016Egalitarian/ozoneDepletionPotential.py +2 -2
  44. hestia_earth/models/recipe2016Egalitarian/terrestrialAcidificationPotential.py +2 -2
  45. hestia_earth/models/recipe2016Hierarchist/ecosystemDamageOzoneFormation.py +2 -2
  46. hestia_earth/models/recipe2016Hierarchist/freshwaterEutrophicationPotential.py +2 -2
  47. hestia_earth/models/recipe2016Hierarchist/humanDamageOzoneFormation.py +2 -2
  48. hestia_earth/models/recipe2016Hierarchist/marineEutrophicationPotential.py +2 -2
  49. hestia_earth/models/recipe2016Hierarchist/ozoneDepletionPotential.py +2 -2
  50. hestia_earth/models/recipe2016Hierarchist/terrestrialAcidificationPotential.py +2 -2
  51. hestia_earth/models/recipe2016Individualist/ecosystemDamageOzoneFormation.py +2 -2
  52. hestia_earth/models/recipe2016Individualist/freshwaterEutrophicationPotential.py +2 -2
  53. hestia_earth/models/recipe2016Individualist/humanDamageOzoneFormation.py +2 -2
  54. hestia_earth/models/recipe2016Individualist/marineEutrophicationPotential.py +2 -2
  55. hestia_earth/models/recipe2016Individualist/ozoneDepletionPotential.py +2 -2
  56. hestia_earth/models/recipe2016Individualist/terrestrialAcidificationPotential.py +2 -2
  57. hestia_earth/models/utils/impact_assessment.py +18 -8
  58. hestia_earth/models/utils/lookup.py +2 -1
  59. hestia_earth/models/version.py +1 -1
  60. {hestia_earth_models-0.64.10.dist-info → hestia_earth_models-0.64.12.dist-info}/METADATA +2 -2
  61. {hestia_earth_models-0.64.10.dist-info → hestia_earth_models-0.64.12.dist-info}/RECORD +71 -62
  62. tests/models/cycle/completeness/test_freshForage.py +21 -0
  63. tests/models/faostat2018/test_faostat_utils.py +84 -0
  64. tests/models/hestia/__init__.py +0 -0
  65. tests/models/hestia/test_landCover.py +209 -0
  66. tests/models/ipcc2019/animal/test_milkYieldPerAnimal.py +21 -0
  67. tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py +48 -1
  68. tests/models/utils/test_impact_assessment.py +3 -3
  69. {hestia_earth_models-0.64.10.dist-info → hestia_earth_models-0.64.12.dist-info}/LICENSE +0 -0
  70. {hestia_earth_models-0.64.10.dist-info → hestia_earth_models-0.64.12.dist-info}/WHEEL +0 -0
  71. {hestia_earth_models-0.64.10.dist-info → hestia_earth_models-0.64.12.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -33,6 +33,6 @@ TERM_ID = 'fatContent'
33
33
 
34
34
  def run(cycle: dict):
35
35
  animals = should_run_by_productivity_lookup(
36
- TERM_ID, cycle, list(LOOKUPS.keys())[0], practice_id=LOOKUPS['liveAnimal']
36
+ TERM_ID, cycle, list(LOOKUPS.keys())[0], practice_column=LOOKUPS['liveAnimal']
37
37
  )
38
38
  return list(map(run_animal_by_productivity(TERM_ID, include_practice=True), animals))
@@ -0,0 +1,91 @@
1
+ """
2
+ Milk Yield Per Animal
3
+
4
+ This model gap-fills the practice "Milk yield per X, raw" for live animals added to the animal node,
5
+ taking values from a lookup file.
6
+ """
7
+ from hestia_earth.models.log import logRequirements, logShouldRun
8
+ from hestia_earth.models.utils.blank_node import merge_blank_nodes, get_lookup_value
9
+ from hestia_earth.models.utils.practice import _new_practice
10
+ from .utils import map_live_animals_by_productivity_lookup
11
+ from .. import MODEL
12
+
13
+ REQUIREMENTS = {
14
+ "Cycle": {
15
+ "site": {
16
+ "@type": "Site",
17
+ "country": {"@type": "Term", "termType": "region"}
18
+ },
19
+ "animals": [{
20
+ "@type": "Animal",
21
+ "term.termType": "liveAnimal",
22
+ "practices": {
23
+ "@type": "Practice",
24
+ "term.termType": "animalManagement"
25
+ }
26
+ }]
27
+ }
28
+ }
29
+ LOOKUPS = {
30
+ "region-liveAnimal-milkYieldPerAnimal": "yield value",
31
+ "liveAnimal": ["milkYieldPracticeTermIds", "ipcc2019MilkYieldPerAnimalTermId"]
32
+ }
33
+ RETURNS = {
34
+ "Animal": [{
35
+ "practices": [{
36
+ "@type": "Practice",
37
+ "value": ""
38
+ }]
39
+ }]
40
+ }
41
+ MODEL_KEY = 'milkYieldPerAnimal'
42
+
43
+
44
+ def _practice(term_id: str, value: float):
45
+ node = _new_practice(term_id, MODEL)
46
+ node['value'] = [value]
47
+ return node
48
+
49
+
50
+ def _run_animal(data: dict):
51
+ animal = data.get('animal')
52
+ value = data.get('value')
53
+ practice_id = get_lookup_value(animal.get('term'), LOOKUPS['liveAnimal'][1])
54
+ return animal | {
55
+ 'practices': merge_blank_nodes(animal.get('practices', []), [_practice(practice_id, value)])
56
+ }
57
+
58
+
59
+ def _should_run(cycle: dict):
60
+ country = cycle.get('site', {}).get('country', {})
61
+ country_id = country.get('@id')
62
+ live_animals_with_value = map_live_animals_by_productivity_lookup(
63
+ None, cycle, list(LOOKUPS.keys())[0], practice_column=LOOKUPS['liveAnimal'][0]
64
+ )
65
+
66
+ def _should_run_animal(value: dict):
67
+ animal = value.get('animal')
68
+ lookup_value = value.get('value')
69
+ term_id = animal.get('term').get('@id')
70
+ practice = value.get('practice')
71
+
72
+ logRequirements(cycle, model=MODEL, term=term_id, model_key=MODEL_KEY,
73
+ country_id=country_id,
74
+ practice=practice.get('term', {}).get('@id'))
75
+
76
+ should_run = all([
77
+ country_id,
78
+ lookup_value is not None,
79
+ # must not have the practice already
80
+ not practice
81
+ ])
82
+ logShouldRun(cycle, MODEL, term_id, should_run, model_key=MODEL_KEY)
83
+
84
+ return should_run
85
+
86
+ return list(filter(_should_run_animal, live_animals_with_value))
87
+
88
+
89
+ def run(cycle: dict):
90
+ animals = _should_run(cycle)
91
+ return list(map(_run_animal, animals))
@@ -33,6 +33,6 @@ TERM_ID = 'trueProteinContent'
33
33
 
34
34
  def run(cycle: dict):
35
35
  animals = should_run_by_productivity_lookup(
36
- TERM_ID, cycle, list(LOOKUPS.keys())[0], practice_id=LOOKUPS['liveAnimal']
36
+ TERM_ID, cycle, list(LOOKUPS.keys())[0], practice_column=LOOKUPS['liveAnimal']
37
37
  )
38
38
  return list(map(run_animal_by_productivity(TERM_ID, include_practice=True), animals))
@@ -11,9 +11,9 @@ from hestia_earth.models.utils.term import get_lookup_value
11
11
  from .. import MODEL
12
12
 
13
13
 
14
- def _get_practice(term_id: str, animal: dict, practice_id: str):
14
+ def _get_practice(term_id: str, animal: dict, practice_column: str):
15
15
  term = animal.get('term', {})
16
- value = get_lookup_value(term, practice_id, model=MODEL, term=term_id)
16
+ value = get_lookup_value(term, practice_column, model=MODEL, term=term_id)
17
17
  practice_ids = non_empty_list((value or '').split(';'))
18
18
  return next(
19
19
  (p for p in animal.get('practices', []) if p.get('term', {}).get('@id') in practice_ids),
@@ -36,7 +36,7 @@ def productivity_lookup_value(term_id: str, lookup: str, country: dict, animal:
36
36
  )
37
37
 
38
38
 
39
- def map_live_animals_by_productivity_lookup(term_id: str, cycle: dict, lookup_col: str, practice_id: str = None):
39
+ def map_live_animals_by_productivity_lookup(term_id: str, cycle: dict, lookup_col: str, practice_column: str = None):
40
40
  country = cycle.get('site', {}).get('country', {})
41
41
  live_animals = filter_list_term_type(cycle.get('animals', []), TermTermType.LIVEANIMAL)
42
42
  live_animals = list(filter(node_has_no_property(term_id), live_animals))
@@ -44,35 +44,40 @@ def map_live_animals_by_productivity_lookup(term_id: str, cycle: dict, lookup_co
44
44
  'animal': animal,
45
45
  'value': productivity_lookup_value(term_id, lookup_col, country, animal)
46
46
  } | ({
47
- 'practice': _get_practice(term_id, animal, practice_id)
48
- } if practice_id else {}) for animal in live_animals]
47
+ 'practice': _get_practice(term_id, animal, practice_column)
48
+ } if practice_column else {}) for animal in live_animals]
49
49
 
50
50
 
51
- def should_run_by_productivity_lookup(term_id: str, cycle: dict, lookup_col: str, practice_id: str = None):
51
+ def should_run_by_productivity_lookup(
52
+ term_id: str,
53
+ cycle: dict,
54
+ lookup_col: str,
55
+ practice_column: str = None
56
+ ):
52
57
  country = cycle.get('site', {}).get('country', {})
53
58
  country_id = country.get('@id')
54
- live_animals_with_value = map_live_animals_by_productivity_lookup(term_id, cycle, lookup_col, practice_id)
59
+ live_animals_with_value = map_live_animals_by_productivity_lookup(term_id, cycle, lookup_col, practice_column)
55
60
 
56
61
  def _should_run_animal(value: dict):
57
62
  animal = value.get('animal')
58
63
  lookup_value = value.get('value')
59
64
  practice = value.get('practice')
60
- term_id = animal.get('term').get('@id')
65
+ animal_term_id = animal.get('term').get('@id')
61
66
 
62
- logRequirements(cycle, model=MODEL, term=term_id, property=term_id,
67
+ logRequirements(cycle, model=MODEL, term=animal_term_id, property=term_id,
63
68
  country_id=country_id,
64
69
  **({
65
70
  lookup_col.replace('-', '_'): lookup_value
66
71
  } | ({
67
72
  'practice': practice.get('term', {}).get('@id')
68
- } if practice_id else {})))
73
+ } if practice_column else {})))
69
74
 
70
75
  should_run = all([
71
76
  country_id,
72
- not practice_id or bool(practice),
77
+ not practice_column or bool(practice),
73
78
  lookup_value is not None
74
79
  ])
75
- logShouldRun(cycle, MODEL, term_id, should_run, property=term_id)
80
+ logShouldRun(cycle, MODEL, animal_term_id, should_run, property=term_id)
76
81
 
77
82
  return should_run
78
83
 
@@ -77,7 +77,9 @@ def _emission(
77
77
  min: list[float] = None,
78
78
  max: list[float] = None,
79
79
  statsDefinition: str = None,
80
- observations: list[int] = None
80
+ observations: list[int] = None,
81
+ start_date: str,
82
+ end_date: str
81
83
  ) -> dict:
82
84
  """
83
85
  Create an emission node based on the provided value and method tier.
@@ -105,7 +107,9 @@ def _emission(
105
107
  "max": max,
106
108
  "statsDefinition": statsDefinition,
107
109
  "observations": observations,
108
- "methodTier": method_tier.value
110
+ "startDate": start_date,
111
+ "endDate": end_date,
112
+ "methodTier": method_tier.value,
109
113
  }
110
114
  emission = _new_emission(term_id, MODEL) | {
111
115
  key: value for key, value in update_dict.items() if value
@@ -141,13 +145,13 @@ def run(cycle: dict) -> list[dict]:
141
145
  management_change_emission_term_id=_MG_EMISSION_TERM_ID
142
146
  )
143
147
 
144
- should_run, cycle_id, inventory, logs = should_run_exec(cycle)
148
+ should_run, kwargs, logs = should_run_exec(cycle)
145
149
 
146
150
  for term_id in [_LU_EMISSION_TERM_ID, _MG_EMISSION_TERM_ID]:
147
151
  logRequirements(cycle, model=MODEL, term=term_id, **logs)
148
152
  logShouldRun(cycle, MODEL, term_id, should_run)
149
153
 
150
- return run_exec(cycle_id, inventory) if should_run else []
154
+ return run_exec(**kwargs) if should_run else []
151
155
 
152
156
 
153
157
  def _should_compile_inventory_func(
@@ -68,7 +68,9 @@ def _emission(
68
68
  min: list[float] = None,
69
69
  max: list[float] = None,
70
70
  statsDefinition: str = None,
71
- observations: list[int] = None
71
+ observations: list[int] = None,
72
+ start_date: str,
73
+ end_date: str
72
74
  ) -> dict:
73
75
  """
74
76
  Create an emission node based on the provided value and method tier.
@@ -96,6 +98,8 @@ def _emission(
96
98
  "max": max,
97
99
  "statsDefinition": statsDefinition,
98
100
  "observations": observations,
101
+ "startDate": start_date,
102
+ "endDate": end_date,
99
103
  "methodTier": method_tier.value,
100
104
  "depth": _DEPTH_LOWER
101
105
  }
@@ -133,13 +137,13 @@ def run(cycle: dict) -> list[dict]:
133
137
  management_change_emission_term_id=_MG_EMISSION_TERM_ID
134
138
  )
135
139
 
136
- should_run, cycle_id, inventory, logs = should_run_exec(cycle)
140
+ should_run, kwargs, logs = should_run_exec(cycle)
137
141
 
138
142
  for term_id in [_LU_EMISSION_TERM_ID, _MG_EMISSION_TERM_ID]:
139
143
  logRequirements(cycle, model=MODEL, term=term_id, **logs)
140
144
  logShouldRun(cycle, MODEL, term_id, should_run)
141
145
 
142
- return run_exec(cycle_id, inventory) if should_run else []
146
+ return run_exec(**kwargs) if should_run else []
143
147
 
144
148
 
145
149
  def _should_run_measurement_func(node: dict) -> bool:
@@ -3,7 +3,7 @@ Utilities for calculating CO2 emissions based on changes in carbon stocks (e.g.,
3
3
  `aboveGroundBiomass` and `belowGroundBiomass`).
4
4
  """
5
5
 
6
- from datetime import datetime
6
+ from datetime import datetime, timedelta
7
7
  from enum import Enum
8
8
  from functools import reduce
9
9
  from itertools import product
@@ -401,6 +401,9 @@ def create_should_run_function(
401
401
  `(should_run, cycle_id, inventory, logs)`
402
402
  """
403
403
  cycle_id = cycle.get("@id")
404
+ cycle_start_date = cycle.get("startDate")
405
+ cycle_end_date = cycle.get("endDate")
406
+
404
407
  site = _get_site(cycle)
405
408
  cycles = related_cycles(site)
406
409
 
@@ -445,13 +448,20 @@ def create_should_run_function(
445
448
 
446
449
  should_run_ = all([has_valid_inventory, has_consecutive_years])
447
450
 
451
+ kwargs = {
452
+ "cycle_id": cycle_id,
453
+ "cycle_start_date": cycle_start_date,
454
+ "cycle_end_date": cycle_end_date,
455
+ "inventory": inventory
456
+ }
457
+
448
458
  logs = should_compile_logs | inventory_logs | {
449
459
  "seed": seed,
450
460
  "has_valid_inventory": has_valid_inventory,
451
461
  "has_consecutive_years": has_consecutive_years
452
462
  }
453
463
 
454
- return should_run_, cycle_id, inventory, logs
464
+ return should_run_, kwargs, logs
455
465
 
456
466
  return should_run
457
467
 
@@ -1413,7 +1423,7 @@ def create_run_function(
1413
1423
 
1414
1424
  return result | update_dict
1415
1425
 
1416
- def run(cycle_id: str, inventory: dict) -> list[dict]:
1426
+ def run(cycle_id: str, cycle_start_date: str, cycle_end_date: str, inventory: dict) -> list[dict]:
1417
1427
  """
1418
1428
  Calculate emissions for a specific cycle using from a carbon stock change using pre-compiled inventory data.
1419
1429
 
@@ -1442,6 +1452,8 @@ def create_run_function(
1442
1452
  new_emission_func(
1443
1453
  term_id=emission_term_id,
1444
1454
  method_tier=total_emission.method,
1455
+ start_date=_get_emission_start_date(total_emission, cycle_start_date),
1456
+ end_date=_get_emission_end_date(total_emission, cycle_end_date),
1445
1457
  **calc_descriptive_stats(
1446
1458
  total_emission.value,
1447
1459
  EmissionStatsDefinition.SIMULATED,
@@ -1451,3 +1463,33 @@ def create_run_function(
1451
1463
  ]
1452
1464
 
1453
1465
  return run
1466
+
1467
+
1468
+ def _get_emission_start_date(emission: CarbonStockChangeEmission, cycle_start_date: str) -> str:
1469
+ cycle_datetime = safe_parse_date(_gapfill_datestr(cycle_start_date))
1470
+ emission_datetime = safe_parse_date(emission.start_date)
1471
+
1472
+ should_run = (
1473
+ cycle_datetime and emission_datetime
1474
+ and cycle_datetime <= emission_datetime # If the cycle starts before the emission, add a `startDate`
1475
+ )
1476
+
1477
+ return (
1478
+ (emission_datetime + timedelta(seconds=1)).strftime(DatestrFormat.YEAR_MONTH_DAY.value) if should_run
1479
+ else None
1480
+ )
1481
+
1482
+
1483
+ def _get_emission_end_date(emission: CarbonStockChangeEmission, cycle_end_date: str) -> str:
1484
+ cycle_datetime = safe_parse_date(_gapfill_datestr(cycle_end_date))
1485
+ emission_datetime = safe_parse_date(emission.end_date)
1486
+
1487
+ should_run = (
1488
+ cycle_datetime and emission_datetime
1489
+ and cycle_datetime >= emission_datetime # If the cycle ends after the emission, add an `endDate`
1490
+ )
1491
+
1492
+ return (
1493
+ emission_datetime.strftime(DatestrFormat.YEAR_MONTH_DAY.value) if should_run
1494
+ else None
1495
+ )
@@ -68,7 +68,9 @@ def _emission(
68
68
  min: list[float] = None,
69
69
  max: list[float] = None,
70
70
  statsDefinition: str = None,
71
- observations: list[int] = None
71
+ observations: list[int] = None,
72
+ start_date: str,
73
+ end_date: str
72
74
  ) -> dict:
73
75
  """
74
76
  Create an emission node based on the provided value and method tier.
@@ -96,6 +98,8 @@ def _emission(
96
98
  "max": max,
97
99
  "statsDefinition": statsDefinition,
98
100
  "observations": observations,
101
+ "startDate": start_date,
102
+ "endDate": end_date,
99
103
  "methodTier": method_tier.value,
100
104
  "depth": _DEPTH_LOWER
101
105
  }
@@ -133,13 +137,13 @@ def run(cycle: dict) -> list[dict]:
133
137
  management_change_emission_term_id=_MG_EMISSION_TERM_ID
134
138
  )
135
139
 
136
- should_run, cycle_id, inventory, logs = should_run_exec(cycle)
140
+ should_run, kwargs, logs = should_run_exec(cycle)
137
141
 
138
142
  for term_id in [_LU_EMISSION_TERM_ID, _MG_EMISSION_TERM_ID]:
139
143
  logRequirements(cycle, model=MODEL, term=term_id, **logs)
140
144
  logShouldRun(cycle, MODEL, term_id, should_run)
141
145
 
142
- return run_exec(cycle_id, inventory) if should_run else []
146
+ return run_exec(**kwargs) if should_run else []
143
147
 
144
148
 
145
149
  def _should_run_measurement_func(node: dict) -> bool:
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
 
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)
@@ -1,6 +1,6 @@
1
1
  from hestia_earth.models.log import logRequirements, logShouldRun
2
2
  from hestia_earth.models.utils.indicator import _new_indicator
3
- from hestia_earth.models.utils.impact_assessment import impact_lookup_value
3
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
4
4
  from . import MODEL
5
5
 
6
6
  REQUIREMENTS = {
@@ -26,7 +26,7 @@ def _indicator(value: float):
26
26
 
27
27
 
28
28
  def run(impact_assessment: dict):
29
- value = impact_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
29
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
30
30
  logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
31
31
  value=value)
32
32
  logShouldRun(impact_assessment, MODEL, TERM_ID, True)