hestia-earth-models 0.66.0__py3-none-any.whl → 0.67.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.
Files changed (55) hide show
  1. hestia_earth/models/cml2001Baseline/abioticResourceDepletionFossilFuels.py +23 -54
  2. hestia_earth/models/cml2001Baseline/resourceUseEnergyDepletionDuringCycle.py +152 -0
  3. hestia_earth/models/cml2001Baseline/resourceUseEnergyDepletionInputsProduction.py +40 -0
  4. hestia_earth/models/cml2001Baseline/resourceUseMineralsAndMetalsDuringCycle.py +80 -0
  5. hestia_earth/models/cml2001Baseline/resourceUseMineralsAndMetalsInputsProduction.py +40 -0
  6. hestia_earth/models/config/ImpactAssessment.json +1869 -1846
  7. hestia_earth/models/cycle/input/hestiaAggregatedData.py +13 -10
  8. hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/__init__.py +4 -3
  9. hestia_earth/models/environmentalFootprintV3_1/marineEutrophicationPotential.py +36 -0
  10. hestia_earth/models/environmentalFootprintV3_1/scarcityWeightedWaterUse.py +40 -0
  11. hestia_earth/models/impact_assessment/product/value.py +1 -1
  12. hestia_earth/models/ipcc2019/aboveGroundBiomass.py +1 -1
  13. hestia_earth/models/ipcc2019/belowGroundBiomass.py +1 -1
  14. hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +2 -1
  15. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1_utils.py +2 -1
  16. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2_utils.py +2 -1
  17. hestia_earth/models/mocking/search-results.json +874 -874
  18. hestia_earth/models/site/management.py +2 -2
  19. hestia_earth/models/utils/__init__.py +6 -0
  20. hestia_earth/models/utils/aggregated.py +13 -10
  21. hestia_earth/models/utils/array_builders.py +4 -3
  22. hestia_earth/models/utils/blank_node.py +14 -10
  23. hestia_earth/models/utils/lookup.py +3 -1
  24. hestia_earth/models/utils/property.py +5 -2
  25. hestia_earth/models/version.py +1 -1
  26. hestia_earth/orchestrator/log.py +11 -0
  27. hestia_earth/orchestrator/models/__init__.py +8 -3
  28. {hestia_earth_models-0.66.0.dist-info → hestia_earth_models-0.67.0.dist-info}/METADATA +1 -1
  29. {hestia_earth_models-0.66.0.dist-info → hestia_earth_models-0.67.0.dist-info}/RECORD +55 -43
  30. tests/models/cml2001Baseline/test_abioticResourceDepletionFossilFuels.py +51 -87
  31. tests/models/cml2001Baseline/test_resourceUseEnergyDepletionDuringCycle.py +103 -0
  32. tests/models/cml2001Baseline/test_resourceUseEnergyDepletionInputsProduction.py +23 -0
  33. tests/models/cml2001Baseline/test_resourceUseMineralsAndMetalsDuringCycle.py +58 -0
  34. tests/models/cml2001Baseline/test_resourceUseMineralsAndMetalsInputsProduction.py +23 -0
  35. tests/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/test_environmentalFootprintSingleOverallScore.py +5 -4
  36. tests/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/test_freshwaterEcotoxicityPotentialCtue.py +6 -5
  37. tests/models/environmentalFootprintV3_1/test_marineEutrophicationPotential.py +27 -0
  38. tests/models/environmentalFootprintV3_1/test_scarcityWeightedWaterUse.py +32 -0
  39. tests/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/test_soilQualityIndexLandOccupation.py +4 -3
  40. tests/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/test_soilQualityIndexLandTransformation.py +4 -3
  41. tests/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/test_soilQualityIndexTotalLandUseEffects.py +4 -4
  42. tests/models/impact_assessment/test_emissions.py +0 -1
  43. tests/models/test_config.py +3 -3
  44. tests/models/test_ecoinventV3.py +0 -1
  45. tests/models/utils/test_array_builders.py +2 -2
  46. /hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/environmentalFootprintSingleOverallScore.py +0 -0
  47. /hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/freshwaterEcotoxicityPotentialCtue.py +0 -0
  48. /hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/soilQualityIndexLandOccupation.py +0 -0
  49. /hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/soilQualityIndexLandTransformation.py +0 -0
  50. /hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/soilQualityIndexTotalLandUseEffects.py +0 -0
  51. /hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/utils.py +0 -0
  52. {hestia_earth_models-0.66.0.dist-info → hestia_earth_models-0.67.0.dist-info}/LICENSE +0 -0
  53. {hestia_earth_models-0.66.0.dist-info → hestia_earth_models-0.67.0.dist-info}/WHEEL +0 -0
  54. {hestia_earth_models-0.66.0.dist-info → hestia_earth_models-0.67.0.dist-info}/top_level.txt +0 -0
  55. /tests/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/__init__.py +0 -0
@@ -77,19 +77,22 @@ def _run_seed(cycle: dict, primary_product: dict, seed_input: dict, product_term
77
77
  # to avoid double counting seed => aggregated impact => seed, we need to get the impact of the previous decade
78
78
  # if the data does not exist, use the aggregated impact of generic crop instead
79
79
  date = aggregated_end_date(cycle.get('endDate'))
80
- match_end_date = [
81
- {'match': {'endDate': date - 10}}
82
- ]
80
+ match_end_date = [{'match': {'endDate': date - 10}}]
81
+ default_product = get_generic_crop()
83
82
 
84
- impact = find_closest_impact(cycle, date, {'term': product}, region, country, match_end_date) or \
85
- find_closest_impact(cycle, date, primary_product, region, country, match_end_date) or \
86
- find_closest_impact(cycle, date, {'term': get_generic_crop()}, region, country)
83
+ impact = (
84
+ find_closest_impact(cycle, date, product, region, country, match_end_date) or
85
+ find_closest_impact(cycle, date, primary_product.get('term', {}), region, country, match_end_date) or
86
+ find_closest_impact(cycle, date, default_product, region, country)
87
+ )
87
88
 
89
+ search_by_product_term_id = (product or primary_product or default_product).get('@id')
90
+ search_by_region_id = (region or country or {}).get('@id') or 'region-world'
88
91
  debugValues(cycle, model=MODEL_ID, term=seed_input.get('term', {}).get('@id'), key=MODEL_KEY,
89
- input_region=(region or {}).get('@id'),
90
- input_country=(country or {}).get('@id'),
91
- date=date,
92
- impact=(impact or {}).get('@id'))
92
+ search_by_product_term_id=search_by_product_term_id,
93
+ search_by_region_id=search_by_region_id,
94
+ search_by_end_date=str(date),
95
+ impact_assessment_id_found=(impact or {}).get('@id'))
93
96
 
94
97
  return seed_input | {MODEL_KEY: linked_node(impact), 'impactAssessmentIsProxy': True} if impact else None
95
98
 
@@ -1,13 +1,14 @@
1
- from os.path import dirname, abspath
2
1
  import sys
3
2
  from importlib import import_module
3
+ from os.path import dirname, abspath
4
4
 
5
5
  from hestia_earth.models.utils.blank_node import run_if_required
6
6
 
7
7
  CURRENT_DIR = dirname(abspath(__file__)) + '/'
8
8
  sys.path.append(CURRENT_DIR)
9
- MODEL = 'environmentalFootprintV3'
10
- PKG = '.'.join(['hestia_earth', 'models', MODEL])
9
+ MODEL = 'environmentalFootprintV3-1'
10
+ MODEL_FOLDER = MODEL.replace('-', '_')
11
+ PKG = '.'.join(['hestia_earth', 'models', MODEL_FOLDER])
11
12
 
12
13
 
13
14
  def run(model: str, data): return run_if_required(MODEL, model, data, import_module(f".{model}", package=PKG))
@@ -0,0 +1,36 @@
1
+ from hestia_earth.models.log import logRequirements, logShouldRun
2
+ from hestia_earth.models.utils.impact_assessment import impact_emission_lookup_value
3
+ from hestia_earth.models.utils.indicator import _new_indicator
4
+ from . import MODEL
5
+
6
+ REQUIREMENTS = {
7
+ "ImpactAssessment": {
8
+ "emissionsResourceUse": [{"@type": "Indicator", "value": "", "term.termType": "emission"}]
9
+ }
10
+ }
11
+
12
+ RETURNS = {
13
+ "Indicator": {
14
+ "value": ""
15
+ }
16
+ }
17
+
18
+ LOOKUPS = {
19
+ "emission": "nEqMarineEutrophicationEnvironmentalFootprintV3"
20
+ }
21
+
22
+ TERM_ID = 'marineEutrophicationPotential'
23
+
24
+
25
+ def _indicator(value: float):
26
+ indicator = _new_indicator(TERM_ID, MODEL)
27
+ indicator['value'] = value
28
+ return indicator
29
+
30
+
31
+ def run(impact_assessment: dict):
32
+ value = impact_emission_lookup_value(MODEL, TERM_ID, impact_assessment, LOOKUPS['emission'])
33
+ logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
34
+ value=value)
35
+ logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
36
+ return _indicator(value) if value is not None else None
@@ -0,0 +1,40 @@
1
+ from hestia_earth.models.log import logRequirements, logShouldRun
2
+ from . import MODEL
3
+ from ..utils.impact_assessment import impact_country_value
4
+ from ..utils.indicator import _new_indicator
5
+
6
+ REQUIREMENTS = {
7
+ "ImpactAssessment": {
8
+ "emissionsResourceUse": [{"@type": "Indicator",
9
+ "term.@id": "freshwaterWithdrawalsDuringCycle",
10
+ "value": ""
11
+ }],
12
+ "optional": {"country": {"@type": "Term", "termType": "region"}}
13
+ }
14
+ }
15
+
16
+ LOOKUPS = {
17
+ "region-resourceUse-environmentalFootprintV31WaterUse": ""
18
+ }
19
+
20
+ RETURNS = {
21
+ "Indicator": {
22
+ "value": ""
23
+ }
24
+ }
25
+ TERM_ID = 'scarcityWeightedWaterUse'
26
+
27
+
28
+ def _indicator(value: float):
29
+ indicator = _new_indicator(TERM_ID, MODEL)
30
+ indicator['value'] = value
31
+ return indicator
32
+
33
+
34
+ def run(impact_assessment: dict):
35
+ value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv",
36
+ country_fallback=True)
37
+ logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
38
+ value=value)
39
+ logShouldRun(impact_assessment, MODEL, TERM_ID, value is not None)
40
+ return None if value is None else _indicator(value)
@@ -25,7 +25,7 @@ MODEL_KEY = 'value'
25
25
 
26
26
 
27
27
  def _run(impact: dict, product: dict):
28
- return {**impact.get('product'), MODEL_KEY: product.get(MODEL_KEY, [])}
28
+ return impact.get('product') | {MODEL_KEY: product.get(MODEL_KEY, [])}
29
29
 
30
30
 
31
31
  def _should_run(impact: dict):
@@ -170,7 +170,7 @@ def _should_run(site: dict) -> tuple[bool, dict, dict]:
170
170
  inventory = _compile_inventory(land_cover) if should_compile_inventory else {}
171
171
  kwargs = {
172
172
  "eco_climate_zone": eco_climate_zone,
173
- "seed": gen_seed(site)
173
+ "seed": gen_seed(site, MODEL, TERM_ID)
174
174
  }
175
175
 
176
176
  logRequirements(
@@ -167,7 +167,7 @@ def _should_run(site: dict) -> tuple[bool, dict, dict]:
167
167
  inventory = _compile_inventory(land_cover) if should_compile_inventory else {}
168
168
  kwargs = {
169
169
  "eco_climate_zone": eco_climate_zone,
170
- "seed": gen_seed(site)
170
+ "seed": gen_seed(site, MODEL, TERM_ID)
171
171
  }
172
172
 
173
173
  logRequirements(
@@ -38,6 +38,7 @@ from hestia_earth.models.utils.time_series import (
38
38
  )
39
39
 
40
40
  from .utils import check_consecutive
41
+ from . import MODEL
41
42
 
42
43
  _ITERATIONS = 10000
43
44
  _MAX_CORRELATION = 1
@@ -424,7 +425,7 @@ def create_should_run_function(
424
425
 
425
426
  land_cover_nodes = get_valid_management_nodes_func(site)
426
427
 
427
- seed = gen_seed(site) # All cycles linked to the same site should be consistent
428
+ seed = gen_seed(site, MODEL, carbon_stock_term_id) # All cycles linked to the same site should be consistent
428
429
  rng = random.default_rng(seed)
429
430
 
430
431
  should_compile_inventory, should_compile_logs = should_compile_inventory_func(
@@ -41,6 +41,7 @@ from .organicCarbonPerHa_utils import (
41
41
  sample_plus_minus_error, sample_plus_minus_uncertainty, SITE_TYPE_TO_IPCC_LAND_USE_CATEGORY,
42
42
  SUPER_MAJORITY_AREA_THRESHOLD, STATS_DEFINITION
43
43
  )
44
+ from . import MODEL
44
45
 
45
46
  _LOOKUPS = {
46
47
  "crop": "IPCC_LAND_USE_CATEGORY",
@@ -555,7 +556,7 @@ def should_run(site: dict) -> tuple[bool, dict, dict]:
555
556
  )
556
557
 
557
558
  kwargs = {
558
- "seed": gen_seed(site),
559
+ "seed": gen_seed(site, MODEL, _TERM_ID),
559
560
  "eco_climate_zone": eco_climate_zone,
560
561
  "ipcc_soil_category": ipcc_soil_category,
561
562
  }
@@ -41,6 +41,7 @@ from .organicCarbonPerHa_utils import (
41
41
  IpccLandUseCategory, IpccManagementCategory, is_cover_crop, MIN_AREA_THRESHOLD, MIN_YIELD_THRESHOLD,
42
42
  sample_constant, sample_plus_minus_uncertainty, sample_truncated_normal, STATS_DEFINITION
43
43
  )
44
+ from . import MODEL
44
45
 
45
46
  _LOOKUPS = {
46
47
  "crop": "IPCC_LAND_USE_CATEGORY",
@@ -412,7 +413,7 @@ def should_run(site: dict) -> tuple[bool, dict, dict]:
412
413
  _compile_inventory(cycles, measurement_nodes)
413
414
  if should_compile_inventory else ({}, {})
414
415
  )
415
- kwargs["seed"] = gen_seed(site)
416
+ kwargs["seed"] = gen_seed(site, MODEL, _TERM_ID)
416
417
 
417
418
  valid_years = [year for year, group in inventory.items() if group.get(_InventoryKey.SHOULD_RUN)]
418
419