hestia-earth-models 0.70.0__py3-none-any.whl → 0.70.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.
- hestia_earth/models/aware/scarcityWeightedWaterUse.py +8 -16
- hestia_earth/models/config/Cycle.json +52 -64
- hestia_earth/models/config/ImpactAssessment.json +12 -4
- hestia_earth/models/config/Site.json +33 -22
- hestia_earth/models/cycle/transformation.py +1 -1
- hestia_earth/models/cycle/utils.py +0 -6
- hestia_earth/models/data/ecoinventV3/__init__.py +15 -13
- hestia_earth/models/ecoalimV9/__init__.py +13 -0
- hestia_earth/models/ecoalimV9/cycle.py +128 -0
- hestia_earth/models/ecoalimV9/impact_assessment.py +125 -0
- hestia_earth/models/ecoalimV9/utils.py +31 -0
- hestia_earth/models/ecoinventV3/__init__.py +6 -14
- hestia_earth/models/ecoinventV3/utils.py +1 -29
- hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py +8 -2
- hestia_earth/models/emissionNotRelevant/__init__.py +33 -8
- hestia_earth/models/{cycle → hestia}/aboveGroundCropResidue.py +4 -3
- hestia_earth/models/{cycle → hestia}/aboveGroundCropResidueTotal.py +1 -1
- hestia_earth/models/{site → hestia}/brackishWater.py +1 -1
- hestia_earth/models/{site → hestia}/cationExchangeCapacityPerKgSoil.py +1 -1
- hestia_earth/models/{cycle → hestia}/coldCarcassWeightPerHead.py +1 -1
- hestia_earth/models/{cycle → hestia}/coldDressedCarcassWeightPerHead.py +1 -1
- hestia_earth/models/{cycle → hestia}/concentrateFeed.py +1 -1
- hestia_earth/models/{cycle → hestia}/cropResidueManagement.py +1 -1
- hestia_earth/models/{cycle → hestia}/croppingIntensity.py +1 -1
- hestia_earth/models/{cycle → hestia}/energyContentLowerHeatingValue.py +1 -1
- hestia_earth/models/{cycle → hestia}/excretaKgMass.py +7 -2
- hestia_earth/models/{cycle → hestia}/excretaKgN.py +1 -1
- hestia_earth/models/{cycle → hestia}/excretaKgVs.py +1 -1
- hestia_earth/models/{cycle → hestia}/feedConversionRatio/__init__.py +1 -1
- hestia_earth/models/{site → hestia}/flowingWater.py +1 -1
- hestia_earth/models/{site → hestia}/freshWater.py +1 -1
- hestia_earth/models/{cycle → hestia}/inorganicFertiliser.py +1 -1
- hestia_earth/models/{cycle → hestia}/irrigatedTypeUnspecified.py +14 -19
- hestia_earth/models/hestia/landCover.py +30 -22
- hestia_earth/models/{cycle → hestia}/liveAnimal.py +1 -1
- hestia_earth/models/{cycle → hestia}/longFallowRatio.py +1 -1
- hestia_earth/models/{cycle → hestia}/materialAndSubstrate.py +1 -1
- hestia_earth/models/{cycle → hestia}/milkYield.py +1 -1
- hestia_earth/models/{site → hestia}/netPrimaryProduction.py +1 -1
- hestia_earth/models/{site → hestia}/organicCarbonPerHa.py +1 -1
- hestia_earth/models/{cycle → hestia}/pastureGrass.py +1 -1
- hestia_earth/models/{cycle → hestia}/pastureSystem.py +1 -1
- hestia_earth/models/{site → hestia}/potentialEvapotranspirationAnnual.py +3 -3
- hestia_earth/models/{site → hestia}/potentialEvapotranspirationMonthly.py +3 -3
- hestia_earth/models/{site → hestia}/precipitationAnnual.py +3 -3
- hestia_earth/models/{site → hestia}/precipitationMonthly.py +3 -3
- hestia_earth/models/{site → hestia}/rainfallAnnual.py +3 -3
- hestia_earth/models/{site → hestia}/rainfallMonthly.py +3 -3
- hestia_earth/models/{cycle → hestia}/readyToCookWeightPerHead.py +1 -1
- hestia_earth/models/{cycle → hestia}/residueBurnt.py +1 -1
- hestia_earth/models/{cycle → hestia}/residueIncorporated.py +1 -1
- hestia_earth/models/{cycle → hestia}/residueLeftOnField.py +1 -1
- hestia_earth/models/hestia/residueRemoved.py +65 -13
- hestia_earth/models/{site → hestia}/salineWater.py +1 -1
- hestia_earth/models/{site → hestia}/soilMeasurement.py +1 -1
- hestia_earth/models/{cycle → hestia}/stockingDensityAnimalHousingAverage.py +1 -1
- hestia_earth/models/{site → hestia}/temperatureAnnual.py +3 -3
- hestia_earth/models/{site → hestia}/temperatureMonthly.py +3 -3
- hestia_earth/models/{site → hestia}/totalNitrogenPerKgSoil.py +1 -1
- hestia_earth/models/{cycle → hestia}/unknownPreSeasonWaterRegime.py +1 -1
- hestia_earth/models/hestia/utils.py +93 -0
- hestia_earth/models/{site → hestia}/waterDepth.py +1 -1
- hestia_earth/models/hestia/waterSalinity.py +78 -0
- hestia_earth/models/ipcc2019/aboveGroundBiomass.py +1 -1
- hestia_earth/models/ipcc2019/belowGroundBiomass.py +1 -1
- hestia_earth/models/ipcc2019/biomass_utils.py +2 -4
- hestia_earth/models/ipcc2019/ch4ToAirFloodedRice.py +163 -78
- hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +31 -20
- hestia_earth/models/ipcc2019/co2ToAirUreaHydrolysis.py +16 -9
- hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +35 -47
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1.py +86 -1
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2.py +127 -1
- hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py +7 -5
- hestia_earth/models/mocking/search-results.json +764 -772
- hestia_earth/models/pooreNemecek2018/utils.py +8 -2
- hestia_earth/models/schmidt2007/ch4ToAirWasteTreatment.py +1 -4
- hestia_earth/models/schmidt2007/h2SToAirWasteTreatment.py +1 -4
- hestia_earth/models/schmidt2007/n2OToAirWasteTreatmentDirect.py +1 -4
- hestia_earth/models/schmidt2007/nh3ToAirWasteTreatment.py +1 -4
- hestia_earth/models/utils/background_emissions.py +52 -0
- hestia_earth/models/utils/blank_node.py +9 -5
- hestia_earth/models/utils/impact_assessment.py +26 -17
- hestia_earth/models/utils/lookup.py +48 -39
- hestia_earth/models/utils/measurement.py +3 -3
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.70.0.dist-info → hestia_earth_models-0.70.1.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.70.0.dist-info → hestia_earth_models-0.70.1.dist-info}/RECORD +163 -158
- tests/models/aware/test_scarcityWeightedWaterUse.py +1 -12
- tests/models/ecoalimV9/__init__.py +0 -0
- tests/models/ecoalimV9/test_cycle.py +21 -0
- tests/models/ecoalimV9/test_impact_assessment.py +24 -0
- tests/models/environmentalFootprintV3_1/test_scarcityWeightedWaterUse.py +4 -2
- tests/models/{cycle → hestia}/test_aboveGroundCropResidue.py +1 -1
- tests/models/{cycle → hestia}/test_aboveGroundCropResidueTotal.py +1 -1
- tests/models/{site → hestia}/test_brackishWater.py +1 -1
- tests/models/{site → hestia}/test_cationExchangeCapacityPerKgSoil.py +1 -1
- tests/models/{cycle → hestia}/test_coldCarcassWeightPerHead.py +1 -1
- tests/models/{cycle → hestia}/test_coldDressedCarcassWeightPerHead.py +1 -1
- tests/models/{cycle → hestia}/test_concentrateFeed.py +1 -1
- tests/models/{cycle → hestia}/test_cropResidueManagement.py +1 -1
- tests/models/{cycle → hestia}/test_croppingIntensity.py +1 -1
- tests/models/{cycle → hestia}/test_energyContentLowerHeatingValue.py +5 -3
- tests/models/{cycle → hestia}/test_excretaKgMass.py +1 -1
- tests/models/{cycle → hestia}/test_excretaKgN.py +1 -1
- tests/models/{cycle → hestia}/test_excretaKgVs.py +1 -1
- tests/models/{cycle → hestia}/test_feedConversionRatio.py +1 -1
- tests/models/{site → hestia}/test_flowingWater.py +1 -1
- tests/models/{site → hestia}/test_freshWater.py +1 -1
- tests/models/{cycle → hestia}/test_inorganicFertiliser.py +1 -1
- tests/models/{cycle → hestia}/test_irrigatedTypeUnspecified.py +2 -5
- tests/models/hestia/test_landCover.py +4 -34
- tests/models/{cycle → hestia}/test_liveAnimal.py +1 -1
- tests/models/{cycle → hestia}/test_longFallowRatio.py +1 -1
- tests/models/{site → hestia}/test_management.py +1 -1
- tests/models/{cycle → hestia}/test_materialsAndSubstrate.py +1 -1
- tests/models/{cycle → hestia}/test_milkYield.py +1 -1
- tests/models/{site → hestia}/test_netPrimaryProduction.py +1 -1
- tests/models/{site → hestia}/test_organicCarbonPerHa.py +1 -1
- tests/models/{site → hestia}/test_organicCarbonPerKgSoil.py +1 -1
- tests/models/{site → hestia}/test_organicCarbonPerM3Soil.py +1 -1
- tests/models/{site → hestia}/test_organicMatterPerKgSoil.py +1 -1
- tests/models/{site → hestia}/test_organicMatterPerM3Soil.py +1 -1
- tests/models/{cycle → hestia}/test_pastureGrass.py +1 -1
- tests/models/{cycle → hestia}/test_pastureSystem.py +1 -1
- tests/models/{site → hestia}/test_potentialEvapotranspirationAnnual.py +1 -1
- tests/models/{site → hestia}/test_potentialEvapotranspirationMonthly.py +1 -1
- tests/models/{site → hestia}/test_precipitationAnnual.py +1 -1
- tests/models/{site → hestia}/test_precipitationMonthly.py +1 -1
- tests/models/{site → hestia}/test_rainfallAnnual.py +1 -1
- tests/models/{site → hestia}/test_rainfallMonthly.py +1 -1
- tests/models/{cycle → hestia}/test_readyToCookWeightPerHead.py +1 -1
- tests/models/{cycle → hestia}/test_residueBurnt.py +1 -1
- tests/models/{cycle → hestia}/test_residueIncorporated.py +1 -1
- tests/models/{cycle → hestia}/test_residueLeftOnField.py +1 -1
- tests/models/hestia/test_residueRemoved.py +15 -3
- tests/models/{site → hestia}/test_salineWater.py +1 -1
- tests/models/{site → hestia}/test_soilMeasurement.py +2 -2
- tests/models/{cycle → hestia}/test_stockingDensityAnimalHousingAverage.py +1 -1
- tests/models/{site → hestia}/test_temperatureAnnual.py +1 -1
- tests/models/{site → hestia}/test_temperatureMonthly.py +1 -1
- tests/models/{site → hestia}/test_totalNitrogenPerKgSoil.py +1 -1
- tests/models/{cycle → hestia}/test_unknownPreSeasonWaterRegime.py +1 -1
- tests/models/{site → hestia}/test_waterDepth.py +1 -1
- tests/models/hestia/test_waterSalinity.py +26 -0
- tests/models/ipcc2019/test_ch4ToAirFloodedRice.py +10 -42
- tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py +2 -1
- tests/models/ipcc2019/test_nonCo2EmissionsToAirNaturalVegetationBurning.py +3 -2
- tests/models/test_ecoinventV3AndEmberClimate.py +2 -2
- tests/models/test_emissionNotRelevant.py +0 -8
- tests/models/utils/test_measurement.py +1 -1
- hestia_earth/models/cycle/residueRemoved.py +0 -54
- hestia_earth/models/hestia/nh3ToSurfaceWaterAquacultureSystems.py +0 -64
- hestia_earth/models/site/utils.py +0 -93
- tests/models/cycle/test_residueRemoved.py +0 -37
- tests/models/hestia/test_nh3ToSurfaceWaterAquacultureSystems.py +0 -51
- /hestia_earth/models/{cycle → hestia}/feedConversionRatio/feedConversionRatioCarbon.py +0 -0
- /hestia_earth/models/{cycle → hestia}/feedConversionRatio/feedConversionRatioDryMatter.py +0 -0
- /hestia_earth/models/{cycle → hestia}/feedConversionRatio/feedConversionRatioEnergy.py +0 -0
- /hestia_earth/models/{cycle → hestia}/feedConversionRatio/feedConversionRatioFedWeight.py +0 -0
- /hestia_earth/models/{cycle → hestia}/feedConversionRatio/feedConversionRatioNitrogen.py +0 -0
- /hestia_earth/models/{site → hestia}/management.py +0 -0
- /hestia_earth/models/{site → hestia}/organicCarbonPerKgSoil.py +0 -0
- /hestia_earth/models/{site → hestia}/organicCarbonPerM3Soil.py +0 -0
- /hestia_earth/models/{site → hestia}/organicMatterPerKgSoil.py +0 -0
- /hestia_earth/models/{site → hestia}/organicMatterPerM3Soil.py +0 -0
- {hestia_earth_models-0.70.0.dist-info → hestia_earth_models-0.70.1.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.70.0.dist-info → hestia_earth_models-0.70.1.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.70.0.dist-info → hestia_earth_models-0.70.1.dist-info}/top_level.txt +0 -0
@@ -14,6 +14,7 @@ REQUIREMENTS = {
|
|
14
14
|
"products": [
|
15
15
|
{
|
16
16
|
"@type": "Product",
|
17
|
+
"value": "",
|
17
18
|
"term.termType": "excreta",
|
18
19
|
"term.units": ["kg N", "kg VS"]
|
19
20
|
}
|
@@ -36,16 +37,20 @@ UNITS = [
|
|
36
37
|
|
37
38
|
|
38
39
|
def _product(value: float, term_id: str):
|
39
|
-
product = _new_product(term_id, value)
|
40
|
+
product = _new_product(term_id, value, MODEL)
|
40
41
|
return product
|
41
42
|
|
42
43
|
|
43
44
|
def _convert_by_product(cycle: dict, product: dict, term_id: str):
|
44
45
|
existing_product = find_term_match(cycle.get('products', []), term_id)
|
46
|
+
existing_product_value = list_sum(existing_product.get('value', []), default=None)
|
45
47
|
|
46
48
|
conversion_to_kg_ratio = convert_product_to_unit(product, existing_product.get('term', {}).get('units')) \
|
47
49
|
if existing_product else None
|
48
|
-
value =
|
50
|
+
value = existing_product_value / conversion_to_kg_ratio if all([
|
51
|
+
existing_product_value is not None,
|
52
|
+
conversion_to_kg_ratio
|
53
|
+
]) else None
|
49
54
|
|
50
55
|
debugValues(cycle, model=MODEL, term=term_id,
|
51
56
|
using_excreta_product=existing_product.get('term', {}).get('@id'),
|
@@ -25,7 +25,7 @@ SITE_TYPE_TO_TERM_ID = {
|
|
25
25
|
|
26
26
|
|
27
27
|
def _measurement(site: dict, term_id: str):
|
28
|
-
data = _new_measurement(term_id)
|
28
|
+
data = _new_measurement(term_id, MODEL)
|
29
29
|
data['value'] = [True]
|
30
30
|
data['methodClassification'] = MeasurementMethodClassification.MODELLED_USING_OTHER_MEASUREMENTS.value
|
31
31
|
return data | get_source(site, BIBLIO_TITLE)
|
@@ -22,7 +22,7 @@ TERM_ID = 'freshWater'
|
|
22
22
|
|
23
23
|
|
24
24
|
def _measurement():
|
25
|
-
data = _new_measurement(TERM_ID)
|
25
|
+
data = _new_measurement(TERM_ID, MODEL)
|
26
26
|
data['value'] = [True]
|
27
27
|
data['methodClassification'] = MeasurementMethodClassification.MODELLED_USING_OTHER_MEASUREMENTS.value
|
28
28
|
return data
|
@@ -1,15 +1,13 @@
|
|
1
|
-
from hestia_earth.schema import
|
1
|
+
from hestia_earth.schema import CycleFunctionalUnit
|
2
2
|
|
3
3
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
4
4
|
from hestia_earth.models.utils.cycle import is_irrigated
|
5
5
|
from hestia_earth.models.utils.practice import _new_practice
|
6
6
|
from hestia_earth.models.utils.input import get_total_irrigation_m3
|
7
|
-
from hestia_earth.models.utils.completeness import _is_term_type_complete
|
8
7
|
from . import MODEL
|
9
8
|
|
10
9
|
REQUIREMENTS = {
|
11
10
|
"Cycle": {
|
12
|
-
"completeness.water": "",
|
13
11
|
"functionalUnit": "1 ha",
|
14
12
|
"none": {
|
15
13
|
"practices": [{"@type": "Practice", "value": "> 0", "term.termType": "waterRegime"}]
|
@@ -31,38 +29,35 @@ TERM_ID = 'irrigatedTypeUnspecified'
|
|
31
29
|
MIN_IRRIGATION_M3 = 250
|
32
30
|
|
33
31
|
|
34
|
-
def _practice(
|
35
|
-
practice = _new_practice(TERM_ID)
|
36
|
-
practice['value'] = [
|
32
|
+
def _practice():
|
33
|
+
practice = _new_practice(TERM_ID, MODEL)
|
34
|
+
practice['value'] = [100]
|
37
35
|
return practice
|
38
36
|
|
39
37
|
|
40
|
-
def _run(irrigation_m3: float):
|
41
|
-
value = 100 if irrigation_m3 > MIN_IRRIGATION_M3 else 0
|
42
|
-
return [_practice(value)]
|
43
|
-
|
44
|
-
|
45
38
|
def _should_run(cycle: dict):
|
46
39
|
functional_unit = cycle.get('functionalUnit')
|
47
|
-
water_complete = _is_term_type_complete(cycle, TermTermType.WATER)
|
48
40
|
irrigation_value_m3 = get_total_irrigation_m3(cycle)
|
41
|
+
is_1_ha_functional_unit = functional_unit == CycleFunctionalUnit._1_HA.value
|
49
42
|
|
50
43
|
no_irrigation_practice = not is_irrigated(cycle, model=MODEL, term=TERM_ID)
|
51
44
|
|
52
45
|
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
53
46
|
no_irrigation_practice=no_irrigation_practice,
|
54
|
-
|
55
|
-
irrigation_value_m3=irrigation_value_m3
|
47
|
+
is_1_ha_functional_unit=is_1_ha_functional_unit,
|
48
|
+
irrigation_value_m3=irrigation_value_m3,
|
49
|
+
irrigation_min_m3=MIN_IRRIGATION_M3,
|
50
|
+
is_irrigated=irrigation_value_m3 > MIN_IRRIGATION_M3)
|
56
51
|
|
57
52
|
should_run = all([
|
58
53
|
no_irrigation_practice,
|
59
|
-
|
60
|
-
|
54
|
+
is_1_ha_functional_unit,
|
55
|
+
irrigation_value_m3 > MIN_IRRIGATION_M3
|
61
56
|
])
|
62
57
|
logShouldRun(cycle, MODEL, TERM_ID, should_run)
|
63
|
-
return should_run
|
58
|
+
return should_run
|
64
59
|
|
65
60
|
|
66
61
|
def run(cycle: dict):
|
67
|
-
should_run
|
68
|
-
return
|
62
|
+
should_run = _should_run(cycle)
|
63
|
+
return [_practice()] if should_run else []
|
@@ -11,6 +11,7 @@ from hestia_earth.utils.model import filter_list_term_type
|
|
11
11
|
from hestia_earth.utils.tools import safe_parse_float, to_precision
|
12
12
|
|
13
13
|
from hestia_earth.models.log import logRequirements, log_as_table, logShouldRun
|
14
|
+
from hestia_earth.models.utils import _omit
|
14
15
|
from hestia_earth.models.utils.constant import DAYS_IN_YEAR
|
15
16
|
from hestia_earth.models.utils.management import _new_management
|
16
17
|
from hestia_earth.models.utils.term import get_lookup_value
|
@@ -91,6 +92,7 @@ SITE_TYPES = {
|
|
91
92
|
DEFAULT_WINDOW_IN_YEARS = 20
|
92
93
|
DATE_TOLERANCE_IN_YEARS = 2
|
93
94
|
OUTPUT_SIGNIFICANT_DIGITS = 3
|
95
|
+
ALLOWED_LAND_USE_TYPES = [ANNUAL_CROPLAND, PERMANENT_CROPLAND, PERMANENT_PASTURE]
|
94
96
|
_LOOKUP_EXPANSION = "region-crop-cropGroupingFaostatProduction-areaHarvestedUpTo20YearExpansion.csv"
|
95
97
|
|
96
98
|
|
@@ -751,16 +753,21 @@ def _collect_land_use_types(nodes: list) -> list:
|
|
751
753
|
"""Look up the land use type from management nodes."""
|
752
754
|
return [
|
753
755
|
{
|
756
|
+
"value": node.get("value", ""),
|
757
|
+
"term": node.get("term", {}),
|
754
758
|
"id": node.get("term", {}).get("@id"),
|
755
759
|
"land-use-type": _get_land_use_term_from_node(node),
|
756
|
-
"endDate": _gapfill_datestr(datestr=node.get("endDate"), mode=DatestrGapfillMode.END)[:10]
|
760
|
+
"endDate": _gapfill_datestr(datestr=node.get("endDate"), mode=DatestrGapfillMode.END)[:10],
|
761
|
+
"startDate": _gapfill_datestr(
|
762
|
+
datestr=node.get("startDate"), mode=DatestrGapfillMode.START
|
763
|
+
)[:10] if node.get("startDate") else None
|
757
764
|
} for node in nodes
|
758
765
|
]
|
759
766
|
|
760
767
|
|
761
|
-
def _no_prior_land_cover_data(nodes: list,
|
768
|
+
def _no_prior_land_cover_data(nodes: list, node: dict) -> bool:
|
762
769
|
target_date = (
|
763
|
-
datetime.strptime(
|
770
|
+
datetime.strptime(node.get('startDate') or node.get('endDate'), DatestrFormat.YEAR_MONTH_DAY.value)
|
764
771
|
- timedelta(days=DEFAULT_WINDOW_IN_YEARS * DAYS_IN_YEAR)
|
765
772
|
)
|
766
773
|
previous_nodes = [
|
@@ -770,45 +777,46 @@ def _no_prior_land_cover_data(nodes: list, end_date: str) -> bool:
|
|
770
777
|
return len(previous_nodes) == 0
|
771
778
|
|
772
779
|
|
773
|
-
def _should_run(site: dict
|
774
|
-
|
775
|
-
|
780
|
+
def _should_run(site: dict) -> tuple[bool, dict]:
|
781
|
+
management_nodes = _collect_land_use_types(
|
782
|
+
[
|
783
|
+
node for node in filter_list_term_type(site.get("management", []), TermTermType.LANDCOVER)
|
784
|
+
if not _should_group_landCover(node)
|
785
|
+
]
|
786
|
+
)
|
776
787
|
relevant_nodes = sorted(
|
777
788
|
[
|
778
|
-
node for node in
|
779
|
-
if node["land-use-type"] in
|
789
|
+
node for node in management_nodes
|
790
|
+
if node["land-use-type"] in ALLOWED_LAND_USE_TYPES
|
780
791
|
],
|
781
|
-
key=lambda n: n.get("endDate")
|
792
|
+
key=lambda n: n.get("startDate") or n.get("endDate")
|
782
793
|
)
|
794
|
+
|
783
795
|
land_use_type = relevant_nodes[0].get("land-use-type") if relevant_nodes else None
|
784
796
|
|
785
797
|
has_no_prior_land_cover_data = _no_prior_land_cover_data(
|
786
|
-
nodes=
|
787
|
-
|
798
|
+
nodes=relevant_nodes,
|
799
|
+
node=relevant_nodes[-1:][0]
|
788
800
|
) if relevant_nodes else None
|
789
801
|
|
790
802
|
should_run_nodes, site_area = _should_run_historical_land_use_change(
|
791
803
|
site=site,
|
792
|
-
nodes=
|
804
|
+
nodes=relevant_nodes,
|
793
805
|
land_use_type=land_use_type
|
794
806
|
) if all([land_use_type, has_no_prior_land_cover_data]) else (False, {})
|
795
807
|
|
796
808
|
logRequirements(site, model=MODEL, model_key=MODEL_KEY,
|
797
|
-
has_management_nodes=bool(
|
809
|
+
has_management_nodes=bool(relevant_nodes),
|
798
810
|
land_use_type=land_use_type,
|
799
|
-
allowed_land_use_types=';'.join(
|
811
|
+
allowed_land_use_types=';'.join(ALLOWED_LAND_USE_TYPES),
|
800
812
|
has_no_prior_land_cover_data=has_no_prior_land_cover_data,
|
801
|
-
|
813
|
+
management_nodes=log_as_table([_omit(n, ['term']) for n in relevant_nodes]))
|
802
814
|
|
803
815
|
should_run = all([land_use_type, has_no_prior_land_cover_data, should_run_nodes])
|
804
816
|
logShouldRun(site, MODEL, None, should_run, model_key=MODEL_KEY)
|
805
|
-
return should_run_nodes, site_area
|
817
|
+
return should_run_nodes, relevant_nodes, site_area
|
806
818
|
|
807
819
|
|
808
820
|
def run(site: dict) -> list:
|
809
|
-
|
810
|
-
|
811
|
-
if not _should_group_landCover(node)
|
812
|
-
]
|
813
|
-
should_run, site_area = _should_run(site=site, management_nodes=management_nodes)
|
814
|
-
return _run(site, management_nodes, site_area) if should_run else []
|
821
|
+
should_run, relevant_nodes, site_area = _should_run(site=site)
|
822
|
+
return _run(site, relevant_nodes, site_area) if should_run else []
|
@@ -51,7 +51,7 @@ VALID_SITE_TYPES = [
|
|
51
51
|
|
52
52
|
|
53
53
|
def practice(term_id: str, value: float, properties: list, sd: float = None, min: float = None, max: float = None):
|
54
|
-
data = _new_practice(term_id)
|
54
|
+
data = _new_practice(term_id, MODEL)
|
55
55
|
data['value'] = [round(value, 2)]
|
56
56
|
if properties:
|
57
57
|
data['properties'] = properties
|
@@ -24,7 +24,7 @@ NPP_Aqua = {TemperatureLevel.LOW: 2, TemperatureLevel.MEDIUM: 4, TemperatureLeve
|
|
24
24
|
|
25
25
|
|
26
26
|
def _measurement(site: dict, value: float):
|
27
|
-
data = _new_measurement(TERM_ID)
|
27
|
+
data = _new_measurement(TERM_ID, MODEL)
|
28
28
|
data['value'] = [value]
|
29
29
|
data['methodClassification'] = MeasurementMethodClassification.MODELLED_USING_OTHER_MEASUREMENTS.value
|
30
30
|
return data | get_source(site, BIBLIO_TITLE)
|
@@ -64,7 +64,7 @@ VALID_MEASUREMENT_METHOD_CLASSIFICATIONS = {
|
|
64
64
|
def _measurement(
|
65
65
|
site: dict, value: float, depthUpper: Union[int, float], depthLower: Union[int, float], date: Optional[str] = None
|
66
66
|
) -> dict:
|
67
|
-
data = _new_measurement(TERM_ID)
|
67
|
+
data = _new_measurement(TERM_ID, MODEL)
|
68
68
|
data['value'] = [value]
|
69
69
|
data['depthUpper'] = int(depthUpper)
|
70
70
|
data['depthLower'] = int(depthLower)
|
@@ -3,7 +3,7 @@ from hestia_earth.utils.tools import flatten, non_empty_list
|
|
3
3
|
|
4
4
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
5
5
|
from hestia_earth.models.utils.measurement import _new_measurement
|
6
|
-
from .utils import
|
6
|
+
from .utils import slice_by_year
|
7
7
|
from . import MODEL
|
8
8
|
|
9
9
|
REQUIREMENTS = {
|
@@ -26,7 +26,7 @@ MEASUREMENT_ID = 'potentialEvapotranspirationMonthly'
|
|
26
26
|
|
27
27
|
|
28
28
|
def _measurement(value: float, start_date: str, end_date: str):
|
29
|
-
data = _new_measurement(TERM_ID)
|
29
|
+
data = _new_measurement(TERM_ID, MODEL)
|
30
30
|
data['value'] = [value]
|
31
31
|
data['startDate'] = start_date
|
32
32
|
data['endDate'] = end_date
|
@@ -38,7 +38,7 @@ def _run(measurement: dict):
|
|
38
38
|
values = measurement.get('value', [])
|
39
39
|
dates = measurement.get('dates', [])
|
40
40
|
term_id = measurement.get('term', {}).get('@id')
|
41
|
-
results =
|
41
|
+
results = slice_by_year(term_id, dates, values)
|
42
42
|
return [_measurement(value, start_date, end_date) for (value, start_date, end_date) in results]
|
43
43
|
|
44
44
|
|
@@ -3,7 +3,7 @@ from hestia_earth.utils.tools import flatten, non_empty_list
|
|
3
3
|
|
4
4
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
5
5
|
from hestia_earth.models.utils.measurement import _new_measurement
|
6
|
-
from .utils import
|
6
|
+
from .utils import group_by_month
|
7
7
|
from . import MODEL
|
8
8
|
|
9
9
|
REQUIREMENTS = {
|
@@ -25,7 +25,7 @@ MEASUREMENT_ID = 'potentialEvapotranspirationDaily'
|
|
25
25
|
|
26
26
|
|
27
27
|
def _measurement(value: list, dates: list):
|
28
|
-
data = _new_measurement(TERM_ID)
|
28
|
+
data = _new_measurement(TERM_ID, MODEL)
|
29
29
|
data['value'] = value
|
30
30
|
data['dates'] = dates
|
31
31
|
data['methodClassification'] = MeasurementMethodClassification.MODELLED_USING_OTHER_MEASUREMENTS.value
|
@@ -36,7 +36,7 @@ def _run(measurement: dict):
|
|
36
36
|
values = measurement.get('value', [])
|
37
37
|
dates = measurement.get('dates', [])
|
38
38
|
term_id = measurement.get('term', {}).get('@id')
|
39
|
-
result =
|
39
|
+
result = group_by_month(term_id, dates, values)
|
40
40
|
return _measurement(result[0], result[1]) if len(result[0]) > 0 else None
|
41
41
|
|
42
42
|
|
@@ -3,7 +3,7 @@ from hestia_earth.utils.tools import flatten, non_empty_list
|
|
3
3
|
|
4
4
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
5
5
|
from hestia_earth.models.utils.measurement import _new_measurement
|
6
|
-
from .utils import
|
6
|
+
from .utils import slice_by_year
|
7
7
|
from . import MODEL
|
8
8
|
|
9
9
|
REQUIREMENTS = {
|
@@ -26,7 +26,7 @@ MEASUREMENT_ID = 'precipitationMonthly'
|
|
26
26
|
|
27
27
|
|
28
28
|
def _measurement(value: float, start_date: str, end_date: str):
|
29
|
-
data = _new_measurement(TERM_ID)
|
29
|
+
data = _new_measurement(TERM_ID, MODEL)
|
30
30
|
data['value'] = [value]
|
31
31
|
data['startDate'] = start_date
|
32
32
|
data['endDate'] = end_date
|
@@ -38,7 +38,7 @@ def _run(measurement: dict):
|
|
38
38
|
values = measurement.get('value', [])
|
39
39
|
dates = measurement.get('dates', [])
|
40
40
|
term_id = measurement.get('term', {}).get('@id')
|
41
|
-
results =
|
41
|
+
results = slice_by_year(term_id, dates, values)
|
42
42
|
return [_measurement(value, start_date, end_date) for (value, start_date, end_date) in results]
|
43
43
|
|
44
44
|
|
@@ -3,7 +3,7 @@ from hestia_earth.utils.tools import flatten, non_empty_list
|
|
3
3
|
|
4
4
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
5
5
|
from hestia_earth.models.utils.measurement import _new_measurement
|
6
|
-
from .utils import
|
6
|
+
from .utils import group_by_month
|
7
7
|
from . import MODEL
|
8
8
|
|
9
9
|
REQUIREMENTS = {
|
@@ -25,7 +25,7 @@ MEASUREMENT_ID = 'precipitationDaily'
|
|
25
25
|
|
26
26
|
|
27
27
|
def _measurement(value: list, dates: list):
|
28
|
-
data = _new_measurement(TERM_ID)
|
28
|
+
data = _new_measurement(TERM_ID, MODEL)
|
29
29
|
data['value'] = value
|
30
30
|
data['dates'] = dates
|
31
31
|
data['methodClassification'] = MeasurementMethodClassification.MODELLED_USING_OTHER_MEASUREMENTS.value
|
@@ -36,7 +36,7 @@ def _run(measurement: dict):
|
|
36
36
|
values = measurement.get('value', [])
|
37
37
|
dates = measurement.get('dates', [])
|
38
38
|
term_id = measurement.get('term', {}).get('@id')
|
39
|
-
result =
|
39
|
+
result = group_by_month(term_id, dates, values)
|
40
40
|
return _measurement(result[0], result[1]) if len(result[0]) > 0 else None
|
41
41
|
|
42
42
|
|
@@ -3,7 +3,7 @@ from hestia_earth.utils.tools import flatten, non_empty_list
|
|
3
3
|
|
4
4
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
5
5
|
from hestia_earth.models.utils.measurement import _new_measurement
|
6
|
-
from .utils import
|
6
|
+
from .utils import slice_by_year
|
7
7
|
from . import MODEL
|
8
8
|
|
9
9
|
REQUIREMENTS = {
|
@@ -26,7 +26,7 @@ MEASUREMENT_ID = 'rainfallMonthly'
|
|
26
26
|
|
27
27
|
|
28
28
|
def _measurement(value: float, start_date: str, end_date: str):
|
29
|
-
data = _new_measurement(TERM_ID)
|
29
|
+
data = _new_measurement(TERM_ID, MODEL)
|
30
30
|
data['value'] = [value]
|
31
31
|
data['startDate'] = start_date
|
32
32
|
data['endDate'] = end_date
|
@@ -38,7 +38,7 @@ def _run(measurement: dict):
|
|
38
38
|
values = measurement.get('value', [])
|
39
39
|
dates = measurement.get('dates', [])
|
40
40
|
term_id = measurement.get('term', {}).get('@id')
|
41
|
-
results =
|
41
|
+
results = slice_by_year(term_id, dates, values)
|
42
42
|
return [_measurement(value, start_date, end_date) for (value, start_date, end_date) in results]
|
43
43
|
|
44
44
|
|
@@ -3,7 +3,7 @@ from hestia_earth.utils.tools import flatten, non_empty_list
|
|
3
3
|
|
4
4
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
5
5
|
from hestia_earth.models.utils.measurement import _new_measurement
|
6
|
-
from .utils import
|
6
|
+
from .utils import group_by_month
|
7
7
|
from . import MODEL
|
8
8
|
|
9
9
|
REQUIREMENTS = {
|
@@ -25,7 +25,7 @@ MEASUREMENT_ID = 'rainfallDaily'
|
|
25
25
|
|
26
26
|
|
27
27
|
def _measurement(value: list, dates: list):
|
28
|
-
data = _new_measurement(TERM_ID)
|
28
|
+
data = _new_measurement(TERM_ID, MODEL)
|
29
29
|
data['value'] = value
|
30
30
|
data['dates'] = dates
|
31
31
|
data['methodClassification'] = MeasurementMethodClassification.MODELLED_USING_OTHER_MEASUREMENTS.value
|
@@ -36,7 +36,7 @@ def _run(measurement: dict):
|
|
36
36
|
values = measurement.get('value', [])
|
37
37
|
dates = measurement.get('dates', [])
|
38
38
|
term_id = measurement.get('term', {}).get('@id')
|
39
|
-
result =
|
39
|
+
result = group_by_month(term_id, dates, values)
|
40
40
|
return _measurement(result[0], result[1]) if len(result[0]) > 0 else None
|
41
41
|
|
42
42
|
|