hestia-earth-models 0.74.4__py3-none-any.whl → 0.74.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 (62) hide show
  1. hestia_earth/models/cml2001Baseline/abioticResourceDepletionMineralsAndMetals.py +0 -1
  2. hestia_earth/models/config/Cycle.json +15 -0
  3. hestia_earth/models/config/ImpactAssessment.json +9 -1
  4. hestia_earth/models/cycle/animal/input/hestiaAggregatedData.py +3 -3
  5. hestia_earth/models/cycle/completeness/seed.py +1 -1
  6. hestia_earth/models/cycle/input/hestiaAggregatedData.py +25 -16
  7. hestia_earth/models/data/hestiaAggregatedData/__init__.py +73 -0
  8. hestia_earth/models/environmentalFootprintV3_1/scarcityWeightedWaterUse.py +1 -1
  9. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandOccupation.py +5 -6
  10. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandTransformation.py +10 -13
  11. hestia_earth/models/fantkeEtAl2016/damageToHumanHealthParticulateMatterFormation.py +1 -1
  12. hestia_earth/models/hestia/landCover.py +24 -0
  13. hestia_earth/models/hestia/landOccupationDuringCycle.py +80 -51
  14. hestia_earth/models/hestia/landTransformation100YearAverageDuringCycle.py +7 -1
  15. hestia_earth/models/hestia/landTransformation20YearAverageDuringCycle.py +7 -1
  16. hestia_earth/models/hestia/resourceUse_utils.py +58 -119
  17. hestia_earth/models/hestia/waterSalinity.py +57 -12
  18. hestia_earth/models/impact_assessment/post_checks/__init__.py +3 -2
  19. hestia_earth/models/impact_assessment/post_checks/remove_cache_fields.py +9 -0
  20. hestia_earth/models/impact_assessment/pre_checks/cache_emissionsResourceUse.py +21 -0
  21. hestia_earth/models/impact_assessment/pre_checks/cycle.py +5 -0
  22. hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChange.py +6 -64
  23. hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChange.py +9 -87
  24. hestia_earth/models/ipcc2019/co2ToAirBiocharStockChange.py +140 -0
  25. hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +329 -217
  26. hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py +10 -87
  27. hestia_earth/models/mocking/__init__.py +2 -2
  28. hestia_earth/models/mocking/mock_search.py +20 -10
  29. hestia_earth/models/mocking/search-results.json +1 -7679
  30. hestia_earth/models/pooreNemecek2018/landOccupationDuringCycle.py +8 -7
  31. hestia_earth/models/poschEtAl2008/terrestrialAcidificationPotentialAccumulatedExceedance.py +1 -1
  32. hestia_earth/models/poschEtAl2008/terrestrialEutrophicationPotentialAccumulatedExceedance.py +1 -1
  33. hestia_earth/models/preload_requests.py +18 -4
  34. hestia_earth/models/schmidt2007/utils.py +3 -3
  35. hestia_earth/models/utils/__init__.py +4 -1
  36. hestia_earth/models/utils/aggregated.py +21 -68
  37. hestia_earth/models/utils/cycle.py +3 -3
  38. hestia_earth/models/utils/impact_assessment.py +45 -41
  39. hestia_earth/models/utils/lookup.py +92 -67
  40. hestia_earth/models/version.py +1 -1
  41. hestia_earth/orchestrator/models/__init__.py +47 -10
  42. hestia_earth/orchestrator/models/transformations.py +3 -1
  43. hestia_earth/orchestrator/strategies/merge/__init__.py +1 -2
  44. hestia_earth/orchestrator/strategies/merge/merge_list.py +31 -8
  45. hestia_earth/orchestrator/utils.py +29 -0
  46. {hestia_earth_models-0.74.4.dist-info → hestia_earth_models-0.74.5.dist-info}/METADATA +2 -3
  47. {hestia_earth_models-0.74.4.dist-info → hestia_earth_models-0.74.5.dist-info}/RECORD +62 -55
  48. tests/models/cycle/animal/input/test_hestiaAggregatedData.py +3 -3
  49. tests/models/cycle/input/test_hestiaAggregatedData.py +9 -18
  50. tests/models/data/__init__.py +0 -0
  51. tests/models/data/test_hestiaAggregatedData.py +32 -0
  52. tests/models/hestia/test_landCover.py +32 -1
  53. tests/models/hestia/test_waterSalinity.py +16 -4
  54. tests/models/ipcc2019/test_co2ToAirAboveGroundBiomassStockChange.py +1 -6
  55. tests/models/ipcc2019/test_co2ToAirBelowGroundBiomassStockChange.py +1 -6
  56. tests/models/ipcc2019/test_co2ToAirBiocharStockChange.py +90 -0
  57. tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py +1 -6
  58. tests/models/pooreNemecek2018/test_landOccupationDuringCycle.py +1 -0
  59. tests/orchestrator/strategies/merge/test_merge_list.py +5 -0
  60. {hestia_earth_models-0.74.4.dist-info → hestia_earth_models-0.74.5.dist-info}/LICENSE +0 -0
  61. {hestia_earth_models-0.74.4.dist-info → hestia_earth_models-0.74.5.dist-info}/WHEEL +0 -0
  62. {hestia_earth_models-0.74.4.dist-info → hestia_earth_models-0.74.5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,140 @@
1
+ from hestia_earth.schema import EmissionMethodTier
2
+ from hestia_earth.utils.date import YEAR
3
+
4
+ from hestia_earth.models.log import logRequirements, logShouldRun
5
+ from hestia_earth.models.utils.emission import _new_emission
6
+
7
+ from .co2ToAirCarbonStockChange_utils import create_run_function, create_should_run_function
8
+ from . import MODEL
9
+
10
+ REQUIREMENTS = {
11
+ "Cycle": {
12
+ "site": {
13
+ "@type": "Site",
14
+ "measurements": [
15
+ {
16
+ "@type": "Measurement",
17
+ "value": "",
18
+ "dates": "",
19
+ "depthUpper": "0",
20
+ "depthLower": "30",
21
+ "term.@id": "biocharOrganicCarbonPerHa"
22
+ }
23
+ ]
24
+ },
25
+ "functionalUnit": "1 ha",
26
+ "endDate": "",
27
+ "optional": {
28
+ "startDate": ""
29
+ }
30
+ }
31
+ }
32
+ RETURNS = {
33
+ "Emission": [{
34
+ "value": "",
35
+ "sd": "",
36
+ "min": "",
37
+ "max": "",
38
+ "statsDefinition": "simulated",
39
+ "observations": "",
40
+ "methodTier": "",
41
+ "depth": 30
42
+ }]
43
+ }
44
+ TERM_ID = 'co2ToAirBiocharStockChange'
45
+
46
+ _DEPTH_UPPER = 0
47
+ _DEPTH_LOWER = 30
48
+
49
+ _CARBON_STOCK_TERM_ID = 'biocharOrganicCarbonPerHa'
50
+
51
+ _TRANSITION_PERIOD_YEARS = 100
52
+ _TRANSITION_PERIOD_DAYS = _TRANSITION_PERIOD_YEARS * YEAR
53
+
54
+ _EXCLUDE_FROM_LOGS = ["land_use_inventory"] # not required for model
55
+
56
+
57
+ def _emission(
58
+ *,
59
+ term_id: str,
60
+ value: list[float],
61
+ method_tier: EmissionMethodTier,
62
+ sd: list[float] = None,
63
+ min: list[float] = None,
64
+ max: list[float] = None,
65
+ statsDefinition: str = None,
66
+ observations: list[int] = None
67
+ ) -> dict:
68
+ """
69
+ Create an emission node based on the provided value and method tier.
70
+
71
+ See [Emission schema](https://www.hestia.earth/schema/Emission) for more information.
72
+
73
+ Parameters
74
+ ----------
75
+ value : float
76
+ The emission value (kg CO2 ha-1).
77
+ sd : float
78
+ The standard deviation (kg CO2 ha-1).
79
+ method_tier : EmissionMethodTier
80
+ The emission method tier.
81
+
82
+ Returns
83
+ -------
84
+ dict
85
+ The emission dictionary with keys 'depth', 'value', and 'methodTier'.
86
+ """
87
+ update_dict = {
88
+ "value": value,
89
+ "sd": sd,
90
+ "min": min,
91
+ "max": max,
92
+ "statsDefinition": statsDefinition,
93
+ "observations": observations,
94
+ "methodTier": method_tier.value,
95
+ "depth": _DEPTH_LOWER
96
+ }
97
+ emission = _new_emission(term_id, MODEL) | {
98
+ key: value for key, value in update_dict.items() if value
99
+ }
100
+ return emission
101
+
102
+
103
+ def run(cycle: dict) -> list[dict]:
104
+ """
105
+ Run the `ipcc2019.co2ToAirBelowGroundBiomassStockChangeManagementChange`.
106
+
107
+ Parameters
108
+ ----------
109
+ cycle : dict
110
+ A HESTIA (Cycle node)[https://www.hestia.earth/schema/Cycle].
111
+
112
+ Returns
113
+ -------
114
+ list[dict]
115
+ A list of [Emission nodes](https://www.hestia.earth/schema/Emission) containing model results.
116
+ """
117
+ should_run_exec = create_should_run_function(
118
+ _CARBON_STOCK_TERM_ID,
119
+ depth_upper=_DEPTH_UPPER,
120
+ depth_lower=_DEPTH_LOWER,
121
+ transition_period=_TRANSITION_PERIOD_DAYS
122
+ )
123
+
124
+ run_exec = create_run_function(
125
+ new_emission_func=_emission,
126
+ land_use_change_emission_term_id=None, # All emissions allocated to management change
127
+ management_change_emission_term_id=TERM_ID
128
+ )
129
+
130
+ should_run, cycle_id, inventory, logs = should_run_exec(cycle)
131
+
132
+ logRequirements(
133
+ cycle,
134
+ model=MODEL,
135
+ term=TERM_ID,
136
+ **{k: v for k, v in logs.items() if k not in _EXCLUDE_FROM_LOGS}
137
+ )
138
+ logShouldRun(cycle, MODEL, TERM_ID, should_run)
139
+
140
+ return run_exec(cycle_id, inventory) if should_run else []