hestia-earth-models 0.65.5__py3-none-any.whl → 0.65.6__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.
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionFossilFuels.py +9 -5
- hestia_earth/models/hestia/landCover.py +70 -22
- hestia_earth/models/mocking/search-results.json +27 -4520
- hestia_earth/models/site/management.py +82 -22
- hestia_earth/models/utils/crop.py +5 -1
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.65.5.dist-info → hestia_earth_models-0.65.6.dist-info}/METADATA +1 -1
- {hestia_earth_models-0.65.5.dist-info → hestia_earth_models-0.65.6.dist-info}/RECORD +13 -13
- tests/models/cml2001Baseline/test_abioticResourceDepletionFossilFuels.py +1 -1
- tests/models/hestia/test_landCover.py +2 -1
- {hestia_earth_models-0.65.5.dist-info → hestia_earth_models-0.65.6.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.65.5.dist-info → hestia_earth_models-0.65.6.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.65.5.dist-info → hestia_earth_models-0.65.6.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"""
|
|
2
|
-
This model calculates the abiotic resource depletion, fossil fuels. Based on the models CML 2002 (Guinée et al., 2002)
|
|
2
|
+
This model calculates the abiotic resource depletion, fossil fuels. Based on the models CML 2002 (Guinée et al., 2002)
|
|
3
|
+
and van Oers et al. 2002 (method, v.4.8)
|
|
3
4
|
|
|
4
|
-
>The earth contains a finite amount of non-renewable resources, such as fossil fuels like coal, oil and gas.
|
|
5
|
+
> The earth contains a finite amount of non-renewable resources, such as fossil fuels like coal, oil and gas.
|
|
6
|
+
The basic idea behind this impact category is that extracting resources today will force future generations to extract
|
|
7
|
+
less or different resources. For example, the depletion of V2.0 – 25th August 2023 28 fossil fuels may lead to the
|
|
8
|
+
non-availability of fossil fuels for future generations. The amount of materials contributing to resource use, fossils,
|
|
9
|
+
are converted into MJ.
|
|
5
10
|
|
|
6
11
|
Source : [Life Cycle Assessment & the EF methods - Comprehensive coverage of impacts](https://green-business.ec.europa.eu/environmental-footprint-methods/life-cycle-assessment-ef-methods_en)
|
|
7
12
|
|
|
@@ -89,9 +94,8 @@ def download_all_non_renewable_terms(lookup_file_name: str) -> list:
|
|
|
89
94
|
lookup = download_lookup(lookup_file_name)
|
|
90
95
|
results = lookup[
|
|
91
96
|
lookup[column_name("abioticResourceDepletionFossilFuelsCml2001Baseline")] == True # noqa: E712
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return terms_ids
|
|
97
|
+
]["termid"]
|
|
98
|
+
return list(map(str, results))
|
|
95
99
|
|
|
96
100
|
|
|
97
101
|
def _valid_resource_indicator(resource: dict) -> bool:
|
|
@@ -6,6 +6,8 @@ functionality of the Blonk model.
|
|
|
6
6
|
"""
|
|
7
7
|
import math
|
|
8
8
|
from collections import defaultdict
|
|
9
|
+
from datetime import datetime, timedelta
|
|
10
|
+
|
|
9
11
|
from hestia_earth.schema import SiteSiteType, TermTermType
|
|
10
12
|
from hestia_earth.utils.lookup import (
|
|
11
13
|
download_lookup, get_table_value, column_name,
|
|
@@ -32,6 +34,8 @@ from .utils import (
|
|
|
32
34
|
crop_ipcc_land_use_category,
|
|
33
35
|
)
|
|
34
36
|
from . import MODEL
|
|
37
|
+
from ..utils.blank_node import _node_date, DatestrFormat
|
|
38
|
+
from ..utils.constant import DAYS_IN_YEAR
|
|
35
39
|
|
|
36
40
|
REQUIREMENTS = {
|
|
37
41
|
"Site": {
|
|
@@ -90,6 +94,7 @@ SITE_TYPES = {
|
|
|
90
94
|
SiteSiteType.PERMANENT_PASTURE.value
|
|
91
95
|
}
|
|
92
96
|
DEFAULT_WINDOW_IN_YEARS = 20
|
|
97
|
+
DATE_TOLERANCE_IN_YEARS = 2
|
|
93
98
|
OUTPUT_SIGNIFICANT_DIGITS = 3
|
|
94
99
|
|
|
95
100
|
|
|
@@ -115,16 +120,6 @@ def site_area_sum_to_100(dict_of_percentages: dict):
|
|
|
115
120
|
math.isclose(sum(dict_of_percentages.values()), 0.0, rel_tol=0.01))
|
|
116
121
|
|
|
117
122
|
|
|
118
|
-
def _lookup_land_use_type(nodes: list) -> str:
|
|
119
|
-
"""Look up the land use type from a management node."""
|
|
120
|
-
return "" if nodes == [] else get_lookup_value(
|
|
121
|
-
lookup_term=nodes[0].get("term", {}),
|
|
122
|
-
column=LOOKUPS.get("landCover")[1],
|
|
123
|
-
model=MODEL,
|
|
124
|
-
term=nodes[0].get("term", {})
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
|
|
128
123
|
def get_changes(country_id: str, end_year: int) -> dict:
|
|
129
124
|
"""
|
|
130
125
|
For each entry in ALL_LAND_USE_TERMS, creates a key: value in output dictionary, also TOTAL
|
|
@@ -512,14 +507,13 @@ def _get_net_expansion_cultivated_vs_harvested(annual_crops_net_expansion, chang
|
|
|
512
507
|
return net_expansion_cultivated_vs_harvested
|
|
513
508
|
|
|
514
509
|
|
|
515
|
-
def _should_run_historical_land_use_change(site: dict, land_use_type: str) -> tuple[bool, dict]:
|
|
516
|
-
management_nodes = filter_list_term_type(site.get("management", []), TermTermType.LANDCOVER)
|
|
510
|
+
def _should_run_historical_land_use_change(site: dict, nodes: list, land_use_type: str) -> tuple[bool, dict]:
|
|
517
511
|
# Assume a single management node for single-cropping.
|
|
518
512
|
return _should_run_historical_land_use_change_single_crop(
|
|
519
513
|
site=site,
|
|
520
|
-
term=
|
|
514
|
+
term=nodes[0].get("term", {}),
|
|
521
515
|
country_id=site.get("country", {}).get("@id"),
|
|
522
|
-
end_year=int(
|
|
516
|
+
end_year=int(nodes[0].get("endDate")[:4]),
|
|
523
517
|
land_use_type=land_use_type
|
|
524
518
|
)
|
|
525
519
|
|
|
@@ -688,18 +682,72 @@ def _should_run_historical_land_use_change_single_crop(
|
|
|
688
682
|
return should_run, site_area
|
|
689
683
|
|
|
690
684
|
|
|
685
|
+
def _get_land_use_term_from_node(node: dict) -> str:
|
|
686
|
+
return get_lookup_value(
|
|
687
|
+
lookup_term=node.get("term", {}),
|
|
688
|
+
column=LOOKUPS.get("landCover")[1],
|
|
689
|
+
model=MODEL,
|
|
690
|
+
term=node.get("term", {})
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
def _collect_land_use_types(nodes: list) -> list:
|
|
695
|
+
"""Look up the land use type from management nodes."""
|
|
696
|
+
return [
|
|
697
|
+
{
|
|
698
|
+
"id": node.get("term", {}).get("@id"),
|
|
699
|
+
"land-use-type": _get_land_use_term_from_node(node),
|
|
700
|
+
"endDate": node.get("endDate")
|
|
701
|
+
} for node in nodes
|
|
702
|
+
]
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
def _no_prior_land_cover_data(nodes: list, end_date: str) -> bool:
|
|
706
|
+
target_date = (
|
|
707
|
+
datetime.strptime(end_date, DatestrFormat.YEAR_MONTH_DAY.value)
|
|
708
|
+
- timedelta(days=DEFAULT_WINDOW_IN_YEARS * DAYS_IN_YEAR)
|
|
709
|
+
)
|
|
710
|
+
previous_nodes = [
|
|
711
|
+
node for node in nodes
|
|
712
|
+
if abs(_node_date(node) - target_date) < timedelta(days=DATE_TOLERANCE_IN_YEARS * DAYS_IN_YEAR)
|
|
713
|
+
]
|
|
714
|
+
return len(previous_nodes) == 0
|
|
715
|
+
|
|
716
|
+
|
|
691
717
|
def _should_run(site: dict) -> tuple[bool, dict]:
|
|
692
718
|
management_nodes = filter_list_term_type(site.get("management", []), TermTermType.LANDCOVER)
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
719
|
+
summarised_nodes = _collect_land_use_types(management_nodes)
|
|
720
|
+
allowed_land_use_types = [ANNUAL_CROPLAND, PERMANENT_CROPLAND, PERMANENT_PASTURE]
|
|
721
|
+
relevant_nodes = sorted(
|
|
722
|
+
[
|
|
723
|
+
node for node in summarised_nodes
|
|
724
|
+
if node["land-use-type"] in allowed_land_use_types
|
|
725
|
+
],
|
|
726
|
+
key=lambda n: n.get("endDate")
|
|
700
727
|
)
|
|
728
|
+
land_use_type = relevant_nodes[0].get("land-use-type") if relevant_nodes else None
|
|
701
729
|
|
|
702
|
-
|
|
730
|
+
has_no_prior_land_cover_data = _no_prior_land_cover_data(
|
|
731
|
+
nodes=management_nodes,
|
|
732
|
+
end_date=relevant_nodes[-1:][0].get("endDate")
|
|
733
|
+
) if relevant_nodes else None
|
|
734
|
+
|
|
735
|
+
should_run_nodes, site_area = _should_run_historical_land_use_change(
|
|
736
|
+
site=site,
|
|
737
|
+
nodes=management_nodes,
|
|
738
|
+
land_use_type=land_use_type
|
|
739
|
+
) if all([land_use_type, has_no_prior_land_cover_data]) else (False, {})
|
|
740
|
+
|
|
741
|
+
logRequirements(site, model=MODEL, model_key=MODEL_KEY,
|
|
742
|
+
has_management_nodes=bool(management_nodes),
|
|
743
|
+
land_use_type=land_use_type,
|
|
744
|
+
allowed_land_use_types=';'.join(allowed_land_use_types),
|
|
745
|
+
has_no_prior_land_cover_data=has_no_prior_land_cover_data,
|
|
746
|
+
summarised_nodes=log_as_table(summarised_nodes))
|
|
747
|
+
|
|
748
|
+
should_run = all([land_use_type, has_no_prior_land_cover_data, should_run_nodes])
|
|
749
|
+
logShouldRun(site, MODEL, None, should_run, model_key=MODEL_KEY)
|
|
750
|
+
return should_run_nodes, site_area
|
|
703
751
|
|
|
704
752
|
|
|
705
753
|
def run(site: dict) -> list:
|