hestia-earth-models 0.58.0__py3-none-any.whl → 0.59.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hestia-earth-models might be problematic. Click here for more details.
- hestia_earth/models/cycle/{irrigated.py → irrigatedTypeUnspecified.py} +4 -4
- hestia_earth/models/cycle/residueIncorporated.py +1 -1
- hestia_earth/models/emepEea2019/nh3ToAirInorganicFertiliser.py +2 -2
- hestia_earth/models/geospatialDatabase/clayContent.py +17 -4
- hestia_earth/models/geospatialDatabase/sandContent.py +17 -4
- hestia_earth/models/impact_assessment/irrigated.py +0 -3
- hestia_earth/models/ipcc2019/co2ToAirSoilCarbonStockChangeManagementChange.py +10 -9
- hestia_earth/models/ipcc2019/n2OToAirCropResidueDecompositionDirect.py +4 -51
- hestia_earth/models/ipcc2019/n2OToAirInorganicFertiliserDirect.py +104 -0
- hestia_earth/models/ipcc2019/n2OToAirOrganicFertiliserDirect.py +105 -0
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py +1059 -1220
- hestia_earth/models/ipcc2019/utils.py +82 -1
- hestia_earth/models/mocking/search-results.json +161 -87
- hestia_earth/models/site/management.py +12 -9
- hestia_earth/models/site/organicCarbonPerHa.py +251 -89
- hestia_earth/models/utils/blank_node.py +157 -34
- hestia_earth/models/utils/cycle.py +6 -3
- hestia_earth/models/utils/measurement.py +1 -1
- hestia_earth/models/utils/term.py +46 -1
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.58.0.dist-info → hestia_earth_models-0.59.0.dist-info}/METADATA +4 -8
- {hestia_earth_models-0.58.0.dist-info → hestia_earth_models-0.59.0.dist-info}/RECORD +34 -30
- tests/models/cycle/{test_irrigated.py → test_irrigatedTypeUnspecified.py} +1 -1
- tests/models/geospatialDatabase/test_clayContent.py +9 -3
- tests/models/geospatialDatabase/test_sandContent.py +9 -3
- tests/models/ipcc2019/test_n2OToAirInorganicFertiliserDirect.py +74 -0
- tests/models/ipcc2019/test_n2OToAirOrganicFertiliserDirect.py +74 -0
- tests/models/ipcc2019/test_organicCarbonPerHa.py +303 -1044
- tests/models/site/test_organicCarbonPerHa.py +51 -5
- tests/models/utils/test_blank_node.py +102 -42
- tests/models/utils/test_term.py +17 -3
- {hestia_earth_models-0.58.0.dist-info → hestia_earth_models-0.59.0.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.58.0.dist-info → hestia_earth_models-0.59.0.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.58.0.dist-info → hestia_earth_models-0.59.0.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from hestia_earth.
|
|
1
|
+
from hestia_earth.schema import TermTermType
|
|
2
|
+
from hestia_earth.utils.model import find_term_match, filter_list_term_type
|
|
2
3
|
from hestia_earth.utils.tools import safe_parse_float
|
|
3
4
|
|
|
4
5
|
from hestia_earth.models.log import debugValues
|
|
@@ -7,6 +8,7 @@ from hestia_earth.models.utils.cycle import get_ecoClimateZone
|
|
|
7
8
|
from hestia_earth.models.utils.constant import Units, get_atomic_conversion
|
|
8
9
|
from hestia_earth.models.utils.blank_node import find_terms_value
|
|
9
10
|
from hestia_earth.models.utils.term import get_lookup_value, get_milkYield_terms
|
|
11
|
+
from hestia_earth.models.utils.ecoClimateZone import get_ecoClimateZone_lookup_value
|
|
10
12
|
from . import MODEL
|
|
11
13
|
|
|
12
14
|
# From IPCC2019 Indirect N2O emission factor, in N [avg, min, max, std]
|
|
@@ -89,3 +91,82 @@ def check_consecutive(ints: list[int]) -> bool:
|
|
|
89
91
|
"""
|
|
90
92
|
range_list = list(range(min(ints), max(ints)+1)) if ints else []
|
|
91
93
|
return all(a == b for a, b in zip(ints, range_list))
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
N2O_FACTORS = {
|
|
97
|
+
# All N inputs in dry climate
|
|
98
|
+
'dry': {
|
|
99
|
+
'value': 0.005,
|
|
100
|
+
'min': 0,
|
|
101
|
+
'max': 0.011
|
|
102
|
+
},
|
|
103
|
+
'wet': {
|
|
104
|
+
# Synthetic fertiliser inputs in wet climate
|
|
105
|
+
TermTermType.INORGANICFERTILISER: {
|
|
106
|
+
'value': 0.016,
|
|
107
|
+
'min': 0.013,
|
|
108
|
+
'max': 0.019
|
|
109
|
+
},
|
|
110
|
+
# Other N inputs in wet climate
|
|
111
|
+
TermTermType.ORGANICFERTILISER: {
|
|
112
|
+
'value': 0.006,
|
|
113
|
+
'min': 0.001,
|
|
114
|
+
'max': 0.011
|
|
115
|
+
},
|
|
116
|
+
TermTermType.CROPRESIDUE: {
|
|
117
|
+
'value': 0.006,
|
|
118
|
+
'min': 0.001,
|
|
119
|
+
'max': 0.011
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
'default': {
|
|
123
|
+
'value': 0.01,
|
|
124
|
+
'min': 0.001,
|
|
125
|
+
'max': 0.018
|
|
126
|
+
},
|
|
127
|
+
'flooded_rice': {
|
|
128
|
+
'value': 0.004,
|
|
129
|
+
'min': 0,
|
|
130
|
+
'max': 0.029
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _get_waterRegime_lookup(model_term_id: str, practice: dict, col: str):
|
|
136
|
+
return safe_parse_float(get_lookup_value(practice.get('term', {}), col, model=MODEL, term=model_term_id), None)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _is_wet(ecoClimateZone: str = None):
|
|
140
|
+
return get_ecoClimateZone_lookup_value(ecoClimateZone, 'wet') == 1 if ecoClimateZone else None
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _ecoClimate_factors(input_term_type: TermTermType, ecoClimateZone: str = None):
|
|
144
|
+
is_wet = _is_wet(ecoClimateZone)
|
|
145
|
+
factors_key = 'default' if is_wet is None else 'wet' if is_wet else 'dry'
|
|
146
|
+
factors = N2O_FACTORS[factors_key]
|
|
147
|
+
return (factors.get(input_term_type) if factors_key == 'wet' else factors, is_wet is None)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _flooded_rice_factors(model_term_id: str, cycle: dict):
|
|
151
|
+
lookup_name = 'IPCC_2019_N2O_rice'
|
|
152
|
+
practices = filter_list_term_type(cycle.get('practices', []), TermTermType.WATERREGIME)
|
|
153
|
+
practice = next((p for p in practices if _get_waterRegime_lookup(model_term_id, p, lookup_name) is not None), None)
|
|
154
|
+
|
|
155
|
+
factors = {
|
|
156
|
+
'value': _get_waterRegime_lookup(model_term_id, practice, lookup_name),
|
|
157
|
+
'min': _get_waterRegime_lookup(model_term_id, practice, lookup_name + '-min'),
|
|
158
|
+
'max': _get_waterRegime_lookup(model_term_id, practice, lookup_name + '-max')
|
|
159
|
+
} if practice else N2O_FACTORS['flooded_rice']
|
|
160
|
+
|
|
161
|
+
return (factors, practice is None)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def get_N2O_factors(
|
|
165
|
+
model_term_id: str,
|
|
166
|
+
cycle: dict,
|
|
167
|
+
input_term_type: TermTermType,
|
|
168
|
+
ecoClimateZone: str = None,
|
|
169
|
+
flooded_rice: bool = False
|
|
170
|
+
):
|
|
171
|
+
return _flooded_rice_factors(model_term_id, cycle) if flooded_rice \
|
|
172
|
+
else _ecoClimate_factors(input_term_type, ecoClimateZone)
|
|
@@ -839,11 +839,11 @@
|
|
|
839
839
|
},
|
|
840
840
|
{
|
|
841
841
|
"@type": "Term",
|
|
842
|
-
"@id": "
|
|
842
|
+
"@id": "shortFallowCrop"
|
|
843
843
|
},
|
|
844
844
|
{
|
|
845
845
|
"@type": "Term",
|
|
846
|
-
"@id": "
|
|
846
|
+
"@id": "longFallowCrop"
|
|
847
847
|
}
|
|
848
848
|
]
|
|
849
849
|
},
|
|
@@ -914,11 +914,11 @@
|
|
|
914
914
|
"results": [
|
|
915
915
|
{
|
|
916
916
|
"@type": "Term",
|
|
917
|
-
"@id": "
|
|
917
|
+
"@id": "residueRemoved"
|
|
918
918
|
},
|
|
919
919
|
{
|
|
920
920
|
"@type": "Term",
|
|
921
|
-
"@id": "
|
|
921
|
+
"@id": "residueIncorporatedMoreThan30DaysBeforeCultivation"
|
|
922
922
|
},
|
|
923
923
|
{
|
|
924
924
|
"@type": "Term",
|
|
@@ -926,7 +926,7 @@
|
|
|
926
926
|
},
|
|
927
927
|
{
|
|
928
928
|
"@type": "Term",
|
|
929
|
-
"@id": "
|
|
929
|
+
"@id": "residueIncorporatedLessThan30DaysBeforeCultivation"
|
|
930
930
|
},
|
|
931
931
|
{
|
|
932
932
|
"@type": "Term",
|
|
@@ -970,27 +970,27 @@
|
|
|
970
970
|
},
|
|
971
971
|
{
|
|
972
972
|
"@type": "Term",
|
|
973
|
-
"@id": "
|
|
973
|
+
"@id": "discardedCropRemoved"
|
|
974
974
|
},
|
|
975
975
|
{
|
|
976
976
|
"@type": "Term",
|
|
977
|
-
"@id": "
|
|
977
|
+
"@id": "aboveGroundCropResidueTotal"
|
|
978
978
|
},
|
|
979
979
|
{
|
|
980
980
|
"@type": "Term",
|
|
981
|
-
"@id": "
|
|
981
|
+
"@id": "aboveGroundCropResidueIncorporated"
|
|
982
982
|
},
|
|
983
983
|
{
|
|
984
984
|
"@type": "Term",
|
|
985
|
-
"@id": "
|
|
985
|
+
"@id": "aboveGroundCropResidueBurnt"
|
|
986
986
|
},
|
|
987
987
|
{
|
|
988
988
|
"@type": "Term",
|
|
989
|
-
"@id": "
|
|
989
|
+
"@id": "belowGroundCropResidue"
|
|
990
990
|
},
|
|
991
991
|
{
|
|
992
992
|
"@type": "Term",
|
|
993
|
-
"@id": "
|
|
993
|
+
"@id": "aboveGroundCropResidueLeftOnField"
|
|
994
994
|
}
|
|
995
995
|
]
|
|
996
996
|
},
|
|
@@ -1111,67 +1111,67 @@
|
|
|
1111
1111
|
"results": [
|
|
1112
1112
|
{
|
|
1113
1113
|
"@type": "Term",
|
|
1114
|
-
"@id": "
|
|
1114
|
+
"@id": "excretaInsectsKgN"
|
|
1115
1115
|
},
|
|
1116
1116
|
{
|
|
1117
1117
|
"@type": "Term",
|
|
1118
|
-
"@id": "
|
|
1118
|
+
"@id": "excretaBeefCattleFeedlotFedKgN"
|
|
1119
1119
|
},
|
|
1120
1120
|
{
|
|
1121
1121
|
"@type": "Term",
|
|
1122
|
-
"@id": "
|
|
1122
|
+
"@id": "excretaGeeseKgN"
|
|
1123
1123
|
},
|
|
1124
1124
|
{
|
|
1125
1125
|
"@type": "Term",
|
|
1126
|
-
"@id": "
|
|
1126
|
+
"@id": "excretaKgN"
|
|
1127
1127
|
},
|
|
1128
1128
|
{
|
|
1129
1129
|
"@type": "Term",
|
|
1130
|
-
"@id": "
|
|
1130
|
+
"@id": "excretaPoultryKgN"
|
|
1131
1131
|
},
|
|
1132
1132
|
{
|
|
1133
1133
|
"@type": "Term",
|
|
1134
|
-
"@id": "
|
|
1134
|
+
"@id": "excretaGoatsKgN"
|
|
1135
1135
|
},
|
|
1136
1136
|
{
|
|
1137
1137
|
"@type": "Term",
|
|
1138
|
-
"@id": "
|
|
1138
|
+
"@id": "excretaBeefCattleExceptFeedlotFedKgN"
|
|
1139
1139
|
},
|
|
1140
1140
|
{
|
|
1141
1141
|
"@type": "Term",
|
|
1142
|
-
"@id": "
|
|
1142
|
+
"@id": "excretaDeerKgN"
|
|
1143
1143
|
},
|
|
1144
1144
|
{
|
|
1145
1145
|
"@type": "Term",
|
|
1146
|
-
"@id": "
|
|
1146
|
+
"@id": "excretaSolidFishCrustaceansKgN"
|
|
1147
1147
|
},
|
|
1148
1148
|
{
|
|
1149
1149
|
"@type": "Term",
|
|
1150
|
-
"@id": "
|
|
1150
|
+
"@id": "excretaDucksKgN"
|
|
1151
1151
|
},
|
|
1152
1152
|
{
|
|
1153
1153
|
"@type": "Term",
|
|
1154
|
-
"@id": "
|
|
1154
|
+
"@id": "excretaTurkeysKgN"
|
|
1155
1155
|
},
|
|
1156
1156
|
{
|
|
1157
1157
|
"@type": "Term",
|
|
1158
|
-
"@id": "
|
|
1158
|
+
"@id": "excretaMixturesKgN"
|
|
1159
1159
|
},
|
|
1160
1160
|
{
|
|
1161
1161
|
"@type": "Term",
|
|
1162
|
-
"@id": "
|
|
1162
|
+
"@id": "excretaLiquidFishCrustaceansKgN"
|
|
1163
1163
|
},
|
|
1164
1164
|
{
|
|
1165
1165
|
"@type": "Term",
|
|
1166
|
-
"@id": "
|
|
1166
|
+
"@id": "processedExcretaKgN"
|
|
1167
1167
|
},
|
|
1168
1168
|
{
|
|
1169
1169
|
"@type": "Term",
|
|
1170
|
-
"@id": "
|
|
1170
|
+
"@id": "excretaBuffaloKgN"
|
|
1171
1171
|
},
|
|
1172
1172
|
{
|
|
1173
1173
|
"@type": "Term",
|
|
1174
|
-
"@id": "
|
|
1174
|
+
"@id": "excretaSolidAndLiquidFishCrustaceansKgN"
|
|
1175
1175
|
},
|
|
1176
1176
|
{
|
|
1177
1177
|
"@type": "Term",
|
|
@@ -1212,47 +1212,47 @@
|
|
|
1212
1212
|
},
|
|
1213
1213
|
{
|
|
1214
1214
|
"@type": "Term",
|
|
1215
|
-
"@id": "
|
|
1215
|
+
"@id": "excretaPigsKgVs"
|
|
1216
1216
|
},
|
|
1217
1217
|
{
|
|
1218
1218
|
"@type": "Term",
|
|
1219
|
-
"@id": "
|
|
1219
|
+
"@id": "excretaCamelsKgVs"
|
|
1220
1220
|
},
|
|
1221
1221
|
{
|
|
1222
1222
|
"@type": "Term",
|
|
1223
|
-
"@id": "
|
|
1223
|
+
"@id": "excretaDucksKgVs"
|
|
1224
1224
|
},
|
|
1225
1225
|
{
|
|
1226
1226
|
"@type": "Term",
|
|
1227
|
-
"@id": "
|
|
1227
|
+
"@id": "processedExcretaKgVs"
|
|
1228
1228
|
},
|
|
1229
1229
|
{
|
|
1230
1230
|
"@type": "Term",
|
|
1231
|
-
"@id": "
|
|
1231
|
+
"@id": "excretaHorsesMulesAndAssesKgVs"
|
|
1232
1232
|
},
|
|
1233
1233
|
{
|
|
1234
1234
|
"@type": "Term",
|
|
1235
|
-
"@id": "
|
|
1235
|
+
"@id": "excretaBuffaloKgVs"
|
|
1236
1236
|
},
|
|
1237
1237
|
{
|
|
1238
1238
|
"@type": "Term",
|
|
1239
|
-
"@id": "
|
|
1239
|
+
"@id": "excretaTurkeysKgVs"
|
|
1240
1240
|
},
|
|
1241
1241
|
{
|
|
1242
1242
|
"@type": "Term",
|
|
1243
|
-
"@id": "
|
|
1243
|
+
"@id": "excretaLiquidFishCrustaceansKgVs"
|
|
1244
1244
|
},
|
|
1245
1245
|
{
|
|
1246
1246
|
"@type": "Term",
|
|
1247
|
-
"@id": "
|
|
1247
|
+
"@id": "excretaSolidAndLiquidFishCrustaceansKgVs"
|
|
1248
1248
|
},
|
|
1249
1249
|
{
|
|
1250
1250
|
"@type": "Term",
|
|
1251
|
-
"@id": "
|
|
1251
|
+
"@id": "excretaDairyCattleKgVs"
|
|
1252
1252
|
},
|
|
1253
1253
|
{
|
|
1254
1254
|
"@type": "Term",
|
|
1255
|
-
"@id": "
|
|
1255
|
+
"@id": "excretaGeeseKgVs"
|
|
1256
1256
|
},
|
|
1257
1257
|
{
|
|
1258
1258
|
"@type": "Term",
|
|
@@ -1299,7 +1299,7 @@
|
|
|
1299
1299
|
"@type": "Term",
|
|
1300
1300
|
"name": "Generic crop, seed",
|
|
1301
1301
|
"@id": "genericCropSeed",
|
|
1302
|
-
"_score": 24.
|
|
1302
|
+
"_score": 24.857483
|
|
1303
1303
|
}
|
|
1304
1304
|
]
|
|
1305
1305
|
},
|
|
@@ -1349,19 +1349,19 @@
|
|
|
1349
1349
|
},
|
|
1350
1350
|
{
|
|
1351
1351
|
"@type": "Term",
|
|
1352
|
-
"@id": "
|
|
1352
|
+
"@id": "irrigatedContinuouslyFlooded"
|
|
1353
1353
|
},
|
|
1354
1354
|
{
|
|
1355
1355
|
"@type": "Term",
|
|
1356
|
-
"@id": "
|
|
1356
|
+
"@id": "irrigatedSurfaceIrrigation"
|
|
1357
1357
|
},
|
|
1358
1358
|
{
|
|
1359
1359
|
"@type": "Term",
|
|
1360
|
-
"@id": "
|
|
1360
|
+
"@id": "irrigated"
|
|
1361
1361
|
},
|
|
1362
1362
|
{
|
|
1363
1363
|
"@type": "Term",
|
|
1364
|
-
"@id": "
|
|
1364
|
+
"@id": "irrigatedManualIrrigation"
|
|
1365
1365
|
},
|
|
1366
1366
|
{
|
|
1367
1367
|
"@type": "Term",
|
|
@@ -1377,11 +1377,11 @@
|
|
|
1377
1377
|
},
|
|
1378
1378
|
{
|
|
1379
1379
|
"@type": "Term",
|
|
1380
|
-
"@id": "
|
|
1380
|
+
"@id": "irrigatedDripIrrigation"
|
|
1381
1381
|
},
|
|
1382
1382
|
{
|
|
1383
1383
|
"@type": "Term",
|
|
1384
|
-
"@id": "
|
|
1384
|
+
"@id": "irrigatedSprinklerIrrigation"
|
|
1385
1385
|
},
|
|
1386
1386
|
{
|
|
1387
1387
|
"@type": "Term",
|
|
@@ -1536,6 +1536,45 @@
|
|
|
1536
1536
|
}
|
|
1537
1537
|
]
|
|
1538
1538
|
},
|
|
1539
|
+
{
|
|
1540
|
+
"name": "get_long_fallow_land_cover_terms",
|
|
1541
|
+
"query": {
|
|
1542
|
+
"bool": {
|
|
1543
|
+
"must": [
|
|
1544
|
+
{
|
|
1545
|
+
"match": {
|
|
1546
|
+
"@type": "Term"
|
|
1547
|
+
}
|
|
1548
|
+
},
|
|
1549
|
+
{
|
|
1550
|
+
"match": {
|
|
1551
|
+
"termType.keyword": "landCover"
|
|
1552
|
+
}
|
|
1553
|
+
},
|
|
1554
|
+
{
|
|
1555
|
+
"match_phrase_prefix": {
|
|
1556
|
+
"name": "long"
|
|
1557
|
+
}
|
|
1558
|
+
},
|
|
1559
|
+
{
|
|
1560
|
+
"match": {
|
|
1561
|
+
"name": "fallow"
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
]
|
|
1565
|
+
}
|
|
1566
|
+
},
|
|
1567
|
+
"results": [
|
|
1568
|
+
{
|
|
1569
|
+
"@type": "Term",
|
|
1570
|
+
"@id": "longFallow"
|
|
1571
|
+
},
|
|
1572
|
+
{
|
|
1573
|
+
"@type": "Term",
|
|
1574
|
+
"@id": "longBareFallow"
|
|
1575
|
+
}
|
|
1576
|
+
]
|
|
1577
|
+
},
|
|
1539
1578
|
{
|
|
1540
1579
|
"name": "get_milkYield_terms",
|
|
1541
1580
|
"query": {
|
|
@@ -1689,7 +1728,48 @@
|
|
|
1689
1728
|
]
|
|
1690
1729
|
},
|
|
1691
1730
|
{
|
|
1692
|
-
"name": "
|
|
1731
|
+
"name": "get_tillage_terms",
|
|
1732
|
+
"query": {
|
|
1733
|
+
"termType.keyword": "tillage",
|
|
1734
|
+
"name": "tillage"
|
|
1735
|
+
},
|
|
1736
|
+
"results": [
|
|
1737
|
+
{
|
|
1738
|
+
"@type": "Term",
|
|
1739
|
+
"@id": "fullTillage"
|
|
1740
|
+
},
|
|
1741
|
+
{
|
|
1742
|
+
"@type": "Term",
|
|
1743
|
+
"@id": "minimumTillage"
|
|
1744
|
+
},
|
|
1745
|
+
{
|
|
1746
|
+
"@type": "Term",
|
|
1747
|
+
"@id": "ridgeTillage"
|
|
1748
|
+
},
|
|
1749
|
+
{
|
|
1750
|
+
"@type": "Term",
|
|
1751
|
+
"@id": "noTillage"
|
|
1752
|
+
},
|
|
1753
|
+
{
|
|
1754
|
+
"@type": "Term",
|
|
1755
|
+
"@id": "fullInversionTillage"
|
|
1756
|
+
},
|
|
1757
|
+
{
|
|
1758
|
+
"@type": "Term",
|
|
1759
|
+
"@id": "deepTillage"
|
|
1760
|
+
},
|
|
1761
|
+
{
|
|
1762
|
+
"@type": "Term",
|
|
1763
|
+
"@id": "mulchTillage"
|
|
1764
|
+
},
|
|
1765
|
+
{
|
|
1766
|
+
"@type": "Term",
|
|
1767
|
+
"@id": "stripTillage"
|
|
1768
|
+
}
|
|
1769
|
+
]
|
|
1770
|
+
},
|
|
1771
|
+
{
|
|
1772
|
+
"name": "get_upland_rice_crop_terms",
|
|
1693
1773
|
"query": {
|
|
1694
1774
|
"bool": {
|
|
1695
1775
|
"must": [
|
|
@@ -1700,12 +1780,12 @@
|
|
|
1700
1780
|
},
|
|
1701
1781
|
{
|
|
1702
1782
|
"match": {
|
|
1703
|
-
"termType.keyword": "
|
|
1783
|
+
"termType.keyword": "crop"
|
|
1704
1784
|
}
|
|
1705
1785
|
},
|
|
1706
1786
|
{
|
|
1707
1787
|
"match_phrase": {
|
|
1708
|
-
"name": "rice
|
|
1788
|
+
"name": "rice"
|
|
1709
1789
|
}
|
|
1710
1790
|
},
|
|
1711
1791
|
{
|
|
@@ -1719,48 +1799,42 @@
|
|
|
1719
1799
|
"results": [
|
|
1720
1800
|
{
|
|
1721
1801
|
"@type": "Term",
|
|
1722
|
-
"@id": "
|
|
1802
|
+
"@id": "riceGrainInHuskUpland"
|
|
1723
1803
|
}
|
|
1724
1804
|
]
|
|
1725
1805
|
},
|
|
1726
1806
|
{
|
|
1727
|
-
"name": "
|
|
1807
|
+
"name": "get_upland_rice_land_cover_terms",
|
|
1728
1808
|
"query": {
|
|
1729
|
-
"
|
|
1730
|
-
|
|
1809
|
+
"bool": {
|
|
1810
|
+
"must": [
|
|
1811
|
+
{
|
|
1812
|
+
"match": {
|
|
1813
|
+
"@type": "Term"
|
|
1814
|
+
}
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
"match": {
|
|
1818
|
+
"termType.keyword": "landCover"
|
|
1819
|
+
}
|
|
1820
|
+
},
|
|
1821
|
+
{
|
|
1822
|
+
"match_phrase": {
|
|
1823
|
+
"name": "rice plant"
|
|
1824
|
+
}
|
|
1825
|
+
},
|
|
1826
|
+
{
|
|
1827
|
+
"match": {
|
|
1828
|
+
"name": "upland"
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
]
|
|
1832
|
+
}
|
|
1731
1833
|
},
|
|
1732
1834
|
"results": [
|
|
1733
1835
|
{
|
|
1734
1836
|
"@type": "Term",
|
|
1735
|
-
"@id": "
|
|
1736
|
-
},
|
|
1737
|
-
{
|
|
1738
|
-
"@type": "Term",
|
|
1739
|
-
"@id": "noTillage"
|
|
1740
|
-
},
|
|
1741
|
-
{
|
|
1742
|
-
"@type": "Term",
|
|
1743
|
-
"@id": "fullTillage"
|
|
1744
|
-
},
|
|
1745
|
-
{
|
|
1746
|
-
"@type": "Term",
|
|
1747
|
-
"@id": "minimumTillage"
|
|
1748
|
-
},
|
|
1749
|
-
{
|
|
1750
|
-
"@type": "Term",
|
|
1751
|
-
"@id": "fullInversionTillage"
|
|
1752
|
-
},
|
|
1753
|
-
{
|
|
1754
|
-
"@type": "Term",
|
|
1755
|
-
"@id": "deepTillage"
|
|
1756
|
-
},
|
|
1757
|
-
{
|
|
1758
|
-
"@type": "Term",
|
|
1759
|
-
"@id": "mulchTillage"
|
|
1760
|
-
},
|
|
1761
|
-
{
|
|
1762
|
-
"@type": "Term",
|
|
1763
|
-
"@id": "stripTillage"
|
|
1837
|
+
"@id": "ricePlantUpland"
|
|
1764
1838
|
}
|
|
1765
1839
|
]
|
|
1766
1840
|
},
|
|
@@ -1777,11 +1851,11 @@
|
|
|
1777
1851
|
},
|
|
1778
1852
|
{
|
|
1779
1853
|
"@type": "Term",
|
|
1780
|
-
"@id": "
|
|
1854
|
+
"@id": "ureaAmmoniumSulphateKgN"
|
|
1781
1855
|
},
|
|
1782
1856
|
{
|
|
1783
1857
|
"@type": "Term",
|
|
1784
|
-
"@id": "
|
|
1858
|
+
"@id": "ureaFormaldehydeKgN"
|
|
1785
1859
|
},
|
|
1786
1860
|
{
|
|
1787
1861
|
"@type": "Term",
|
|
@@ -1789,11 +1863,11 @@
|
|
|
1789
1863
|
},
|
|
1790
1864
|
{
|
|
1791
1865
|
"@type": "Term",
|
|
1792
|
-
"@id": "
|
|
1866
|
+
"@id": "sulphurCoatedUreaKgN"
|
|
1793
1867
|
},
|
|
1794
1868
|
{
|
|
1795
1869
|
"@type": "Term",
|
|
1796
|
-
"@id": "
|
|
1870
|
+
"@id": "ureaCalciumNitrateKgN"
|
|
1797
1871
|
}
|
|
1798
1872
|
]
|
|
1799
1873
|
},
|
|
@@ -1833,11 +1907,11 @@
|
|
|
1833
1907
|
"results": [
|
|
1834
1908
|
{
|
|
1835
1909
|
"@type": "Term",
|
|
1836
|
-
"@id": "
|
|
1910
|
+
"@id": "woodFuel"
|
|
1837
1911
|
},
|
|
1838
1912
|
{
|
|
1839
1913
|
"@type": "Term",
|
|
1840
|
-
"@id": "
|
|
1914
|
+
"@id": "woodPellets"
|
|
1841
1915
|
},
|
|
1842
1916
|
{
|
|
1843
1917
|
"@type": "Term",
|
|
@@ -79,7 +79,9 @@ def _copy_item_if_exists(source: dict, keys: List[str] = [], dest: dict = {}) ->
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
def _get_landCover_term_id(product: dict) -> str:
|
|
82
|
-
|
|
82
|
+
value = get_lookup_value(product.get('term', {}), LAND_COVER_KEY, model=MODEL, model_key=LAND_COVER_KEY)
|
|
83
|
+
# TODO: what should happen when there are multiple values?
|
|
84
|
+
return value.split(';')[0] if value else None
|
|
83
85
|
|
|
84
86
|
|
|
85
87
|
def _get_items_with_relevant_term_type(cycles: List[dict], item_name: str, relevant_values: list):
|
|
@@ -111,6 +113,11 @@ def should_run(site: dict):
|
|
|
111
113
|
)
|
|
112
114
|
]
|
|
113
115
|
|
|
116
|
+
products_crop_forage = _get_items_with_relevant_term_type(
|
|
117
|
+
cycles=cycles,
|
|
118
|
+
item_name="products",
|
|
119
|
+
relevant_values=[TermTermType.CROP, TermTermType.FORAGE]
|
|
120
|
+
)
|
|
114
121
|
products_crop_forage = [
|
|
115
122
|
_copy_item_if_exists(
|
|
116
123
|
source=product,
|
|
@@ -120,11 +127,7 @@ def should_run(site: dict):
|
|
|
120
127
|
"value": 100
|
|
121
128
|
}
|
|
122
129
|
)
|
|
123
|
-
for product in
|
|
124
|
-
cycles=cycles,
|
|
125
|
-
item_name="products",
|
|
126
|
-
relevant_values=[TermTermType.CROP, TermTermType.FORAGE]
|
|
127
|
-
)
|
|
130
|
+
for product in list(filter(_get_landCover_term_id, products_crop_forage))
|
|
128
131
|
]
|
|
129
132
|
|
|
130
133
|
practices = [
|
|
@@ -150,9 +153,9 @@ def should_run(site: dict):
|
|
|
150
153
|
model=MODEL,
|
|
151
154
|
term=None,
|
|
152
155
|
model_key=MODEL_KEY,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
products_crop_forage_ids=log_blank_nodes_id(products_crop_forage),
|
|
157
|
+
products_land_cover_ids=log_blank_nodes_id(products_land_cover),
|
|
158
|
+
practice_ids=log_blank_nodes_id(practices)
|
|
156
159
|
)
|
|
157
160
|
|
|
158
161
|
_should_run = any(products_crop_forage + products_land_cover + practices)
|