hestia-earth-models 0.70.6__py3-none-any.whl → 0.72.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.
- hestia_earth/models/cache_nodes.py +157 -0
- hestia_earth/models/cache_sites.py +1 -1
- hestia_earth/models/config/Cycle.json +0 -30
- hestia_earth/models/config/Site.json +8 -0
- hestia_earth/models/data/ecoinventV3/__init__.py +7 -5
- hestia_earth/models/ecoinventV3/__init__.py +8 -1
- hestia_earth/models/geospatialDatabase/histosol.py +14 -7
- hestia_earth/models/hestia/aboveGroundCropResidue.py +3 -3
- hestia_earth/models/hestia/histosol.py +53 -0
- hestia_earth/models/hestia/seed_emissions.py +25 -21
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1.py +22 -7
- hestia_earth/models/mocking/search-results.json +1172 -1168
- hestia_earth/models/utils/aggregated.py +3 -3
- hestia_earth/models/utils/background_emissions.py +24 -0
- hestia_earth/models/utils/measurement.py +16 -3
- hestia_earth/models/utils/pesticideAI.py +1 -1
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.70.6.dist-info → hestia_earth_models-0.72.0.dist-info}/METADATA +3 -3
- {hestia_earth_models-0.70.6.dist-info → hestia_earth_models-0.72.0.dist-info}/RECORD +26 -26
- tests/models/geospatialDatabase/test_histosol.py +21 -20
- tests/models/hestia/test_histosol.py +24 -0
- tests/models/ipcc2019/test_organicCarbonPerHa_tier_1.py +4 -3
- tests/models/test_cache_nodes.py +31 -0
- hestia_earth/models/ipcc2006/co2ToAirOrganicSoilCultivation.py +0 -100
- hestia_earth/models/ipcc2006/n2OToAirOrganicSoilCultivationDirect.py +0 -99
- tests/models/ipcc2006/test_co2ToAirOrganicSoilCultivation.py +0 -49
- tests/models/ipcc2006/test_n2OToAirOrganicSoilCultivationDirect.py +0 -32
- {hestia_earth_models-0.70.6.dist-info → hestia_earth_models-0.72.0.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.70.6.dist-info → hestia_earth_models-0.72.0.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.70.6.dist-info → hestia_earth_models-0.72.0.dist-info}/top_level.txt +0 -0
@@ -52,12 +52,12 @@ def find_closest_impact(cycle: dict, end_date: str, term: dict, country: dict, m
|
|
52
52
|
'minimum_should_match': 1
|
53
53
|
}
|
54
54
|
} if term else None,
|
55
|
-
_match_country(country)
|
55
|
+
_match_country(country),
|
56
|
+
{'range': {'endDate': {'lte': f"{end_date}-12-31"}}}
|
56
57
|
]) + must_queries,
|
57
58
|
'should': [
|
58
59
|
# if the Cycle is organic, we can try to match organic aggregate first
|
59
|
-
{'match': {'name': {'query': 'Organic' if is_organic(cycle) else 'Conventional', 'boost': 1000}}}
|
60
|
-
{'match': {'endDate': {'query': end_date, 'boost': 1000}}}
|
60
|
+
{'match': {'name': {'query': 'Organic' if is_organic(cycle) else 'Conventional', 'boost': 1000}}}
|
61
61
|
]
|
62
62
|
}
|
63
63
|
}
|
@@ -1,7 +1,11 @@
|
|
1
|
+
from hestia_earth.schema import TermTermType
|
1
2
|
from hestia_earth.utils.model import find_term_match
|
2
3
|
from hestia_earth.utils.tools import flatten
|
4
|
+
from hestia_earth.utils.emission import cycle_emissions_in_system_boundary
|
3
5
|
|
6
|
+
from hestia_earth.models.log import logShouldRun
|
4
7
|
from . import is_from_model
|
8
|
+
from .blank_node import get_lookup_value
|
5
9
|
|
6
10
|
|
7
11
|
def _animal_inputs(animal: dict):
|
@@ -50,3 +54,23 @@ def no_gap_filled_background_emissions(cycle: dict):
|
|
50
54
|
])
|
51
55
|
|
52
56
|
return check_input
|
57
|
+
|
58
|
+
|
59
|
+
def all_background_emission_term_ids(cycle: dict):
|
60
|
+
term_ids = cycle_emissions_in_system_boundary(cycle)
|
61
|
+
return list(set([
|
62
|
+
get_lookup_value({'termType': TermTermType.EMISSION.value, '@id': term_id}, 'inputProductionGroupId')
|
63
|
+
for term_id in term_ids
|
64
|
+
]))
|
65
|
+
|
66
|
+
|
67
|
+
def log_missing_emissions(cycle: dict, **log_args):
|
68
|
+
all_emission_term_ids = all_background_emission_term_ids(cycle)
|
69
|
+
|
70
|
+
def log_input(input_term_id: str, included_emission_term_ids: list):
|
71
|
+
missing_emission_term_ids = [
|
72
|
+
term_id for term_id in all_emission_term_ids if term_id not in included_emission_term_ids
|
73
|
+
]
|
74
|
+
for emission_id in missing_emission_term_ids:
|
75
|
+
logShouldRun(cycle, term=input_term_id, should_run=False, emission_id=emission_id, **log_args)
|
76
|
+
return log_input
|
@@ -3,9 +3,9 @@ from collections.abc import Iterable
|
|
3
3
|
from functools import reduce
|
4
4
|
from statistics import mode, mean
|
5
5
|
from typing import Any, Optional, Union
|
6
|
-
from hestia_earth.schema import MeasurementMethodClassification, SchemaType
|
7
|
-
from hestia_earth.utils.model import linked_node
|
8
|
-
from hestia_earth.utils.tools import non_empty_list, flatten, safe_parse_float
|
6
|
+
from hestia_earth.schema import MeasurementMethodClassification, SchemaType, TermTermType
|
7
|
+
from hestia_earth.utils.model import linked_node, filter_list_term_type
|
8
|
+
from hestia_earth.utils.tools import non_empty_list, flatten, safe_parse_float, list_sum
|
9
9
|
from hestia_earth.utils.date import diff_in_days
|
10
10
|
|
11
11
|
from . import flatten_args
|
@@ -295,3 +295,16 @@ def group_measurements_by_method_classification(
|
|
295
295
|
|
296
296
|
grouped_nodes = reduce(group_node, valid_nodes, defaultdict(list))
|
297
297
|
return dict(grouped_nodes)
|
298
|
+
|
299
|
+
|
300
|
+
def total_other_soilType_value(measurements: list, term_id: str):
|
301
|
+
sum_group = get_lookup_value({'@id': term_id, 'termType': TermTermType.SOILTYPE.value}, 'sumMax100Group')
|
302
|
+
measurements = [
|
303
|
+
m for m in filter_list_term_type(measurements, TermTermType.SOILTYPE)
|
304
|
+
if all([
|
305
|
+
get_lookup_value(m.get('term'), 'sumMax100Group') == sum_group,
|
306
|
+
m.get('depthUpper', 0) == 0,
|
307
|
+
m.get('depthLower', 0) == 30
|
308
|
+
])
|
309
|
+
]
|
310
|
+
return list_sum([list_sum(m.get('value') or []) for m in measurements])
|
@@ -34,7 +34,7 @@ def impact_lookup_value(model: str, term_id: str, impact_assessment: dict, looku
|
|
34
34
|
lookup_col=lookup_col,
|
35
35
|
term_type_pesticideVeterinaryDrug_complete=is_complete,
|
36
36
|
has_pesticides_inputs=has_pesticides_inputs,
|
37
|
-
|
37
|
+
impact_value_from_pesticide_ais=pesticides_total_value)
|
38
38
|
|
39
39
|
should_run = is_complete and any([
|
40
40
|
len(pesticides) == 0,
|
hestia_earth/models/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
VERSION = '0.
|
1
|
+
VERSION = '0.72.0'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: hestia-earth-models
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.72.0
|
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
|
@@ -11,14 +11,14 @@ 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==
|
14
|
+
Requires-Dist: hestia-earth-schema==33.*
|
15
15
|
Requires-Dist: hestia-earth-utils>=0.14.1
|
16
16
|
Requires-Dist: python-dateutil>=2.8.1
|
17
17
|
Requires-Dist: CurrencyConverter==0.16.8
|
18
18
|
Requires-Dist: haversine>=2.7.0
|
19
19
|
Requires-Dist: pydash
|
20
20
|
Provides-Extra: spatial
|
21
|
-
Requires-Dist: hestia-earth-earth-engine>=0.
|
21
|
+
Requires-Dist: hestia-earth-earth-engine>=0.5.0; extra == "spatial"
|
22
22
|
|
23
23
|
# HESTIA Engine Models
|
24
24
|
|
@@ -1,10 +1,11 @@
|
|
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/
|
3
|
+
hestia_earth/models/cache_nodes.py,sha256=CqcTkvT0SQw-MKExUJgM3wDRt2sgdxgVYb6ylNnfC4I,5423
|
4
|
+
hestia_earth/models/cache_sites.py,sha256=VwUNMhmCXZIEnligS0jtcWDdn13GIknpzxBMWzG9kcg,6353
|
4
5
|
hestia_earth/models/log.py,sha256=eRuH86v7Thuw-QXdKqaqVmA_MkwnOCo0UBEwtuDq4Oc,3554
|
5
6
|
hestia_earth/models/preload_requests.py,sha256=vK_G1UzhNMhYy7ymnCtHUz_vv3cfApCSKqv29VREEBQ,1943
|
6
7
|
hestia_earth/models/requirements.py,sha256=eU4yT443fx7BnaokhrLB_PCizJI7Y6m4auyo8vQauNg,17363
|
7
|
-
hestia_earth/models/version.py,sha256=
|
8
|
+
hestia_earth/models/version.py,sha256=oZa0yE6Lt-ORDt2I3jrU1imNWQVvSZ1o__484ngeMDI,19
|
8
9
|
hestia_earth/models/agribalyse2016/__init__.py,sha256=WvK0qCQbnYtg9oZxrACd1wGormZyXibPtpCnIQeDqbw,415
|
9
10
|
hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=1ngl8pdxeNhlVV8keAeWRwGorr_1uFXM9EoPUWx-uSc,4382
|
10
11
|
hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=queToXuzq0tQ9_XuUJ2pJgSywXmbt9uX3ZoIKgqkROM,2660
|
@@ -33,9 +34,9 @@ hestia_earth/models/cml2001Baseline/terrestrialAcidificationPotentialIncludingFa
|
|
33
34
|
hestia_earth/models/cml2001NonBaseline/__init__.py,sha256=vI8wp8Og_e8DiJqYYvp33YoI3t4ffAC31LWlnV20JTg,419
|
34
35
|
hestia_earth/models/cml2001NonBaseline/eutrophicationPotentialIncludingFateAverageEurope.py,sha256=lcgyRHY08KCBFPERJNqV4DYGEJCvyHBDnJXD0kEkVqM,1097
|
35
36
|
hestia_earth/models/cml2001NonBaseline/terrestrialAcidificationPotentialExcludingFate.py,sha256=xcrxfs9UoV_EWvV-XzMt35oPWCUsTzqg2SGA3j2MFIw,1091
|
36
|
-
hestia_earth/models/config/Cycle.json,sha256=
|
37
|
+
hestia_earth/models/config/Cycle.json,sha256=3akuXAYWwsTc9v4g8y0yGQooDXc_D4y8J5Q7RFLTAmg,58113
|
37
38
|
hestia_earth/models/config/ImpactAssessment.json,sha256=R22Pa6Szl05s13xFGKmrVZ4EgKD4UyUrruxxVujsJt4,56201
|
38
|
-
hestia_earth/models/config/Site.json,sha256=
|
39
|
+
hestia_earth/models/config/Site.json,sha256=dp5tQ37lU_xakeWg4UAgqQR3YoCS7BkasYo1TtNHabo,14074
|
39
40
|
hestia_earth/models/config/__init__.py,sha256=l1WqL7ezlank86ABP4zUia_hIvM9ba-sOE3z6wNrea8,2333
|
40
41
|
hestia_earth/models/config/run-calculations.json,sha256=e3nJ4M6CP1iFzfv8ou_ZUFbFxYkDxJgwuNDXTm4PBDc,615
|
41
42
|
hestia_earth/models/config/trigger-calculations.json,sha256=3dmn2bRuj6QEtSTOLdIy31ho7thgUXyDsnqZzPV9rAQ,623
|
@@ -93,14 +94,14 @@ hestia_earth/models/cycle/product/value.py,sha256=JYHlfmOakU1xgDcgGWc78WzRd50HYq
|
|
93
94
|
hestia_earth/models/dammgen2009/__init__.py,sha256=dZ8tIXl6e3ZEixYrWiW7rzoqRJVFOoxi4RPvM3N0L1E,412
|
94
95
|
hestia_earth/models/dammgen2009/noxToAirExcreta.py,sha256=QTavWhklMVD00Z5YyinTrheqZwW85frjYEJPYtHWKDg,1744
|
95
96
|
hestia_earth/models/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
96
|
-
hestia_earth/models/data/ecoinventV3/__init__.py,sha256=
|
97
|
+
hestia_earth/models/data/ecoinventV3/__init__.py,sha256=DK1avgh58KlsUJY4nOTAaRlKsISJF4MOrrxdByHDr4o,1240
|
97
98
|
hestia_earth/models/deRuijterEtAl2010/__init__.py,sha256=lbH6mB98dmZZlwdZctNYtEmVwAow957l80Dv7JSPDsI,418
|
98
99
|
hestia_earth/models/deRuijterEtAl2010/nh3ToAirCropResidueDecomposition.py,sha256=2z10WqMsGUDDO8xJ3lmXvSUHgzz2t6PPRDha5NHoT5s,3291
|
99
100
|
hestia_earth/models/ecoalimV9/__init__.py,sha256=_evwL-DZejYohms9PUi4TNqLic44-UbOzw178wak7Pk,410
|
100
101
|
hestia_earth/models/ecoalimV9/cycle.py,sha256=i_Ydzqt9JN3akmZMToz_JJq_nd_pCUZ-4D0wM_0BhgY,4725
|
101
102
|
hestia_earth/models/ecoalimV9/impact_assessment.py,sha256=HY2hvAq9Fv-rreroHdWpXxRCP3s6GD_5eWpcB8UWzhs,4506
|
102
103
|
hestia_earth/models/ecoalimV9/utils.py,sha256=AWmWQhjvze3J6s35bH-EQIGc58xCeMA8_56hQD7CX8A,1170
|
103
|
-
hestia_earth/models/ecoinventV3/__init__.py,sha256=
|
104
|
+
hestia_earth/models/ecoinventV3/__init__.py,sha256=SleW3Mrg1g9mvJpyzWq_9CUDvruZfydenBOrfUNzG7o,5339
|
104
105
|
hestia_earth/models/ecoinventV3/utils.py,sha256=RxqaHB9hr0RdTKSjfvDN0pC8DIOyxMCr4I_xjas1POw,460
|
105
106
|
hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py,sha256=N2XY-DADYgxHvPsery5wg7K_m_S83o-HMR0LtHd4uHE,5844
|
106
107
|
hestia_earth/models/ecoinventV3AndEmberClimate/utils.py,sha256=AzslK6YB0jxVMLfkLVmhHpkM7mx639N0mIWbErD6GMw,1133
|
@@ -154,7 +155,7 @@ hestia_earth/models/geospatialDatabase/ecoClimateZone.py,sha256=WBeaYmzer3CeviHn
|
|
154
155
|
hestia_earth/models/geospatialDatabase/ecoregion.py,sha256=Hr2zJd-KGmOB5PU6nAbTtnUDWMBwhFOUf8PwT-lcPis,1206
|
155
156
|
hestia_earth/models/geospatialDatabase/erodibility.py,sha256=M62CetEcHuExeXl7P7DVKZWWbk9tenjaDFvjMsWbga4,1843
|
156
157
|
hestia_earth/models/geospatialDatabase/heavyWinterPrecipitation.py,sha256=54pvHOfcfEUNNhTIWIPGRzqO_t59ACh-zhnLidO2xro,1956
|
157
|
-
hestia_earth/models/geospatialDatabase/histosol.py,sha256=
|
158
|
+
hestia_earth/models/geospatialDatabase/histosol.py,sha256=uVl96zpxPHYDW81SxnEpMPpNeVdfzBYRCUhVP6EFN4A,2614
|
158
159
|
hestia_earth/models/geospatialDatabase/longFallowRatio.py,sha256=X-qJS0euYVwhGHd4rCnlRSL3KOMLQJl5kO8QqSREcpA,2561
|
159
160
|
hestia_earth/models/geospatialDatabase/nutrientLossToAquaticEnvironment.py,sha256=uEsoYJ1mzgUo6fQhUrcJ-ATcFw1j9oEgqMXKbQuFRxQ,1973
|
160
161
|
hestia_earth/models/geospatialDatabase/organicCarbonPerKgSoil.py,sha256=O_3GdoyY3FrwAq37MHleb0kiXZhsqpuAcik9TYpAvU4,2830
|
@@ -183,7 +184,7 @@ hestia_earth/models/haversineFormula/__init__.py,sha256=o155nR-XI67iCSBVNYIu4sPR
|
|
183
184
|
hestia_earth/models/haversineFormula/transport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
184
185
|
hestia_earth/models/haversineFormula/transport/distance.py,sha256=l00mmyRgWsHWFtk4OTFrhqyOmc-73C4Wkfn5WKM99TA,3990
|
185
186
|
hestia_earth/models/hestia/__init__.py,sha256=o5vAmPzSaK9XPgL8GCne3-lugfCOgZhHELYolNgqyyY,407
|
186
|
-
hestia_earth/models/hestia/aboveGroundCropResidue.py,sha256=
|
187
|
+
hestia_earth/models/hestia/aboveGroundCropResidue.py,sha256=7OOO2_0nVoEwqslZ-daATfFTcm_GhAZR1NWBV_ULcYw,5903
|
187
188
|
hestia_earth/models/hestia/aboveGroundCropResidueTotal.py,sha256=NcaHzSLTmTP0yTO_2mqqouNzkCVYRkDm31LZqOCiFD4,2715
|
188
189
|
hestia_earth/models/hestia/brackishWater.py,sha256=znc-p3W7sclCeytj3Jg6YUzGu2tFD8inswjapn-_8ds,1285
|
189
190
|
hestia_earth/models/hestia/cationExchangeCapacityPerKgSoil.py,sha256=GtF-X2ogdXLX0dKed8d2L3baI5MfpN6UXZbZm2aG3Es,3660
|
@@ -198,6 +199,7 @@ hestia_earth/models/hestia/excretaKgN.py,sha256=-GfHPx6AECNPW2i_ioCuf-DhW7Xau201
|
|
198
199
|
hestia_earth/models/hestia/excretaKgVs.py,sha256=fzBV7hgznevLTcvHyHKQk9upkCgmJ0xH1NuMETeSF8A,2860
|
199
200
|
hestia_earth/models/hestia/flowingWater.py,sha256=Iy5PCWun7GMrr0zszd0zpp9lKADpXesjC3doqLY4n28,1603
|
200
201
|
hestia_earth/models/hestia/freshWater.py,sha256=EHUWNFmgIqr9y7DTcn1_HcpJdI7WP1cv4LMrkpaf8zQ,1262
|
202
|
+
hestia_earth/models/hestia/histosol.py,sha256=IexiWTSlSJYGjrdpYmRooW6v8LjhYATPQ8smMz1UZBA,1612
|
201
203
|
hestia_earth/models/hestia/inorganicFertiliser.py,sha256=SQv5X4vkgmvUIUV79dJ71Y9u2EW3T5Scu2GoTr3K0Yw,8930
|
202
204
|
hestia_earth/models/hestia/irrigatedTypeUnspecified.py,sha256=VdYzfYxcRzWv21qxRkDn9HBid7-Bt_CgIv4iyXJH03g,1929
|
203
205
|
hestia_earth/models/hestia/landCover.py,sha256=Bt7zQzp8gS0oL8ljsXLYPBG5cQzxOkFaJnKwrcTDlxQ,32360
|
@@ -230,7 +232,7 @@ hestia_earth/models/hestia/residueLeftOnField.py,sha256=EZoPlDhh1aNJvPT52Bvro6xc
|
|
230
232
|
hestia_earth/models/hestia/residueRemoved.py,sha256=2I4wTJJcORrhkWiRJOzjwxRMIn3Jjeggh1dhFC2CK4Y,4969
|
231
233
|
hestia_earth/models/hestia/resourceUse_utils.py,sha256=SYMN-40NW76LaVo2jVdnCbTgYN03mmSqvYRzgDzm5jI,8564
|
232
234
|
hestia_earth/models/hestia/salineWater.py,sha256=NB9nu1oiqbUd0k-9chBsY92vOsg5mDrSf1OCR3tlA6k,1263
|
233
|
-
hestia_earth/models/hestia/seed_emissions.py,sha256
|
235
|
+
hestia_earth/models/hestia/seed_emissions.py,sha256=-XON8tXYU2qTy4QQE6rvzL1iKut91rwWsW7fcMyl44I,11372
|
234
236
|
hestia_earth/models/hestia/soilMeasurement.py,sha256=cP4nuz2DE-FLaFbP-0fG5wbIgU28s3n4-lo8-RTFpF0,7088
|
235
237
|
hestia_earth/models/hestia/stockingDensityAnimalHousingAverage.py,sha256=Ce0RZmAADDtGksfXzhX4lh-jdAs3WlCQqy2FAF3xFjo,1850
|
236
238
|
hestia_earth/models/hestia/temperatureAnnual.py,sha256=IhMoO-SkSp1JBxgu9bSr1OCtr7QQlZsoCXqhsWeEprs,1963
|
@@ -264,7 +266,6 @@ hestia_earth/models/ipcc2006/__init__.py,sha256=ReUFPLqIyp16QEOGaiHmz41QbuwYBQYD
|
|
264
266
|
hestia_earth/models/ipcc2006/aboveGroundCropResidueRemoved.py,sha256=6FDgMH5eiO1mEn20oerYpWty6t9058JS3MCdfVmeY_o,2714
|
265
267
|
hestia_earth/models/ipcc2006/aboveGroundCropResidueTotal.py,sha256=vD_kpvOJmjTOjDEnlqSYBSZxjuPGvzpmCr0JIC84GKE,3431
|
266
268
|
hestia_earth/models/ipcc2006/belowGroundCropResidue.py,sha256=KzeRphJb1IWB_EPVcxa9tbCoNmEe80D9lKxgQOqfKoU,4138
|
267
|
-
hestia_earth/models/ipcc2006/co2ToAirOrganicSoilCultivation.py,sha256=kCWC_Zibs0uZ1a1mQy-9fXzmvVL-2l_FopDnkt-ayy0,3852
|
268
269
|
hestia_earth/models/ipcc2006/n2OToAirCropResidueDecompositionDirect.py,sha256=_2oTngpspikbFwgFTtOWs-SgEVF8LzznvITGITTtol4,2913
|
269
270
|
hestia_earth/models/ipcc2006/n2OToAirCropResidueDecompositionIndirect.py,sha256=kf4WjdMzs6d8h433LFuUH9LJKJ_aMHTqEHDToGY5-Xk,2315
|
270
271
|
hestia_earth/models/ipcc2006/n2OToAirExcretaDirect.py,sha256=VvQTIh58JyhrdPk5FdJQBkjBDr5-Cv7CnGkNEcco3P4,1986
|
@@ -273,7 +274,6 @@ hestia_earth/models/ipcc2006/n2OToAirInorganicFertiliserDirect.py,sha256=0Lyhqh3
|
|
273
274
|
hestia_earth/models/ipcc2006/n2OToAirInorganicFertiliserIndirect.py,sha256=s5-pnhzz3fEYkdMZEGGlecp7XlPh_9vxyN78VoOUP2Y,3171
|
274
275
|
hestia_earth/models/ipcc2006/n2OToAirOrganicFertiliserDirect.py,sha256=xB-5jp551knTSWvJeeowO1ERpLCdXrZJKttN7xU_6RY,2396
|
275
276
|
hestia_earth/models/ipcc2006/n2OToAirOrganicFertiliserIndirect.py,sha256=NAdGaG6-5Mrrwe17ED8R_3en-zuMqHFDtrRlqi9USSI,3103
|
276
|
-
hestia_earth/models/ipcc2006/n2OToAirOrganicSoilCultivationDirect.py,sha256=TzwfuMnyQv_iLsi15Vq1cxU7Kgnu5VK6Ru9yWXtBQIA,3749
|
277
277
|
hestia_earth/models/ipcc2006/utils.py,sha256=flB7HWrynzOorKlmrpbETGD63NMv45H8Wxjj3RCav98,739
|
278
278
|
hestia_earth/models/ipcc2013ExcludingFeedbacks/__init__.py,sha256=v4Qe-X4w3tqIHGJBNnEAK81x4ZuQMwYxQYXRncugmcU,427
|
279
279
|
hestia_earth/models/ipcc2013ExcludingFeedbacks/gwp100.py,sha256=2fFEHTXxel_XPiMXQlWbgtpdLVzockhK77gmG9Yy_So,1041
|
@@ -320,7 +320,7 @@ hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py,sha
|
|
320
320
|
hestia_earth/models/ipcc2019/noxToAirInorganicFertiliser.py,sha256=fmmFgjtvOD2TrrLY03jYly_KvDnCsAXqhL_tmZQQt-A,4480
|
321
321
|
hestia_earth/models/ipcc2019/noxToAirOrganicFertiliser.py,sha256=9dx_MRTwJGxJRq6mj2EJQMdQ2w6j7lw0fQk0If_cIGc,4152
|
322
322
|
hestia_earth/models/ipcc2019/organicCarbonPerHa.py,sha256=D8Lph5clGjXb5F7sk-jlnqE30C2lokhqndpA0hUMwTk,7791
|
323
|
-
hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1.py,sha256=
|
323
|
+
hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1.py,sha256=7At4xCtNWpyzOg6GFIL_nMCpLi82Y6RleCZgXbIMi_k,79161
|
324
324
|
hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2.py,sha256=5_AltohTyRMBT8dFdULOdTS79Ydpbb2CaYZGlYQEFQY,69244
|
325
325
|
hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py,sha256=s_F3fyHhPuqragrHxluqdK0GCGnEor17jGlGKue0UsA,9867
|
326
326
|
hestia_earth/models/ipcc2019/organicSoilCultivation_utils.py,sha256=mJCKYZxqk5vFknckjIjGw478BjZbvKC_xQ-zYpvJ8xM,5628
|
@@ -444,7 +444,7 @@ hestia_earth/models/linkedImpactAssessment/utils.py,sha256=S1zlux02gU2Lajrtoq-zQ
|
|
444
444
|
hestia_earth/models/mocking/__init__.py,sha256=9VX50c-grz-snfd-7MBS0KfF7AadtbKuj7kK6PqtsgE,687
|
445
445
|
hestia_earth/models/mocking/build_mock_search.py,sha256=p15ccEUmkmLp1RiGNznxMz3OFHbI8P1-29ExuohiQN8,1355
|
446
446
|
hestia_earth/models/mocking/mock_search.py,sha256=ccFe_WrI73JElFmxp4hPNLCX7eeU--lBC1JFR901KJY,1069
|
447
|
-
hestia_earth/models/mocking/search-results.json,sha256=
|
447
|
+
hestia_earth/models/mocking/search-results.json,sha256=gfkYvS0BhyTeKKR6H6DaAMg0fUmTg1hEjf2ORpp1t1s,162536
|
448
448
|
hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
|
449
449
|
hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=Qt-mel4dkhK6N5uUOutNOinCTFjbjtGzITaaI0LvYc4,2396
|
450
450
|
hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=JT0RybbvWVlo01FO8K0Yj41HrEaJT3Kj1xfayr2X-xw,2315
|
@@ -586,11 +586,11 @@ hestia_earth/models/transformation/product/excreta.py,sha256=tggXIoUujzu8O949_3K
|
|
586
586
|
hestia_earth/models/usetoxV2/__init__.py,sha256=pK37V3H-KvYcvRKw4Mv8CWrB2N0LFLzmv0jKLdhGGqs,409
|
587
587
|
hestia_earth/models/usetoxV2/freshwaterEcotoxicityPotentialCtue.py,sha256=pPX8u-Aq6Pg5Y9xw0CS0S2WkAHQpOMl0lL2tLQwwOuU,918
|
588
588
|
hestia_earth/models/utils/__init__.py,sha256=hXSBcHSMYWjg_Fe_H5IVsxu_OmVCTummZ205t_GE6pY,6847
|
589
|
-
hestia_earth/models/utils/aggregated.py,sha256=
|
589
|
+
hestia_earth/models/utils/aggregated.py,sha256=G7FNJfHqJ_eoXB66kGdjLyZGDOI_gsF56o7VnyW3bqA,4801
|
590
590
|
hestia_earth/models/utils/animalProduct.py,sha256=M5IunAKGY6oZv3j1Ascl34ywyeLWApqOIlBzbtlA2FE,721
|
591
591
|
hestia_earth/models/utils/aquacultureManagement.py,sha256=dxrbC1Xf140cohxTbSw6TxLAnAASWTdNZwBBam4yQnw,171
|
592
592
|
hestia_earth/models/utils/array_builders.py,sha256=ko1pDZKaUudZqxOZ99vJamKAdoR6ND4ZmxVrYH6YjPc,19498
|
593
|
-
hestia_earth/models/utils/background_emissions.py,sha256=
|
593
|
+
hestia_earth/models/utils/background_emissions.py,sha256=ywxhI_x8zHnFootp5jzimUaNGHRsInnp8F0pBGIviVg,2870
|
594
594
|
hestia_earth/models/utils/blank_node.py,sha256=zQhMFG4o7kUQY0J_7g84E8E1hwatSRZINTUb6fELB2s,56040
|
595
595
|
hestia_earth/models/utils/cache_sources.py,sha256=MBkrPpjwNiC4ApDjeYVHZjWBbpvAerXRDrMHpjasAZ0,377
|
596
596
|
hestia_earth/models/utils/completeness.py,sha256=iRG4uviOAQQ4T2Nr4LlelPVTS_F1felGZNJYxek_JG8,1239
|
@@ -615,10 +615,10 @@ hestia_earth/models/utils/landCover.py,sha256=8-nfynzCx9gf9YfhpuoH6Cn4kQwWFpYA5R
|
|
615
615
|
hestia_earth/models/utils/liveAnimal.py,sha256=GnajBPZw5d94raf80KtLloaOqlfqGAPwUtP9bRlGWeE,1754
|
616
616
|
hestia_earth/models/utils/lookup.py,sha256=UCkg_MluWfgkznQBCXCZECahGmI7VNszVclLGRoXhlA,6190
|
617
617
|
hestia_earth/models/utils/management.py,sha256=urvoHvTw5wrO12POjGQ50Or25X1Y4Gx26l4fDoVt-Ck,376
|
618
|
-
hestia_earth/models/utils/measurement.py,sha256=
|
618
|
+
hestia_earth/models/utils/measurement.py,sha256=EalW6D3wnD7jygV-m1miIZRkQ_S9qIqWGuXpcDrYk28,11685
|
619
619
|
hestia_earth/models/utils/method.py,sha256=ZYN2_Fyeiwr9pmvD84ZPg7ZHBlvaIY2A6XL4F_KByS0,740
|
620
620
|
hestia_earth/models/utils/organicFertiliser.py,sha256=2HY-a0EBzUw4DkEAXClLMXVCEZTKYf0BwFHBo7lQ5Tg,363
|
621
|
-
hestia_earth/models/utils/pesticideAI.py,sha256=
|
621
|
+
hestia_earth/models/utils/pesticideAI.py,sha256=DQIAjgkWjKPyuMLUvnEgVkeQGCEOBjyJJktWU747b00,2047
|
622
622
|
hestia_earth/models/utils/practice.py,sha256=GEu2G2yMPbcIHldOzgv5OFp8bQ1Jt9OFgj0c_0F_kUc,372
|
623
623
|
hestia_earth/models/utils/product.py,sha256=Oha4lMvediC1Lc5DksA6sAUT94Q1Cs9F4LFVe_uaqP4,11177
|
624
624
|
hestia_earth/models/utils/productivity.py,sha256=rTJX_nemxHpOcPN7jiM2hFHknoLUIW8y-hFxVxIkg70,593
|
@@ -650,6 +650,7 @@ hestia_earth/orchestrator/strategies/run/add_blank_node_if_missing.py,sha256=lAf
|
|
650
650
|
hestia_earth/orchestrator/strategies/run/add_key_if_missing.py,sha256=t3U-v87XpbtpsvjA_r0Ftm7MhNkGB0kcUSGFlKBIK_I,352
|
651
651
|
hestia_earth/orchestrator/strategies/run/always.py,sha256=D0In6_kr28s-fgqspawgvj5cgFClxGvepZYqtYsjWVE,217
|
652
652
|
tests/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
653
|
+
tests/models/test_cache_nodes.py,sha256=lSSoBGFVXpNv_TePSetls6QbnhfLC7dNLmfiFqT6WuY,1043
|
653
654
|
tests/models/test_cache_sites.py,sha256=eZkbgAhfA-67GhPgE4lk8byHnYvX2Ate1KPsE6jH1-c,2954
|
654
655
|
tests/models/test_config.py,sha256=w27OA_pk9NuDbxzMD--l72Ea97SL1HS6bos6mOUCy8k,3386
|
655
656
|
tests/models/test_ecoinventV3.py,sha256=SvBn1ZomoturZhjj4BE2EU46Sq0il-tOJIqutmGadWs,2023
|
@@ -789,7 +790,7 @@ tests/models/geospatialDatabase/test_ecoClimateZone.py,sha256=ad0BBOhjl6uMUP_-Qh
|
|
789
790
|
tests/models/geospatialDatabase/test_ecoregion.py,sha256=xPEXQKXpF4ghpVwuyZWC-4mmN9qywF-s_QKkmU40H70,868
|
790
791
|
tests/models/geospatialDatabase/test_erodibility.py,sha256=UW6SZS1nY3rzr2TqRcFDoq6a5KJ6ox-8L0k-im23R0s,1013
|
791
792
|
tests/models/geospatialDatabase/test_heavyWinterPrecipitation.py,sha256=1xv7L_b3ochbcu6y6TQrTUL0ZLr6aR44kAPsEN_1kAE,1026
|
792
|
-
tests/models/geospatialDatabase/test_histosol.py,sha256=
|
793
|
+
tests/models/geospatialDatabase/test_histosol.py,sha256=neoBruV0gRGm2PheAZiuTjIFiqzQss-FRUENjjM3zmc,1170
|
793
794
|
tests/models/geospatialDatabase/test_longFallowRatio.py,sha256=VoYURFuOnlC8ozxcMLTzv99MGlymlVXd596T5MKVvOU,1004
|
794
795
|
tests/models/geospatialDatabase/test_nutrientLossToAquaticEnvironment.py,sha256=ZtoNdI_dB3Nk79Ts9JJrlda7z6HRE2cwCQHC2DiWCsY,1034
|
795
796
|
tests/models/geospatialDatabase/test_organicCarbonPerKgSoil.py,sha256=sx9raq5YGuyVjZ5GfNeo36LXNT5zfvn3W-kDWeoaJWI,1636
|
@@ -834,6 +835,7 @@ tests/models/hestia/test_excretaKgVs.py,sha256=3dNFATeYM5LI1y3Q3m5cbazvNp-zMKLwt
|
|
834
835
|
tests/models/hestia/test_feedConversionRatio.py,sha256=LgO9Tl4yHKh0XyTe9dXqt1ccqY2UFcrJh5fIUfFMq9w,2132
|
835
836
|
tests/models/hestia/test_flowingWater.py,sha256=0-70Iyr0HKQHHC5jFEF9LUQQZ23spOo5tFWXQ8kfR7w,1372
|
836
837
|
tests/models/hestia/test_freshWater.py,sha256=v2UD69csKrniKP3MXkOEHxQeE6O3-lvIViCvLA7Zgws,984
|
838
|
+
tests/models/hestia/test_histosol.py,sha256=7g-3wQPZok2O8mExcnKZxO_T2Ye_h3UHv3HG3Kn8orM,888
|
837
839
|
tests/models/hestia/test_inorganicFertiliser.py,sha256=v2Zs1Ig-ChOaq9gXuurcBt12izkH2bRUUuzW6rh3rqQ,643
|
838
840
|
tests/models/hestia/test_irrigatedTypeUnspecified.py,sha256=bluZADFagxfXW4QyI0CIJzG97D2V33w333Z9Vwjqo0M,2015
|
839
841
|
tests/models/hestia/test_landCover.py,sha256=XwzHCbJQt-jBpCnXcWLumTREyMNEEkUAuM2GViJl3iU,7492
|
@@ -894,7 +896,6 @@ tests/models/ipcc2006/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
894
896
|
tests/models/ipcc2006/test_aboveGroundCropResidueRemoved.py,sha256=5F7eU4qWYfTZAzjUsuUOE5rA2vZ0x6e6Bm10PgmG9Zg,1177
|
895
897
|
tests/models/ipcc2006/test_aboveGroundCropResidueTotal.py,sha256=FrSR1xBTRtJ99pXAklXLtDRC00FSW1vXSAvQNeBoXTQ,1725
|
896
898
|
tests/models/ipcc2006/test_belowGroundCropResidue.py,sha256=cFqLDFy5pcgOyzKC9l-RClEP6CWCdVNnq48S90SITVM,1720
|
897
|
-
tests/models/ipcc2006/test_co2ToAirOrganicSoilCultivation.py,sha256=wM1BYFcK28aiNVP6JUEWdc90kCd3w4rjOnpxzwuYV_o,1609
|
898
899
|
tests/models/ipcc2006/test_n2OToAirCropResidueDecompositionDirect.py,sha256=pgUznkTiyLwhMVHzFE40wzwvtY40OsPQp1QWTsaPDqU,1815
|
899
900
|
tests/models/ipcc2006/test_n2OToAirCropResidueDecompositionIndirect.py,sha256=cxn5rX_pZqbl7m8rhJARuyjG2P5O-BQbufeEcTmO06k,1357
|
900
901
|
tests/models/ipcc2006/test_n2OToAirExcretaDirect.py,sha256=tm6Lm90_4qEkCU6UIFsOD6yhrMrq69lkF1LvCjXPjE4,2132
|
@@ -903,7 +904,6 @@ tests/models/ipcc2006/test_n2OToAirInorganicFertiliserDirect.py,sha256=Z385htV4X
|
|
903
904
|
tests/models/ipcc2006/test_n2OToAirInorganicFertiliserIndirect.py,sha256=wmasF-q-IwMbEfnKzCHBGqnSQtY8Xg0OohccvofnwQY,1283
|
904
905
|
tests/models/ipcc2006/test_n2OToAirOrganicFertiliserDirect.py,sha256=L6J9s9Xp__zIS1xzz0WUg83fpdOo8c9t6wWrNeQMuM8,1688
|
905
906
|
tests/models/ipcc2006/test_n2OToAirOrganicFertiliserIndirect.py,sha256=NEt5s9hQ5bGk3YuqOMVOeWdBzLOXbScU-D1JsiAFNBQ,1678
|
906
|
-
tests/models/ipcc2006/test_n2OToAirOrganicSoilCultivationDirect.py,sha256=M7b_uZD5nvW3cnL0wEJ_uuNPOQxho3Xk1O1xAIqflvk,1058
|
907
907
|
tests/models/ipcc2013ExcludingFeedbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
908
908
|
tests/models/ipcc2013ExcludingFeedbacks/test_gwp100.py,sha256=Od9ALNCag5pCVJnp2pIXOenadJLhKD4X4DDmLcgET2A,875
|
909
909
|
tests/models/ipcc2013IncludingFeedbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -949,7 +949,7 @@ tests/models/ipcc2019/test_nonCo2EmissionsToAirNaturalVegetationBurning.py,sha25
|
|
949
949
|
tests/models/ipcc2019/test_noxToAirInorganicFertiliser.py,sha256=NZBSBJLM_j2PEpHRON2ysgKNF8x5sHfQVoAKQdGsfzk,1537
|
950
950
|
tests/models/ipcc2019/test_noxToAirOrganicFertiliser.py,sha256=LR5pjV5vRbgSSQAw8kYRp_ij4CHInzgaDS6EggQuBiw,1104
|
951
951
|
tests/models/ipcc2019/test_organicCarbonPerHa.py,sha256=g_uOqzj6EiyvoAZRpd4PakMYQ7Vfn0QiDGLCTVz92A8,15607
|
952
|
-
tests/models/ipcc2019/test_organicCarbonPerHa_tier_1.py,sha256=
|
952
|
+
tests/models/ipcc2019/test_organicCarbonPerHa_tier_1.py,sha256=lSGxHvfz84etnXbu6cJU0Fh06H_lI3yIlSiF3Wg9tec,20683
|
953
953
|
tests/models/ipcc2019/test_organicCarbonPerHa_tier_2.py,sha256=OKkISE_gcF1yrEHzHowk65MbDRdgy-ILdzGWIy6X8JU,5502
|
954
954
|
tests/models/ipcc2019/test_organicCarbonPerHa_utils.py,sha256=Zd2QlN_Q3k9djuByOH62A00tryVzlvNtsd46N79TTeU,1778
|
955
955
|
tests/models/ipcc2019/test_pastureGrass.py,sha256=6B8ZmuI1w4rA4wGduWx0l6e0BgGz8b2knTUIcT0GDOg,2725
|
@@ -1243,8 +1243,8 @@ tests/orchestrator/strategies/run/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
|
|
1243
1243
|
tests/orchestrator/strategies/run/test_add_blank_node_if_missing.py,sha256=K4xg4UAXfNhSaLyknKVPO7MGBF44Z_gD7CuZ_pe28gU,3512
|
1244
1244
|
tests/orchestrator/strategies/run/test_add_key_if_missing.py,sha256=hKwvk1ohcBVnQUCTiDhRW99J0xEa29BpwFi1KC0yWLE,329
|
1245
1245
|
tests/orchestrator/strategies/run/test_always.py,sha256=w5-Dhp6yLzgZGAeMRz3OrqZbbAed9gZ1O266a3z9k7w,134
|
1246
|
-
hestia_earth_models-0.
|
1247
|
-
hestia_earth_models-0.
|
1248
|
-
hestia_earth_models-0.
|
1249
|
-
hestia_earth_models-0.
|
1250
|
-
hestia_earth_models-0.
|
1246
|
+
hestia_earth_models-0.72.0.dist-info/LICENSE,sha256=TD25LoiRJsA5CPUNrcyt1PXlGcbUGFMAeZoBcfCrCNE,1154
|
1247
|
+
hestia_earth_models-0.72.0.dist-info/METADATA,sha256=W4w6OHS9XPsC3e3WNeIW-qMUpdkJWfxmP8Hl6sIj-SI,4045
|
1248
|
+
hestia_earth_models-0.72.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
1249
|
+
hestia_earth_models-0.72.0.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
|
1250
|
+
hestia_earth_models-0.72.0.dist-info/RECORD,,
|
@@ -1,32 +1,33 @@
|
|
1
|
-
|
1
|
+
import os
|
2
2
|
import json
|
3
|
+
import pytest
|
4
|
+
from unittest.mock import MagicMock, patch
|
3
5
|
from tests.utils import fixtures_path, fake_new_measurement
|
4
6
|
|
5
|
-
from hestia_earth.models.geospatialDatabase.histosol import MODEL, TERM_ID, run
|
7
|
+
from hestia_earth.models.geospatialDatabase.histosol import MODEL, TERM_ID, run
|
6
8
|
|
7
9
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
8
10
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
11
|
+
_folders = [d for d in os.listdir(fixtures_folder) if os.path.isdir(os.path.join(fixtures_folder, d))]
|
9
12
|
|
10
13
|
|
11
|
-
@
|
12
|
-
@patch(f"{class_path}.has_geospatial_data")
|
13
|
-
def test_should_run(*args):
|
14
|
-
# with no soilType => run
|
15
|
-
site = {'measurements': []}
|
16
|
-
assert _should_run(site) is True
|
17
|
-
|
18
|
-
# with an existing soilType => NO run
|
19
|
-
with open(f"{fixtures_folder}/with-soilType.jsonld", encoding='utf-8') as f:
|
20
|
-
site = json.load(f)
|
21
|
-
assert not _should_run(site)
|
22
|
-
|
23
|
-
|
14
|
+
@pytest.mark.parametrize("folder", _folders)
|
24
15
|
@patch(f"{class_path}.get_source", return_value={})
|
16
|
+
@patch(f"{class_path}.download", return_value=50)
|
17
|
+
@patch(f"{class_path}.should_download", return_value=True)
|
25
18
|
@patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
def test_run(
|
20
|
+
mock_new_measurement: MagicMock,
|
21
|
+
mock_should_download: MagicMock,
|
22
|
+
mock_download: MagicMock,
|
23
|
+
mock_get_source: MagicMock,
|
24
|
+
folder: str
|
25
|
+
):
|
26
|
+
with open(f"{fixtures_folder}/{folder}/site.jsonld", encoding='utf-8') as f:
|
29
27
|
site = json.load(f)
|
30
28
|
|
31
|
-
|
32
|
-
|
29
|
+
with open(f"{fixtures_folder}/{folder}/result.jsonld", encoding='utf-8') as f:
|
30
|
+
expected = json.load(f)
|
31
|
+
|
32
|
+
value = run(site)
|
33
|
+
assert value == expected, folder
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import os
|
2
|
+
import json
|
3
|
+
import pytest
|
4
|
+
from unittest.mock import MagicMock, patch
|
5
|
+
from tests.utils import fixtures_path, fake_new_measurement
|
6
|
+
|
7
|
+
from hestia_earth.models.hestia.histosol import MODEL, TERM_ID, run
|
8
|
+
|
9
|
+
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
10
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
11
|
+
_folders = [d for d in os.listdir(fixtures_folder) if os.path.isdir(os.path.join(fixtures_folder, d))]
|
12
|
+
|
13
|
+
|
14
|
+
@pytest.mark.parametrize("folder", _folders)
|
15
|
+
@patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
|
16
|
+
def test_run(mock_new_measurement: MagicMock, folder: str):
|
17
|
+
with open(f"{fixtures_folder}/{folder}/site.jsonld", encoding='utf-8') as f:
|
18
|
+
site = json.load(f)
|
19
|
+
|
20
|
+
with open(f"{fixtures_folder}/{folder}/result.jsonld", encoding='utf-8') as f:
|
21
|
+
expected = json.load(f)
|
22
|
+
|
23
|
+
value = run(site)
|
24
|
+
assert value == expected, folder
|
@@ -120,7 +120,8 @@ SOIL_CATEGORY_PARAMS = [
|
|
120
120
|
("usdaSoilType/pod", IpccSoilCategory.SPODIC_SOILS),
|
121
121
|
("usdaSoilType/san", IpccSoilCategory.SANDY_SOILS),
|
122
122
|
("usdaSoilType/vol", IpccSoilCategory.VOLCANIC_SOILS),
|
123
|
-
("usdaSoilType/wet", IpccSoilCategory.WETLAND_SOILS)
|
123
|
+
("usdaSoilType/wet", IpccSoilCategory.WETLAND_SOILS),
|
124
|
+
("with-depths", IpccSoilCategory.HIGH_ACTIVITY_CLAY_SOILS) # Closes #1248
|
124
125
|
]
|
125
126
|
|
126
127
|
|
@@ -202,12 +203,12 @@ MANAGEMENT_CATEGORY_PARAMS = [
|
|
202
203
|
IpccLandUseCategory.GRASSLAND,
|
203
204
|
IpccManagementCategory.NOMINALLY_MANAGED
|
204
205
|
),
|
205
|
-
("nominally-managed/unknown", IpccLandUseCategory.GRASSLAND, IpccManagementCategory.NOMINALLY_MANAGED),
|
206
206
|
("not-relevant", IpccLandUseCategory.OTHER, IpccManagementCategory.NOT_RELEVANT),
|
207
207
|
("reduced-tillage", IpccLandUseCategory.ANNUAL_CROPS, IpccManagementCategory.REDUCED_TILLAGE),
|
208
208
|
("severely-degraded", IpccLandUseCategory.GRASSLAND, IpccManagementCategory.SEVERELY_DEGRADED),
|
209
209
|
("unknown/annual-crops", IpccLandUseCategory.ANNUAL_CROPS, IpccManagementCategory.UNKNOWN),
|
210
|
-
("unknown/annual-crops-wet", IpccLandUseCategory.ANNUAL_CROPS_WET, IpccManagementCategory.UNKNOWN)
|
210
|
+
("unknown/annual-crops-wet", IpccLandUseCategory.ANNUAL_CROPS_WET, IpccManagementCategory.UNKNOWN),
|
211
|
+
("unknown/grassland", IpccLandUseCategory.GRASSLAND, IpccManagementCategory.UNKNOWN)
|
211
212
|
]
|
212
213
|
|
213
214
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import json
|
2
|
+
from unittest.mock import patch
|
3
|
+
from tests.utils import fixtures_path
|
4
|
+
|
5
|
+
from hestia_earth.models.cache_nodes import _cache_related_nodes, _cache_sources
|
6
|
+
|
7
|
+
class_path = 'hestia_earth.models.cache_nodes'
|
8
|
+
fixtures_folder = f"{fixtures_path}/cache_nodes"
|
9
|
+
|
10
|
+
|
11
|
+
def test_cache_related_nodes():
|
12
|
+
with open(f"{fixtures_folder}/nodes.json_no_validate", encoding='utf-8') as f:
|
13
|
+
data = json.load(f)
|
14
|
+
|
15
|
+
with open(f"{fixtures_folder}/cache_related_nodes/result.json_no_validate", encoding='utf-8') as f:
|
16
|
+
expected = json.load(f)
|
17
|
+
|
18
|
+
result = _cache_related_nodes(data.get('nodes'))
|
19
|
+
assert result == expected
|
20
|
+
|
21
|
+
|
22
|
+
@patch(f"{class_path}.find_sources", return_value=['source1'])
|
23
|
+
def test_cache_sources(*args):
|
24
|
+
with open(f"{fixtures_folder}/nodes.json_no_validate", encoding='utf-8') as f:
|
25
|
+
data = json.load(f)
|
26
|
+
|
27
|
+
with open(f"{fixtures_folder}/cache_sources/result.json_no_validate", encoding='utf-8') as f:
|
28
|
+
expected = json.load(f)
|
29
|
+
|
30
|
+
result = _cache_sources(data.get('nodes'))
|
31
|
+
assert result == expected
|
@@ -1,100 +0,0 @@
|
|
1
|
-
from hestia_earth.schema import EmissionMethodTier
|
2
|
-
|
3
|
-
from hestia_earth.models.log import logRequirements, logShouldRun
|
4
|
-
from hestia_earth.models.utils.constant import Units, get_atomic_conversion
|
5
|
-
from hestia_earth.models.utils.emission import _new_emission
|
6
|
-
from hestia_earth.models.utils.measurement import most_relevant_measurement_value
|
7
|
-
from hestia_earth.models.utils.ecoClimateZone import get_ecoClimateZone_lookup_value
|
8
|
-
from hestia_earth.models.utils.cycle import land_occupation_per_ha
|
9
|
-
from . import MODEL
|
10
|
-
|
11
|
-
REQUIREMENTS = {
|
12
|
-
"Cycle": {
|
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
|
-
],
|
30
|
-
"site": {
|
31
|
-
"@type": "Site",
|
32
|
-
"measurements": [
|
33
|
-
{"@type": "Measurement", "value": "", "term.@id": "histosol"},
|
34
|
-
{"@type": "Measurement", "value": "", "term.@id": "ecoClimateZone"}
|
35
|
-
]
|
36
|
-
},
|
37
|
-
"optional": {
|
38
|
-
"cycleDuration": ""
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
42
|
-
LOOKUPS = {
|
43
|
-
"crop": "isPlantation",
|
44
|
-
"ecoClimateZone": "IPCC_2006_ORGANIC_SOILS_TONNES_CO2-C_HECTARE"
|
45
|
-
}
|
46
|
-
RETURNS = {
|
47
|
-
"Emission": [{
|
48
|
-
"value": "",
|
49
|
-
"methodTier": "tier 1"
|
50
|
-
}]
|
51
|
-
}
|
52
|
-
TERM_ID = 'co2ToAirOrganicSoilCultivation'
|
53
|
-
TIER = EmissionMethodTier.TIER_1.value
|
54
|
-
|
55
|
-
|
56
|
-
def _emission(value: float):
|
57
|
-
emission = _new_emission(TERM_ID, MODEL)
|
58
|
-
emission['value'] = [value]
|
59
|
-
emission['methodTier'] = TIER
|
60
|
-
return emission
|
61
|
-
|
62
|
-
|
63
|
-
def _run(histosol: float, organic_soil_factor: float, land_occupation: float):
|
64
|
-
value = land_occupation * histosol / 100 * organic_soil_factor
|
65
|
-
return [_emission(value)]
|
66
|
-
|
67
|
-
|
68
|
-
def _get_CO2_factor(eco_climate_zone: str, site_type: str):
|
69
|
-
return get_ecoClimateZone_lookup_value(
|
70
|
-
eco_climate_zone, LOOKUPS['ecoClimateZone'], site_type
|
71
|
-
) * 1000 * get_atomic_conversion(Units.KG_CO2, Units.TO_C)
|
72
|
-
|
73
|
-
|
74
|
-
def _should_run(cycle: dict):
|
75
|
-
end_date = cycle.get('endDate')
|
76
|
-
site = cycle.get('site', {})
|
77
|
-
site_type = site.get('siteType', None)
|
78
|
-
measurements = site.get('measurements', [])
|
79
|
-
|
80
|
-
def _get_measurement_content(term_id: str):
|
81
|
-
return most_relevant_measurement_value(measurements, term_id, end_date)
|
82
|
-
|
83
|
-
histosol = _get_measurement_content('histosol')
|
84
|
-
eco_climate_zone = _get_measurement_content('ecoClimateZone')
|
85
|
-
organic_soil_factor = _get_CO2_factor(eco_climate_zone, site_type) if eco_climate_zone else 0
|
86
|
-
land_occupation = land_occupation_per_ha(MODEL, TERM_ID, cycle)
|
87
|
-
|
88
|
-
logRequirements(cycle, model=MODEL, term=TERM_ID,
|
89
|
-
organic_soil_factor=organic_soil_factor,
|
90
|
-
land_occupation=land_occupation,
|
91
|
-
histosol=histosol)
|
92
|
-
|
93
|
-
should_run = all([organic_soil_factor, land_occupation, histosol is not None])
|
94
|
-
logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
|
95
|
-
return should_run, histosol, organic_soil_factor, land_occupation
|
96
|
-
|
97
|
-
|
98
|
-
def run(cycle: dict):
|
99
|
-
should_run, histosol, organic_soil_factor, land_occupation = _should_run(cycle)
|
100
|
-
return _run(histosol, organic_soil_factor, land_occupation) if should_run else []
|