hestia-earth-models 0.62.2__py3-none-any.whl → 0.62.3__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/agribalyse2016/fuelElectricity.py +1 -1
- hestia_earth/models/cycle/animal/input/hestiaAggregatedData.py +1 -1
- hestia_earth/models/cycle/cycleDuration.py +7 -2
- hestia_earth/models/cycle/input/hestiaAggregatedData.py +1 -1
- hestia_earth/models/cycle/product/price.py +5 -1
- hestia_earth/models/cycle/product/revenue.py +6 -7
- hestia_earth/models/ecoinventV3/__init__.py +25 -52
- hestia_earth/models/ecoinventV3/utils.py +40 -0
- hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py +92 -91
- hestia_earth/models/ecoinventV3AndEmberClimate/utils.py +15 -105
- hestia_earth/models/faostat2018/product/price.py +1 -2
- hestia_earth/models/geospatialDatabase/croppingIntensity.py +2 -1
- hestia_earth/models/geospatialDatabase/utils.py +1 -1
- hestia_earth/models/ipcc2019/aboveGroundCropResidueTotal.py +15 -10
- hestia_earth/models/ipcc2019/belowGroundCropResidue.py +16 -11
- hestia_earth/models/ipcc2019/carbonContent.py +1 -1
- hestia_earth/models/ipcc2019/croppingDuration.py +2 -2
- hestia_earth/models/ipcc2019/ligninContent.py +1 -1
- hestia_earth/models/ipcc2019/nitrogenContent.py +1 -1
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py +3 -3
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1_utils.py +5 -5
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2_utils.py +17 -17
- hestia_earth/models/koble2014/cropResidueManagement.py +1 -1
- hestia_earth/models/linkedImpactAssessment/emissions.py +15 -14
- hestia_earth/models/mocking/search-results.json +3 -155
- hestia_earth/models/pooreNemecek2018/longFallowPeriod.py +1 -1
- hestia_earth/models/preload_requests.py +1 -1
- hestia_earth/models/requirements.py +6 -6
- hestia_earth/models/site/management.py +29 -52
- hestia_earth/models/site/organicCarbonPerHa.py +1 -1
- hestia_earth/models/utils/__init__.py +1 -1
- hestia_earth/models/utils/blank_node.py +14 -9
- hestia_earth/models/utils/cycle.py +12 -12
- hestia_earth/models/utils/measurement.py +3 -3
- hestia_earth/models/utils/site.py +0 -7
- hestia_earth/models/utils/term.py +3 -22
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.62.2.dist-info → hestia_earth_models-0.62.3.dist-info}/METADATA +12 -12
- {hestia_earth_models-0.62.2.dist-info → hestia_earth_models-0.62.3.dist-info}/RECORD +47 -46
- {hestia_earth_models-0.62.2.dist-info → hestia_earth_models-0.62.3.dist-info}/WHEEL +1 -1
- tests/models/cycle/product/test_revenue.py +0 -3
- tests/models/cycle/test_cycleDuration.py +1 -1
- tests/models/site/test_management.py +3 -31
- tests/models/test_ecoinventV3.py +12 -0
- tests/models/test_ecoinventV3AndEmberClimate.py +5 -72
- {hestia_earth_models-0.62.2.dist-info → hestia_earth_models-0.62.3.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.62.2.dist-info → hestia_earth_models-0.62.3.dist-info}/top_level.txt +0 -0
|
@@ -353,7 +353,7 @@ def get_single_returns(model: str, key: str):
|
|
|
353
353
|
Returns
|
|
354
354
|
-------
|
|
355
355
|
list
|
|
356
|
-
The returned data following
|
|
356
|
+
The returned data following HESTIA's schema.
|
|
357
357
|
"""
|
|
358
358
|
returns = _model_returns({'model': model, 'key': key})
|
|
359
359
|
return_type = list(returns.keys())[0] if returns else None
|
|
@@ -368,7 +368,7 @@ def list_models(
|
|
|
368
368
|
termType: str = None, tier: str = None, productTermId: str = None, productTermType: str = None, siteType: str = None
|
|
369
369
|
) -> list:
|
|
370
370
|
"""
|
|
371
|
-
Return list of models present in
|
|
371
|
+
Return list of models present in HESTIA.
|
|
372
372
|
|
|
373
373
|
Parameters
|
|
374
374
|
----------
|
|
@@ -410,7 +410,7 @@ def get_models(termId: str):
|
|
|
410
410
|
Returns
|
|
411
411
|
-------
|
|
412
412
|
list
|
|
413
|
-
The list of modelscurrently in
|
|
413
|
+
The list of modelscurrently in HESTIA that are matching this Term (as `{"model": model, "key": key}`).
|
|
414
414
|
"""
|
|
415
415
|
return list(filter(lambda m: m.get('key') == termId, ALL_MODELS))
|
|
416
416
|
|
|
@@ -420,7 +420,7 @@ def get_all(
|
|
|
420
420
|
termType: str = None, tier: str = None, productTermId: str = None, productTermType: str = None, siteType: str = None
|
|
421
421
|
) -> list:
|
|
422
422
|
"""
|
|
423
|
-
Get the requirements to run all the models in
|
|
423
|
+
Get the requirements to run all the models in HESTIA.
|
|
424
424
|
|
|
425
425
|
Parameters
|
|
426
426
|
----------
|
|
@@ -441,7 +441,7 @@ def get_all(
|
|
|
441
441
|
Returns
|
|
442
442
|
-------
|
|
443
443
|
list
|
|
444
|
-
The data requirements following
|
|
444
|
+
The data requirements following HESTIA's schema as multiple nodes.
|
|
445
445
|
"""
|
|
446
446
|
models = list_models(
|
|
447
447
|
termType=termType, tier=tier, productTermId=productTermId, productTermType=productTermType, siteType=siteType
|
|
@@ -469,7 +469,7 @@ def get_single(model: str, key: str) -> list:
|
|
|
469
469
|
Returns
|
|
470
470
|
-------
|
|
471
471
|
list
|
|
472
|
-
The data requirements following
|
|
472
|
+
The data requirements following HESTIA's schema as multiple nodes.
|
|
473
473
|
"""
|
|
474
474
|
model = {'model': model, 'key': key}
|
|
475
475
|
linked_models = _recursive_linked_models(model)
|
|
@@ -18,14 +18,13 @@ from functools import reduce
|
|
|
18
18
|
from hestia_earth.schema import SchemaType, TermTermType
|
|
19
19
|
from hestia_earth.utils.api import download_hestia
|
|
20
20
|
from hestia_earth.utils.model import filter_list_term_type, linked_node
|
|
21
|
-
from hestia_earth.utils.tools import safe_parse_float
|
|
21
|
+
from hestia_earth.utils.tools import flatten, safe_parse_float
|
|
22
22
|
from hestia_earth.utils.blank_node import get_node_value
|
|
23
23
|
|
|
24
24
|
from hestia_earth.models.log import logRequirements, logShouldRun, log_blank_nodes_id
|
|
25
25
|
from hestia_earth.models.utils.term import get_lookup_value
|
|
26
26
|
from hestia_earth.models.utils.blank_node import condense_nodes
|
|
27
27
|
from hestia_earth.models.utils.site import related_cycles
|
|
28
|
-
from hestia_earth.models.utils.site import get_land_cover_term_id as get_landCover_term_id_from_site_type
|
|
29
28
|
from . import MODEL
|
|
30
29
|
|
|
31
30
|
REQUIREMENTS = {
|
|
@@ -131,16 +130,14 @@ def _extract_node_value(node: dict) -> dict:
|
|
|
131
130
|
return node | {'value': get_node_value(node)}
|
|
132
131
|
|
|
133
132
|
|
|
134
|
-
def _include(value: dict, keys: list)
|
|
133
|
+
def _include(value: dict, keys: list): return {k: v for k, v in value.items() if k in keys}
|
|
135
134
|
|
|
136
135
|
|
|
137
|
-
def _default_dates(cycle: dict, values: list)
|
|
138
|
-
"""Only uses the dates from the cycle if they are missing from the item."""
|
|
136
|
+
def _default_dates(cycle: dict, values: list):
|
|
139
137
|
return [(_include(cycle, ["startDate", "endDate"]) | v) for v in values]
|
|
140
138
|
|
|
141
139
|
|
|
142
140
|
def _overwrite_dates(cycle: dict, values: list) -> list:
|
|
143
|
-
"""Always uses the dates from the cycle."""
|
|
144
141
|
return [v | _include(cycle, ["startDate", "endDate"]) for v in values]
|
|
145
142
|
|
|
146
143
|
|
|
@@ -152,21 +149,22 @@ def _copy_item_if_exists(source: dict, keys: list[str] = None, dest: dict = None
|
|
|
152
149
|
|
|
153
150
|
def _get_landCover_term_id(product: dict) -> str:
|
|
154
151
|
value = get_lookup_value(product.get('term', {}), LAND_COVER_KEY, model=MODEL, model_key=LAND_COVER_KEY)
|
|
152
|
+
# TODO: what should happen when there are multiple values?
|
|
155
153
|
return value.split(';')[0] if value else None
|
|
156
154
|
|
|
157
155
|
|
|
158
|
-
def
|
|
159
|
-
|
|
160
|
-
)
|
|
161
|
-
"""
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
156
|
+
def _get_items_with_relevant_term_type(
|
|
157
|
+
cycles: list[dict], item_name: str, relevant_values: list, date_fill: callable = _default_dates
|
|
158
|
+
):
|
|
159
|
+
"""Get items from the list of cycles with any of the relevant values. Also adds dates if missing."""
|
|
160
|
+
return flatten(
|
|
161
|
+
[
|
|
162
|
+
date_fill(
|
|
163
|
+
cycle=cycle,
|
|
164
|
+
values=filter_list_term_type(cycle.get(item_name, []), relevant_values)
|
|
165
|
+
) for cycle in cycles
|
|
166
|
+
]
|
|
167
|
+
)
|
|
170
168
|
|
|
171
169
|
|
|
172
170
|
def _get_lookup_with_debug(term: dict, column: str) -> any:
|
|
@@ -213,23 +211,27 @@ def _get_relevant_inputs(cycles: list[dict]) -> list:
|
|
|
213
211
|
return relevant_inputs
|
|
214
212
|
|
|
215
213
|
|
|
216
|
-
def
|
|
214
|
+
def _should_run(site: dict):
|
|
215
|
+
# Only get related cycles once.
|
|
216
|
+
cycles = related_cycles(site)
|
|
217
|
+
|
|
217
218
|
products_land_cover = [
|
|
218
219
|
_extract_node_value(
|
|
219
220
|
_include(
|
|
220
221
|
value=product,
|
|
221
222
|
keys=["term", "value", "startDate", "endDate", "properties"]
|
|
222
223
|
)
|
|
223
|
-
) for product
|
|
224
|
+
) for product in _get_items_with_relevant_term_type(
|
|
224
225
|
cycles=cycles,
|
|
225
226
|
item_name="products",
|
|
226
|
-
|
|
227
|
+
relevant_values=[TermTermType.LANDCOVER]
|
|
227
228
|
)
|
|
228
229
|
]
|
|
229
|
-
|
|
230
|
+
|
|
231
|
+
products_crop_forage = _get_items_with_relevant_term_type(
|
|
230
232
|
cycles=cycles,
|
|
231
233
|
item_name="products",
|
|
232
|
-
|
|
234
|
+
relevant_values=[TermTermType.CROP, TermTermType.FORAGE],
|
|
233
235
|
date_fill=_overwrite_dates
|
|
234
236
|
)
|
|
235
237
|
products_crop_forage = [
|
|
@@ -241,33 +243,9 @@ def _should_run_all_products(cycles):
|
|
|
241
243
|
"value": 100
|
|
242
244
|
}
|
|
243
245
|
)
|
|
244
|
-
for product in list(filter(_get_landCover_term_id,
|
|
246
|
+
for product in list(filter(_get_landCover_term_id, products_crop_forage))
|
|
245
247
|
]
|
|
246
|
-
|
|
247
|
-
cycles=cycles,
|
|
248
|
-
item_name="products",
|
|
249
|
-
relevant_terms=[TermTermType.LIVEANIMAL, TermTermType.ANIMALPRODUCT]
|
|
250
|
-
)
|
|
251
|
-
products_animal = [
|
|
252
|
-
_copy_item_if_exists(
|
|
253
|
-
source=product,
|
|
254
|
-
keys=["startDate", "endDate", "properties"],
|
|
255
|
-
dest={
|
|
256
|
-
"term": linked_node(download_hestia(get_landCover_term_id_from_site_type(site_type))),
|
|
257
|
-
"value": 100
|
|
258
|
-
}
|
|
259
|
-
)
|
|
260
|
-
for product, site_type in products_animal_with_site_type if product
|
|
261
|
-
]
|
|
262
|
-
|
|
263
|
-
return products_animal, products_crop_forage, products_land_cover
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
def _should_run(site: dict):
|
|
267
|
-
cycles = related_cycles(site)
|
|
268
|
-
|
|
269
|
-
products_animal, products_crop_forage, products_land_cover = _should_run_all_products(cycles)
|
|
270
|
-
all_products = products_land_cover + products_crop_forage + products_animal
|
|
248
|
+
all_products = products_land_cover + products_crop_forage
|
|
271
249
|
all_products = condense_nodes(all_products)
|
|
272
250
|
|
|
273
251
|
practices = [
|
|
@@ -276,10 +254,10 @@ def _should_run(site: dict):
|
|
|
276
254
|
value=practice,
|
|
277
255
|
keys=["term", "value", "startDate", "endDate"]
|
|
278
256
|
)
|
|
279
|
-
) for practice
|
|
257
|
+
) for practice in _get_items_with_relevant_term_type(
|
|
280
258
|
cycles=cycles,
|
|
281
259
|
item_name="practices",
|
|
282
|
-
|
|
260
|
+
relevant_values=[
|
|
283
261
|
TermTermType.WATERREGIME,
|
|
284
262
|
TermTermType.TILLAGE,
|
|
285
263
|
TermTermType.CROPRESIDUEMANAGEMENT,
|
|
@@ -297,7 +275,6 @@ def _should_run(site: dict):
|
|
|
297
275
|
model_key=MODEL_KEY,
|
|
298
276
|
products_crop_forage_ids=log_blank_nodes_id(products_crop_forage),
|
|
299
277
|
products_land_cover_ids=log_blank_nodes_id(products_land_cover),
|
|
300
|
-
products_animal=log_blank_nodes_id(products_animal),
|
|
301
278
|
practice_ids=log_blank_nodes_id(practices),
|
|
302
279
|
inputs=log_blank_nodes_id(relevant_inputs)
|
|
303
280
|
)
|
|
@@ -278,7 +278,7 @@ def _rescale_soc_value(
|
|
|
278
278
|
"""
|
|
279
279
|
Rescale an SOC measurement value from a source depth interval to a target depth interval.
|
|
280
280
|
|
|
281
|
-
Depths are converted from centimetres (
|
|
281
|
+
Depths are converted from centimetres (HESTIA schema) to metres for use in `cdf` function.
|
|
282
282
|
|
|
283
283
|
Parameters
|
|
284
284
|
----------
|
|
@@ -61,7 +61,7 @@ def _filter_list_term_unit(values: list, unit: Any):
|
|
|
61
61
|
|
|
62
62
|
def is_from_model(node: dict) -> bool:
|
|
63
63
|
"""
|
|
64
|
-
Check if the Blank Node came from one of the
|
|
64
|
+
Check if the Blank Node came from one of the HESTIA Models.
|
|
65
65
|
|
|
66
66
|
Parameters
|
|
67
67
|
----------
|
|
@@ -267,12 +267,17 @@ def get_total_value_converted_with_min_ratio(
|
|
|
267
267
|
total_value_with_property = list_sum([value for term_id, value, prop_value in values if prop_value])
|
|
268
268
|
total_value_ratio = total_value_with_property / total_value if total_value > 0 else 0
|
|
269
269
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
270
|
+
logs = {
|
|
271
|
+
f"{prop_id}-term-id": prop_id,
|
|
272
|
+
f"{prop_id}-total-value": total_value,
|
|
273
|
+
f"{prop_id}-total-value-with-property": total_value_with_property,
|
|
274
|
+
f"{prop_id}-total-value-with-ratio": total_value_ratio,
|
|
275
|
+
f"{prop_id}-min-value-ratio": min_ratio,
|
|
276
|
+
f"{prop_id}-values": value_logs
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
debugValues(node, model=model, term=term,
|
|
280
|
+
**logs)
|
|
276
281
|
|
|
277
282
|
return list_sum([
|
|
278
283
|
value * prop_value for term_id, value, prop_value in values if all([value, prop_value])
|
|
@@ -612,7 +617,7 @@ def cumulative_nodes_lookup_match(
|
|
|
612
617
|
|
|
613
618
|
class DatestrFormat(Enum):
|
|
614
619
|
"""
|
|
615
|
-
Enum representing ISO date formats permitted by
|
|
620
|
+
Enum representing ISO date formats permitted by HESTIA.
|
|
616
621
|
|
|
617
622
|
See: https://en.wikipedia.org/wiki/ISO_8601
|
|
618
623
|
"""
|
|
@@ -677,7 +682,7 @@ def _check_datestr_format(datestr: str, format: DatestrFormat) -> bool:
|
|
|
677
682
|
|
|
678
683
|
def _get_datestr_format(datestr: str, default: Optional[Any] = None) -> Union[DatestrFormat, Any, None]:
|
|
679
684
|
"""
|
|
680
|
-
Check a datestr against each ISO format permitted by the
|
|
685
|
+
Check a datestr against each ISO format permitted by the HESTIA schema and
|
|
681
686
|
return the matching format.
|
|
682
687
|
"""
|
|
683
688
|
return next(
|
|
@@ -1170,7 +1175,7 @@ def group_nodes_by_last_date(nodes: list) -> dict[str, list[dict]]:
|
|
|
1170
1175
|
Parameters
|
|
1171
1176
|
----------
|
|
1172
1177
|
nodes : list[dict]
|
|
1173
|
-
A list of
|
|
1178
|
+
A list of HESTIA format nodes.
|
|
1174
1179
|
|
|
1175
1180
|
Return
|
|
1176
1181
|
------
|
|
@@ -22,7 +22,7 @@ def unique_currencies(cycle: dict) -> list:
|
|
|
22
22
|
Parameters
|
|
23
23
|
----------
|
|
24
24
|
cycle : dict
|
|
25
|
-
The `Cycle` as defined in the
|
|
25
|
+
The `Cycle` as defined in the HESTIA Schema.
|
|
26
26
|
|
|
27
27
|
Returns
|
|
28
28
|
-------
|
|
@@ -41,7 +41,7 @@ def default_currency(cycle: dict) -> str:
|
|
|
41
41
|
Parameters
|
|
42
42
|
----------
|
|
43
43
|
cycle : dict
|
|
44
|
-
The `Cycle` as defined in the
|
|
44
|
+
The `Cycle` as defined in the HESTIA Schema.
|
|
45
45
|
|
|
46
46
|
Returns
|
|
47
47
|
-------
|
|
@@ -59,7 +59,7 @@ def get_crop_residue_decomposition_N_total(cycle: dict) -> float:
|
|
|
59
59
|
Parameters
|
|
60
60
|
----------
|
|
61
61
|
cycle : dict
|
|
62
|
-
The `Cycle` as defined in the
|
|
62
|
+
The `Cycle` as defined in the HESTIA Schema.
|
|
63
63
|
|
|
64
64
|
Returns
|
|
65
65
|
-------
|
|
@@ -87,7 +87,7 @@ def get_excreta_N_total(cycle: dict) -> float:
|
|
|
87
87
|
Parameters
|
|
88
88
|
----------
|
|
89
89
|
cycle : dict
|
|
90
|
-
The `Cycle` as defined in the
|
|
90
|
+
The `Cycle` as defined in the HESTIA Schema.
|
|
91
91
|
|
|
92
92
|
Returns
|
|
93
93
|
-------
|
|
@@ -115,7 +115,7 @@ def get_organic_fertiliser_N_total(cycle: dict) -> float:
|
|
|
115
115
|
Parameters
|
|
116
116
|
----------
|
|
117
117
|
cycle : dict
|
|
118
|
-
The `Cycle` as defined in the
|
|
118
|
+
The `Cycle` as defined in the HESTIA Schema.
|
|
119
119
|
|
|
120
120
|
Returns
|
|
121
121
|
-------
|
|
@@ -141,7 +141,7 @@ def get_organic_fertiliser_P_total(cycle: dict) -> float:
|
|
|
141
141
|
Parameters
|
|
142
142
|
----------
|
|
143
143
|
cycle : dict
|
|
144
|
-
The `Cycle` as defined in the
|
|
144
|
+
The `Cycle` as defined in the HESTIA Schema.
|
|
145
145
|
|
|
146
146
|
Returns
|
|
147
147
|
-------
|
|
@@ -165,7 +165,7 @@ def get_inorganic_fertiliser_N_total(cycle: dict) -> float:
|
|
|
165
165
|
Parameters
|
|
166
166
|
----------
|
|
167
167
|
cycle : dict
|
|
168
|
-
The `Cycle` as defined in the
|
|
168
|
+
The `Cycle` as defined in the HESTIA Schema.
|
|
169
169
|
|
|
170
170
|
Returns
|
|
171
171
|
-------
|
|
@@ -189,7 +189,7 @@ def get_inorganic_fertiliser_P_total(cycle: dict) -> float:
|
|
|
189
189
|
Parameters
|
|
190
190
|
----------
|
|
191
191
|
cycle : dict
|
|
192
|
-
The `Cycle` as defined in the
|
|
192
|
+
The `Cycle` as defined in the HESTIA Schema.
|
|
193
193
|
|
|
194
194
|
Returns
|
|
195
195
|
-------
|
|
@@ -260,7 +260,7 @@ def land_occupation_per_ha(model: str, term_id: str, cycle: dict):
|
|
|
260
260
|
term_id : str
|
|
261
261
|
The name of the term running this function. For debugging purpose only.
|
|
262
262
|
cycle : dict
|
|
263
|
-
The `Cycle` as defined in the
|
|
263
|
+
The `Cycle` as defined in the HESTIA Schema.
|
|
264
264
|
|
|
265
265
|
Returns
|
|
266
266
|
-------
|
|
@@ -302,9 +302,9 @@ def land_occupation_per_kg(model: str, term_id: str, cycle: dict, site: dict, pr
|
|
|
302
302
|
term_id : str
|
|
303
303
|
The name of the term running this function. For debugging purpose only.
|
|
304
304
|
cycle : dict
|
|
305
|
-
The `Cycle` as defined in the
|
|
305
|
+
The `Cycle` as defined in the HESTIA Schema.
|
|
306
306
|
site : dict
|
|
307
|
-
The `Site` as defined in the
|
|
307
|
+
The `Site` as defined in the HESTIA Schema.
|
|
308
308
|
primary_product : dict
|
|
309
309
|
The primary `Product` of the `Cycle`.
|
|
310
310
|
|
|
@@ -447,7 +447,7 @@ def check_cycle_site_ids_identical(cycles: list[dict]) -> bool:
|
|
|
447
447
|
Parameters
|
|
448
448
|
----------
|
|
449
449
|
cycles : list[dict]
|
|
450
|
-
A list of
|
|
450
|
+
A list of HESTIA `Cycle` nodes, see: https://www.hestia.earth/schema/Cycle.
|
|
451
451
|
|
|
452
452
|
Returns
|
|
453
453
|
-------
|
|
@@ -111,7 +111,7 @@ def group_measurement_values_by_year(
|
|
|
111
111
|
Parameters
|
|
112
112
|
----------
|
|
113
113
|
measurement : dict
|
|
114
|
-
A
|
|
114
|
+
A HESTIA `Measurement` node, see: https://www.hestia.earth/schema/Measurement.
|
|
115
115
|
inner_key: Any | None
|
|
116
116
|
An optional inner dictionary key for the outputted annualised groups (can be used to merge annualised
|
|
117
117
|
dictionaries together), default value: `None`.
|
|
@@ -165,9 +165,9 @@ def most_relevant_measurement_value_by_depth_and_date(
|
|
|
165
165
|
Parameters
|
|
166
166
|
----------
|
|
167
167
|
measurements list[dict]
|
|
168
|
-
A list of
|
|
168
|
+
A list of HESTIA `Measurement` nodes, see: https://www.hestia.earth/schema/Measurement.
|
|
169
169
|
term_id : str
|
|
170
|
-
The `@id` of a
|
|
170
|
+
The `@id` of a HESTIA `Term`. Example: `"sandContent"`
|
|
171
171
|
date : str
|
|
172
172
|
The target date in ISO 8601 string format (`"YYYY-MM-DD"`), see: https://en.wikipedia.org/wiki/ISO_8601.
|
|
173
173
|
depth_upper : int
|
|
@@ -5,7 +5,6 @@ from hestia_earth.utils.tools import non_empty_list, flatten, safe_parse_date
|
|
|
5
5
|
|
|
6
6
|
from hestia_earth.models.log import debugMissingLookup
|
|
7
7
|
from . import cached_value, _load_calculated_node
|
|
8
|
-
from .term import get_land_cover_siteTypes
|
|
9
8
|
|
|
10
9
|
CACHE_YEARS_KEY = 'years'
|
|
11
10
|
WATER_TYPES = [
|
|
@@ -121,9 +120,3 @@ def region_factor(model: str, region_id: str, term_id: str, termType: TermTermTy
|
|
|
121
120
|
value = get_table_value(download_lookup(lookup_name), 'termid', region_id, column_name(term_id))
|
|
122
121
|
debugMissingLookup(lookup_name, 'termid', region_id, term_id, value, model=model, term=term_id)
|
|
123
122
|
return value
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
def get_land_cover_term_id(site_type: str):
|
|
127
|
-
land_cover_terms = get_land_cover_siteTypes()
|
|
128
|
-
term = next((term for term in land_cover_terms if term["name"].lower() == site_type.lower()), {})
|
|
129
|
-
return term.get('@id')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from hestia_earth.schema import SchemaType, TermTermType
|
|
1
|
+
from hestia_earth.schema import SchemaType, TermTermType
|
|
2
2
|
from hestia_earth.utils.lookup import download_lookup, get_table_value, column_name
|
|
3
3
|
from hestia_earth.utils.api import find_node, search
|
|
4
4
|
|
|
@@ -615,7 +615,7 @@ def get_electricity_grid_mix_terms():
|
|
|
615
615
|
list
|
|
616
616
|
List of matching `Term` as dict.
|
|
617
617
|
"""
|
|
618
|
-
|
|
618
|
+
terms = search({
|
|
619
619
|
"bool": {
|
|
620
620
|
"must": [
|
|
621
621
|
{"match": {"@type": SchemaType.TERM.value}},
|
|
@@ -625,23 +625,4 @@ def get_electricity_grid_mix_terms():
|
|
|
625
625
|
],
|
|
626
626
|
}
|
|
627
627
|
}, limit=LIMIT, fields=['@type', '@id', 'name', 'termType', 'units'])
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
def get_land_cover_siteTypes():
|
|
631
|
-
"""
|
|
632
|
-
Find all `Land Cover` terms with siteTypes
|
|
633
|
-
|
|
634
|
-
Returns
|
|
635
|
-
-------
|
|
636
|
-
List of landCover terms with associated siteTypes.
|
|
637
|
-
"""
|
|
638
|
-
return search({
|
|
639
|
-
"bool": {
|
|
640
|
-
"must": [
|
|
641
|
-
{"match": {"@type": "Term"}},
|
|
642
|
-
{"match": {"termType": "landCover"}}
|
|
643
|
-
],
|
|
644
|
-
"should": [{"match": {"name": siteType.value}} for siteType in SiteSiteType],
|
|
645
|
-
"minimum_should_match": 1
|
|
646
|
-
},
|
|
647
|
-
})
|
|
628
|
+
return list(map(lambda n: n["@id"], terms))
|
hestia_earth/models/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = '0.62.
|
|
1
|
+
VERSION = '0.62.3'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hestia-earth-models
|
|
3
|
-
Version: 0.62.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.62.3
|
|
4
|
+
Summary: HESTIA's set of modules for filling gaps in the activity data using external datasets (e.g. populating soil properties with a geospatial dataset using provided coordinates) and internal lookups (e.g. populating machinery use from fuel use). Includes rules for when gaps should be filled versus not (e.g. never gap fill yield, gap fill crop residue if yield provided etc.).
|
|
5
5
|
Home-page: https://gitlab.com/hestia-earth/hestia-engine-models
|
|
6
|
-
Author:
|
|
6
|
+
Author: HESTIA Team
|
|
7
7
|
Author-email: guillaumeroyer.mail@gmail.com
|
|
8
8
|
License: GPL
|
|
9
9
|
Platform: UNKNOWN
|
|
@@ -11,25 +11,25 @@ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.6
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: hestia-earth.schema
|
|
15
|
-
Requires-Dist: hestia-earth.utils
|
|
16
|
-
Requires-Dist: python-dateutil
|
|
17
|
-
Requires-Dist: CurrencyConverter
|
|
18
|
-
Requires-Dist: haversine
|
|
14
|
+
Requires-Dist: hestia-earth.schema==29.*
|
|
15
|
+
Requires-Dist: hestia-earth.utils>=0.13.2
|
|
16
|
+
Requires-Dist: python-dateutil>=2.8.1
|
|
17
|
+
Requires-Dist: CurrencyConverter==0.16.8
|
|
18
|
+
Requires-Dist: haversine>=2.7.0
|
|
19
19
|
Requires-Dist: pydash
|
|
20
20
|
Provides-Extra: spatial
|
|
21
|
-
Requires-Dist: hestia-earth.earth-engine
|
|
21
|
+
Requires-Dist: hestia-earth.earth-engine>=0.4.7; extra == "spatial"
|
|
22
22
|
|
|
23
|
-
#
|
|
23
|
+
# HESTIA Engine Models
|
|
24
24
|
|
|
25
25
|
[](https://gitlab.com/hestia-earth/hestia-engine-models/commits/master)
|
|
26
26
|
[](https://gitlab.com/hestia-earth/hestia-engine-models/commits/master)
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
HESTIA's set of models for running calculations or retrieving data using external datasets and internal lookups.
|
|
29
29
|
|
|
30
30
|
## Documentation
|
|
31
31
|
|
|
32
|
-
Documentation for every model can be found in the [
|
|
32
|
+
Documentation for every model can be found in the [HESTIA API Documentation](https://hestia.earth/docs/#hestia-calculation-models).
|
|
33
33
|
|
|
34
34
|
## Install
|
|
35
35
|
|