hestia-earth-models 0.63.0__py3-none-any.whl → 0.64.1__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/cycle/endDate.py +47 -0
- hestia_earth/models/cycle/otherSitesUnusedDuration.py +91 -0
- hestia_earth/models/cycle/siteUnusedDuration.py +2 -1
- hestia_earth/models/cycle/startDate.py +38 -10
- hestia_earth/models/cycle/startDateDefinition.py +2 -2
- hestia_earth/models/cycle/unknownPreSeasonWaterRegime.py +51 -0
- hestia_earth/models/ecoinventV3/__init__.py +18 -2
- hestia_earth/models/edip2003/__init__.py +13 -0
- hestia_earth/models/edip2003/ozoneDepletionPotential.py +34 -0
- hestia_earth/models/faostat2018/landTransformationFromCropland100YearAverage.py +1 -1
- hestia_earth/models/faostat2018/landTransformationFromCropland20YearAverage.py +1 -1
- hestia_earth/models/faostat2018/utils.py +2 -2
- hestia_earth/models/geospatialDatabase/clayContent.py +44 -17
- hestia_earth/models/geospatialDatabase/organicCarbonPerKgSoil.py +43 -17
- hestia_earth/models/geospatialDatabase/sandContent.py +43 -16
- hestia_earth/models/geospatialDatabase/siltContent.py +58 -18
- hestia_earth/models/geospatialDatabase/soilPh.py +43 -16
- hestia_earth/models/geospatialDatabase/totalNitrogenPerKgSoil.py +45 -15
- hestia_earth/models/geospatialDatabase/utils.py +11 -5
- hestia_earth/models/hyde32/landTransformationFromCropland100YearAverageDuringCycle.py +2 -1
- hestia_earth/models/hyde32/landTransformationFromCropland20YearAverageDuringCycle.py +2 -1
- hestia_earth/models/hyde32/landTransformationFromForest100YearAverageDuringCycle.py +2 -1
- hestia_earth/models/hyde32/landTransformationFromForest20YearAverageDuringCycle.py +2 -1
- hestia_earth/models/hyde32/landTransformationFromOtherNaturalVegetation100YearAverageDuringCycle.py +2 -1
- hestia_earth/models/hyde32/landTransformationFromOtherNaturalVegetation20YearAverageDuringCycle.py +2 -1
- hestia_earth/models/hyde32/landTransformationFromPermanentPasture100YearAverageDuringCycle.py +2 -1
- hestia_earth/models/hyde32/landTransformationFromPermanentPasture20YearAverageDuringCycle.py +2 -1
- hestia_earth/models/hyde32/utils.py +7 -4
- hestia_earth/models/impact_assessment/allocationMethod.py +39 -0
- hestia_earth/models/impact_assessment/emissions.py +3 -1
- hestia_earth/models/mocking/search-results.json +61 -19
- hestia_earth/models/pooreNemecek2018/excretaKgN.py +9 -9
- hestia_earth/models/pooreNemecek2018/excretaKgVs.py +6 -8
- hestia_earth/models/poschEtAl2008/__init__.py +13 -0
- hestia_earth/models/poschEtAl2008/terrestrialAcidificationPotentialAccumulatedExceedance.py +40 -0
- hestia_earth/models/site/management.py +15 -1
- hestia_earth/models/site/pre_checks/cache_geospatialDatabase.py +23 -16
- hestia_earth/models/site/waterDepth.py +0 -3
- hestia_earth/models/utils/indicator.py +3 -1
- hestia_earth/models/utils/term.py +34 -0
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.63.0.dist-info → hestia_earth_models-0.64.1.dist-info}/METADATA +3 -3
- {hestia_earth_models-0.63.0.dist-info → hestia_earth_models-0.64.1.dist-info}/RECORD +72 -56
- tests/models/cycle/test_endDate.py +22 -0
- tests/models/cycle/test_otherSitesUnusedDuration.py +54 -0
- tests/models/cycle/test_startDate.py +23 -5
- tests/models/cycle/test_unknownPreSeasonWaterRegime.py +36 -0
- tests/models/edip2003/__init__.py +0 -0
- tests/models/edip2003/test_ozoneDepletionPotential.py +46 -0
- tests/models/geospatialDatabase/test_clayContent.py +16 -2
- tests/models/geospatialDatabase/test_organicCarbonPerKgSoil.py +16 -2
- tests/models/geospatialDatabase/test_sandContent.py +16 -2
- tests/models/geospatialDatabase/test_siltContent.py +2 -2
- tests/models/geospatialDatabase/test_soilPh.py +16 -2
- tests/models/geospatialDatabase/test_totalNitrogenPerKgSoil.py +16 -2
- tests/models/hyde32/test_landTransformationFromCropland100YearAverageDuringCycle.py +1 -0
- tests/models/hyde32/test_landTransformationFromCropland20YearAverageDuringCycle.py +1 -0
- tests/models/hyde32/test_landTransformationFromForest100YearAverageDuringCycle.py +1 -0
- tests/models/hyde32/test_landTransformationFromForest20YearAverageDuringCycle.py +1 -0
- tests/models/hyde32/test_landTransformationFromOtherNaturalVegetation100YearAverageDuringCycle.py +1 -0
- tests/models/hyde32/test_landTransformationFromOtherNaturalVegetation20YearAverageDuringCycle.py +1 -0
- tests/models/hyde32/test_landTransformationFromPermanentPasture100YearAverageDuringCycle.py +1 -0
- tests/models/hyde32/test_landTransformationFromPermanentPasture20YearAverageDuringCycle.py +1 -0
- tests/models/impact_assessment/test_allocationMethod.py +48 -0
- tests/models/poschEtAl2008/__init__.py +0 -0
- tests/models/poschEtAl2008/test_terrestrialAcidificationPotentialAccumulatedExceedance.py +45 -0
- tests/models/test_cache_sites.py +10 -4
- tests/models/test_ecoinventV3.py +1 -0
- tests/models/utils/test_source.py +1 -1
- {hestia_earth_models-0.63.0.dist-info → hestia_earth_models-0.64.1.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.63.0.dist-info → hestia_earth_models-0.64.1.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.63.0.dist-info → hestia_earth_models-0.64.1.dist-info}/top_level.txt +0 -0
|
@@ -979,11 +979,11 @@
|
|
|
979
979
|
},
|
|
980
980
|
{
|
|
981
981
|
"@type": "Term",
|
|
982
|
-
"@id": "
|
|
982
|
+
"@id": "longFallowCrop"
|
|
983
983
|
},
|
|
984
984
|
{
|
|
985
985
|
"@type": "Term",
|
|
986
|
-
"@id": "
|
|
986
|
+
"@id": "shortFallowCrop"
|
|
987
987
|
}
|
|
988
988
|
]
|
|
989
989
|
},
|
|
@@ -1062,11 +1062,11 @@
|
|
|
1062
1062
|
},
|
|
1063
1063
|
{
|
|
1064
1064
|
"@type": "Term",
|
|
1065
|
-
"@id": "
|
|
1065
|
+
"@id": "residueIncorporatedLessThan30DaysBeforeCultivation"
|
|
1066
1066
|
},
|
|
1067
1067
|
{
|
|
1068
1068
|
"@type": "Term",
|
|
1069
|
-
"@id": "
|
|
1069
|
+
"@id": "residueRemoved"
|
|
1070
1070
|
},
|
|
1071
1071
|
{
|
|
1072
1072
|
"@type": "Term",
|
|
@@ -1094,19 +1094,19 @@
|
|
|
1094
1094
|
},
|
|
1095
1095
|
{
|
|
1096
1096
|
"@type": "Term",
|
|
1097
|
-
"@id": "
|
|
1097
|
+
"@id": "discardedCropLeftOnField"
|
|
1098
1098
|
},
|
|
1099
1099
|
{
|
|
1100
1100
|
"@type": "Term",
|
|
1101
|
-
"@id": "
|
|
1101
|
+
"@id": "discardedCropTotal"
|
|
1102
1102
|
},
|
|
1103
1103
|
{
|
|
1104
1104
|
"@type": "Term",
|
|
1105
|
-
"@id": "
|
|
1105
|
+
"@id": "discardedCropIncorporated"
|
|
1106
1106
|
},
|
|
1107
1107
|
{
|
|
1108
1108
|
"@type": "Term",
|
|
1109
|
-
"@id": "
|
|
1109
|
+
"@id": "aboveGroundCropResidueRemoved"
|
|
1110
1110
|
},
|
|
1111
1111
|
{
|
|
1112
1112
|
"@type": "Term",
|
|
@@ -1475,6 +1475,48 @@
|
|
|
1475
1475
|
}
|
|
1476
1476
|
]
|
|
1477
1477
|
},
|
|
1478
|
+
{
|
|
1479
|
+
"name": "get_flooded_pre_season_terms",
|
|
1480
|
+
"query": {
|
|
1481
|
+
"bool": {
|
|
1482
|
+
"must": [
|
|
1483
|
+
{
|
|
1484
|
+
"match": {
|
|
1485
|
+
"@type": "Term"
|
|
1486
|
+
}
|
|
1487
|
+
},
|
|
1488
|
+
{
|
|
1489
|
+
"match": {
|
|
1490
|
+
"termType": "landUseManagement"
|
|
1491
|
+
}
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
"match_phrase": {
|
|
1495
|
+
"name": "flooded pre-season"
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
]
|
|
1499
|
+
}
|
|
1500
|
+
},
|
|
1501
|
+
"results": [
|
|
1502
|
+
{
|
|
1503
|
+
"@type": "Term",
|
|
1504
|
+
"@id": "floodedPreSeasonMoreThan30Days"
|
|
1505
|
+
},
|
|
1506
|
+
{
|
|
1507
|
+
"@type": "Term",
|
|
1508
|
+
"@id": "nonFloodedPreSeasonLessThan180Days"
|
|
1509
|
+
},
|
|
1510
|
+
{
|
|
1511
|
+
"@type": "Term",
|
|
1512
|
+
"@id": "nonFloodedPreSeasonMoreThan180Days"
|
|
1513
|
+
},
|
|
1514
|
+
{
|
|
1515
|
+
"@type": "Term",
|
|
1516
|
+
"@id": "nonFloodedPreSeasonMoreThan365Days"
|
|
1517
|
+
}
|
|
1518
|
+
]
|
|
1519
|
+
},
|
|
1478
1520
|
{
|
|
1479
1521
|
"name": "get_generic_crop",
|
|
1480
1522
|
"query": {
|
|
@@ -1486,7 +1528,7 @@
|
|
|
1486
1528
|
"@type": "Term",
|
|
1487
1529
|
"name": "Generic crop, seed",
|
|
1488
1530
|
"@id": "genericCropSeed",
|
|
1489
|
-
"_score":
|
|
1531
|
+
"_score": 25.47927
|
|
1490
1532
|
}
|
|
1491
1533
|
]
|
|
1492
1534
|
},
|
|
@@ -1722,61 +1764,61 @@
|
|
|
1722
1764
|
"@type": "Term",
|
|
1723
1765
|
"name": "Glass or high accessible cover",
|
|
1724
1766
|
"@id": "glassOrHighAccessibleCover",
|
|
1725
|
-
"_score":
|
|
1767
|
+
"_score": 58.564175
|
|
1726
1768
|
},
|
|
1727
1769
|
{
|
|
1728
1770
|
"@type": "Term",
|
|
1729
1771
|
"name": "River or stream",
|
|
1730
1772
|
"@id": "riverOrStream",
|
|
1731
|
-
"_score":
|
|
1773
|
+
"_score": 50.11611
|
|
1732
1774
|
},
|
|
1733
1775
|
{
|
|
1734
1776
|
"@type": "Term",
|
|
1735
1777
|
"name": "Other natural vegetation",
|
|
1736
1778
|
"@id": "otherNaturalVegetation",
|
|
1737
|
-
"_score":
|
|
1779
|
+
"_score": 40.03552
|
|
1738
1780
|
},
|
|
1739
1781
|
{
|
|
1740
1782
|
"@type": "Term",
|
|
1741
1783
|
"name": "Natural forest",
|
|
1742
1784
|
"@id": "naturalForest",
|
|
1743
|
-
"_score":
|
|
1785
|
+
"_score": 30.704037
|
|
1744
1786
|
},
|
|
1745
1787
|
{
|
|
1746
1788
|
"@type": "Term",
|
|
1747
1789
|
"name": "Permanent pasture",
|
|
1748
1790
|
"@id": "permanentPasture",
|
|
1749
|
-
"_score":
|
|
1791
|
+
"_score": 27.611277
|
|
1750
1792
|
},
|
|
1751
1793
|
{
|
|
1752
1794
|
"@type": "Term",
|
|
1753
1795
|
"name": "Animal housing",
|
|
1754
1796
|
"@id": "animalHousing",
|
|
1755
|
-
"_score":
|
|
1797
|
+
"_score": 26.687897
|
|
1756
1798
|
},
|
|
1757
1799
|
{
|
|
1758
1800
|
"@type": "Term",
|
|
1759
1801
|
"name": "Root or tuber crop plant",
|
|
1760
1802
|
"@id": "rootOrTuberCropPlant",
|
|
1761
|
-
"_score":
|
|
1803
|
+
"_score": 24.424568
|
|
1762
1804
|
},
|
|
1763
1805
|
{
|
|
1764
1806
|
"@type": "Term",
|
|
1765
1807
|
"name": "High intensity grazing pasture",
|
|
1766
1808
|
"@id": "highIntensityGrazingPasture",
|
|
1767
|
-
"_score":
|
|
1809
|
+
"_score": 23.257332
|
|
1768
1810
|
},
|
|
1769
1811
|
{
|
|
1770
1812
|
"@type": "Term",
|
|
1771
1813
|
"name": "Permanent cropland",
|
|
1772
1814
|
"@id": "permanentCropland",
|
|
1773
|
-
"_score":
|
|
1815
|
+
"_score": 19.83205
|
|
1774
1816
|
},
|
|
1775
1817
|
{
|
|
1776
1818
|
"@type": "Term",
|
|
1777
1819
|
"name": "Forest",
|
|
1778
1820
|
"@id": "forest",
|
|
1779
|
-
"_score":
|
|
1821
|
+
"_score": 19.576632
|
|
1780
1822
|
}
|
|
1781
1823
|
]
|
|
1782
1824
|
},
|
|
@@ -28,6 +28,14 @@ REQUIREMENTS = {
|
|
|
28
28
|
"Cycle": {
|
|
29
29
|
"completeness.animalFeed": "",
|
|
30
30
|
"completeness.product": "",
|
|
31
|
+
"products": [{
|
|
32
|
+
"@type": "Product",
|
|
33
|
+
"value": "",
|
|
34
|
+
"term.termType": ["liveAnimal", "animalProduct", "liveAquaticSpecies"],
|
|
35
|
+
"optional": {
|
|
36
|
+
"properties": [{"@type": "Property", "value": "", "term.@id": "nitrogenContent"}]
|
|
37
|
+
}
|
|
38
|
+
}],
|
|
31
39
|
"or": [
|
|
32
40
|
{
|
|
33
41
|
"animals": [{
|
|
@@ -55,15 +63,7 @@ REQUIREMENTS = {
|
|
|
55
63
|
]
|
|
56
64
|
}]
|
|
57
65
|
}
|
|
58
|
-
]
|
|
59
|
-
"products": [{
|
|
60
|
-
"@type": "Product",
|
|
61
|
-
"value": "",
|
|
62
|
-
"term.termType": ["liveAnimal", "animalProduct", "liveAquaticSpecies"],
|
|
63
|
-
"optional": {
|
|
64
|
-
"properties": [{"@type": "Property", "value": "", "term.@id": "nitrogenContent"}]
|
|
65
|
-
}
|
|
66
|
-
}]
|
|
66
|
+
]
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
RETURNS = {
|
|
@@ -26,6 +26,12 @@ from . import MODEL
|
|
|
26
26
|
|
|
27
27
|
REQUIREMENTS = {
|
|
28
28
|
"Cycle": {
|
|
29
|
+
"products": [{
|
|
30
|
+
"@type": "Product",
|
|
31
|
+
"primary": "True",
|
|
32
|
+
"value": "",
|
|
33
|
+
"term.termType": ["animalProduct", "liveAnimal", "liveAquaticSpecies"]
|
|
34
|
+
}],
|
|
29
35
|
"or": [
|
|
30
36
|
{
|
|
31
37
|
"completeness.animalFeed": "",
|
|
@@ -72,14 +78,6 @@ REQUIREMENTS = {
|
|
|
72
78
|
"@type": "Site",
|
|
73
79
|
"measurements": [{"@type": "Measurement", "value": "", "term.@id": "netPrimaryProduction"}]
|
|
74
80
|
}
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"products": [{
|
|
78
|
-
"@type": "Product",
|
|
79
|
-
"primary": "True",
|
|
80
|
-
"value": "",
|
|
81
|
-
"term.termType": ["animalProduct", "liveAnimal", "liveAquaticSpecies"]
|
|
82
|
-
}]
|
|
83
81
|
}
|
|
84
82
|
]
|
|
85
83
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from os.path import dirname, abspath
|
|
2
|
+
import sys
|
|
3
|
+
from importlib import import_module
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.utils.blank_node import run_if_required
|
|
6
|
+
|
|
7
|
+
CURRENT_DIR = dirname(abspath(__file__)) + '/'
|
|
8
|
+
sys.path.append(CURRENT_DIR)
|
|
9
|
+
MODEL = 'poschEtAl2008'
|
|
10
|
+
PKG = '.'.join(['hestia_earth', 'models', MODEL])
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def run(model: str, data): return run_if_required(MODEL, model, data, import_module(f".{model}", package=PKG))
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
2
|
+
from hestia_earth.models.utils.impact_assessment import impact_country_value
|
|
3
|
+
from hestia_earth.models.utils.indicator import _new_indicator
|
|
4
|
+
from . import MODEL
|
|
5
|
+
|
|
6
|
+
REQUIREMENTS = {
|
|
7
|
+
"ImpactAssessment": {
|
|
8
|
+
"or": {
|
|
9
|
+
"country": {"@type": "Term", "termType": "region"},
|
|
10
|
+
"site": {
|
|
11
|
+
"@type": "Site",
|
|
12
|
+
"region": {"@type": "Term", "termType": "region"}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"emissionsResourceUse": [{"@type": "Indicator", "value": "", "term.termType": "emission"}]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
RETURNS = {
|
|
19
|
+
"Indicator": {
|
|
20
|
+
"value": ""
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
LOOKUPS = {
|
|
24
|
+
"region-emission-terrestrialAcidificationPotentialAccumulatedExceedance": ""
|
|
25
|
+
}
|
|
26
|
+
TERM_ID = 'terrestrialAcidificationPotentialAccumulatedExceedance'
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _indicator(value: float):
|
|
30
|
+
indicator = _new_indicator(TERM_ID, MODEL)
|
|
31
|
+
indicator['value'] = value
|
|
32
|
+
return indicator
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def run(impact_assessment: dict):
|
|
36
|
+
value = impact_country_value(MODEL, TERM_ID, impact_assessment, f"{list(LOOKUPS.keys())[0]}.csv")
|
|
37
|
+
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
38
|
+
value=value)
|
|
39
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, True)
|
|
40
|
+
return _indicator(value)
|
|
@@ -85,7 +85,8 @@ LOOKUPS = {
|
|
|
85
85
|
"forage": ["landCoverTermId"],
|
|
86
86
|
"inorganicFertiliser": "nitrogenContent",
|
|
87
87
|
"organicFertiliser": "ANIMAL_MANURE",
|
|
88
|
-
"soilAmendment": "PRACTICE_INCREASING_C_INPUT"
|
|
88
|
+
"soilAmendment": "PRACTICE_INCREASING_C_INPUT",
|
|
89
|
+
"landUseManagement": "GAP_FILL_TO_MANAGEMENT"
|
|
89
90
|
}
|
|
90
91
|
MODEL_KEY = 'management'
|
|
91
92
|
LAND_COVER_KEY = LOOKUPS['crop'][0]
|
|
@@ -216,6 +217,18 @@ def _get_relevant_inputs(cycles: list[dict]) -> list:
|
|
|
216
217
|
return relevant_inputs
|
|
217
218
|
|
|
218
219
|
|
|
220
|
+
def _has_gap_fill_to_management_set(practices: list) -> list:
|
|
221
|
+
"""
|
|
222
|
+
Include only landUseManagement practices where GAP_FILL_TO_MANAGEMENT = True
|
|
223
|
+
"""
|
|
224
|
+
result = [
|
|
225
|
+
p for p in practices
|
|
226
|
+
if p.get("term", {}).get("termType", {}) != TermTermType.LANDUSEMANAGEMENT.value
|
|
227
|
+
or get_lookup_value(lookup_term=p.get("term", {}), column=LOOKUPS["landUseManagement"])
|
|
228
|
+
]
|
|
229
|
+
return result
|
|
230
|
+
|
|
231
|
+
|
|
219
232
|
def _should_run_all_products(cycles: list, site_type: str):
|
|
220
233
|
products_land_cover = [
|
|
221
234
|
_extract_node_value(
|
|
@@ -292,6 +305,7 @@ def _should_run(site: dict):
|
|
|
292
305
|
]
|
|
293
306
|
)
|
|
294
307
|
]
|
|
308
|
+
practices = _has_gap_fill_to_management_set(practices)
|
|
295
309
|
practices = condense_nodes(practices)
|
|
296
310
|
|
|
297
311
|
relevant_inputs = _get_relevant_inputs(cycles)
|
|
@@ -3,15 +3,16 @@ Pre Checks Cache Geospatial Database
|
|
|
3
3
|
|
|
4
4
|
This model caches results from Geospatial Database.
|
|
5
5
|
"""
|
|
6
|
+
from typing import Union, List
|
|
6
7
|
from functools import reduce
|
|
7
|
-
from hestia_earth.utils.tools import flatten
|
|
8
|
+
from hestia_earth.utils.tools import flatten
|
|
8
9
|
|
|
9
10
|
from hestia_earth.models.log import debugValues
|
|
10
11
|
from hestia_earth.models.utils import CACHE_KEY, cached_value, first_day_of_month, last_day_of_month
|
|
11
12
|
from hestia_earth.models.utils.site import CACHE_YEARS_KEY
|
|
12
13
|
from hestia_earth.models.geospatialDatabase.utils import (
|
|
13
14
|
MAX_AREA_SIZE, CACHE_VALUE, CACHE_AREA_SIZE,
|
|
14
|
-
has_geospatial_data, has_coordinates, get_area_size, geospatial_data, _run_query, _collection_name
|
|
15
|
+
has_geospatial_data, has_coordinates, get_area_size, geospatial_data, _run_query, _collection_name, _cache_sub_key
|
|
15
16
|
)
|
|
16
17
|
from hestia_earth.models.geospatialDatabase import list_ee_params
|
|
17
18
|
|
|
@@ -34,11 +35,7 @@ def cache_site_results(results: list, collections: list, area_size: int = None):
|
|
|
34
35
|
collection = collections[index]
|
|
35
36
|
name = collection.get('name')
|
|
36
37
|
value = results[index]
|
|
37
|
-
cache_sub_key =
|
|
38
|
-
collection.get('year'),
|
|
39
|
-
collection.get('start_date'),
|
|
40
|
-
collection.get('end_date')
|
|
41
|
-
]))
|
|
38
|
+
cache_sub_key = _cache_sub_key(collection)
|
|
42
39
|
data = (group.get(name, {}) | {cache_sub_key: value} if cache_sub_key else value)
|
|
43
40
|
return group | {name: data}
|
|
44
41
|
|
|
@@ -62,20 +59,24 @@ def _extend_collection_by_month(year: int):
|
|
|
62
59
|
} for month in range(1, 13)]
|
|
63
60
|
|
|
64
61
|
|
|
65
|
-
def
|
|
66
|
-
|
|
62
|
+
def _extend_collection_data(name: str, collection: dict):
|
|
63
|
+
return collection | {'name': name, 'collection': _collection_name(collection.get('collection'))}
|
|
67
64
|
|
|
65
|
+
|
|
66
|
+
def _extend_collection(name: str, collection: Union[List[dict], dict], years: list = []):
|
|
68
67
|
year_params = [{'year': str(year)} for year in years]
|
|
69
68
|
# fetch from first year to last
|
|
70
69
|
month_years = range(years[0], years[-1] + 1) if len(years) > 1 else years
|
|
71
70
|
month_params = flatten(map(_extend_collection_by_month, month_years))
|
|
72
71
|
|
|
73
72
|
return [
|
|
74
|
-
(
|
|
73
|
+
(_extend_collection_data(name, collection) | params) for params in year_params
|
|
75
74
|
] if name.endswith('Annual') else [
|
|
76
|
-
(
|
|
75
|
+
(_extend_collection_data(name, collection) | params) for params in month_params
|
|
77
76
|
] if name.endswith('Monthly') else [
|
|
78
|
-
|
|
77
|
+
_extend_collection_data(name, col) for col in collection
|
|
78
|
+
] if isinstance(collection, list) else [
|
|
79
|
+
_extend_collection_data(name, collection)
|
|
79
80
|
]
|
|
80
81
|
|
|
81
82
|
|
|
@@ -85,18 +86,24 @@ def _extend_collections(values: list, years: list = []):
|
|
|
85
86
|
])
|
|
86
87
|
|
|
87
88
|
|
|
89
|
+
def _is_type(value: dict, ee_type: str):
|
|
90
|
+
params = value.get('params')
|
|
91
|
+
return any([
|
|
92
|
+
p.get('ee_type') == ee_type for p in params
|
|
93
|
+
]) if isinstance(params, list) else params.get('ee_type') == ee_type
|
|
94
|
+
|
|
95
|
+
|
|
88
96
|
def list_collections(years: list = [], include_region: bool = False, years_only: bool = False):
|
|
89
97
|
ee_params = list_ee_params()
|
|
90
98
|
# only cache `raster` results as can be combined in a single query
|
|
91
|
-
rasters = [value for value in ee_params if value
|
|
99
|
+
rasters = [value for value in ee_params if _is_type(value, 'raster')]
|
|
92
100
|
rasters = _extend_collections(rasters, years or [])
|
|
93
101
|
rasters = [raster for raster in rasters if not years_only or _is_collection_by_year(raster)]
|
|
94
102
|
|
|
95
103
|
vectors = [
|
|
96
|
-
value for value in ee_params if
|
|
97
|
-
value.get('params').get('ee_type') == 'vector',
|
|
104
|
+
value for value in ee_params if _is_type(value, 'vector') and (
|
|
98
105
|
include_region or not value.get('params').get('collection', '').startswith('gadm36')
|
|
99
|
-
|
|
106
|
+
)
|
|
100
107
|
]
|
|
101
108
|
# no vectors are running with specific years
|
|
102
109
|
vectors = [] if years_only else _extend_collections(vectors)
|
|
@@ -14,9 +14,6 @@ RETURNS = {
|
|
|
14
14
|
"methodClassification": "modelled using other measurements"
|
|
15
15
|
}]
|
|
16
16
|
}
|
|
17
|
-
LOOKUPS = {
|
|
18
|
-
"crop": "Non_bearing_duration"
|
|
19
|
-
}
|
|
20
17
|
TERM_ID = 'waterDepth'
|
|
21
18
|
BIBLIO_TITLE = 'Reducing food’s environmental impacts through producers and consumers'
|
|
22
19
|
SITE_TYPE_TO_DEPTH = {
|
|
@@ -5,7 +5,9 @@ from hestia_earth.utils.model import linked_node
|
|
|
5
5
|
from . import _term_id, _include_methodModel
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
def _new_indicator(term, model=None):
|
|
8
|
+
def _new_indicator(term, model=None, land_cover_id=None):
|
|
9
9
|
node = {'@type': SchemaType.INDICATOR.value}
|
|
10
10
|
node['term'] = linked_node(term if isinstance(term, dict) else download_hestia(_term_id(term)))
|
|
11
|
+
if land_cover_id:
|
|
12
|
+
node['landCover'] = linked_node(download_hestia(land_cover_id))
|
|
11
13
|
return _include_methodModel(node, model)
|
|
@@ -252,6 +252,40 @@ def get_rice_paddy_terms():
|
|
|
252
252
|
return [n['@id'] for n in terms if 'depth' not in n['@id'].lower()]
|
|
253
253
|
|
|
254
254
|
|
|
255
|
+
def get_flooded_pre_season_terms():
|
|
256
|
+
"""
|
|
257
|
+
Find all `landUseManagement` terms of "flooded pre season" from the Glossary:
|
|
258
|
+
https://hestia.earth/glossary?termType=landUseManagement&query=flooded%20pre-season
|
|
259
|
+
|
|
260
|
+
Returns
|
|
261
|
+
-------
|
|
262
|
+
list
|
|
263
|
+
List of matching term `@id` as `str`.
|
|
264
|
+
"""
|
|
265
|
+
terms = search({
|
|
266
|
+
"bool": {
|
|
267
|
+
"must": [
|
|
268
|
+
{
|
|
269
|
+
"match": {
|
|
270
|
+
"@type": SchemaType.TERM.value
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"match": {
|
|
275
|
+
"termType": TermTermType.LANDUSEMANAGEMENT.value
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"match_phrase": {
|
|
280
|
+
"name": "flooded pre-season"
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
}, limit=LIMIT)
|
|
286
|
+
return list(map(lambda n: n['@id'], terms))
|
|
287
|
+
|
|
288
|
+
|
|
255
289
|
def get_crop_residue_terms():
|
|
256
290
|
"""
|
|
257
291
|
Find all `cropResidue` terms from the Glossary:
|
hestia_earth/models/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = '0.
|
|
1
|
+
VERSION = '0.64.1'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hestia-earth-models
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.64.1
|
|
4
4
|
Summary: HESTIA's set of modules for filling gaps in the activity data using external datasets (e.g. populating soil properties with a geospatial dataset using provided coordinates) and internal lookups (e.g. populating machinery use from fuel use). Includes rules for when gaps should be filled versus not (e.g. never gap fill yield, gap fill crop residue if yield provided etc.).
|
|
5
5
|
Home-page: https://gitlab.com/hestia-earth/hestia-engine-models
|
|
6
6
|
Author: HESTIA Team
|
|
@@ -11,8 +11,8 @@ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.6
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: hestia-earth.schema==
|
|
15
|
-
Requires-Dist: hestia-earth.utils>=0.13.
|
|
14
|
+
Requires-Dist: hestia-earth.schema==30.*
|
|
15
|
+
Requires-Dist: hestia-earth.utils>=0.13.4
|
|
16
16
|
Requires-Dist: python-dateutil>=2.8.1
|
|
17
17
|
Requires-Dist: CurrencyConverter==0.16.8
|
|
18
18
|
Requires-Dist: haversine>=2.7.0
|