hestia-earth-models 0.59.6__py3-none-any.whl → 0.59.7__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/cache_sites.py +6 -8
- hestia_earth/models/cycle/siteDuration.py +1 -1
- hestia_earth/models/emepEea2019/nh3ToAirInorganicFertiliser.py +9 -6
- hestia_earth/models/faostat2018/product/price.py +14 -3
- hestia_earth/models/geospatialDatabase/utils.py +0 -1
- hestia_earth/models/ipcc2019/co2ToAirLimeHydrolysis.py +1 -1
- hestia_earth/models/ipcc2019/co2ToAirUreaHydrolysis.py +2 -7
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py +7 -2
- hestia_earth/models/mocking/search-results.json +1 -1
- hestia_earth/models/site/pre_checks/cache_geospatialDatabase.py +2 -2
- hestia_earth/models/utils/property.py +2 -1
- hestia_earth/models/utils/site.py +7 -4
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.59.6.dist-info → hestia_earth_models-0.59.7.dist-info}/METADATA +1 -1
- {hestia_earth_models-0.59.6.dist-info → hestia_earth_models-0.59.7.dist-info}/RECORD +20 -20
- tests/models/faostat2018/product/test_price.py +15 -3
- tests/models/ipcc2019/test_organicCarbonPerHa.py +95 -40
- {hestia_earth_models-0.59.6.dist-info → hestia_earth_models-0.59.7.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.59.6.dist-info → hestia_earth_models-0.59.7.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.59.6.dist-info → hestia_earth_models-0.59.7.dist-info}/top_level.txt +0 -0
|
@@ -34,7 +34,7 @@ def _cache_results(results: list, collections: list, index: int):
|
|
|
34
34
|
return cache_site_results(results[start:end], collections)
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def _run_values(sites: list, param_type: ParamType, rasters: list = [], vectors: list = [], years: list =
|
|
37
|
+
def _run_values(sites: list, param_type: ParamType, rasters: list = [], vectors: list = [], years: list = None):
|
|
38
38
|
param_values = list(map(_VALUE_AS_PARAM.get(param_type), sites))
|
|
39
39
|
# unique list
|
|
40
40
|
param_values = list(set(param_values)) if param_type == ParamType.GADM_IDS else list({
|
|
@@ -66,11 +66,9 @@ def _run_values(sites: list, param_type: ParamType, rasters: list = [], vectors:
|
|
|
66
66
|
} | ({CACHE_AREA_SIZE: area_size} if area_size is not None else {})
|
|
67
67
|
return {
|
|
68
68
|
**site,
|
|
69
|
-
CACHE_KEY:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
CACHE_GEOSPATIAL_KEY: cached_data
|
|
73
|
-
}
|
|
69
|
+
CACHE_KEY: (
|
|
70
|
+
cached_value(site) | {CACHE_GEOSPATIAL_KEY: cached_data}
|
|
71
|
+
) | ({CACHE_YEARS_KEY: years} if years else {})
|
|
74
72
|
}
|
|
75
73
|
|
|
76
74
|
return reduce(lambda prev, curr: prev + [_process_site(curr)], sites, [])
|
|
@@ -114,7 +112,7 @@ def _group_sites(sites: dict):
|
|
|
114
112
|
}
|
|
115
113
|
|
|
116
114
|
|
|
117
|
-
def run(sites: list, years: list, include_region: bool = False):
|
|
115
|
+
def run(sites: list, years: list = None, include_region: bool = False):
|
|
118
116
|
"""
|
|
119
117
|
Run all queries at once for the list of provided Sites.
|
|
120
118
|
Note: Earth Engine needs to be initiliased with `init_gee()` before running this function.
|
|
@@ -129,7 +127,7 @@ def run(sites: list, years: list, include_region: bool = False):
|
|
|
129
127
|
Prefecth region IDs.
|
|
130
128
|
This will cache region-level data and will make the request slower. Only use if needed.
|
|
131
129
|
"""
|
|
132
|
-
rasters, vectors = list_collections(years, include_region
|
|
130
|
+
rasters, vectors = list_collections(years, include_region)
|
|
133
131
|
|
|
134
132
|
filtered_data = _group_sites(sites)
|
|
135
133
|
|
|
@@ -17,14 +17,17 @@ from . import MODEL
|
|
|
17
17
|
|
|
18
18
|
REQUIREMENTS = {
|
|
19
19
|
"Cycle": {
|
|
20
|
-
"
|
|
21
|
-
|
|
20
|
+
"completeness.fertiliser": "True",
|
|
21
|
+
"inputs": [
|
|
22
|
+
{
|
|
22
23
|
"@type": "Input",
|
|
23
24
|
"value": "",
|
|
24
|
-
"term.termType":
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
"term.termType": "inorganicFertiliser",
|
|
26
|
+
"optional": {
|
|
27
|
+
"properties": [{"@type": "Property", "value": "", "term.@id": "nitrogenContent"}]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
],
|
|
28
31
|
"site": {
|
|
29
32
|
"@type": "Site",
|
|
30
33
|
"country": {"@type": "Term", "termType": "region"},
|
|
@@ -41,7 +41,8 @@ LOOKUPS = {
|
|
|
41
41
|
"liveAnimal": ["primaryMeatProductFaoPriceTermId"],
|
|
42
42
|
"animalProduct": ["animalProductGroupingFAOEquivalent", "animalProductGroupingFAO"],
|
|
43
43
|
"region-animalProduct-animalProductGroupingFAO-price": "use value from above",
|
|
44
|
-
"region-animalProduct-animalProductGroupingFAO-averageColdCarcassWeight": "use value from above"
|
|
44
|
+
"region-animalProduct-animalProductGroupingFAO-averageColdCarcassWeight": "use value from above",
|
|
45
|
+
"region-animalProduct-animalProductGroupingFAO-weightPerItem": "use value from above"
|
|
45
46
|
}
|
|
46
47
|
MODEL_KEY = 'price'
|
|
47
48
|
LOOKUP_NAME = {
|
|
@@ -52,6 +53,9 @@ LOOKUP_GROUPING = {
|
|
|
52
53
|
TermTermType.CROP.value: get_crop_grouping_faostat_production,
|
|
53
54
|
TermTermType.ANIMALPRODUCT.value: get_animalProduct_grouping_fao
|
|
54
55
|
}
|
|
56
|
+
LOOKUP_UNITS_NUMBER = {
|
|
57
|
+
TermTermType.ANIMALPRODUCT.value: f"region-{TermTermType.ANIMALPRODUCT.value}-{FAO_LOOKUP_COLUMN}-weightPerItem.csv"
|
|
58
|
+
}
|
|
55
59
|
|
|
56
60
|
|
|
57
61
|
def _term_grouping(term: dict): return LOOKUP_GROUPING.get(term.get('termType'), lambda *_: None)(MODEL, term)
|
|
@@ -123,6 +127,7 @@ def _run_by_country(cycle: dict, product: dict, country_id: str, year: int = Non
|
|
|
123
127
|
product_term = product.get('term', {})
|
|
124
128
|
term_id = product_term.get('@id')
|
|
125
129
|
term_type = product_term.get('termType')
|
|
130
|
+
term_units = product_term.get('units')
|
|
126
131
|
|
|
127
132
|
has_yield = len(product.get('value', [])) > 0
|
|
128
133
|
not_already_set = MODEL_KEY not in product.keys()
|
|
@@ -133,17 +138,23 @@ def _run_by_country(cycle: dict, product: dict, country_id: str, year: int = Non
|
|
|
133
138
|
should_run = all([not_already_set, has_yield, grouping])
|
|
134
139
|
value = _lookup_data(term_id, grouping, country_id, year, term_type=term_type) if should_run else None
|
|
135
140
|
|
|
141
|
+
# if units is number instead of kg, need to convert to number first
|
|
142
|
+
conversion_to_number = safe_parse_float(get_table_value(
|
|
143
|
+
download_lookup(LOOKUP_UNITS_NUMBER.get(term_type)), 'termid', country_id, column_name(grouping)
|
|
144
|
+
), 1) if term_units == Units.NUMBER.value else 1
|
|
145
|
+
|
|
136
146
|
logRequirements(cycle, model=MODEL, term=term_id, key=MODEL_KEY, by='country',
|
|
137
147
|
has_yield=has_yield,
|
|
138
148
|
not_already_set=not_already_set,
|
|
139
149
|
year=year,
|
|
140
150
|
price_per_ton=value,
|
|
141
|
-
groupingFAO=f"'{grouping}'"
|
|
151
|
+
groupingFAO=f"'{grouping}'",
|
|
152
|
+
conversion_to_number=conversion_to_number)
|
|
142
153
|
|
|
143
154
|
logShouldRun(cycle, MODEL, term_id, should_run, key=MODEL_KEY, by='country')
|
|
144
155
|
|
|
145
156
|
# divide by 1000 to convert price per tonne to kg
|
|
146
|
-
return _product(product, value / 1000) if value is not None else None
|
|
157
|
+
return _product(product, value / 1000 * conversion_to_number) if value is not None else None
|
|
147
158
|
|
|
148
159
|
|
|
149
160
|
def _should_run_product(product: dict):
|
|
@@ -11,13 +11,8 @@ from . import MODEL
|
|
|
11
11
|
|
|
12
12
|
REQUIREMENTS = {
|
|
13
13
|
"Cycle": {
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
"inputs": [{"@type": "Input", "value": "", "term.termType": "inorganicFertiliser"}]
|
|
17
|
-
},
|
|
18
|
-
"optional": {
|
|
19
|
-
"inputs": [{"@type": "Input", "value": "", "term.@id": "inorganicNitrogenFertiliserUnspecifiedKgN"}]
|
|
20
|
-
}
|
|
14
|
+
"completeness.fertiliser": "",
|
|
15
|
+
"inputs": [{"@type": "Input", "value": "", "term.termType": "inorganicFertiliser"}]
|
|
21
16
|
}
|
|
22
17
|
}
|
|
23
18
|
RETURNS = {
|
|
@@ -259,6 +259,11 @@ The number of years required for soil organic carbon to reach equilibrium after
|
|
|
259
259
|
a change in land use, management regime or carbon input regime.
|
|
260
260
|
"""
|
|
261
261
|
|
|
262
|
+
EXCLUDED_ECO_CLIMATE_ZONES_TIER_1 = {
|
|
263
|
+
5, # Polar Moist
|
|
264
|
+
6 # Polar Dry
|
|
265
|
+
}
|
|
266
|
+
|
|
262
267
|
VALID_SITE_TYPES_TIER_1 = [
|
|
263
268
|
SiteSiteType.CROPLAND.value,
|
|
264
269
|
SiteSiteType.FOREST.value,
|
|
@@ -287,7 +292,7 @@ def _measurement(year: int, value: float, method_classification: str) -> dict:
|
|
|
287
292
|
dict
|
|
288
293
|
A valid Hestia `Measurement` node, see: https://www.hestia.earth/schema/Measurement.
|
|
289
294
|
"""
|
|
290
|
-
measurement = _new_measurement(TERM_ID
|
|
295
|
+
measurement = _new_measurement(TERM_ID)
|
|
291
296
|
measurement["value"] = [value]
|
|
292
297
|
measurement["dates"] = [f"{year}-12-31"]
|
|
293
298
|
measurement["depthUpper"] = DEPTH_UPPER
|
|
@@ -3578,7 +3583,7 @@ def _should_run_tier_1(
|
|
|
3578
3583
|
Determines whether there is sufficient data in the inventory and keyword args to run the tier 1 model.
|
|
3579
3584
|
"""
|
|
3580
3585
|
return all([
|
|
3581
|
-
eco_climate_zone and eco_climate_zone
|
|
3586
|
+
eco_climate_zone and eco_climate_zone not in EXCLUDED_ECO_CLIMATE_ZONES_TIER_1,
|
|
3582
3587
|
soc_ref and soc_ref > 0,
|
|
3583
3588
|
any(year for year, group in inventory.items() if group.get(_InventoryKey.SHOULD_RUN_TIER_1))
|
|
3584
3589
|
])
|
|
@@ -77,7 +77,7 @@ def _extend_collections(values: list, years: list = []):
|
|
|
77
77
|
])
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
def list_collections(years: list, include_region: bool = False):
|
|
80
|
+
def list_collections(years: list = [], include_region: bool = False):
|
|
81
81
|
ee_params = list_ee_params()
|
|
82
82
|
# only cache `raster` results as can be combined in a single query
|
|
83
83
|
rasters = [value for value in ee_params if value.get('params').get('ee_type') == 'raster']
|
|
@@ -89,7 +89,7 @@ def list_collections(years: list, include_region: bool = False):
|
|
|
89
89
|
])
|
|
90
90
|
]
|
|
91
91
|
|
|
92
|
-
return (_extend_collections(rasters, years), _extend_collections(vectors))
|
|
92
|
+
return (_extend_collections(rasters, years or []), _extend_collections(vectors))
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
def _cache_results(site: dict, area_size: float):
|
|
@@ -93,7 +93,8 @@ def node_property_lookup_value(model: str, term: dict, prop_id: str, default=Non
|
|
|
93
93
|
lookup_name = f"{term.get('termType')}-property.csv"
|
|
94
94
|
lookup = download_lookup(lookup_name)
|
|
95
95
|
term_id = term.get('@id')
|
|
96
|
-
|
|
96
|
+
lookup_value = get_table_value(lookup, 'termid', term_id, column_name(prop_id))
|
|
97
|
+
value = extract_grouped_data(lookup_value, 'Avg') if 'Avg' in lookup_value else lookup_value
|
|
97
98
|
debugMissingLookup(lookup_name, 'termid', term_id, prop_id, value, model=model, term=term_id, **log_args)
|
|
98
99
|
return safe_parse_float(value, default=None)
|
|
99
100
|
except Exception:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from hestia_earth.schema import SchemaType, SiteSiteType, TermTermType
|
|
2
2
|
from hestia_earth.utils.api import find_related
|
|
3
3
|
from hestia_earth.utils.lookup import download_lookup, get_table_value, column_name
|
|
4
|
-
from hestia_earth.utils.tools import non_empty_list, safe_parse_date
|
|
4
|
+
from hestia_earth.utils.tools import non_empty_list, safe_parse_date, flatten
|
|
5
5
|
|
|
6
6
|
from hestia_earth.models.log import debugMissingLookup
|
|
7
7
|
from . import cached_value, _load_calculated_node
|
|
@@ -63,14 +63,17 @@ def related_cycles(site_id: str):
|
|
|
63
63
|
return non_empty_list(map(lambda node: _load_calculated_node(node, SchemaType.CYCLE), nodes or []))
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
def
|
|
67
|
-
date = safe_parse_date(cycle.get(
|
|
66
|
+
def _cycle_year(cycle: dict, key: str):
|
|
67
|
+
date = safe_parse_date(cycle.get(key))
|
|
68
68
|
return date.year if date else None
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
def related_years(site: dict):
|
|
72
72
|
return cached_value(site, CACHE_YEARS_KEY) or (
|
|
73
|
-
non_empty_list(set(
|
|
73
|
+
sorted(non_empty_list(set(flatten([
|
|
74
|
+
_cycle_year(cycle, 'startDate'),
|
|
75
|
+
_cycle_year(cycle, 'endDate')
|
|
76
|
+
] for cycle in related_cycles(site.get('@id'))))))
|
|
74
77
|
)
|
|
75
78
|
|
|
76
79
|
|
hestia_earth/models/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = '0.59.
|
|
1
|
+
VERSION = '0.59.7'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hestia-earth-models
|
|
3
|
-
Version: 0.59.
|
|
3
|
+
Version: 0.59.7
|
|
4
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
6
|
Author: Hestia Team
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
hestia_earth/__init__.py,sha256=G-d438vPx7m_ks5e9XTtM3u7LDRO5dSSukibukWmyPM,56
|
|
2
2
|
hestia_earth/models/__init__.py,sha256=qEFeq3yuf3lQKVseALmL8aPM8fpCS54B_5pry00M3hk,76
|
|
3
|
-
hestia_earth/models/cache_sites.py,sha256=
|
|
3
|
+
hestia_earth/models/cache_sites.py,sha256=tPuUiSVSwKfTueuinDsiVRAbxIdDmpJ8V0AOdMOX_yE,4783
|
|
4
4
|
hestia_earth/models/log.py,sha256=b63I3qyTtQs17xxbq8RI0Fv2lvZ1oDZ9k0njhxqiFFk,3459
|
|
5
5
|
hestia_earth/models/requirements.py,sha256=znNZJAhwX2iYiKcAQXPftY7z_1MsNa0QxCXkXyHm_U0,17363
|
|
6
|
-
hestia_earth/models/version.py,sha256=
|
|
6
|
+
hestia_earth/models/version.py,sha256=YdTI02fIcHtygnhw1S3ojSKc9kpReMFy_DlUYJO0yXY,19
|
|
7
7
|
hestia_earth/models/agribalyse2016/__init__.py,sha256=WvK0qCQbnYtg9oZxrACd1wGormZyXibPtpCnIQeDqbw,415
|
|
8
8
|
hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=mrh8seYSYdTgcMDCETLiknuPeJehg071YoG4UiyW0yU,4404
|
|
9
9
|
hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=_Rbngu0DzHKa62JwBl58ZC_ui1zLF2que_nB7ukhOQc,3392
|
|
@@ -55,7 +55,7 @@ hestia_earth/models/cycle/residueBurnt.py,sha256=HwU1D9ibiIul-FlXDUcEMDEc_KxpB8u
|
|
|
55
55
|
hestia_earth/models/cycle/residueIncorporated.py,sha256=9_s2RMOy5D20eq9ziDBEA_Y7RiFFMeK0bDJ65CW4qlE,2763
|
|
56
56
|
hestia_earth/models/cycle/residueLeftOnField.py,sha256=qYxKGAdUORN7Vjqj7AZC2VGV_rM3MN0-padDGhgjiNU,2175
|
|
57
57
|
hestia_earth/models/cycle/residueRemoved.py,sha256=jxDu_Jfcyd-rm-qo8ZuRIf-GGxtFBMpmGy1zHOavwy0,2135
|
|
58
|
-
hestia_earth/models/cycle/siteDuration.py,sha256=
|
|
58
|
+
hestia_earth/models/cycle/siteDuration.py,sha256=XAxCA_51kQaWh4_0L_Y08cGn-qsMRUcyaPrn84rfafI,1058
|
|
59
59
|
hestia_earth/models/cycle/startDate.py,sha256=RTpA7NX5afktdQH0Z6c2SB7LCSi5R28aPcqq7Xn5lkw,1181
|
|
60
60
|
hestia_earth/models/cycle/transformation.py,sha256=06KTfVubh2I47dfnG9Iv6AbuUBbURM8BAVOkRu7XmHw,1255
|
|
61
61
|
hestia_earth/models/cycle/utils.py,sha256=ZcVwvRwVNK48jZfnhrHl2ai4a96YzcmRgO-eQXwQNjo,1408
|
|
@@ -110,7 +110,7 @@ hestia_earth/models/emepEea2019/__init__.py,sha256=l90-pWrqIzt1ap1WNk0gF4iZeF5_T
|
|
|
110
110
|
hestia_earth/models/emepEea2019/co2ToAirFuelCombustion.py,sha256=DfoGlB5HjA1gafO0OutJjfsA6yPP_PsAd-p16evwCiQ,1609
|
|
111
111
|
hestia_earth/models/emepEea2019/n2OToAirFuelCombustionDirect.py,sha256=R3lRF5-Md4Jd7irvTe8WJZJPc9-wa1pD6UWVk7lnGtQ,1616
|
|
112
112
|
hestia_earth/models/emepEea2019/nh3ToAirExcreta.py,sha256=lWo1AaorIk4HtTCQAND3RFbCHO-em1DbA5ZOxv0Ldn8,3750
|
|
113
|
-
hestia_earth/models/emepEea2019/nh3ToAirInorganicFertiliser.py,sha256=
|
|
113
|
+
hestia_earth/models/emepEea2019/nh3ToAirInorganicFertiliser.py,sha256=w9Cti3pBKVRsTbFJJorFy1-vREB0iIi9UkZKwRezOE4,6469
|
|
114
114
|
hestia_earth/models/emepEea2019/noxToAirFuelCombustion.py,sha256=y49RvO5OkrZ4iK7o2Kmx5xW52y8SS9xEKAmlXlTQtWc,1609
|
|
115
115
|
hestia_earth/models/emepEea2019/so2ToAirFuelCombustion.py,sha256=bo_0mFcwicpOkPsvZRAnL2tDBDRBAQqsPD_Wc5e20K4,1609
|
|
116
116
|
hestia_earth/models/emepEea2019/utils.py,sha256=ikoZn3JPe9wz-_voVlIqVwh4jBgmnfKi2oyLhi7_7E4,1398
|
|
@@ -129,7 +129,7 @@ hestia_earth/models/faostat2018/readyToCookWeightPerHead.py,sha256=b1_GZQ3oFl88w
|
|
|
129
129
|
hestia_earth/models/faostat2018/seed.py,sha256=ts9PKs9UnZnJ9nPFlL7etL1Qb9uIWIES8Mz8W7FWbOw,2917
|
|
130
130
|
hestia_earth/models/faostat2018/utils.py,sha256=r69UWDdMOLTYkI8_oQeEnUCOAZCnmwj_NwyrypAOb_A,3734
|
|
131
131
|
hestia_earth/models/faostat2018/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
132
|
-
hestia_earth/models/faostat2018/product/price.py,sha256=
|
|
132
|
+
hestia_earth/models/faostat2018/product/price.py,sha256=J0G-Si0AnlER69FFbC8Lkwpn_05CtA8wV46KoFAYPm0,7757
|
|
133
133
|
hestia_earth/models/geospatialDatabase/__init__.py,sha256=TH-FW3aoL7r1GquRChr7rde7uQonKQRDR00udG8tDrQ,957
|
|
134
134
|
hestia_earth/models/geospatialDatabase/aware.py,sha256=cbxFnShXW8QUCIjU4uuO1DdK9KhYiLf41ZVjS9hSppI,1358
|
|
135
135
|
hestia_earth/models/geospatialDatabase/clayContent.py,sha256=HWaswqkf1FZXcRHw8DrMvvpH2Uo3nbjX4C0D1tqyTBw,2710
|
|
@@ -160,7 +160,7 @@ hestia_earth/models/geospatialDatabase/temperatureLongTermAnnualMean.py,sha256=j
|
|
|
160
160
|
hestia_earth/models/geospatialDatabase/temperatureMonthly.py,sha256=hJjbnTgefBtRwL5IJHaaPFtRvzTDv7l5nDI8vdadMCg,3353
|
|
161
161
|
hestia_earth/models/geospatialDatabase/totalNitrogenPerKgSoil.py,sha256=kjP3ue-tlzMQNx2hBM56_CBBRa8Pcosmd2BPgyiNVW4,2081
|
|
162
162
|
hestia_earth/models/geospatialDatabase/totalPhosphorusPerKgSoil.py,sha256=5oasLMYgfnPwSse0D8EEe_pV57AMusac853BgVSUh5E,2070
|
|
163
|
-
hestia_earth/models/geospatialDatabase/utils.py,sha256=
|
|
163
|
+
hestia_earth/models/geospatialDatabase/utils.py,sha256=tjc9Z1wkDzlZ0v82oy5fHwixak3YDq4QCZprNjnm5_M,6208
|
|
164
164
|
hestia_earth/models/geospatialDatabase/waterDepth.py,sha256=Xy2UxwAJrgdOkcw59NetEHMt5vgRYE6qg4fgXb1ptlU,1643
|
|
165
165
|
hestia_earth/models/globalCropWaterModel2008/__init__.py,sha256=vQxexzFCl2Uv2RiIJfcppkRi9RgzBsJ68yhVDK4GvAU,425
|
|
166
166
|
hestia_earth/models/globalCropWaterModel2008/rootingDepth.py,sha256=pajS-6UWxqIqnzW0IjkgNm-2Vl3bMor2UZOQtQQERuc,4096
|
|
@@ -228,9 +228,9 @@ hestia_earth/models/ipcc2019/carbonContent.py,sha256=I76bJaO1OYSrIjwDKxhwY-DZGZJ
|
|
|
228
228
|
hestia_earth/models/ipcc2019/ch4ToAirEntericFermentation.py,sha256=khX90NjkmlvosyRZ77QxgwTKwg42Z_ftOWTTAanHViw,11420
|
|
229
229
|
hestia_earth/models/ipcc2019/ch4ToAirExcreta.py,sha256=IzYHdnzT8Z-WQGoZIt9-O98VqriA5rKr38He_TbYadk,6723
|
|
230
230
|
hestia_earth/models/ipcc2019/ch4ToAirFloodedRice.py,sha256=f3orp6tDZ7f8bE9-lLZC0H_SgCKsDASAlphVRAHKJ0I,6885
|
|
231
|
-
hestia_earth/models/ipcc2019/co2ToAirLimeHydrolysis.py,sha256=
|
|
231
|
+
hestia_earth/models/ipcc2019/co2ToAirLimeHydrolysis.py,sha256=7z0zdqiiWQwkyJCgSNMoK2mft3cJkTRlqwKrMuSKdWI,2454
|
|
232
232
|
hestia_earth/models/ipcc2019/co2ToAirSoilCarbonStockChangeManagementChange.py,sha256=lW3OZcIO3QEifrs_g_K_aytSXvpPFN51vYVuZRGIdDc,25367
|
|
233
|
-
hestia_earth/models/ipcc2019/co2ToAirUreaHydrolysis.py,sha256=
|
|
233
|
+
hestia_earth/models/ipcc2019/co2ToAirUreaHydrolysis.py,sha256=071H3ykjzJFW2K5PKvbAaeIj0aL8LTzMiG_pIeYEpEc,3520
|
|
234
234
|
hestia_earth/models/ipcc2019/croppingDuration.py,sha256=_jlFrTNDOARH2_g8s4dzuaCoLHSX2BHzSQd3uuQN32Y,3173
|
|
235
235
|
hestia_earth/models/ipcc2019/ligninContent.py,sha256=wp5EbCthCDAKyvPBfZULS9-uKEY58TQQ8ey1pf-juv8,7267
|
|
236
236
|
hestia_earth/models/ipcc2019/n2OToAirCropResidueDecompositionDirect.py,sha256=Fand7NbT27unwgFTxi_9NxT024s63vQ7U6-tk9yp3d8,3990
|
|
@@ -250,7 +250,7 @@ hestia_earth/models/ipcc2019/no3ToGroundwaterInorganicFertiliser.py,sha256=wTvMB
|
|
|
250
250
|
hestia_earth/models/ipcc2019/no3ToGroundwaterOrganicFertiliser.py,sha256=zOhp6NhYUuUNU_LMMwhZBP78YC2XRWRlGnajBUX2AN8,3095
|
|
251
251
|
hestia_earth/models/ipcc2019/noxToAirInorganicFertiliser.py,sha256=D-UyzY55mOiIcXRzEtvPY-r1bDFgb9YqA08SmHsQeNA,4226
|
|
252
252
|
hestia_earth/models/ipcc2019/noxToAirOrganicFertiliser.py,sha256=SVgVNp76bIv9oUjrZZuI6xYLo4Gw2DRU5tbp14gydOE,3911
|
|
253
|
-
hestia_earth/models/ipcc2019/organicCarbonPerHa.py,sha256=
|
|
253
|
+
hestia_earth/models/ipcc2019/organicCarbonPerHa.py,sha256=omxrtnAZ58qHQYIhi38R7VFn7SRzf8Kk89KgP0VELFQ,141507
|
|
254
254
|
hestia_earth/models/ipcc2019/pastureGrass.py,sha256=ntgDsXYIJA3xN5Cn2VzlZ2zDItTb6jXwONOW4VSfFqA,23177
|
|
255
255
|
hestia_earth/models/ipcc2019/utils.py,sha256=MSDMu15D9DnilFUgi4_6jYXC0FaKso3OODauGTMB6hs,6229
|
|
256
256
|
hestia_earth/models/ipcc2021/__init__.py,sha256=VTgGFKhwMmk_nuI1RRq0in27fHYVPBonlXlPK00K8no,409
|
|
@@ -353,7 +353,7 @@ hestia_earth/models/lcImpactCertainEffectsInfinite/damageToTerrestrialEcosystems
|
|
|
353
353
|
hestia_earth/models/linkedImpactAssessment/__init__.py,sha256=d19wzr4GnWXpMWRhchqwp3S8txrUkpIWrGPwnWdXhjI,6236
|
|
354
354
|
hestia_earth/models/mocking/__init__.py,sha256=kmSeOTSvurMUxw7Ajhf3G-SVPQ1NgmirMTk4TSOEicY,765
|
|
355
355
|
hestia_earth/models/mocking/mock_search.py,sha256=V-ycVBTkJu7PP37Ivy_16hpKBV4aEtJb5S9DfChPNSU,2038
|
|
356
|
-
hestia_earth/models/mocking/search-results.json,sha256=
|
|
356
|
+
hestia_earth/models/mocking/search-results.json,sha256=4jtf6WHW7XorahPkYbGLFzjW19pM4iSgBmjcPa-v18A,39322
|
|
357
357
|
hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
|
|
358
358
|
hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=Qt-mel4dkhK6N5uUOutNOinCTFjbjtGzITaaI0LvYc4,2396
|
|
359
359
|
hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=JT0RybbvWVlo01FO8K0Yj41HrEaJT3Kj1xfayr2X-xw,2315
|
|
@@ -473,7 +473,7 @@ hestia_earth/models/site/measurement/value.py,sha256=7IhUbIj7n5vB7yXoNxXsWbliEJj
|
|
|
473
473
|
hestia_earth/models/site/post_checks/__init__.py,sha256=CkExxesk1GuG8NjrbKfix1iDuVUgU-9i1ccM_X7MZn4,284
|
|
474
474
|
hestia_earth/models/site/post_checks/cache.py,sha256=_MZsNsclecUdHDT2MsYx4cEsVUXydIasddgZNA6SU4k,284
|
|
475
475
|
hestia_earth/models/site/pre_checks/__init__.py,sha256=fjv6nU5fiL-CLyaa-cBpiLB-xujgPzeK7i7ZJuTOjCI,394
|
|
476
|
-
hestia_earth/models/site/pre_checks/cache_geospatialDatabase.py,sha256=
|
|
476
|
+
hestia_earth/models/site/pre_checks/cache_geospatialDatabase.py,sha256=K-6EvJvcBijo_gVeIlOtYsYwdM9iBVTBy0jOSmr4OL4,4831
|
|
477
477
|
hestia_earth/models/site/pre_checks/cache_sources.py,sha256=RzvSgHJTpVkAB3mEvRju_irDQmdJRK7GUdU6PhS2Gaw,904
|
|
478
478
|
hestia_earth/models/site/pre_checks/cache_years.py,sha256=qGwTaHlWxnVT7iVxXVcpJ-oG6M-VH4ZpCDTdTixUHR4,883
|
|
479
479
|
hestia_earth/models/stehfestBouwman2006/__init__.py,sha256=EhvD4NK6oEPevusLb1WdYV3GT_fCtQx4gvdMhK_dEIQ,420
|
|
@@ -534,8 +534,8 @@ hestia_earth/models/utils/pesticideAI.py,sha256=oAQTUlgXnSJrBGvIphlmVcjx2gbCHH6k
|
|
|
534
534
|
hestia_earth/models/utils/practice.py,sha256=tNadOzsrNlCEt801B815XaruJXzZ5yPASam7B3sWpXE,1091
|
|
535
535
|
hestia_earth/models/utils/product.py,sha256=H9UqJNzTqtMWXDQnbRkZlTpv_hg4s-Tya469fBk8InA,10143
|
|
536
536
|
hestia_earth/models/utils/productivity.py,sha256=bUBVCZInGqHuHZvHDSYPQkjWXQxOtTjEk-1-f_BsFOo,594
|
|
537
|
-
hestia_earth/models/utils/property.py,sha256=
|
|
538
|
-
hestia_earth/models/utils/site.py,sha256=
|
|
537
|
+
hestia_earth/models/utils/property.py,sha256=XSSPRUJm6fcc4kJWjZ8A_ZCie7h3QsjwlUg2wDWytdQ,5002
|
|
538
|
+
hestia_earth/models/utils/site.py,sha256=oLuai82WdN_qAAG09XmLEbhf7-jr7AT7BGxRBUs1Bno,3292
|
|
539
539
|
hestia_earth/models/utils/source.py,sha256=HhZkvQoFdy6j6FC2cwP5EbHXHFM4pif9gpnuzeDwEh4,1746
|
|
540
540
|
hestia_earth/models/utils/temperature.py,sha256=ljlG4-yCgFFb6LRZweb18cZKLrr7K2mqd4E4Hz_D1f8,476
|
|
541
541
|
hestia_earth/models/utils/term.py,sha256=XH3-xTkv8WNB0obOjo6Y5YLT8B3zcON6Z-JeskCsCXY,17112
|
|
@@ -662,7 +662,7 @@ tests/models/faostat2018/test_liveweightPerHead.py,sha256=1gnezEdoWvb8Hu-W6YCD3f
|
|
|
662
662
|
tests/models/faostat2018/test_readyToCookWeightPerHead.py,sha256=pMDcONs0WUvANcJ6_OPF7TBwMF45JGMxFRPNPtHLqVI,1570
|
|
663
663
|
tests/models/faostat2018/test_seed.py,sha256=tUXoNVveX0m0ed9UXB4zXxIZsPxktXyUXlbWuUKG0sQ,1705
|
|
664
664
|
tests/models/faostat2018/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
665
|
-
tests/models/faostat2018/product/test_price.py,sha256=
|
|
665
|
+
tests/models/faostat2018/product/test_price.py,sha256=vUTT-FZVbXnDrwQVOgq8PWTDuFK_gAT6aqJ9ZK6Qcsc,3493
|
|
666
666
|
tests/models/geospatialDatabase/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
667
667
|
tests/models/geospatialDatabase/test_aware.py,sha256=tbBBvXrOqdO0cMPJTa02UfhlwfosH8iNoJLzZNFs1NU,857
|
|
668
668
|
tests/models/geospatialDatabase/test_clayContent.py,sha256=KdkmsJMB1FsJXZCggcGWh3LlDKDDlwvcmSLEhZpdM_g,1177
|
|
@@ -782,7 +782,7 @@ tests/models/ipcc2019/test_no3ToGroundwaterInorganicFertiliser.py,sha256=e7REnQ9
|
|
|
782
782
|
tests/models/ipcc2019/test_no3ToGroundwaterOrganicFertiliser.py,sha256=e1ZViD12qB3bLdH3TJw3GbBP8iqMen-UJbcFkytb3VQ,1609
|
|
783
783
|
tests/models/ipcc2019/test_noxToAirInorganicFertiliser.py,sha256=NZBSBJLM_j2PEpHRON2ysgKNF8x5sHfQVoAKQdGsfzk,1537
|
|
784
784
|
tests/models/ipcc2019/test_noxToAirOrganicFertiliser.py,sha256=LR5pjV5vRbgSSQAw8kYRp_ij4CHInzgaDS6EggQuBiw,1104
|
|
785
|
-
tests/models/ipcc2019/test_organicCarbonPerHa.py,sha256=
|
|
785
|
+
tests/models/ipcc2019/test_organicCarbonPerHa.py,sha256=TO3ubi8z8-iYEAdf295Z30ft5W1652GPkmaiQCb7QN4,23197
|
|
786
786
|
tests/models/ipcc2019/test_pastureGrass.py,sha256=pE4PWdR541v4xWDYihP7Dou8V1iqg5GwD5_rjGRzrds,2292
|
|
787
787
|
tests/models/ipcc2021/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
788
788
|
tests/models/ipcc2021/test_gwp100.py,sha256=JRklKMSg-OXopb9ZufGgl94deuMuJSsfNXRZDBtOZrE,1119
|
|
@@ -1049,8 +1049,8 @@ tests/models/utils/test_source.py,sha256=mv3vHZV5cjpoLA2I1109-YUkuzAiuhbRSnv_76_
|
|
|
1049
1049
|
tests/models/utils/test_term.py,sha256=M5Sa26v2gzQYbZ4H_fo7DspnaCx__-WtL-MULGapCWk,3509
|
|
1050
1050
|
tests/models/webbEtAl2012AndSintermannEtAl2012/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
1051
1051
|
tests/models/webbEtAl2012AndSintermannEtAl2012/test_nh3ToAirOrganicFertiliser.py,sha256=qi2FNXS5Af2WDtm7nq_FsprH3BfCF0XxnE0XHmC4aIY,2244
|
|
1052
|
-
hestia_earth_models-0.59.
|
|
1053
|
-
hestia_earth_models-0.59.
|
|
1054
|
-
hestia_earth_models-0.59.
|
|
1055
|
-
hestia_earth_models-0.59.
|
|
1056
|
-
hestia_earth_models-0.59.
|
|
1052
|
+
hestia_earth_models-0.59.7.dist-info/LICENSE,sha256=EFSZhfUdZCTsCIYdHzTGewMKfRfp7X9t1s2aaKxm8O0,1154
|
|
1053
|
+
hestia_earth_models-0.59.7.dist-info/METADATA,sha256=ZIvcMUOqXgRxksT65t2aFMM4hzvl0Wox15BJuffBBGo,3134
|
|
1054
|
+
hestia_earth_models-0.59.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
1055
|
+
hestia_earth_models-0.59.7.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
|
|
1056
|
+
hestia_earth_models-0.59.7.dist-info/RECORD,,
|
|
@@ -27,11 +27,23 @@ def test_run_crop(*args):
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
@patch(f"{class_path}.download_hestia", return_value={})
|
|
30
|
-
def
|
|
31
|
-
with open(f"{fixtures_folder}/animalProduct/cycle.jsonld", encoding='utf-8') as f:
|
|
30
|
+
def test_run_animalProduct_kg(*args):
|
|
31
|
+
with open(f"{fixtures_folder}/animalProduct/kg/cycle.jsonld", encoding='utf-8') as f:
|
|
32
32
|
cycle = json.load(f)
|
|
33
33
|
|
|
34
|
-
with open(f"{fixtures_folder}/animalProduct/result.jsonld", encoding='utf-8') as f:
|
|
34
|
+
with open(f"{fixtures_folder}/animalProduct/kg/result.jsonld", encoding='utf-8') as f:
|
|
35
|
+
expected = json.load(f)
|
|
36
|
+
|
|
37
|
+
value = run(cycle)
|
|
38
|
+
assert value == expected
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@patch(f"{class_path}.download_hestia", return_value={})
|
|
42
|
+
def test_run_animalProduct_number(*args):
|
|
43
|
+
with open(f"{fixtures_folder}/animalProduct/number/cycle.jsonld", encoding='utf-8') as f:
|
|
44
|
+
cycle = json.load(f)
|
|
45
|
+
|
|
46
|
+
with open(f"{fixtures_folder}/animalProduct/number/result.jsonld", encoding='utf-8') as f:
|
|
35
47
|
expected = json.load(f)
|
|
36
48
|
|
|
37
49
|
value = run(cycle)
|
|
@@ -20,6 +20,7 @@ from hestia_earth.models.ipcc2019.organicCarbonPerHa import (
|
|
|
20
20
|
_check_cropland_medium_category,
|
|
21
21
|
_get_carbon_input_kwargs,
|
|
22
22
|
_iterate_soc_equilibriums,
|
|
23
|
+
_should_run,
|
|
23
24
|
IpccCarbonInputCategory,
|
|
24
25
|
IpccLandUseCategory,
|
|
25
26
|
IpccManagementCategory,
|
|
@@ -103,37 +104,38 @@ def find_term_property_side_effect(term: dict, property: str, *_):
|
|
|
103
104
|
# --- TIER 1 & TIER 2 TESTS ---
|
|
104
105
|
|
|
105
106
|
|
|
106
|
-
# subfolder, load_cycles
|
|
107
|
-
|
|
108
|
-
("tier-1-and-2/cropland", True),
|
|
109
|
-
("tier-1-and-2/with-zero-carbon-input", True), # Closes issue 777
|
|
110
|
-
("tier-2/with-generalised-monthly-measurements", True), # Closes issue 600
|
|
111
|
-
("tier-2/with-incomplete-climate-data", True), # Closes issue 599
|
|
112
|
-
("tier-2/with-initial-soc", True),
|
|
113
|
-
("tier-2/with-multi-year-cycles", True),
|
|
114
|
-
("tier-2/with-multi-year-cycles-and-missing-properties", True), # Closes issue 734
|
|
115
|
-
("tier-2/without-any-measurements", True), # Closes issue 594
|
|
116
|
-
("tier-2/without-initial-soc", True),
|
|
117
|
-
("tier-2/with-irrigation", True),
|
|
118
|
-
("tier-2/with-irrigation-dates", True),
|
|
119
|
-
("tier-2/with-paddy-rice", True),
|
|
120
|
-
("tier-2/with-sand-without-date", True), # Closes issue 739
|
|
121
|
-
("tier-2/with-irrigated-upland-rice", True),
|
|
122
|
-
("tier-1/cropland-depth-as-float", False),
|
|
123
|
-
("tier-1/cropland-with-measured-soc", False),
|
|
124
|
-
("tier-1/cropland-without-measured-soc", False),
|
|
125
|
-
("tier-1/permanent-pasture", False),
|
|
126
|
-
("tier-1/should-not-run", False),
|
|
127
|
-
("tier-1/without-management-with-measured-soc", False),
|
|
128
|
-
("tier-1/land-use-change", False), # Closes issue 755
|
|
129
|
-
("tier-1/run-with-site-type", False) # Closes issue 755
|
|
107
|
+
# subfolder, load_cycles, should_run
|
|
108
|
+
SHOULD_RUN_SUBFOLDERS = [
|
|
109
|
+
("tier-1-and-2/cropland", True, True),
|
|
110
|
+
("tier-1-and-2/with-zero-carbon-input", True, True), # Closes issue 777
|
|
111
|
+
("tier-2/with-generalised-monthly-measurements", True, False), # Closes issue 600
|
|
112
|
+
("tier-2/with-incomplete-climate-data", True, False), # Closes issue 599
|
|
113
|
+
("tier-2/with-initial-soc", True, True),
|
|
114
|
+
("tier-2/with-multi-year-cycles", True, True),
|
|
115
|
+
("tier-2/with-multi-year-cycles-and-missing-properties", True, True), # Closes issue 734
|
|
116
|
+
("tier-2/without-any-measurements", True, False), # Closes issue 594
|
|
117
|
+
("tier-2/without-initial-soc", True, True),
|
|
118
|
+
("tier-2/with-irrigation", True, True),
|
|
119
|
+
("tier-2/with-irrigation-dates", True, True),
|
|
120
|
+
("tier-2/with-paddy-rice", True, False),
|
|
121
|
+
("tier-2/with-sand-without-date", True, True), # Closes issue 739
|
|
122
|
+
("tier-2/with-irrigated-upland-rice", True, False),
|
|
123
|
+
("tier-1/cropland-depth-as-float", False, True),
|
|
124
|
+
("tier-1/cropland-with-measured-soc", False, True),
|
|
125
|
+
("tier-1/cropland-without-measured-soc", False, True),
|
|
126
|
+
("tier-1/permanent-pasture", False, True),
|
|
127
|
+
("tier-1/should-not-run", False, False),
|
|
128
|
+
("tier-1/without-management-with-measured-soc", False, False),
|
|
129
|
+
("tier-1/land-use-change", False, True), # Closes issue 755
|
|
130
|
+
("tier-1/run-with-site-type", False, True), # Closes issue 755
|
|
131
|
+
("tier-1/cropland-polar", False, False) # Closes issue 794
|
|
130
132
|
]
|
|
131
133
|
|
|
132
134
|
|
|
133
135
|
@mark.parametrize(
|
|
134
|
-
"subfolder, load_cycles",
|
|
135
|
-
|
|
136
|
-
ids=[params[0] for params in
|
|
136
|
+
"subfolder, load_cycles, should_run",
|
|
137
|
+
SHOULD_RUN_SUBFOLDERS,
|
|
138
|
+
ids=[params[0] for params in SHOULD_RUN_SUBFOLDERS]
|
|
137
139
|
)
|
|
138
140
|
@patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
|
|
139
141
|
@patch(f"{class_path}.get_cover_crop_property_terms", return_value=COVER_CROP_PROPERTY_TERM_IDS)
|
|
@@ -143,8 +145,8 @@ RUN_SUBFOLDERS = [
|
|
|
143
145
|
@patch(f"{class_path}.get_upland_rice_land_cover_terms", return_value=UPLAND_RICE_LAND_COVER_TERM_IDS)
|
|
144
146
|
@patch(f"{class_path}.get_upland_rice_crop_terms", return_value=UPLAND_RICE_CROP_TERM_IDS)
|
|
145
147
|
@patch(f"{class_path}.related_cycles")
|
|
146
|
-
@patch("hestia_earth.models.utils.property.find_term_property")
|
|
147
|
-
def
|
|
148
|
+
@patch("hestia_earth.models.utils.property.find_term_property", side_effect=find_term_property_side_effect)
|
|
149
|
+
def test_should_run(
|
|
148
150
|
mock_find_term_property,
|
|
149
151
|
mock_related_cycles,
|
|
150
152
|
_mock_get_upland_rice_crop_terms,
|
|
@@ -155,7 +157,8 @@ def test_run(
|
|
|
155
157
|
_mock_get_cover_crop_property_terms,
|
|
156
158
|
_mock_new_measurement,
|
|
157
159
|
subfolder,
|
|
158
|
-
load_cycles
|
|
160
|
+
load_cycles,
|
|
161
|
+
should_run
|
|
159
162
|
):
|
|
160
163
|
folder = f"{fixtures_folder}/{subfolder}"
|
|
161
164
|
|
|
@@ -163,20 +166,17 @@ def test_run(
|
|
|
163
166
|
with open(f"{folder}/cycles.jsonld", encoding='utf-8') as f:
|
|
164
167
|
return json.load(f)
|
|
165
168
|
|
|
166
|
-
mock_find_term_property.side_effect = find_term_property_side_effect
|
|
167
169
|
mock_related_cycles.return_value = load_cycles_from_file() if load_cycles else []
|
|
168
170
|
|
|
169
171
|
with open(f"{folder}/site.jsonld", encoding='utf-8') as f:
|
|
170
172
|
site = json.load(f)
|
|
171
173
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
+
should_run_tier_1, should_run_tier_2, *_ = _should_run(site)
|
|
175
|
+
should_run_ = should_run_tier_1 or should_run_tier_2
|
|
174
176
|
|
|
175
|
-
|
|
176
|
-
assert result == expected
|
|
177
|
+
assert should_run_ == should_run
|
|
177
178
|
|
|
178
179
|
|
|
179
|
-
@patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
|
|
180
180
|
@patch(f"{class_path}.get_cover_crop_property_terms", return_value=COVER_CROP_PROPERTY_TERM_IDS)
|
|
181
181
|
@patch(f"{class_path}.get_crop_residue_incorporated_or_left_on_field_terms", return_value=CROP_RESIDUE_INCORP_TERM_IDS)
|
|
182
182
|
@patch(f"{class_path}.get_irrigated_terms", return_value=IRRIGATED_TERM_IDS)
|
|
@@ -184,11 +184,66 @@ def test_run(
|
|
|
184
184
|
@patch(f"{class_path}.get_upland_rice_land_cover_terms", return_value=UPLAND_RICE_LAND_COVER_TERM_IDS)
|
|
185
185
|
@patch(f"{class_path}.get_upland_rice_crop_terms", return_value=UPLAND_RICE_CROP_TERM_IDS)
|
|
186
186
|
@patch(f"{class_path}.related_cycles", return_value=[])
|
|
187
|
-
|
|
187
|
+
@patch("hestia_earth.models.utils.property.find_term_property", side_effect=find_term_property_side_effect)
|
|
188
|
+
def test_should_run_no_data(*args):
|
|
188
189
|
SITE = {}
|
|
189
|
-
EXPECTED =
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
EXPECTED = False
|
|
191
|
+
|
|
192
|
+
should_run_tier_1, should_run_tier_2, *_ = _should_run(SITE)
|
|
193
|
+
should_run = should_run_tier_1 or should_run_tier_2
|
|
194
|
+
|
|
195
|
+
assert should_run == EXPECTED
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
RUN_SUBFOLDERS = [
|
|
199
|
+
(subfolder, load_cycles) for subfolder, load_cycles, should_run in SHOULD_RUN_SUBFOLDERS
|
|
200
|
+
if should_run
|
|
201
|
+
]
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
@mark.parametrize(
|
|
205
|
+
"subfolder, load_cycles",
|
|
206
|
+
RUN_SUBFOLDERS,
|
|
207
|
+
ids=[params[0] for params in RUN_SUBFOLDERS]
|
|
208
|
+
)
|
|
209
|
+
@patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
|
|
210
|
+
@patch(f"{class_path}.get_cover_crop_property_terms", return_value=COVER_CROP_PROPERTY_TERM_IDS)
|
|
211
|
+
@patch(f"{class_path}.get_crop_residue_incorporated_or_left_on_field_terms", return_value=CROP_RESIDUE_INCORP_TERM_IDS)
|
|
212
|
+
@patch(f"{class_path}.get_irrigated_terms", return_value=IRRIGATED_TERM_IDS)
|
|
213
|
+
@patch(f"{class_path}.get_residue_removed_or_burnt_terms", return_value=RESIDUE_REMOVED_OR_BURNT_TERM_IDS)
|
|
214
|
+
@patch(f"{class_path}.get_upland_rice_land_cover_terms", return_value=UPLAND_RICE_LAND_COVER_TERM_IDS)
|
|
215
|
+
@patch(f"{class_path}.get_upland_rice_crop_terms", return_value=UPLAND_RICE_CROP_TERM_IDS)
|
|
216
|
+
@patch(f"{class_path}.related_cycles")
|
|
217
|
+
@patch("hestia_earth.models.utils.property.find_term_property", side_effect=find_term_property_side_effect)
|
|
218
|
+
def test_run(
|
|
219
|
+
mock_find_term_property,
|
|
220
|
+
mock_related_cycles,
|
|
221
|
+
_mock_get_upland_rice_crop_terms,
|
|
222
|
+
_mock_get_upland_rice_land_cover_terms,
|
|
223
|
+
_mock_get_residue_removed_or_burnt_terms,
|
|
224
|
+
_mock_get_irrigated_terms,
|
|
225
|
+
_mock_get_crop_residue_incorporated_or_left_on_field_terms,
|
|
226
|
+
_mock_get_cover_crop_property_terms,
|
|
227
|
+
_mock_new_measurement,
|
|
228
|
+
subfolder,
|
|
229
|
+
load_cycles
|
|
230
|
+
):
|
|
231
|
+
folder = f"{fixtures_folder}/{subfolder}"
|
|
232
|
+
|
|
233
|
+
def load_cycles_from_file():
|
|
234
|
+
with open(f"{folder}/cycles.jsonld", encoding='utf-8') as f:
|
|
235
|
+
return json.load(f)
|
|
236
|
+
|
|
237
|
+
mock_related_cycles.return_value = load_cycles_from_file() if load_cycles else []
|
|
238
|
+
|
|
239
|
+
with open(f"{folder}/site.jsonld", encoding='utf-8') as f:
|
|
240
|
+
site = json.load(f)
|
|
241
|
+
|
|
242
|
+
with open(f"{folder}/result.jsonld", encoding='utf-8') as f:
|
|
243
|
+
expected = json.load(f)
|
|
244
|
+
|
|
245
|
+
result = run(site)
|
|
246
|
+
assert result == expected
|
|
192
247
|
|
|
193
248
|
|
|
194
249
|
# --- TIER 2 TESTS: SUB-MODELS ---
|
|
File without changes
|
|
File without changes
|
|
File without changes
|