hestia-earth-models 0.64.3__py3-none-any.whl → 0.64.5__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/blonkConsultants2016/ch4ToAirNaturalVegetationBurning.py +5 -9
- hestia_earth/models/blonkConsultants2016/co2ToAirAboveGroundBiomassStockChangeLandUseChange.py +5 -9
- hestia_earth/models/blonkConsultants2016/n2OToAirNaturalVegetationBurningDirect.py +6 -13
- hestia_earth/models/cycle/animal/input/properties.py +6 -0
- hestia_earth/models/cycle/completeness/soilAmendment.py +3 -2
- hestia_earth/models/cycle/concentrateFeed.py +10 -4
- hestia_earth/models/cycle/input/properties.py +6 -0
- hestia_earth/models/cycle/liveAnimal.py +2 -2
- hestia_earth/models/cycle/milkYield.py +3 -3
- hestia_earth/models/cycle/otherSitesArea.py +59 -0
- hestia_earth/models/cycle/otherSitesUnusedDuration.py +9 -8
- hestia_earth/models/cycle/pastureSystem.py +3 -2
- hestia_earth/models/cycle/product/properties.py +6 -0
- hestia_earth/models/cycle/siteArea.py +83 -0
- hestia_earth/models/cycle/stockingDensityAnimalHousingAverage.py +28 -16
- hestia_earth/models/cycle/utils.py +1 -1
- hestia_earth/models/environmentalFootprintV3/soilQualityIndexLandOccupation.py +128 -0
- hestia_earth/models/environmentalFootprintV3/utils.py +17 -0
- hestia_earth/models/fantkeEtAl2016/__init__.py +13 -0
- hestia_earth/models/fantkeEtAl2016/damageToHumanHealthParticulateMatterFormation.py +49 -0
- hestia_earth/models/frischknechtEtAl2000/__init__.py +13 -0
- hestia_earth/models/frischknechtEtAl2000/ionisingRadiationKbqU235Eq.py +90 -0
- hestia_earth/models/ipcc2006/co2ToAirOrganicSoilCultivation.py +17 -6
- hestia_earth/models/ipcc2006/n2OToAirOrganicSoilCultivationDirect.py +17 -6
- hestia_earth/models/ipcc2019/animal/liveweightGain.py +4 -3
- hestia_earth/models/ipcc2019/animal/liveweightPerHead.py +4 -3
- hestia_earth/models/ipcc2019/animal/weightAtMaturity.py +5 -4
- hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +904 -0
- hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChangeManagementChange.py +70 -618
- hestia_earth/models/mocking/search-results.json +390 -318
- hestia_earth/models/pooreNemecek2018/saplings.py +10 -7
- hestia_earth/models/site/management.py +18 -14
- hestia_earth/models/site/soilMeasurement.py +2 -2
- hestia_earth/models/utils/__init__.py +38 -0
- hestia_earth/models/utils/array_builders.py +63 -52
- hestia_earth/models/utils/blank_node.py +137 -82
- hestia_earth/models/utils/descriptive_stats.py +3 -239
- hestia_earth/models/utils/emission.py +6 -2
- hestia_earth/models/utils/feedipedia.py +15 -2
- hestia_earth/models/utils/impact_assessment.py +10 -5
- hestia_earth/models/utils/landCover.py +9 -0
- hestia_earth/models/utils/lookup.py +16 -3
- hestia_earth/models/utils/measurement.py +3 -28
- hestia_earth/models/utils/stats.py +429 -0
- hestia_earth/models/utils/term.py +15 -3
- hestia_earth/models/utils/time_series.py +90 -0
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.64.3.dist-info → hestia_earth_models-0.64.5.dist-info}/METADATA +1 -1
- {hestia_earth_models-0.64.3.dist-info → hestia_earth_models-0.64.5.dist-info}/RECORD +76 -54
- tests/models/blonkConsultants2016/test_ch4ToAirNaturalVegetationBurning.py +2 -2
- tests/models/blonkConsultants2016/test_co2ToAirAboveGroundBiomassStockChangeLandUseChange.py +2 -2
- tests/models/blonkConsultants2016/test_n2OToAirNaturalVegetationBurningDirect.py +2 -2
- tests/models/cycle/completeness/test_soilAmendment.py +1 -1
- tests/models/cycle/test_liveAnimal.py +1 -1
- tests/models/cycle/test_milkYield.py +1 -1
- tests/models/cycle/test_otherSitesArea.py +68 -0
- tests/models/cycle/test_siteArea.py +51 -0
- tests/models/cycle/test_stockingDensityAnimalHousingAverage.py +2 -2
- tests/models/environmentalFootprintV3/test_soilQualityIndexLandOccupation.py +136 -0
- tests/models/fantkeEtAl2016/__init__.py +0 -0
- tests/models/fantkeEtAl2016/test_damageToHumanHealthParticulateMatterFormation.py +20 -0
- tests/models/frischknechtEtAl2000/__init__.py +0 -0
- tests/models/frischknechtEtAl2000/test_ionisingRadiationKbqU235Eq.py +70 -0
- tests/models/ipcc2019/test_co2ToAirCarbonStockChange_utils.py +50 -0
- tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChangeManagementChange.py +1 -39
- tests/models/pooreNemecek2018/test_saplings.py +1 -1
- tests/models/site/test_management.py +3 -153
- tests/models/utils/test_array_builders.py +67 -6
- tests/models/utils/test_blank_node.py +191 -7
- tests/models/utils/test_descriptive_stats.py +2 -86
- tests/models/utils/test_measurement.py +1 -22
- tests/models/utils/test_stats.py +186 -0
- tests/models/utils/test_time_series.py +88 -0
- {hestia_earth_models-0.64.3.dist-info → hestia_earth_models-0.64.5.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.64.3.dist-info → hestia_earth_models-0.64.5.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.64.3.dist-info → hestia_earth_models-0.64.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from hestia_earth.schema import TermTermType
|
|
2
|
+
from hestia_earth.utils.lookup import download_lookup
|
|
3
|
+
from hestia_earth.utils.tools import list_sum, non_empty_list
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.log import logRequirements, logShouldRun, log_as_table
|
|
6
|
+
from hestia_earth.models.utils import hectar_to_square_meter, days_to_years
|
|
7
|
+
from hestia_earth.models.utils.blank_node import most_relevant_blank_node_by_type
|
|
8
|
+
from hestia_earth.models.utils.indicator import _new_indicator
|
|
9
|
+
from hestia_earth.models.utils.landCover import get_pef_grouping
|
|
10
|
+
from hestia_earth.models.utils.lookup import fallback_country
|
|
11
|
+
from . import MODEL
|
|
12
|
+
from .utils import get_coefficient_factor
|
|
13
|
+
|
|
14
|
+
REQUIREMENTS = {
|
|
15
|
+
"Cycle": {
|
|
16
|
+
"siteDuration": "> 0",
|
|
17
|
+
"siteArea": "> 0",
|
|
18
|
+
"site": {"siteType": "",
|
|
19
|
+
"@type": "Site",
|
|
20
|
+
"management": [{"@type": "Management", "value": "", "term.termType": "landCover"}],
|
|
21
|
+
"country": {"@type": "Term", "termType": "region"}
|
|
22
|
+
},
|
|
23
|
+
"optional": {
|
|
24
|
+
"otherSitesDuration": "> 0",
|
|
25
|
+
"otherSitesArea": "> 0",
|
|
26
|
+
"otherSites": [
|
|
27
|
+
{
|
|
28
|
+
"siteType": "",
|
|
29
|
+
"@type": "Site",
|
|
30
|
+
"management": [{"@type": "Management", "value": "", "term.termType": "landCover"}],
|
|
31
|
+
"country": {"@type": "Term", "termType": "region"}
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
LOOKUPS = {
|
|
38
|
+
"@doc": "Performs lookup on landCover.csv for column headers and region-pefTermGrouping-landOccupation.csv for CFs",
|
|
39
|
+
"region-pefTermGrouping-landOccupation": "",
|
|
40
|
+
"landCover": [
|
|
41
|
+
"pefTermGrouping"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
RETURNS = {
|
|
46
|
+
"Indicator": {
|
|
47
|
+
"value": ""
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
TERM_ID = 'soilQualityIndexLandOccupation'
|
|
51
|
+
LOOKUP = f"{list(LOOKUPS.keys())[1]}.csv"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _indicator(value: float):
|
|
55
|
+
indicator = _new_indicator(TERM_ID, MODEL)
|
|
56
|
+
indicator['value'] = value
|
|
57
|
+
return indicator
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _run(sites: list):
|
|
61
|
+
values = [site['coeff'] * hectar_to_square_meter(site['area']) * days_to_years(site['duration']) for site in sites]
|
|
62
|
+
return _indicator(list_sum(values)) if values else None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _should_run(cycle: dict):
|
|
66
|
+
end_date = cycle.get('endDate')
|
|
67
|
+
|
|
68
|
+
has_site = bool(cycle.get('site', False))
|
|
69
|
+
has_other_sites = bool(cycle.get('otherSites', []))
|
|
70
|
+
|
|
71
|
+
all_sites = non_empty_list([cycle.get('site')] + cycle.get('otherSites', []))
|
|
72
|
+
site_areas = [cycle.get('siteArea')] + cycle.get('otherSitesArea', [])
|
|
73
|
+
site_durations = [cycle.get('siteDuration')] + cycle.get('otherSitesDuration', [])
|
|
74
|
+
|
|
75
|
+
sites = [
|
|
76
|
+
{
|
|
77
|
+
'site-type': site.get('siteType'),
|
|
78
|
+
'country-id': site.get('country', {}).get('@id'),
|
|
79
|
+
'area': site_areas[index],
|
|
80
|
+
'duration': site_durations[index],
|
|
81
|
+
'landCover-id': (most_relevant_blank_node_by_type(
|
|
82
|
+
site.get("management", []),
|
|
83
|
+
term_type=TermTermType.LANDCOVER.value,
|
|
84
|
+
date=end_date
|
|
85
|
+
) or {}).get('term', {}).get('@id'),
|
|
86
|
+
}
|
|
87
|
+
for index, site in enumerate(all_sites)
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
sites = [
|
|
91
|
+
site for site in sites
|
|
92
|
+
if all([
|
|
93
|
+
site.get('area', 0) > 0,
|
|
94
|
+
site.get('duration', 0) > 0,
|
|
95
|
+
site.get('landCover-id'),
|
|
96
|
+
])
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
sites = [
|
|
100
|
+
site |
|
|
101
|
+
{
|
|
102
|
+
'coeff': get_coefficient_factor(
|
|
103
|
+
LOOKUP,
|
|
104
|
+
fallback_country(site.get('country-id'), [download_lookup(LOOKUP)]),
|
|
105
|
+
get_pef_grouping(site.get('landCover-id')),
|
|
106
|
+
term_id=TERM_ID
|
|
107
|
+
)
|
|
108
|
+
} for site in sites
|
|
109
|
+
]
|
|
110
|
+
valid_sites = [site for site in sites if site.get('coeff') is not None]
|
|
111
|
+
|
|
112
|
+
has_valid_sites = bool(valid_sites)
|
|
113
|
+
|
|
114
|
+
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
|
115
|
+
has_valid_sites=has_valid_sites,
|
|
116
|
+
has_site=has_site,
|
|
117
|
+
has_other_sites=has_other_sites,
|
|
118
|
+
valid_sites=log_as_table(valid_sites),
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
should_run = all([has_valid_sites])
|
|
122
|
+
logShouldRun(cycle, MODEL, TERM_ID, should_run)
|
|
123
|
+
return should_run, valid_sites
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def run(cycle: dict):
|
|
127
|
+
should_run, sites = _should_run(cycle)
|
|
128
|
+
return _run(sites) if should_run else None
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
from hestia_earth.utils.lookup import download_lookup
|
|
3
|
+
from hestia_earth.utils.lookup import get_table_value, column_name
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.log import debugMissingLookup
|
|
6
|
+
from . import MODEL
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_coefficient_factor(lookup_name: str, country_id: str, occupation_type: Optional[str], term_id: str):
|
|
10
|
+
"""
|
|
11
|
+
Gets the EU PEF Characteristic factor for a given eu site type and country
|
|
12
|
+
"""
|
|
13
|
+
coefficient = get_table_value(download_lookup(lookup_name), 'termid', country_id, column_name(occupation_type))
|
|
14
|
+
debugMissingLookup(
|
|
15
|
+
lookup_name, 'termid', country_id, column_name(occupation_type), coefficient, model=MODEL, term=term_id
|
|
16
|
+
)
|
|
17
|
+
return coefficient
|
|
@@ -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 = 'fantkeEtAl2016'
|
|
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,49 @@
|
|
|
1
|
+
from hestia_earth.utils.lookup import column_name
|
|
2
|
+
|
|
3
|
+
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
4
|
+
from . import MODEL
|
|
5
|
+
from ..utils.impact_assessment import impact_lookup_value
|
|
6
|
+
from ..utils.indicator import _new_indicator
|
|
7
|
+
|
|
8
|
+
REQUIREMENTS = {
|
|
9
|
+
"ImpactAssessment": {
|
|
10
|
+
"emissionsResourceUse": [
|
|
11
|
+
{
|
|
12
|
+
"@type": "Indicator", "value": "", "term.termType": "emission"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
TERM_ID = 'damageToHumanHealthParticulateMatterFormation'
|
|
19
|
+
|
|
20
|
+
LOOKUPS = {
|
|
21
|
+
"emission": "damageToHumanHealthParticulateMatterFormationFantkeEtAl2016"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
RETURNS = {
|
|
25
|
+
"Indicator": {
|
|
26
|
+
"value": ""
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
default_group_key = 'default'
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _indicator(value: float):
|
|
34
|
+
indicator = _new_indicator(TERM_ID, MODEL)
|
|
35
|
+
indicator['value'] = value
|
|
36
|
+
return indicator
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def run(impact_assessment: dict):
|
|
40
|
+
value = impact_lookup_value(model=MODEL, term_id=TERM_ID, impact=impact_assessment,
|
|
41
|
+
lookup_col=column_name(LOOKUPS['emission']),
|
|
42
|
+
grouped_key=default_group_key)
|
|
43
|
+
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
44
|
+
value=value)
|
|
45
|
+
|
|
46
|
+
should_run = all([value is not None])
|
|
47
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, should_run)
|
|
48
|
+
|
|
49
|
+
return _indicator(value) if should_run else None
|
|
@@ -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 = 'frischknechtEtAl2000'
|
|
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,90 @@
|
|
|
1
|
+
from functools import reduce
|
|
2
|
+
from hestia_earth.schema import TermTermType
|
|
3
|
+
from hestia_earth.utils.tools import list_sum, flatten, non_empty_list
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
6
|
+
from hestia_earth.models.utils.emission import filter_emission_inputs
|
|
7
|
+
from hestia_earth.models.utils.indicator import _new_indicator
|
|
8
|
+
from hestia_earth.models.utils.lookup import factor_value
|
|
9
|
+
from . import MODEL
|
|
10
|
+
|
|
11
|
+
REQUIREMENTS = {
|
|
12
|
+
"ImpactAssessment": {
|
|
13
|
+
"emissionsResourceUse": [{
|
|
14
|
+
"@type": "Indicator",
|
|
15
|
+
"value": "",
|
|
16
|
+
"term.@id": [
|
|
17
|
+
"ionisingCompoundsToAirInputsProduction",
|
|
18
|
+
"ionisingCompoundsToWaterInputsProduction",
|
|
19
|
+
"ionisingCompoundsToSaltwaterInputsProduction"
|
|
20
|
+
],
|
|
21
|
+
"inputs": [{"@type": "Input", "term.termType": "waste"}]
|
|
22
|
+
}]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
LOOKUPS = {
|
|
26
|
+
"waste": [
|
|
27
|
+
"ionisingCompoundsToAirInputsProduction",
|
|
28
|
+
"ionisingCompoundsToWaterInputsProduction",
|
|
29
|
+
"ionisingCompoundsToSaltwaterInputsProduction"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
RETURNS = {
|
|
33
|
+
"Indicator": {
|
|
34
|
+
"value": "",
|
|
35
|
+
"inputs": ""
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
TERM_ID = 'ionisingRadiationKbqU235Eq'
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _indicator(value: float, input: dict):
|
|
43
|
+
indicator = _new_indicator(TERM_ID, MODEL)
|
|
44
|
+
indicator['value'] = value
|
|
45
|
+
indicator['inputs'] = [input]
|
|
46
|
+
return indicator
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _run(grouped_emissions_inputs: list):
|
|
50
|
+
input = grouped_emissions_inputs[0].get('input')
|
|
51
|
+
values = [
|
|
52
|
+
factor_value(
|
|
53
|
+
model=MODEL,
|
|
54
|
+
term_id=TERM_ID,
|
|
55
|
+
lookup_name=f"{TermTermType.WASTE.value}.csv",
|
|
56
|
+
lookup_col=i.get('emission').get('term', {}).get('@id')
|
|
57
|
+
)(data=i.get('emission') | {'term': i.get('input')})
|
|
58
|
+
for i in grouped_emissions_inputs
|
|
59
|
+
]
|
|
60
|
+
value = list_sum(values)
|
|
61
|
+
return _indicator(value, input) if value else None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _should_run(impact_assessment: dict):
|
|
65
|
+
emissions = flatten([
|
|
66
|
+
([
|
|
67
|
+
{'emission': emission, 'input': input}
|
|
68
|
+
for input in filter_emission_inputs(emission, TermTermType.WASTE)
|
|
69
|
+
])
|
|
70
|
+
for emission in impact_assessment.get('emissionsResourceUse', [])
|
|
71
|
+
if emission.get('term', {}).get('@id') in LOOKUPS[TermTermType.WASTE.value]
|
|
72
|
+
])
|
|
73
|
+
emissions_per_input = reduce(
|
|
74
|
+
lambda p, c: p | {c.get('input').get('@id'): p.get(c.get('input').get('@id'), []) + [c]},
|
|
75
|
+
emissions,
|
|
76
|
+
{}
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
logRequirements(impact_assessment, model=MODEL,
|
|
80
|
+
has_emissions=bool(emissions_per_input))
|
|
81
|
+
|
|
82
|
+
should_run = all([emissions_per_input])
|
|
83
|
+
|
|
84
|
+
logShouldRun(impact_assessment, MODEL, TERM_ID, should_run)
|
|
85
|
+
return should_run, emissions_per_input
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def run(impact_assessment: dict):
|
|
89
|
+
should_run, emissions_per_input = _should_run(impact_assessment)
|
|
90
|
+
return non_empty_list(map(_run, emissions_per_input.values())) if should_run else []
|
|
@@ -10,12 +10,23 @@ from . import MODEL
|
|
|
10
10
|
|
|
11
11
|
REQUIREMENTS = {
|
|
12
12
|
"Cycle": {
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
"or": [
|
|
14
|
+
{
|
|
15
|
+
"cycleDuration": "",
|
|
16
|
+
"practices": [{"@type": "Practice", "value": "", "term.@id": "longFallowRatio"}]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"@doc": "for plantations, additional properties are required",
|
|
20
|
+
"practices": [
|
|
21
|
+
{"@type": "Practice", "value": "", "term.@id": "nurseryDensity"},
|
|
22
|
+
{"@type": "Practice", "value": "", "term.@id": "nurseryDuration"},
|
|
23
|
+
{"@type": "Practice", "value": "", "term.@id": "plantationProductiveLifespan"},
|
|
24
|
+
{"@type": "Practice", "value": "", "term.@id": "plantationDensity"},
|
|
25
|
+
{"@type": "Practice", "value": "", "term.@id": "plantationLifespan"},
|
|
26
|
+
{"@type": "Practice", "value": "", "term.@id": "rotationDuration"}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
],
|
|
19
30
|
"site": {
|
|
20
31
|
"@type": "Site",
|
|
21
32
|
"measurements": [
|
|
@@ -10,12 +10,23 @@ from . import MODEL
|
|
|
10
10
|
|
|
11
11
|
REQUIREMENTS = {
|
|
12
12
|
"Cycle": {
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
"or": [
|
|
14
|
+
{
|
|
15
|
+
"cycleDuration": "",
|
|
16
|
+
"practices": [{"@type": "Practice", "value": "", "term.@id": "longFallowRatio"}]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"@doc": "for plantations, additional properties are required",
|
|
20
|
+
"practices": [
|
|
21
|
+
{"@type": "Practice", "value": "", "term.@id": "nurseryDensity"},
|
|
22
|
+
{"@type": "Practice", "value": "", "term.@id": "nurseryDuration"},
|
|
23
|
+
{"@type": "Practice", "value": "", "term.@id": "plantationProductiveLifespan"},
|
|
24
|
+
{"@type": "Practice", "value": "", "term.@id": "plantationDensity"},
|
|
25
|
+
{"@type": "Practice", "value": "", "term.@id": "plantationLifespan"},
|
|
26
|
+
{"@type": "Practice", "value": "", "term.@id": "rotationDuration"}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
],
|
|
19
30
|
"site": {
|
|
20
31
|
"@type": "Site",
|
|
21
32
|
"measurements": [
|
|
@@ -65,10 +65,11 @@ def _should_run(cycle: dict):
|
|
|
65
65
|
} for animal in live_animals]
|
|
66
66
|
|
|
67
67
|
def _should_run_animal(value: dict):
|
|
68
|
+
animal = value.get('animal')
|
|
68
69
|
lookup_value = value.get('value')
|
|
69
|
-
term_id =
|
|
70
|
+
term_id = animal.get('term').get('@id')
|
|
70
71
|
|
|
71
|
-
logRequirements(cycle, model=MODEL, term=term_id,
|
|
72
|
+
logRequirements(cycle, model=MODEL, term=term_id, property=TERM_ID,
|
|
72
73
|
country_id=country_id,
|
|
73
74
|
liveweightGain=lookup_value)
|
|
74
75
|
|
|
@@ -76,7 +77,7 @@ def _should_run(cycle: dict):
|
|
|
76
77
|
country_id,
|
|
77
78
|
lookup_value is not None
|
|
78
79
|
])
|
|
79
|
-
logShouldRun(cycle, MODEL, term_id, should_run)
|
|
80
|
+
logShouldRun(cycle, MODEL, term_id, should_run, property=TERM_ID)
|
|
80
81
|
|
|
81
82
|
return should_run
|
|
82
83
|
|
|
@@ -65,10 +65,11 @@ def _should_run(cycle: dict):
|
|
|
65
65
|
} for animal in live_animals]
|
|
66
66
|
|
|
67
67
|
def _should_run_animal(value: dict):
|
|
68
|
+
animal = value.get('animal')
|
|
68
69
|
lookup_value = value.get('value')
|
|
69
|
-
term_id =
|
|
70
|
+
term_id = animal.get('term').get('@id')
|
|
70
71
|
|
|
71
|
-
logRequirements(cycle, model=MODEL, term=term_id,
|
|
72
|
+
logRequirements(cycle, model=MODEL, term=term_id, property=TERM_ID,
|
|
72
73
|
country_id=country_id,
|
|
73
74
|
liveweightPerHead=lookup_value)
|
|
74
75
|
|
|
@@ -76,7 +77,7 @@ def _should_run(cycle: dict):
|
|
|
76
77
|
country_id,
|
|
77
78
|
lookup_value is not None
|
|
78
79
|
])
|
|
79
|
-
logShouldRun(cycle, MODEL, term_id, should_run)
|
|
80
|
+
logShouldRun(cycle, MODEL, term_id, should_run, property=TERM_ID)
|
|
80
81
|
|
|
81
82
|
return should_run
|
|
82
83
|
|
|
@@ -76,12 +76,13 @@ def _should_run(cycle: dict):
|
|
|
76
76
|
} for animal in live_animals]
|
|
77
77
|
|
|
78
78
|
def _should_run_animal(value: dict):
|
|
79
|
+
animal = value.get('animal')
|
|
79
80
|
lookup_value = value.get('value')
|
|
80
|
-
term_id =
|
|
81
|
-
liveweightPerHead = find_term_match(
|
|
81
|
+
term_id = animal.get('term').get('@id')
|
|
82
|
+
liveweightPerHead = find_term_match(animal.get('properties', []), 'liveweightPerHead', {})
|
|
82
83
|
liveweightPerHead_value = liveweightPerHead.get('value')
|
|
83
84
|
|
|
84
|
-
logRequirements(cycle, model=MODEL, term=term_id,
|
|
85
|
+
logRequirements(cycle, model=MODEL, term=term_id, property=TERM_ID,
|
|
85
86
|
country_id=country_id,
|
|
86
87
|
weightAtMaturity=lookup_value,
|
|
87
88
|
liveweightPerHead=liveweightPerHead_value)
|
|
@@ -91,7 +92,7 @@ def _should_run(cycle: dict):
|
|
|
91
92
|
lookup_value is not None,
|
|
92
93
|
lookup_value is None or liveweightPerHead_value is None or lookup_value >= liveweightPerHead_value
|
|
93
94
|
])
|
|
94
|
-
logShouldRun(cycle, MODEL, term_id, should_run)
|
|
95
|
+
logShouldRun(cycle, MODEL, term_id, should_run, property=TERM_ID)
|
|
95
96
|
|
|
96
97
|
return should_run
|
|
97
98
|
|