hestia-earth-models 0.70.2__py3-none-any.whl → 0.70.4__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.
- hestia_earth/models/config/Cycle.json +8 -0
- hestia_earth/models/cycle/practice/landCover.py +181 -0
- hestia_earth/models/emepEea2019/nh3ToAirExcreta.py +1 -1
- hestia_earth/models/geospatialDatabase/altitude.py +1 -0
- hestia_earth/models/geospatialDatabase/clayContent.py +3 -3
- hestia_earth/models/geospatialDatabase/sandContent.py +3 -3
- hestia_earth/models/geospatialDatabase/utils.py +1 -2
- hestia_earth/models/hestia/landCover.py +25 -12
- hestia_earth/models/hestia/management.py +11 -107
- hestia_earth/models/ipcc2019/ch4ToAirOrganicSoilCultivation.py +7 -7
- hestia_earth/models/ipcc2019/co2ToAirOrganicSoilCultivation.py +5 -4
- hestia_earth/models/ipcc2019/n2OToAirOrganicSoilCultivationDirect.py +7 -7
- hestia_earth/models/ipcc2019/no3ToGroundwaterExcreta.py +1 -1
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1.py +2 -2
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2.py +15 -4
- hestia_earth/models/ipcc2019/organicSoilCultivation_utils.py +11 -3
- hestia_earth/models/mocking/search-results.json +1295 -1309
- hestia_earth/models/pooreNemecek2018/excretaKgN.py +3 -1
- hestia_earth/models/utils/blank_node.py +2 -2
- hestia_earth/models/utils/excretaManagement.py +2 -2
- hestia_earth/models/utils/property.py +14 -9
- hestia_earth/models/utils/site.py +2 -1
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.70.2.dist-info → hestia_earth_models-0.70.4.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.70.2.dist-info → hestia_earth_models-0.70.4.dist-info}/RECORD +35 -33
- tests/models/cycle/practice/test_landCover.py +27 -0
- tests/models/hestia/test_landCover.py +24 -1
- tests/models/ipcc2019/test_ch4ToAirEntericFermentation.py +2 -2
- tests/models/ipcc2019/test_ch4ToAirOrganicSoilCultivation.py +2 -1
- tests/models/ipcc2019/test_co2ToAirOrganicSoilCultivation.py +2 -1
- tests/models/ipcc2019/test_n2OToAirOrganicSoilCultivationDirect.py +2 -1
- tests/models/ipcc2019/test_organicCarbonPerHa_tier_1.py +8 -3
- {hestia_earth_models-0.70.2.dist-info → hestia_earth_models-0.70.4.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.70.2.dist-info → hestia_earth_models-0.70.4.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.70.2.dist-info → hestia_earth_models-0.70.4.dist-info}/top_level.txt +0 -0
@@ -1346,7 +1346,7 @@ def _assign_ipcc_management_category(
|
|
1346
1346
|
ipcc_land_use_category, IpccManagementCategory.NOT_RELEVANT
|
1347
1347
|
)
|
1348
1348
|
|
1349
|
-
land_cover_nodes = filter_list_term_type(management_nodes, [TermTermType.
|
1349
|
+
land_cover_nodes = filter_list_term_type(management_nodes, [TermTermType.PASTUREMANAGEMENT])
|
1350
1350
|
tillage_nodes = filter_list_term_type(management_nodes, [TermTermType.TILLAGE])
|
1351
1351
|
|
1352
1352
|
should_run_ = any([
|
@@ -1461,7 +1461,7 @@ Value: Corresponding decision tree for IPCC management categories based on land
|
|
1461
1461
|
"""
|
1462
1462
|
|
1463
1463
|
_IPCC_LAND_USE_CATEGORY_TO_DEFAULT_IPCC_MANAGEMENT_CATEGORY = {
|
1464
|
-
IpccLandUseCategory.GRASSLAND: IpccManagementCategory.
|
1464
|
+
IpccLandUseCategory.GRASSLAND: IpccManagementCategory.NOMINALLY_MANAGED,
|
1465
1465
|
IpccLandUseCategory.ANNUAL_CROPS_WET: IpccManagementCategory.UNKNOWN,
|
1466
1466
|
IpccLandUseCategory.ANNUAL_CROPS: IpccManagementCategory.UNKNOWN
|
1467
1467
|
}
|
@@ -204,11 +204,19 @@ _CARBON_INPUT_PROPERTY_TERM_IDS = [
|
|
204
204
|
_DRY_MATTER_TERM_ID
|
205
205
|
]
|
206
206
|
|
207
|
-
|
207
|
+
_INPUT_CARBON_SOURCE_TERM_TYPES = [
|
208
208
|
TermTermType.ORGANICFERTILISER.value,
|
209
209
|
TermTermType.SOILAMENDMENT.value
|
210
210
|
]
|
211
211
|
|
212
|
+
_PRACTICE_CARBON_SOURCE_TERM_TYPES = [
|
213
|
+
TermTermType.LANDCOVER
|
214
|
+
]
|
215
|
+
|
216
|
+
_PRODUCT_CARBON_SOURCE_TERM_TYPES = [
|
217
|
+
TermTermType.CROPRESIDUE
|
218
|
+
]
|
219
|
+
|
212
220
|
_VALID_SITE_TYPES = [
|
213
221
|
SiteSiteType.CROPLAND.value
|
214
222
|
]
|
@@ -1447,7 +1455,10 @@ def _get_carbon_sources(cycle: dict) -> list[CarbonSource]:
|
|
1447
1455
|
list[CarbonSource]
|
1448
1456
|
A formatted list of `CarbonSource`s.
|
1449
1457
|
"""
|
1450
|
-
|
1458
|
+
carbon_source_nodes = filter_list_term_type(
|
1459
|
+
cycle.get("inputs", []) + cycle.get("practices", []) + cycle.get("products", []),
|
1460
|
+
_INPUT_CARBON_SOURCE_TERM_TYPES + _PRACTICE_CARBON_SOURCE_TERM_TYPES + _PRODUCT_CARBON_SOURCE_TERM_TYPES
|
1461
|
+
)
|
1451
1462
|
|
1452
1463
|
group_fac = cycle.get('fraction_of_group_duration')
|
1453
1464
|
node_fac = cycle.get('fraction_of_node_duration')
|
@@ -1466,7 +1477,7 @@ def _get_carbon_sources(cycle: dict) -> list[CarbonSource]:
|
|
1466
1477
|
if validator(node)
|
1467
1478
|
),
|
1468
1479
|
None
|
1469
|
-
) for node in
|
1480
|
+
) for node in carbon_source_nodes
|
1470
1481
|
])
|
1471
1482
|
|
1472
1483
|
|
@@ -1603,7 +1614,7 @@ def _should_run_carbon_source(node: dict) -> bool:
|
|
1603
1614
|
"""
|
1604
1615
|
return any([
|
1605
1616
|
node.get("term", {}).get("@id") in _CARBON_SOURCE_TERM_IDS,
|
1606
|
-
node.get("term", {}).get("termType") in
|
1617
|
+
node.get("term", {}).get("termType") in _INPUT_CARBON_SOURCE_TERM_TYPES
|
1607
1618
|
])
|
1608
1619
|
|
1609
1620
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from enum import Enum
|
2
2
|
from typing import Literal
|
3
|
+
import numpy as np
|
3
4
|
|
4
5
|
from hestia_earth.schema import SiteSiteType
|
5
6
|
from hestia_earth.utils.model import find_primary_product
|
@@ -22,8 +23,7 @@ _NETHERLANDS_TERM_ID = "GADM-NLD"
|
|
22
23
|
|
23
24
|
_CONVERSION_FACTORS = {
|
24
25
|
"co2ToAirOrganicSoilCultivation": 1000 * get_atomic_conversion(Units.KG_CO2, Units.TO_C),
|
25
|
-
"
|
26
|
-
"n2OToAirOrganicSoilCultivationDirect": 1000 * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
26
|
+
"n2OToAirOrganicSoilCultivationDirect": get_atomic_conversion(Units.KG_N2O, Units.TO_N)
|
27
27
|
}
|
28
28
|
_DEFAULT_FACTOR = {"value": 0}
|
29
29
|
_EXCLUDED_ECO_CLIMATE_ZONES = [EcoClimateZone.POLAR_MOIST, EcoClimateZone.POLAR_DRY]
|
@@ -136,7 +136,7 @@ def calc_emission(
|
|
136
136
|
"""
|
137
137
|
Calculate the emission and convert it to kg/ha-1.
|
138
138
|
"""
|
139
|
-
return emission_factor * land_occupation * histosol * _CONVERSION_FACTORS
|
139
|
+
return emission_factor * land_occupation * histosol * _CONVERSION_FACTORS.get(emission_id, 1) / 100
|
140
140
|
|
141
141
|
|
142
142
|
def remap_categories(
|
@@ -157,3 +157,11 @@ def valid_eco_climate_zone(
|
|
157
157
|
Validate that the model should run for a specific eco-climate zone.
|
158
158
|
"""
|
159
159
|
return isinstance(eco_climate_zone, EcoClimateZone) and eco_climate_zone not in _EXCLUDED_ECO_CLIMATE_ZONES
|
160
|
+
|
161
|
+
|
162
|
+
def format_number(value) -> str:
|
163
|
+
return f"{value:.3g}" if isinstance(value, (float, int)) else "None"
|
164
|
+
|
165
|
+
|
166
|
+
def format_nd_array(value) -> str:
|
167
|
+
return f"{np.mean(value):.3g} ± {np.std(value):.3g}" if isinstance(value, np.ndarray) else "None"
|