hestia-earth-models 0.68.1__py3-none-any.whl → 0.69.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/agribalyse2016/fuelElectricity.py +0 -5
- hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py +0 -11
- hestia_earth/models/aware/scarcityWeightedWaterUse.py +0 -4
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionFossilFuels.py +0 -18
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionMineralsAndMetals.py +0 -12
- hestia_earth/models/cml2001Baseline/resourceUseEnergyDepletionDuringCycle.py +0 -5
- hestia_earth/models/cml2001Baseline/resourceUseMineralsAndMetalsDuringCycle.py +0 -4
- hestia_earth/models/config/Cycle.json +23 -30
- hestia_earth/models/cycle/aboveGroundCropResidueTotal.py +0 -6
- hestia_earth/models/cycle/animal/input/hestiaAggregatedData.py +0 -8
- hestia_earth/models/cycle/animal/input/properties.py +0 -9
- hestia_earth/models/cycle/animal/milkYield.py +0 -6
- hestia_earth/models/cycle/animal/properties.py +0 -6
- hestia_earth/models/cycle/completeness/animalFeed.py +0 -6
- hestia_earth/models/cycle/completeness/cropResidue.py +0 -6
- hestia_earth/models/cycle/completeness/electricityFuel.py +0 -6
- hestia_earth/models/cycle/completeness/excreta.py +0 -6
- hestia_earth/models/cycle/completeness/freshForage.py +0 -6
- hestia_earth/models/cycle/completeness/material.py +0 -6
- hestia_earth/models/cycle/completeness/seed.py +0 -6
- hestia_earth/models/cycle/completeness/soilAmendment.py +0 -6
- hestia_earth/models/cycle/concentrateFeed.py +0 -6
- hestia_earth/models/cycle/cropResidueManagement.py +0 -5
- hestia_earth/models/cycle/cycleDuration.py +0 -8
- hestia_earth/models/cycle/endDate.py +0 -7
- hestia_earth/models/cycle/excretaKgMass.py +0 -5
- hestia_earth/models/cycle/excretaKgN.py +0 -5
- hestia_earth/models/cycle/excretaKgVs.py +0 -5
- hestia_earth/models/cycle/inorganicFertiliser.py +0 -6
- hestia_earth/models/cycle/input/hestiaAggregatedData.py +0 -13
- hestia_earth/models/cycle/input/properties.py +0 -9
- hestia_earth/models/cycle/input/value.py +0 -6
- hestia_earth/models/cycle/liveAnimal.py +0 -5
- hestia_earth/models/cycle/materialAndSubstrate.py +1 -6
- hestia_earth/models/cycle/milkYield.py +0 -10
- hestia_earth/models/cycle/otherSitesArea.py +0 -6
- hestia_earth/models/cycle/otherSitesUnusedDuration.py +0 -6
- hestia_earth/models/cycle/pastureSystem.py +0 -6
- hestia_earth/models/cycle/post_checks/cache.py +0 -5
- hestia_earth/models/cycle/post_checks/otherSites.py +0 -7
- hestia_earth/models/cycle/post_checks/site.py +0 -7
- hestia_earth/models/cycle/practice/value.py +0 -7
- hestia_earth/models/cycle/pre_checks/cache_sources.py +0 -5
- hestia_earth/models/cycle/pre_checks/otherSites.py +0 -7
- hestia_earth/models/cycle/pre_checks/site.py +0 -6
- hestia_earth/models/cycle/product/currency.py +0 -5
- hestia_earth/models/cycle/product/economicValueShare.py +0 -14
- hestia_earth/models/cycle/product/price.py +0 -5
- hestia_earth/models/cycle/product/primary.py +0 -5
- hestia_earth/models/cycle/product/properties.py +0 -7
- hestia_earth/models/cycle/product/revenue.py +0 -9
- hestia_earth/models/cycle/product/value.py +0 -6
- hestia_earth/models/cycle/siteArea.py +0 -6
- hestia_earth/models/cycle/siteDuration.py +0 -10
- hestia_earth/models/cycle/siteUnusedDuration.py +0 -6
- hestia_earth/models/cycle/startDate.py +0 -8
- hestia_earth/models/cycle/startDateDefinition.py +0 -6
- hestia_earth/models/cycle/transformation.py +0 -5
- hestia_earth/models/dammgen2009/noxToAirExcreta.py +2 -2
- hestia_earth/models/ecoinventV3/__init__.py +0 -15
- hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py +0 -11
- hestia_earth/models/emepEea2019/nh3ToAirExcreta.py +14 -40
- hestia_earth/models/emepEea2019/pm10ToAirAnimalHousing.py +0 -4
- hestia_earth/models/emepEea2019/pm25ToAirAnimalHousing.py +0 -4
- hestia_earth/models/emepEea2019/tspToAirAnimalHousing.py +0 -4
- hestia_earth/models/emissionNotRelevant/__init__.py +0 -5
- hestia_earth/models/environmentalFootprintV3_1/environmentalFootprintSingleOverallScore.py +0 -9
- hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandOccupation.py +0 -6
- hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandTransformation.py +0 -6
- hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexTotalLandUseEffects.py +0 -6
- hestia_earth/models/epa2014/no3ToGroundwaterExcreta.py +2 -2
- hestia_earth/models/faostat2018/product/price.py +0 -5
- hestia_earth/models/geospatialDatabase/awareWaterBasinId.py +0 -5
- hestia_earth/models/geospatialDatabase/ecoClimateZone.py +1 -20
- hestia_earth/models/geospatialDatabase/ecoregion.py +0 -7
- hestia_earth/models/geospatialDatabase/potentialEvapotranspirationAnnual.py +0 -4
- hestia_earth/models/geospatialDatabase/potentialEvapotranspirationMonthly.py +0 -4
- hestia_earth/models/geospatialDatabase/precipitationAnnual.py +0 -4
- hestia_earth/models/geospatialDatabase/precipitationMonthly.py +0 -4
- hestia_earth/models/geospatialDatabase/region.py +0 -5
- hestia_earth/models/geospatialDatabase/temperatureAnnual.py +0 -4
- hestia_earth/models/geospatialDatabase/temperatureMonthly.py +0 -4
- hestia_earth/models/haversineFormula/transport/distance.py +0 -7
- hestia_earth/models/hestia/landCover.py +31 -18
- hestia_earth/models/hestia/landTransformation100YearAverageDuringCycle.py +0 -11
- hestia_earth/models/hestia/landTransformation20YearAverageDuringCycle.py +0 -11
- hestia_earth/models/hestia/nh3ToSurfaceWaterAquacultureSystems.py +64 -0
- hestia_earth/models/hestia/residueRemoved.py +0 -4
- hestia_earth/models/hestia/resourceUse_utils.py +0 -5
- hestia_earth/models/hestia/seed_emissions.py +0 -13
- hestia_earth/models/impact_assessment/allocationMethod.py +0 -6
- hestia_earth/models/impact_assessment/emissions.py +0 -9
- hestia_earth/models/impact_assessment/irrigated.py +0 -5
- hestia_earth/models/impact_assessment/organic.py +0 -5
- hestia_earth/models/impact_assessment/post_checks/cycle.py +0 -7
- hestia_earth/models/impact_assessment/post_checks/site.py +0 -7
- hestia_earth/models/impact_assessment/pre_checks/cycle.py +0 -6
- hestia_earth/models/impact_assessment/pre_checks/site.py +0 -6
- hestia_earth/models/impact_assessment/product/economicValueShare.py +0 -6
- hestia_earth/models/impact_assessment/product/value.py +0 -5
- hestia_earth/models/ipcc2019/aboveGroundBiomass.py +9 -2
- hestia_earth/models/ipcc2019/animal/milkYieldPerAnimal.py +0 -6
- hestia_earth/models/ipcc2019/animal/pastureGrass.py +0 -10
- hestia_earth/models/ipcc2019/animal/weightAtMaturity.py +0 -4
- hestia_earth/models/ipcc2019/belowGroundBiomass.py +9 -2
- hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py +1 -1
- hestia_earth/models/ipcc2019/croppingDuration.py +0 -5
- hestia_earth/models/ipcc2019/n2OToAirExcretaDirect.py +1 -1
- hestia_earth/models/ipcc2019/no3ToGroundwaterExcreta.py +51 -15
- hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +0 -12
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py +2 -15
- hestia_earth/models/ipcc2019/{organicCarbonPerHa_tier_1_utils.py → organicCarbonPerHa_tier_1.py} +3 -15
- hestia_earth/models/ipcc2019/{organicCarbonPerHa_tier_2_utils.py → organicCarbonPerHa_tier_2.py} +3 -13
- hestia_earth/models/ipcc2019/pastureGrass.py +0 -10
- hestia_earth/models/koble2014/aboveGroundCropResidue.py +0 -9
- hestia_earth/models/koble2014/cropResidueManagement.py +0 -6
- hestia_earth/models/linkedImpactAssessment/emissions.py +0 -5
- hestia_earth/models/mocking/search-results.json +1202 -1146
- hestia_earth/models/pooreNemecek2018/ch4ToAirAquacultureSystems.py +14 -15
- hestia_earth/models/pooreNemecek2018/excretaKgN.py +12 -17
- hestia_earth/models/pooreNemecek2018/excretaKgVs.py +22 -23
- hestia_earth/models/pooreNemecek2018/n2OToAirAquacultureSystemsDirect.py +6 -9
- hestia_earth/models/pooreNemecek2018/n2ToAirAquacultureSystems.py +6 -9
- hestia_earth/models/pooreNemecek2018/nh3ToAirAquacultureSystems.py +11 -15
- hestia_earth/models/pooreNemecek2018/noxToAirAquacultureSystems.py +6 -9
- hestia_earth/models/pooreNemecek2018/utils.py +2 -2
- hestia_earth/models/site/defaultMethodClassification.py +0 -7
- hestia_earth/models/site/defaultMethodClassificationDescription.py +0 -7
- hestia_earth/models/site/flowingWater.py +0 -5
- hestia_earth/models/site/management.py +0 -21
- hestia_earth/models/site/measurement/value.py +0 -6
- hestia_earth/models/site/post_checks/country.py +0 -5
- hestia_earth/models/site/potentialEvapotranspirationAnnual.py +0 -3
- hestia_earth/models/site/potentialEvapotranspirationMonthly.py +0 -3
- hestia_earth/models/site/pre_checks/cache_geospatialDatabase.py +0 -5
- hestia_earth/models/site/pre_checks/cache_sources.py +0 -5
- hestia_earth/models/site/pre_checks/cache_years.py +0 -5
- hestia_earth/models/site/pre_checks/country.py +0 -5
- hestia_earth/models/site/precipitationAnnual.py +0 -3
- hestia_earth/models/site/precipitationMonthly.py +0 -3
- hestia_earth/models/site/rainfallAnnual.py +0 -3
- hestia_earth/models/site/rainfallMonthly.py +0 -3
- hestia_earth/models/site/soilMeasurement.py +0 -5
- hestia_earth/models/site/temperatureAnnual.py +0 -3
- hestia_earth/models/site/temperatureMonthly.py +0 -3
- hestia_earth/models/transformation/input/excreta.py +0 -5
- hestia_earth/models/transformation/input/max.py +0 -8
- hestia_earth/models/transformation/input/min.py +0 -8
- hestia_earth/models/transformation/input/properties.py +0 -6
- hestia_earth/models/transformation/input/sd.py +0 -8
- hestia_earth/models/transformation/input/value.py +0 -8
- hestia_earth/models/transformation/product/excreta.py +0 -7
- hestia_earth/models/utils/excretaManagement.py +37 -0
- hestia_earth/models/utils/lookup.py +2 -0
- hestia_earth/models/utils/practice.py +1 -27
- hestia_earth/models/utils/source.py +29 -9
- hestia_earth/models/version.py +1 -1
- hestia_earth/orchestrator/strategies/run/add_blank_node_if_missing.py +12 -8
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/RECORD +179 -187
- tests/models/emepEea2019/test_nh3ToAirExcreta.py +6 -17
- tests/models/hestia/test_nh3ToSurfaceWaterAquacultureSystems.py +51 -0
- tests/models/ipcc2019/test_aboveGroundBiomass.py +4 -0
- tests/models/ipcc2019/test_belowGroundBiomass.py +4 -0
- tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py +1 -1
- tests/models/ipcc2019/test_no3ToGroundwaterExcreta.py +24 -9
- tests/models/ipcc2019/test_organicCarbonPerHa.py +2 -2
- tests/models/ipcc2019/{test_organicCarbonPerHa_tier_1_utils.py → test_organicCarbonPerHa_tier_1.py} +2 -2
- tests/models/ipcc2019/{test_organicCarbonPerHa_tier_2_utils.py → test_organicCarbonPerHa_tier_2.py} +2 -2
- tests/models/pooreNemecek2018/test_ch4ToAirAquacultureSystems.py +1 -7
- tests/models/pooreNemecek2018/test_n2OToAirAquacultureSystemsDirect.py +1 -7
- tests/models/pooreNemecek2018/test_n2ToAirAquacultureSystems.py +1 -7
- tests/models/pooreNemecek2018/test_nh3ToAirAquacultureSystems.py +1 -7
- tests/models/pooreNemecek2018/test_noxToAirAquacultureSystems.py +1 -7
- tests/models/utils/test_source.py +6 -1
- tests/orchestrator/strategies/run/test_add_blank_node_if_missing.py +1 -1
- hestia_earth/models/blonkConsultants2016/__init__.py +0 -13
- hestia_earth/models/blonkConsultants2016/ch4ToAirNaturalVegetationBurning.py +0 -78
- hestia_earth/models/blonkConsultants2016/co2ToAirAboveGroundBiomassStockChangeLandUseChange.py +0 -78
- hestia_earth/models/blonkConsultants2016/n2OToAirNaturalVegetationBurningDirect.py +0 -78
- hestia_earth/models/blonkConsultants2016/utils.py +0 -30
- tests/models/blonkConsultants2016/__init__.py +0 -0
- tests/models/blonkConsultants2016/test_ch4ToAirNaturalVegetationBurning.py +0 -34
- tests/models/blonkConsultants2016/test_co2ToAirAboveGroundBiomassStockChangeLandUseChange.py +0 -36
- tests/models/blonkConsultants2016/test_n2OToAirNaturalVegetationBurningDirect.py +0 -34
- tests/models/blonkConsultants2016/test_utils.py +0 -9
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.68.1.dist-info → hestia_earth_models-0.69.1.dist-info}/top_level.txt +0 -0
@@ -10,7 +10,6 @@ from hestia_earth.models.utils.temperature import TemperatureLevel, get_level
|
|
10
10
|
from hestia_earth.models.utils.blank_node import get_total_value
|
11
11
|
from hestia_earth.models.utils.emission import _new_emission
|
12
12
|
from hestia_earth.models.utils.measurement import most_relevant_measurement_value
|
13
|
-
from hestia_earth.models.utils.practice import is_model_enabled
|
14
13
|
from hestia_earth.models.utils.aquacultureManagement import valid_site_type
|
15
14
|
from . import MODEL
|
16
15
|
|
@@ -110,10 +109,10 @@ def _Conv_Aquaculture_CH4C_CH4CAir(waterDepth: float):
|
|
110
109
|
return Conv_Aquaculture_CH4C_CH4CAir_2m if waterDepth > 2 else Conv_Aquaculture_CH4C_CH4CAir_0_2m
|
111
110
|
|
112
111
|
|
113
|
-
def _run(excretaKgVs: float, temp: float, system: str, waterDepth: float,
|
112
|
+
def _run(excretaKgVs: float, temp: float, system: str, waterDepth: float, yield_per_m2: float, slaughterAge: int):
|
114
113
|
value = min(
|
115
114
|
excretaKgVs * _oc(temp) * _oc_flow(temp, system) * _Conv_Aquaculture_CH4C_CH4CAir(waterDepth),
|
116
|
-
Conv_Aquaculture_CH4Cmax * slaughterAge /
|
115
|
+
Conv_Aquaculture_CH4Cmax * slaughterAge / yield_per_m2
|
117
116
|
) * get_atomic_conversion(Units.KG_CH4, Units.TO_C)
|
118
117
|
return [_emission(value)]
|
119
118
|
|
@@ -123,15 +122,16 @@ def _get_term_id(node: dict):
|
|
123
122
|
|
124
123
|
|
125
124
|
def _should_run(cycle: dict):
|
126
|
-
model_enabled = is_model_enabled(MODEL, TERM_ID, cycle.get('practices', [None])[0])
|
127
125
|
|
128
126
|
products = cycle.get('products', [])
|
129
127
|
excr_products = filter_list_term_type(products, TermTermType.EXCRETA)
|
130
|
-
excretaKgVs = list_sum(get_total_value(_filter_list_term_unit(excr_products, Units.KG_VS)))
|
128
|
+
excretaKgVs = list_sum(get_total_value(_filter_list_term_unit(excr_products, Units.KG_VS)), default=None)
|
131
129
|
|
132
130
|
practices = cycle.get('practices', [])
|
133
|
-
|
134
|
-
|
131
|
+
yield_per_m2 = list_sum(
|
132
|
+
find_term_match(practices, 'yieldOfPrimaryAquacultureProductLiveweightPerM2').get('value', []), default=None
|
133
|
+
)
|
134
|
+
slaughterAge = list_sum(find_term_match(practices, 'slaughterAge').get('value', []), default=None)
|
135
135
|
|
136
136
|
site = cycle.get('site', {})
|
137
137
|
end_date = cycle.get('endDate')
|
@@ -146,23 +146,22 @@ def _should_run(cycle: dict):
|
|
146
146
|
set_to_zero = not valid_site_type(cycle) # if site is not water, set value to 0
|
147
147
|
|
148
148
|
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
149
|
-
model_enabled=model_enabled,
|
150
149
|
excretaKgVs=excretaKgVs,
|
151
150
|
temp=temp,
|
152
151
|
system=system,
|
153
152
|
waterDepth=waterDepth,
|
154
|
-
|
153
|
+
yield_of_target_species=yield_per_m2,
|
155
154
|
slaughterAge=slaughterAge,
|
156
155
|
set_to_zero=set_to_zero)
|
157
156
|
|
158
|
-
should_run = (
|
159
|
-
|
160
|
-
) or set_to_zero
|
157
|
+
should_run = all([
|
158
|
+
excretaKgVs, temp, system, waterDepth, yield_per_m2, slaughterAge
|
159
|
+
]) or set_to_zero
|
161
160
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
162
|
-
return should_run, excretaKgVs, temp, system, waterDepth,
|
161
|
+
return should_run, excretaKgVs, temp, system, waterDepth, yield_per_m2, slaughterAge, set_to_zero
|
163
162
|
|
164
163
|
|
165
164
|
def run(cycle: dict):
|
166
|
-
should_run, excretaKgVs, temp, system, waterDepth,
|
165
|
+
should_run, excretaKgVs, temp, system, waterDepth, yield_per_m2, slaughterAge, set_to_zero = _should_run(cycle)
|
167
166
|
return [_emission(0)] if set_to_zero else \
|
168
|
-
_run(excretaKgVs, temp, system, waterDepth,
|
167
|
+
_run(excretaKgVs, temp, system, waterDepth, yield_per_m2, slaughterAge) if should_run else []
|
@@ -1,22 +1,9 @@
|
|
1
|
-
"""
|
2
|
-
Excreta (kg N)
|
3
|
-
|
4
|
-
This model uses a mass balance to calculate the total amount of excreta (as N) created by animals.
|
5
|
-
The inputs into the mass balance are the total amount of feed and the total amount of net primary production
|
6
|
-
in the water body.
|
7
|
-
The outputs of the mass balance are the weight of the animal and the excreta.
|
8
|
-
The formula is excreta = feed + NPP - animal.
|
9
|
-
|
10
|
-
For [live aquatic species](https://hestia.earth/glossary?termType=liveAquaticSpecies), if the mass balance fails
|
11
|
-
(i.e. [animal feed](https://hestia.earth/schema/Completeness#animalFeed) is not complete, see requirements below),
|
12
|
-
a simplified formula is used: total nitrogen content of the fish * 3.31.
|
13
|
-
See [Poore & Nemecek (2018)](https://science.sciencemag.org/content/360/6392/987) for further details.
|
14
|
-
"""
|
15
1
|
from hestia_earth.schema import TermTermType
|
16
2
|
from hestia_earth.utils.model import find_primary_product
|
17
3
|
from hestia_earth.utils.tools import list_sum
|
18
4
|
|
19
5
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
6
|
+
from hestia_earth.models.utils import _omit
|
20
7
|
from hestia_earth.models.utils.property import _get_nitrogen_content
|
21
8
|
from hestia_earth.models.utils.input import get_feed_inputs
|
22
9
|
from hestia_earth.models.utils.product import _new_product, get_animal_produced_nitrogen
|
@@ -83,9 +70,13 @@ LOOKUPS = {
|
|
83
70
|
MODEL_KEY = 'excretaKgN'
|
84
71
|
|
85
72
|
|
86
|
-
def _product(excreta_product: str, value: float):
|
73
|
+
def _product(excreta_product: str, value: float = None):
|
87
74
|
product = _new_product(excreta_product.get('term', {}).get('@id'), value, MODEL)
|
88
|
-
return excreta_product | product
|
75
|
+
return _omit(excreta_product, ['value']) | product
|
76
|
+
|
77
|
+
|
78
|
+
def _run_no_value(excreta_products: list):
|
79
|
+
return [_product(excreta_product) for excreta_product in excreta_products]
|
89
80
|
|
90
81
|
|
91
82
|
def _run(excreta_products: list, mass_balance_items: list, alternate_items: list):
|
@@ -154,4 +145,8 @@ def _should_run(cycle: dict):
|
|
154
145
|
|
155
146
|
def run(cycle: dict):
|
156
147
|
should_run, excreta_products, mass_balance_items, alternate_items = _should_run(cycle)
|
157
|
-
return
|
148
|
+
return (
|
149
|
+
_run(excreta_products, mass_balance_items, alternate_items) if should_run else
|
150
|
+
# add product without value to show the logs
|
151
|
+
_run_no_value(excreta_products)
|
152
|
+
)
|
@@ -1,20 +1,9 @@
|
|
1
|
-
"""
|
2
|
-
Excreta (kg VS)
|
3
|
-
|
4
|
-
This model calculates the Excreta (kg VS) from the products as described in
|
5
|
-
[Poore & Nemecek (2018)](https://science.sciencemag.org/content/360/6392/987).
|
6
|
-
The model computes it as the balance between the carbon in the inputs plus the carbon produced in the pond
|
7
|
-
minus the carbon contained in the primary product.
|
8
|
-
If the mass balance fails
|
9
|
-
(i.e. [animal feed](https://hestia.earth/schema/Completeness#animalFeed) is not complete, see requirements below),
|
10
|
-
the fomula is = total excreta as N / [Volatile solids content](https://hestia.earth/term/volatileSolidsContent).
|
11
|
-
"""
|
12
1
|
from hestia_earth.schema import SiteSiteType, TermTermType
|
13
2
|
from hestia_earth.utils.model import find_primary_product, find_term_match, filter_list_term_type
|
14
3
|
from hestia_earth.utils.tools import list_sum, safe_parse_float
|
15
4
|
|
16
5
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
17
|
-
from hestia_earth.models.utils import get_kg_VS_term_id, _filter_list_term_unit
|
6
|
+
from hestia_earth.models.utils import get_kg_VS_term_id, _filter_list_term_unit, _omit
|
18
7
|
from hestia_earth.models.utils.constant import Units
|
19
8
|
from hestia_earth.models.utils.term import get_lookup_value
|
20
9
|
from hestia_earth.models.utils.property import get_node_property
|
@@ -80,7 +69,7 @@ REQUIREMENTS = {
|
|
80
69
|
}
|
81
70
|
],
|
82
71
|
"optional": {
|
83
|
-
"practices": [{"@type": "Practice", "term.termType": "
|
72
|
+
"practices": [{"@type": "Practice", "term.termType": "system"}]
|
84
73
|
}
|
85
74
|
},
|
86
75
|
{
|
@@ -114,15 +103,19 @@ Conv_AQ_OC_OCSed_Marine = 0.55
|
|
114
103
|
Conv_AQ_OC_OCSed_Fresh = 0.35
|
115
104
|
|
116
105
|
|
117
|
-
def _product(excreta_product: str, value: float):
|
106
|
+
def _product(excreta_product: str, value: float = None):
|
118
107
|
product = _new_product(excreta_product.get('term', {}).get('@id'), value, MODEL)
|
119
|
-
return excreta_product | product
|
108
|
+
return _omit(excreta_product, ['value']) | product
|
109
|
+
|
110
|
+
|
111
|
+
def _run_no_value(excreta_vs_products: list, excreta_n_products: list):
|
112
|
+
return [_product(excreta_product) for excreta_product in (excreta_n_products or excreta_vs_products)]
|
120
113
|
|
121
114
|
|
122
115
|
def _run(excreta_vs_products: list, excreta_n_products: list, mass_balance_items: list, inputs_c: float):
|
123
|
-
carbonContent,
|
116
|
+
carbonContent, yield_per_m2, slaughterAge, aqocsed, npp = mass_balance_items
|
124
117
|
value = max(
|
125
|
-
inputs_c + (npp * slaughterAge) / (
|
118
|
+
inputs_c + (npp * slaughterAge) / (yield_per_m2 * 1000) - carbonContent - carbonContent * Conv_AQ_CLW_CO2CR,
|
126
119
|
carbonContent * Conv_AQ_CLW_CExcr
|
127
120
|
) * aqocsed if all(mass_balance_items) else 0
|
128
121
|
return [
|
@@ -160,13 +153,15 @@ def _should_run(cycle: dict):
|
|
160
153
|
inputs_c = convert_to_carbon(cycle, MODEL, inputs_feed, term=first_term_id, model_key=MODEL_KEY)
|
161
154
|
|
162
155
|
practices = cycle.get('practices', [])
|
163
|
-
|
164
|
-
|
156
|
+
yield_per_m2 = list_sum(
|
157
|
+
find_term_match(practices, 'yieldOfPrimaryAquacultureProductLiveweightPerM2').get('value', []), default=None
|
158
|
+
)
|
159
|
+
slaughterAge = list_sum(find_term_match(practices, 'slaughterAge').get('value', []), default=None)
|
165
160
|
|
166
161
|
end_date = cycle.get('endDate')
|
167
162
|
site = cycle.get('site', {})
|
168
163
|
aqocsed = _get_conv_aq_ocsed(site.get('siteType', {}))
|
169
|
-
npp = most_relevant_measurement_value(site.get('measurements', []), 'netPrimaryProduction', end_date
|
164
|
+
npp = most_relevant_measurement_value(site.get('measurements', []), 'netPrimaryProduction', end_date)
|
170
165
|
|
171
166
|
# we can still run the model with excreta in "kg N" units
|
172
167
|
excreta_products = filter_list_term_type(cycle.get('products', []), TermTermType.EXCRETA)
|
@@ -191,7 +186,7 @@ def _should_run(cycle: dict):
|
|
191
186
|
if vsc > 0
|
192
187
|
]
|
193
188
|
|
194
|
-
mass_balance_items = [carbonContent,
|
189
|
+
mass_balance_items = [carbonContent, yield_per_m2, slaughterAge, aqocsed, npp]
|
195
190
|
|
196
191
|
should_run = all([
|
197
192
|
is_animalFeed_complete,
|
@@ -208,7 +203,7 @@ def _should_run(cycle: dict):
|
|
208
203
|
aqocsed=aqocsed,
|
209
204
|
inputs_c=inputs_c,
|
210
205
|
carbonContent=carbonContent,
|
211
|
-
yield_of_target_species=
|
206
|
+
yield_of_target_species=yield_per_m2,
|
212
207
|
slaughterAge=slaughterAge,
|
213
208
|
netPrimaryProduction=npp,
|
214
209
|
default_using_kg_N=default_using_kg_N)
|
@@ -219,4 +214,8 @@ def _should_run(cycle: dict):
|
|
219
214
|
|
220
215
|
def run(cycle: dict):
|
221
216
|
should_run, excreta_vs_products, excreta_n_products, mass_balance_items, inputs_c = _should_run(cycle)
|
222
|
-
return
|
217
|
+
return (
|
218
|
+
_run(excreta_vs_products, excreta_n_products, mass_balance_items, inputs_c) if should_run else
|
219
|
+
# add product without value to show the logs
|
220
|
+
_run_no_value(excreta_vs_products, excreta_n_products)
|
221
|
+
)
|
@@ -4,14 +4,13 @@ from hestia_earth.models.log import logRequirements, logShouldRun
|
|
4
4
|
from hestia_earth.models.utils.constant import Units, get_atomic_conversion
|
5
5
|
from hestia_earth.models.utils.emission import _new_emission
|
6
6
|
from hestia_earth.models.utils.input import total_excreta, total_excreta_tan
|
7
|
-
from hestia_earth.models.utils.practice import is_model_enabled
|
8
7
|
from hestia_earth.models.utils.aquacultureManagement import valid_site_type
|
9
8
|
from . import MODEL
|
10
9
|
|
11
10
|
REQUIREMENTS = {
|
12
11
|
"Cycle": {
|
13
|
-
"
|
14
|
-
"@type": "
|
12
|
+
"products": [{
|
13
|
+
"@type": "Product",
|
15
14
|
"value": "",
|
16
15
|
"term.termType": "excreta",
|
17
16
|
"term.units": "kg N",
|
@@ -48,20 +47,18 @@ def _run(excr_tan: float, excr_n: float):
|
|
48
47
|
|
49
48
|
|
50
49
|
def _should_run(cycle: dict):
|
51
|
-
|
52
|
-
excr_n = total_excreta(
|
53
|
-
excr_tan = total_excreta_tan(
|
54
|
-
model_enabled = is_model_enabled(MODEL, TERM_ID, cycle.get('practices', [None])[0])
|
50
|
+
products = cycle.get('products', [])
|
51
|
+
excr_n = total_excreta(products)
|
52
|
+
excr_tan = total_excreta_tan(products)
|
55
53
|
|
56
54
|
set_to_zero = not valid_site_type(cycle) # if site is not water, set value to 0
|
57
55
|
|
58
56
|
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
59
|
-
model_enabled=model_enabled,
|
60
57
|
excr_n=excr_n,
|
61
58
|
excr_tan=excr_tan,
|
62
59
|
set_to_zero=set_to_zero)
|
63
60
|
|
64
|
-
should_run =
|
61
|
+
should_run = any([excr_n or excr_tan or set_to_zero])
|
65
62
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
66
63
|
return should_run, excr_tan, excr_n, set_to_zero
|
67
64
|
|
@@ -3,14 +3,13 @@ from hestia_earth.schema import EmissionMethodTier
|
|
3
3
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
4
4
|
from hestia_earth.models.utils.emission import _new_emission
|
5
5
|
from hestia_earth.models.utils.input import total_excreta, total_excreta_tan
|
6
|
-
from hestia_earth.models.utils.practice import is_model_enabled
|
7
6
|
from hestia_earth.models.utils.aquacultureManagement import valid_site_type
|
8
7
|
from . import MODEL
|
9
8
|
|
10
9
|
REQUIREMENTS = {
|
11
10
|
"Cycle": {
|
12
|
-
"
|
13
|
-
"@type": "
|
11
|
+
"products": [{
|
12
|
+
"@type": "Product",
|
14
13
|
"value": "",
|
15
14
|
"term.termType": "excreta",
|
16
15
|
"term.units": "kg N",
|
@@ -46,20 +45,18 @@ def _run(excr_tan: float, excr_n: float):
|
|
46
45
|
|
47
46
|
|
48
47
|
def _should_run(cycle: dict):
|
49
|
-
|
50
|
-
excr_n = total_excreta(
|
51
|
-
excr_tan = total_excreta_tan(
|
52
|
-
model_enabled = is_model_enabled(MODEL, TERM_ID, cycle.get('practices', [None])[0])
|
48
|
+
products = cycle.get('products', [])
|
49
|
+
excr_n = total_excreta(products)
|
50
|
+
excr_tan = total_excreta_tan(products)
|
53
51
|
|
54
52
|
set_to_zero = not valid_site_type(cycle) # if site is not water, set value to 0
|
55
53
|
|
56
54
|
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
57
|
-
model_enabled=model_enabled,
|
58
55
|
excr_n=excr_n,
|
59
56
|
excr_tan=excr_tan,
|
60
57
|
set_to_zero=set_to_zero)
|
61
58
|
|
62
|
-
should_run =
|
59
|
+
should_run = any([excr_n or excr_tan or set_to_zero])
|
63
60
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
64
61
|
return should_run, excr_tan, excr_n, set_to_zero
|
65
62
|
|
@@ -7,14 +7,13 @@ from hestia_earth.models.utils.constant import Units, get_atomic_conversion
|
|
7
7
|
from hestia_earth.models.utils.site import FRESH_WATER_TYPES
|
8
8
|
from hestia_earth.models.utils.emission import _new_emission
|
9
9
|
from hestia_earth.models.utils.input import total_excreta_tan
|
10
|
-
from hestia_earth.models.utils.practice import is_model_enabled
|
11
10
|
from hestia_earth.models.utils.aquacultureManagement import valid_site_type
|
12
11
|
from . import MODEL
|
13
12
|
|
14
13
|
REQUIREMENTS = {
|
15
14
|
"Cycle": {
|
16
|
-
"
|
17
|
-
"@type": "
|
15
|
+
"products": [{
|
16
|
+
"@type": "Product",
|
18
17
|
"value": "",
|
19
18
|
"term.termType": "excreta",
|
20
19
|
"term.units": "kg N",
|
@@ -65,11 +64,10 @@ def _run(excr_tan: float, yield_of_target_species: float, has_slow_flowing: bool
|
|
65
64
|
|
66
65
|
def _should_run(cycle: dict):
|
67
66
|
practices = cycle.get('practices', [])
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
find_term_match(practices, 'yieldOfPrimaryAquacultureProductLiveweightPerM2').get('value', []))
|
67
|
+
excr_tan = total_excreta_tan(cycle.get('products', []))
|
68
|
+
yield_per_m2 = list_sum(
|
69
|
+
find_term_match(practices, 'yieldOfPrimaryAquacultureProductLiveweightPerM2').get('value', []), default=None
|
70
|
+
)
|
73
71
|
|
74
72
|
measurements = cycle.get('site', {}).get('measurements', [])
|
75
73
|
is_freshwater = cycle.get('site', {}).get('siteType') in FRESH_WATER_TYPES
|
@@ -78,23 +76,21 @@ def _should_run(cycle: dict):
|
|
78
76
|
set_to_zero = not valid_site_type(cycle) # if site is not water, set value to 0
|
79
77
|
|
80
78
|
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
81
|
-
model_enabled=model_enabled,
|
82
79
|
excr_tan=excr_tan,
|
83
|
-
yield_of_target_species=
|
80
|
+
yield_of_target_species=yield_per_m2,
|
84
81
|
has_slow_flowing=has_slow_flowing,
|
85
82
|
is_freshwater=is_freshwater,
|
86
83
|
set_to_zero=set_to_zero)
|
87
84
|
|
88
85
|
should_run = all([
|
89
|
-
model_enabled,
|
90
86
|
excr_tan,
|
91
|
-
not has_slow_flowing or
|
87
|
+
not has_slow_flowing or yield_per_m2 > 0
|
92
88
|
]) or set_to_zero
|
93
89
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
94
|
-
return should_run, excr_tan,
|
90
|
+
return should_run, excr_tan, yield_per_m2, has_slow_flowing, set_to_zero
|
95
91
|
|
96
92
|
|
97
93
|
def run(cycle: dict):
|
98
|
-
should_run, excr_tan,
|
94
|
+
should_run, excr_tan, yield_per_m2, has_slow_flowing, set_to_zero = _should_run(cycle)
|
99
95
|
return [_emission(0)] if set_to_zero else \
|
100
|
-
_run(excr_tan,
|
96
|
+
_run(excr_tan, yield_per_m2, has_slow_flowing) if should_run else []
|
@@ -4,14 +4,13 @@ from hestia_earth.models.log import logRequirements, logShouldRun
|
|
4
4
|
from hestia_earth.models.utils.constant import Units, get_atomic_conversion
|
5
5
|
from hestia_earth.models.utils.emission import _new_emission
|
6
6
|
from hestia_earth.models.utils.input import total_excreta, total_excreta_tan
|
7
|
-
from hestia_earth.models.utils.practice import is_model_enabled
|
8
7
|
from hestia_earth.models.utils.aquacultureManagement import valid_site_type
|
9
8
|
from . import MODEL
|
10
9
|
|
11
10
|
REQUIREMENTS = {
|
12
11
|
"Cycle": {
|
13
|
-
"
|
14
|
-
"@type": "
|
12
|
+
"products": [{
|
13
|
+
"@type": "Product",
|
15
14
|
"value": "",
|
16
15
|
"term.termType": "excreta",
|
17
16
|
"term.units": "kg N",
|
@@ -54,20 +53,18 @@ def _run(excr_tan: float, excr_n: float):
|
|
54
53
|
|
55
54
|
|
56
55
|
def _should_run(cycle: dict):
|
57
|
-
|
58
|
-
excr_n = total_excreta(
|
59
|
-
excr_tan = total_excreta_tan(
|
60
|
-
model_enabled = is_model_enabled(MODEL, TERM_ID, cycle.get('practices', [None])[0])
|
56
|
+
products = cycle.get('products', [])
|
57
|
+
excr_n = total_excreta(products)
|
58
|
+
excr_tan = total_excreta_tan(products)
|
61
59
|
|
62
60
|
set_to_zero = not valid_site_type(cycle) # if site is not water, set value to 0
|
63
61
|
|
64
62
|
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
65
|
-
model_enabled=model_enabled,
|
66
63
|
excr_n=excr_n,
|
67
64
|
excr_tan=excr_tan,
|
68
65
|
set_to_zero=set_to_zero)
|
69
66
|
|
70
|
-
should_run =
|
67
|
+
should_run = any([excr_n or excr_tan or set_to_zero])
|
71
68
|
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
72
69
|
return should_run, excr_tan, excr_n, set_to_zero
|
73
70
|
|
@@ -83,8 +83,8 @@ def get_excreta_product_with_ratio(cycle: dict, lookup: str, **log_args):
|
|
83
83
|
if not product or not product.get('value', [])
|
84
84
|
] if practices_with_products else None
|
85
85
|
|
86
|
-
return products or [{
|
86
|
+
return products or non_empty_list([{
|
87
87
|
'@type': 'Product',
|
88
88
|
'term': {'@type': 'Term', '@id': default_product_id},
|
89
89
|
'value': [100]
|
90
|
-
}]
|
90
|
+
} if default_product_id else None])
|
@@ -1,10 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Default Method Classification.
|
3
|
-
|
4
|
-
When gap-filling `management` node on Site, the
|
5
|
-
`defaultMethodClassification` and `defaultMethodClassificationDescription` fields become required.
|
6
|
-
This model will use the first value in the `management` node.
|
7
|
-
"""
|
8
1
|
from hestia_earth.schema import SiteDefaultMethodClassification
|
9
2
|
|
10
3
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
@@ -1,10 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Default Method Classification Description.
|
3
|
-
|
4
|
-
When gap-filling `management` node on Site, the
|
5
|
-
`defaultMethodClassification` and `defaultMethodClassificationDescription` fields become required.
|
6
|
-
This model will use the first value in the `management` node.
|
7
|
-
"""
|
8
1
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
9
2
|
from . import MODEL
|
10
3
|
|
@@ -1,8 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Flowing Water
|
3
|
-
|
4
|
-
This model returns a measurement of fast flowing water or slow flowing water depending on the type of the site.
|
5
|
-
"""
|
6
1
|
from hestia_earth.schema import MeasurementMethodClassification, SiteSiteType
|
7
2
|
|
8
3
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
@@ -1,24 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Management node
|
3
|
-
|
4
|
-
This model provides data gap-filled data from cycles in the form of a list of management nodes
|
5
|
-
(https://www.hestia.earth/schema/Management).
|
6
|
-
|
7
|
-
It includes products of type crop, forage, landCover (gap-filled with a value of 100) and practices of type waterRegime,
|
8
|
-
tillage, cropResidueManagement and landUseManagement.
|
9
|
-
|
10
|
-
All values are copied from the source node, except for crop and forage terms in which case the dates are copied from the
|
11
|
-
cycle.
|
12
|
-
|
13
|
-
Where `startDate` is missing from landCover products, gap-filling is attempted using
|
14
|
-
`endDate` - `cycleDuration` (or `maximumCycleDuration` lookup).
|
15
|
-
This is the `endDate` of the `landCover` product.
|
16
|
-
This ensures no overlapping date ranges.
|
17
|
-
If both `endDate` and `startDate` are missing from the product, these will be gap-filled from the `Cycle`.
|
18
|
-
|
19
|
-
When nodes are chronologically consecutive with "% area" or "boolean" units and the same term and value, they are
|
20
|
-
condensed into a single node to aid readability.
|
21
|
-
"""
|
22
1
|
from typing import List
|
23
2
|
from datetime import timedelta, datetime
|
24
3
|
from functools import reduce
|
@@ -1,9 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Measurement Value
|
3
|
-
|
4
|
-
This model calculates the `value` of the [Measurement](https://hestia.earth/schema/Measurement)
|
5
|
-
by taking an average from the `min` and `max` values.
|
6
|
-
"""
|
7
1
|
from hestia_earth.utils.tools import non_empty_list, list_average
|
8
2
|
|
9
3
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
@@ -1,8 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Pre Checks Cache Years
|
3
|
-
|
4
|
-
This model caches the years of all Cycles related to this Site.
|
5
|
-
"""
|
6
1
|
from hestia_earth.models.log import debugValues
|
7
2
|
from hestia_earth.models.utils import CACHE_KEY, cached_value
|
8
3
|
from hestia_earth.models.utils.site import CACHE_YEARS_KEY, related_years
|
@@ -1,8 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Soil Measurement
|
3
|
-
|
4
|
-
This model harmonises matching soil measurements into depth ranges of 0-30 and 0-50 and gap fills missing measurements.
|
5
|
-
"""
|
6
1
|
from collections import defaultdict
|
7
2
|
from copy import deepcopy
|
8
3
|
from hestia_earth.schema import MeasurementMethodClassification
|
@@ -1,8 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Input Excreta
|
3
|
-
|
4
|
-
Copy Cycle (or previous Transformation) `excreta` products into the Transformation inputs if they are missing.
|
5
|
-
"""
|
6
1
|
from functools import reduce
|
7
2
|
from hestia_earth.schema import NodeType, TermTermType, Input, Product
|
8
3
|
from hestia_earth.utils.model import filter_list_term_type, find_term_match
|
@@ -1,11 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Input Value
|
3
|
-
|
4
|
-
This model calculates the [Input max](https://hestia.earth/schema/Input#max)
|
5
|
-
by taking the max of the same [Product](https://hestia.earth/schema/Product) of the
|
6
|
-
previous Transformation (or Cycle if first Transformation) and applying the
|
7
|
-
[share](https://hestia.earth/schema/Transformation/transformedShare).
|
8
|
-
"""
|
9
1
|
from functools import reduce
|
10
2
|
from hestia_earth.schema import NodeType
|
11
3
|
|