hestia-earth-models 0.44.5__py3-none-any.whl → 0.44.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.

@@ -21,7 +21,7 @@ from hestia_earth.models.utils.term import get_lookup_value
21
21
  from hestia_earth.models.utils.property import _get_nitrogen_content
22
22
  from hestia_earth.models.utils.product import _new_product, animal_produced
23
23
  from hestia_earth.models.utils.input import get_feed_nitrogen
24
- from hestia_earth.models.utils.term import get_excreta_terms
24
+ from hestia_earth.models.utils.term import get_excreta_N_terms
25
25
  from . import MODEL
26
26
 
27
27
  REQUIREMENTS = {
@@ -81,7 +81,7 @@ def _run(term_id: str, mass_balance_items: list, alternate_items: list):
81
81
 
82
82
 
83
83
  def _no_excreta_term(products: list):
84
- term_ids = get_excreta_terms()
84
+ term_ids = get_excreta_N_terms()
85
85
  return all([not find_term_match(products, term) for term in term_ids])
86
86
 
87
87
 
@@ -15,12 +15,11 @@ from hestia_earth.utils.tools import list_sum, safe_parse_float
15
15
 
16
16
  from hestia_earth.models.log import logRequirements, logShouldRun
17
17
  from hestia_earth.models.utils.term import get_lookup_value
18
- from hestia_earth.models.utils.constant import Units
19
18
  from hestia_earth.models.utils.property import get_node_property
20
19
  from hestia_earth.models.utils.product import _new_product
21
20
  from hestia_earth.models.utils.input import get_feed_carbon
22
21
  from hestia_earth.models.utils.measurement import most_relevant_measurement_value
23
- from hestia_earth.models.utils.term import get_excreta_terms
22
+ from hestia_earth.models.utils.term import get_excreta_VS_terms
24
23
  from . import MODEL
25
24
  from .excretaKgN import _get_excreta_n_term
26
25
 
@@ -117,7 +116,7 @@ def _get_excreta_vs_term(product: dict):
117
116
 
118
117
 
119
118
  def _no_excreta_term(products: list):
120
- term_ids = get_excreta_terms(Units.KG_VS)
119
+ term_ids = get_excreta_VS_terms()
121
120
  return all([not find_term_match(products, term) for term in term_ids])
122
121
 
123
122
 
@@ -0,0 +1,75 @@
1
+ from hestia_earth.schema import MeasurementStatsDefinition, MeasurementMethodClassification
2
+ from hestia_earth.utils.model import find_term_match
3
+
4
+ from hestia_earth.models.log import logRequirements, logShouldRun
5
+ from hestia_earth.models.utils.measurement import _new_measurement, group_measurements_by_depth, measurement_value
6
+ from . import MODEL
7
+
8
+ REQUIREMENTS = {
9
+ "Site": {
10
+ "measurements": [
11
+ {"@type": "Measurement", "value": "", "term.@id": "clayContent"},
12
+ {"@type": "Measurement", "value": "", "term.@id": "soilPh"},
13
+ {"@type": "Measurement", "value": "", "term.@id": "organicCarbonPerKgSoil"}
14
+ ]
15
+ }
16
+ }
17
+ RETURNS = {
18
+ "Measurement": [{
19
+ "value": "",
20
+ "depthUpper": "",
21
+ "depthLower": "",
22
+ "statsDefinition": "modelled",
23
+ "methodClassification": "modelled using other physical measurements"
24
+ }]
25
+ }
26
+ TERM_ID = 'cationExchangeCapacityPerKgSoil'
27
+ BIBLIO_TITLE = 'Contribution of Organic Matter and Clay to Soil Cation-Exchange Capacity as Affected by the pH of the Saturating Solution' # noqa: E501
28
+
29
+
30
+ def measurement(value: float, depthUpper: int = None, depthLower: int = None):
31
+ data = _new_measurement(TERM_ID, None, BIBLIO_TITLE)
32
+ data['value'] = [value]
33
+ if depthUpper is not None:
34
+ data['depthUpper'] = depthUpper
35
+ if depthLower is not None:
36
+ data['depthLower'] = depthLower
37
+ data['statsDefinition'] = MeasurementStatsDefinition.MODELLED.value
38
+ data['methodClassification'] = MeasurementMethodClassification.MODELLED_USING_OTHER_PHYSICAL_MEASUREMENTS.value
39
+ return data
40
+
41
+
42
+ def _run(measurements: list):
43
+ clayContent = find_term_match(measurements, 'clayContent')
44
+ clayContent_value = measurement_value(clayContent)
45
+ soilPh = measurement_value(find_term_match(measurements, 'soilPh'))
46
+ organicCarbonPerKgSoil = measurement_value(find_term_match(measurements, 'organicCarbonPerKgSoil'))
47
+
48
+ value = ((51 * soilPh - 59) * (organicCarbonPerKgSoil/10) + (30 + 4.4 * soilPh) * clayContent_value)/100
49
+
50
+ depthUpper = clayContent.get('depthUpper')
51
+ depthLower = clayContent.get('depthLower')
52
+
53
+ return measurement(value, depthUpper=depthUpper, depthLower=depthLower)
54
+
55
+
56
+ def _should_run(site: dict, measurements: list):
57
+ clayContent = find_term_match(measurements, 'clayContent', None)
58
+ soilPh = find_term_match(measurements, 'soilPh', None)
59
+ organicCarbonPerKgSoil = find_term_match(measurements, 'organicCarbonPerKgSoil', None)
60
+
61
+ logRequirements(site, model=MODEL, term=TERM_ID,
62
+ has_clayContent=clayContent is not None,
63
+ has_soilPh=soilPh is not None,
64
+ has_organicCarbonPerKgSoil=organicCarbonPerKgSoil is not None)
65
+
66
+ should_run = all([clayContent is not None, soilPh is not None, organicCarbonPerKgSoil is not None])
67
+ logShouldRun(site, MODEL, TERM_ID, should_run)
68
+ return should_run
69
+
70
+
71
+ def run(site: dict):
72
+ grouped_measurements = list(group_measurements_by_depth(site.get('measurements', [])).values())
73
+ return [
74
+ _run(measurements) for measurements in grouped_measurements if _should_run(site, measurements)
75
+ ]
@@ -0,0 +1,82 @@
1
+ from hestia_earth.schema import MeasurementStatsDefinition, MeasurementMethodClassification
2
+ from hestia_earth.utils.model import find_term_match
3
+
4
+ from hestia_earth.models.log import logRequirements, logShouldRun
5
+ from hestia_earth.models.utils.measurement import _new_measurement, group_measurements_by_depth, measurement_value
6
+ from . import MODEL
7
+
8
+ REQUIREMENTS = {
9
+ "Site": {
10
+ "measurements": [
11
+ {"@type": "Measurement", "value": "", "term.@id": "soilBulkDensity", "depthUpper": "", "depthLower": ""},
12
+ {"@type": "Measurement", "value": "", "term.@id": "organicCarbonPerKgSoil", "depthUpper": "", "depthLower": ""} # noqa: E501
13
+ ]
14
+ }
15
+ }
16
+ RETURNS = {
17
+ "Measurement": [{
18
+ "value": "",
19
+ "depthUpper": "",
20
+ "depthLower": "",
21
+ "statsDefinition": "modelled",
22
+ "methodClassification": "modelled using other physical measurements"
23
+ }]
24
+ }
25
+ TERM_ID = 'organicCarbonPerHa'
26
+ BIBLIO_TITLE = 'Soil organic carbon sequestration rates in vineyard agroecosystems under different soil management practices: A meta-analysis' # noqa: E501
27
+
28
+
29
+ def measurement(value: float, depthUpper: int, depthLower: int):
30
+ data = _new_measurement(TERM_ID, None, BIBLIO_TITLE)
31
+ data['value'] = [value]
32
+ data['depthUpper'] = depthUpper
33
+ data['depthLower'] = depthLower
34
+ data['statsDefinition'] = MeasurementStatsDefinition.MODELLED.value
35
+ data['methodClassification'] = MeasurementMethodClassification.MODELLED_USING_OTHER_PHYSICAL_MEASUREMENTS.value
36
+ return data
37
+
38
+
39
+ def _run(measurements: list):
40
+ soilBulkDensity = measurement_value(find_term_match(measurements, 'soilBulkDensity'))
41
+ organicCarbonPerKgSoil = find_term_match(measurements, 'organicCarbonPerKgSoil')
42
+ organicCarbonPerKgSoil_value = measurement_value(organicCarbonPerKgSoil)
43
+
44
+ value = (
45
+ organicCarbonPerKgSoil.get('depthLower') - organicCarbonPerKgSoil.get('depthUpper')
46
+ ) * soilBulkDensity * (organicCarbonPerKgSoil_value/10) * 1000
47
+
48
+ depthUpper = organicCarbonPerKgSoil.get('depthUpper')
49
+ depthLower = organicCarbonPerKgSoil.get('depthLower')
50
+
51
+ return measurement(value, depthUpper, depthLower)
52
+
53
+
54
+ def _should_run(site: dict, measurements: list):
55
+ soilBulkDensity = find_term_match(measurements, 'soilBulkDensity', None)
56
+ has_soilBulkDensity_depthLower = (soilBulkDensity or {}).get('depthLower') is not None
57
+ has_soilBulkDensity_depthUpper = (soilBulkDensity or {}).get('depthUpper') is not None
58
+ organicCarbonPerKgSoil = find_term_match(measurements, 'organicCarbonPerKgSoil', None)
59
+ has_organicCarbonPerKgSoil_depthLower = (organicCarbonPerKgSoil or {}).get('depthLower') is not None
60
+ has_organicCarbonPerKgSoil_depthUpper = (organicCarbonPerKgSoil or {}).get('depthUpper') is not None
61
+
62
+ logRequirements(site, model=MODEL, term=TERM_ID,
63
+ has_soilBulkDensity=soilBulkDensity is not None,
64
+ has_soilBulkDensity_depthLower=has_soilBulkDensity_depthLower,
65
+ has_soilBulkDensity_depthUpper=has_soilBulkDensity_depthUpper,
66
+ has_organicCarbonPerKgSoil=organicCarbonPerKgSoil is not None,
67
+ has_organicCarbonPerKgSoil_depthLower=has_organicCarbonPerKgSoil_depthLower,
68
+ has_organicCarbonPerKgSoil_depthUpper=has_organicCarbonPerKgSoil_depthUpper)
69
+
70
+ should_run = all([
71
+ soilBulkDensity is not None, has_soilBulkDensity_depthLower, has_soilBulkDensity_depthUpper,
72
+ organicCarbonPerKgSoil is not None, has_organicCarbonPerKgSoil_depthLower, has_organicCarbonPerKgSoil_depthUpper
73
+ ])
74
+ logShouldRun(site, MODEL, TERM_ID, should_run)
75
+ return should_run
76
+
77
+
78
+ def run(site: dict):
79
+ grouped_measurements = list(group_measurements_by_depth(site.get('measurements', [])).values())
80
+ return [
81
+ _run(measurements) for measurements in grouped_measurements if _should_run(site, measurements)
82
+ ]
@@ -1,8 +1,10 @@
1
+ from functools import reduce
1
2
  from dateutil import parser
2
3
  from statistics import mode, mean
3
4
  from hestia_earth.schema import SchemaType
4
5
  from hestia_earth.utils.api import download_hestia
5
6
  from hestia_earth.utils.model import linked_node
7
+ from hestia_earth.utils.tools import non_empty_list
6
8
 
7
9
  from . import _term_id, _include_method, _include_source
8
10
  from .term import get_lookup_value
@@ -59,3 +61,21 @@ def most_relevant_measurement(measurements: list, term_id: str, date: str):
59
61
  def most_relevant_measurement_value(measurements: list, term_id: str, date: str, default=None):
60
62
  measurement = most_relevant_measurement(measurements, term_id, date)
61
63
  return measurement_value(measurement) if measurement else default
64
+
65
+
66
+ def _group_measurement_key(measurement: dict):
67
+ keys = non_empty_list([
68
+ str(measurement.get('depthUpper', '')),
69
+ str(measurement.get('depthLower', '')),
70
+ measurement.get('startDate'),
71
+ measurement.get('endDate')
72
+ ])
73
+ return '-'.join(keys) if len(keys) > 0 else 'default'
74
+
75
+
76
+ def group_measurements_by_depth(measurements: list):
77
+ def group_by(group: dict, measurement: dict):
78
+ key = _group_measurement_key(measurement)
79
+ return group | {key: group.get(key, []) + [measurement]}
80
+
81
+ return reduce(group_by, measurements, {})
@@ -142,7 +142,7 @@ def get_urea_terms():
142
142
  return list(map(lambda n: n['@id'], terms))
143
143
 
144
144
 
145
- def get_excreta_terms(units: Units = Units.KG_N):
145
+ def get_excreta_N_terms():
146
146
  """
147
147
  Find all `excreta` terms in `kg N` from the Glossary:
148
148
  https://hestia.earth/glossary?termType=excreta
@@ -154,7 +154,24 @@ def get_excreta_terms(units: Units = Units.KG_N):
154
154
  """
155
155
  terms = find_node(SchemaType.TERM, {
156
156
  'termType.keyword': TermTermType.EXCRETA.value,
157
- 'units.keyword': units.value
157
+ 'units.keyword': Units.KG_N.value
158
+ }, limit=LIMIT)
159
+ return list(map(lambda n: n['@id'], terms))
160
+
161
+
162
+ def get_excreta_VS_terms():
163
+ """
164
+ Find all `excreta` terms in `kg Vs` from the Glossary:
165
+ https://hestia.earth/glossary?termType=excreta
166
+
167
+ Returns
168
+ -------
169
+ list
170
+ List of matching term `@id` as `str`.
171
+ """
172
+ terms = find_node(SchemaType.TERM, {
173
+ 'termType.keyword': TermTermType.EXCRETA.value,
174
+ 'units.keyword': Units.KG_VS.value
158
175
  }, limit=LIMIT)
159
176
  return list(map(lambda n: n['@id'], terms))
160
177
 
@@ -1 +1 @@
1
- VERSION = '0.44.5'
1
+ VERSION = '0.44.7'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hestia-earth-models
3
- Version: 0.44.5
3
+ Version: 0.44.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
@@ -2,7 +2,7 @@ hestia_earth/__init__.py,sha256=G-d438vPx7m_ks5e9XTtM3u7LDRO5dSSukibukWmyPM,56
2
2
  hestia_earth/models/__init__.py,sha256=qEFeq3yuf3lQKVseALmL8aPM8fpCS54B_5pry00M3hk,76
3
3
  hestia_earth/models/log.py,sha256=rOgKa-gSrcS-Y1gO9eJXJaA3ofxcQW_45hGly2Lf00Y,2444
4
4
  hestia_earth/models/requirements.py,sha256=znNZJAhwX2iYiKcAQXPftY7z_1MsNa0QxCXkXyHm_U0,17363
5
- hestia_earth/models/version.py,sha256=hoi3MVqrG9g-cPpNeOXtDOr5ZWcpld7ZgUACIEJPvBE,19
5
+ hestia_earth/models/version.py,sha256=siXWAyoDG_AIMVLULiR25FA-JVP5ErxJNeP4ZVU5pwI,19
6
6
  hestia_earth/models/agribalyse2016/__init__.py,sha256=WvK0qCQbnYtg9oZxrACd1wGormZyXibPtpCnIQeDqbw,415
7
7
  hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=ztMnY6XTwsJD-lp62jJyzN2AUODvFHIs5d5CaFrlVGI,3567
8
8
  hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=10XV1fz_yBYlqmNJ3cxmT2I2Vp_0w7nT4zMIuBw2wCY,3294
@@ -315,13 +315,13 @@ hestia_earth/models/lcImpactCertainEffectsInfinite/damageToTerrestrialEcosystems
315
315
  hestia_earth/models/linkedImpactAssessment/__init__.py,sha256=x6xsPu-Rwh-7HKsvHuKmgM1YML6fQy2z9Hsy9_BeO2Y,3565
316
316
  hestia_earth/models/mocking/__init__.py,sha256=Y39V6yj_3M1q8v9ShCHwPeJOstypOVIvb_FldMEbF7g,766
317
317
  hestia_earth/models/mocking/mock_search.py,sha256=ysPhzvMGvsHKqQXKRFi8ZqohcnyKutBlNqT_j0OH8L4,1983
318
- hestia_earth/models/mocking/search-results.json,sha256=e8Iz2xEF_PHUSl9Ket0dp2692-bYXxjG-_9XKHwR-Wg,27757
318
+ hestia_earth/models/mocking/search-results.json,sha256=OxONqG0icjhfpsx9abPt-4FQDnOD2OQFHJot1eJNX_8,29671
319
319
  hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
320
320
  hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=trQBxjc8V77q96sxvK4Y9HfpD64zgyGuB5o5_o0lHts,2189
321
321
  hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=do9zHHR8VuqFcWNLnql5t3tV478SCVc7tC3mEs5cdUk,2184
322
322
  hestia_earth/models/pooreNemecek2018/ch4ToAirAquacultureSystems.py,sha256=iPNQCPSF0oXzmR7KQqgySpeQAkPFgmBhbta6m6t6Y2U,6603
323
- hestia_earth/models/pooreNemecek2018/excretaKgN.py,sha256=fHPbi6D6GluKhjaRBZQTx4TtzNewvHdnWrPyuGZecE4,5677
324
- hestia_earth/models/pooreNemecek2018/excretaKgVs.py,sha256=bsSZcyzBoVB6Ybk5CgElzPp7mTpQJXsPMdB3ROf6dcM,7751
323
+ hestia_earth/models/pooreNemecek2018/excretaKgN.py,sha256=vgjxJP-KXmUujVerDtbLvDNGiqouFK4DgOiLPbSSPh4,5681
324
+ hestia_earth/models/pooreNemecek2018/excretaKgVs.py,sha256=FAZDTyC-5tsqtFlfBPSdFaB6QeASwKIOc7d6_TT_eNQ,7693
325
325
  hestia_earth/models/pooreNemecek2018/landOccupationDuringCycle.py,sha256=Zlq4gfVPrneqTaahtUiEtmjNqct75AoIag33gOZbC3E,2820
326
326
  hestia_earth/models/pooreNemecek2018/longFallowPeriod.py,sha256=RHrkBR-U2VSGpwPBs9RCWVlZtHin5BXESKE9jienrRw,1374
327
327
  hestia_earth/models/pooreNemecek2018/n2OToAirAquacultureSystemsDirect.py,sha256=BgxKSBSRdyNU1_q8Vf9GULkIewuXKmgfDQU9Thzxc1g,2724
@@ -401,8 +401,10 @@ hestia_earth/models/schererPfister2015/pToGroundwaterSoilFlux.py,sha256=Gt3YdTCu
401
401
  hestia_earth/models/schererPfister2015/pToSurfaceWaterSoilFlux.py,sha256=bzgtCAtX0D5cRqoL24Ukg2IDr00Up7Ji4m1QQ9fJ-9w,2741
402
402
  hestia_earth/models/schererPfister2015/utils.py,sha256=LEvz9guqto0kuF5rXcQjgYsD3CvEmORvJQqRA1f7uMI,3130
403
403
  hestia_earth/models/site/__init__.py,sha256=aQRep10EVnCIY97xAxTFQ_AFJNNoZtPvb50mIu_HmQo,342
404
+ hestia_earth/models/site/cationExchangeCapacityPerKgSoil.py,sha256=TOc5u1r0-wOXjdmNunz0QErexNRQc2n9i3fMykvFu60,3153
404
405
  hestia_earth/models/site/flowingWater.py,sha256=ZPeXd2tNYgG24kYOGQZM9lrUzCi9nZsabvHJsaH0hy4,1796
405
406
  hestia_earth/models/site/netPrimaryProduction.py,sha256=mwoQcjYkCbHxzZ8PhFN7RtjwKa5igqkICpNVJq08lYc,1901
407
+ hestia_earth/models/site/organicCarbonPerHa.py,sha256=_duLpVHx-rx0f1I5IzreDp9LulC0JULrX63bm2W_tcM,3905
406
408
  hestia_earth/models/site/organicCarbonPerKgSoil.py,sha256=zY9QUho9jhaQK-X0x_DszZOoj-Ol8NzNcASk-Ix_qEk,1870
407
409
  hestia_earth/models/site/organicCarbonPerM3Soil.py,sha256=r-rDBLr-h10__csvlWreoe2MVBpMT5MMmokZVLRJ7Iw,1870
408
410
  hestia_earth/models/site/organicMatterPerKgSoil.py,sha256=VXXLt9lBWkNR8xY4tGOi9DmiaRBKydbevwJ_HL2JNf0,1870
@@ -464,7 +466,7 @@ hestia_earth/models/utils/inorganicFertiliser.py,sha256=zJpNvDNaEsZ2T_V4APAQy4rm
464
466
  hestia_earth/models/utils/input.py,sha256=CsoMC_Jjnifl5mjPWhWOBhiHmNI5IGWRfPjshOV1Ipg,6798
465
467
  hestia_earth/models/utils/liveAnimal.py,sha256=u_Lym0hVinncCZMYF_KscCA3vuelWmlyHn4I-jVRDs4,1505
466
468
  hestia_earth/models/utils/lookup.py,sha256=Y9ekB_AGpmZKZI7NnYodvvF2pFHlkFHkryMk1SVWp60,5307
467
- hestia_earth/models/utils/measurement.py,sha256=jeX82DPwVQHFBMe5V0yGvQEDDv4ymMtiMsMbOwgM9oU,2607
469
+ hestia_earth/models/utils/measurement.py,sha256=FPH1yPOztLe2J5dwGbrHMDFiEPe7aBVYKHvRUY8Cd2c,3266
468
470
  hestia_earth/models/utils/pesticideAI.py,sha256=KQNXos2oG-TbDARxg3ksJAfAAYeiaQIZ5e3V2S0A-fA,1329
469
471
  hestia_earth/models/utils/practice.py,sha256=tNadOzsrNlCEt801B815XaruJXzZ5yPASam7B3sWpXE,1091
470
472
  hestia_earth/models/utils/product.py,sha256=OFzxe2mFdqUfhQ7tfXkhd-sYMqIxPLIgKJFq65oNrQE,8605
@@ -472,7 +474,7 @@ hestia_earth/models/utils/productivity.py,sha256=bUBVCZInGqHuHZvHDSYPQkjWXQxOtTj
472
474
  hestia_earth/models/utils/property.py,sha256=X4DDQKHEVYqtW6nNxBhLZ40_avix2dLDxR22Ipeq0TA,4274
473
475
  hestia_earth/models/utils/site.py,sha256=RZHcftsauPtvC7ma6ea31m3tIjyAR_VRBTcvYAC9v7s,2153
474
476
  hestia_earth/models/utils/temperature.py,sha256=ljlG4-yCgFFb6LRZweb18cZKLrr7K2mqd4E4Hz_D1f8,476
475
- hestia_earth/models/utils/term.py,sha256=u_tF-4ESmjxy9AvSpp4FkHJvdjBmFd9XUvRkf_eqLOU,11669
477
+ hestia_earth/models/utils/term.py,sha256=Es4AMaD-sFL9-FxTDB9OSLd-xno-ZMHSorDKsUzTr2E,12095
476
478
  hestia_earth/models/webbEtAl2012AndSintermannEtAl2012/__init__.py,sha256=Niv7ZFMBCwThlbCKGOwA17QdkpOUDFrqrFItGNqnZAA,434
477
479
  hestia_earth/models/webbEtAl2012AndSintermannEtAl2012/nh3ToAirOrganicFertiliser.py,sha256=fcqomqaWp4BNh937FdC5M-WrhBovtoH-pdUlCnkz7TU,4061
478
480
  tests/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -780,8 +782,8 @@ tests/models/pooreNemecek2018/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
780
782
  tests/models/pooreNemecek2018/test_aboveGroundCropResidueTotal.py,sha256=m-cpFULarm0Ee4MV-OvhYPRg7W2_mvbrqHkjDZgcQsw,1660
781
783
  tests/models/pooreNemecek2018/test_belowGroundCropResidue.py,sha256=A6EOD2B6frN0UtuUTP3GwZ7bNEtEudQfztHXjdiDwdQ,1655
782
784
  tests/models/pooreNemecek2018/test_ch4ToAirAquacultureSystems.py,sha256=rUxD57yl82Ht8IyhbiQhi0xl8L9iLdnLpbI-T5C0Mck,2722
783
- tests/models/pooreNemecek2018/test_excretaKgN.py,sha256=ZUV7ysGt359NHy3SGyHOziLB0SO6K7jFG7ejjz0hqfM,4004
784
- tests/models/pooreNemecek2018/test_excretaKgVs.py,sha256=K4gMk3e2uWoiFeo6LyWP-_-ZBhZN8WbEm_bTVl8Qe6Y,2698
785
+ tests/models/pooreNemecek2018/test_excretaKgN.py,sha256=WZViYAz9A7UwDrmVx4y7SYRFuLxdxJIdkQSxvXmzbhM,4016
786
+ tests/models/pooreNemecek2018/test_excretaKgVs.py,sha256=2D3V4uLWFKdhdpFlr7gjb6Cli3tqBNcy0CXjIcPJ4x0,2707
785
787
  tests/models/pooreNemecek2018/test_landOccupationDuringCycle.py,sha256=PZ56Xqv6xHgjCpmDK1CTxGzLjaD8rzZ1RO-TopZNF3o,1652
786
788
  tests/models/pooreNemecek2018/test_longFallowPeriod.py,sha256=PuwIFqZs2yn4jg9mx4Lk7Z227KAbU5IoV5CiGUV8mpA,925
787
789
  tests/models/pooreNemecek2018/test_n2OToAirAquacultureSystemsDirect.py,sha256=4YAoUhIwfEmRe2B5BvNg247VeB7UXHNeZqr2mRtJA7Y,2207
@@ -860,8 +862,10 @@ tests/models/schererPfister2015/test_pToDrainageWaterSoilFlux.py,sha256=57MVRyiE
860
862
  tests/models/schererPfister2015/test_pToGroundwaterSoilFlux.py,sha256=lOTL-ue6hEbQsKIss6VsN7bJME5UCB3pTbqbLtMp9rk,1064
861
863
  tests/models/schererPfister2015/test_pToSurfaceWaterSoilFlux.py,sha256=1VJo9q-Kb2OboK2RMp3-bkP6lXfkFbqMz1ACJC75FWw,1441
862
864
  tests/models/site/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
865
+ tests/models/site/test_cationExchangeCapacityPerKgSoil.py,sha256=FOtllJ_E4Ld4MngPn__CsQXXeHhZ5fNB-ruSd8DUgFQ,963
863
866
  tests/models/site/test_flowingWater.py,sha256=q7ktHV7sffIUBf0SgIhbkL_U_c7RTHYv6oWhXY4A6io,1274
864
867
  tests/models/site/test_netPrimaryProduction.py,sha256=FaC5TEwHnR56_QrXkIB5u3mgSLOcSmBRbL8vzqaZwk0,1056
868
+ tests/models/site/test_organicCarbonPerHa.py,sha256=m392fH_aEt_tI6dVhAzOVHKpeuztNgP5p6yNiLTs4Mw,983
865
869
  tests/models/site/test_organicCarbonPerKgSoil.py,sha256=fqPe2JbrZwwMK497Qnb2WPx4-n2vda4PW-S3tQa_CGI,1035
866
870
  tests/models/site/test_organicCarbonPerM3Soil.py,sha256=8fOwtcBAFH1fSduIXXtYOdL83oYAVxC4f6BAZpY5X_w,1035
867
871
  tests/models/site/test_organicMatterPerKgSoil.py,sha256=EvZ6HknxjUjhdmdYostB9eCc_WowpRWpmssWM2vT_NU,1035
@@ -918,11 +922,11 @@ tests/models/utils/test_practice.py,sha256=ILaxkb3qICor9AquAGYiOtA-YKnq0hppmJQzN
918
922
  tests/models/utils/test_product.py,sha256=heyd7zYUXaqiiPgBkWJr-OxMNcdVzC8jSRCfvMt4CQE,1726
919
923
  tests/models/utils/test_property.py,sha256=t2npw86IK7C6G4ypiPtanFi0db4PB7G5VBR1GjRGl34,618
920
924
  tests/models/utils/test_site.py,sha256=deEIYptl2MHEklSfHbZV9qA59YKqZLQr8y5rWYiD460,680
921
- tests/models/utils/test_term.py,sha256=jcANyHzzLpkq7AQReFmTa16vtMlwgCNfhDbr9FLlYX4,1808
925
+ tests/models/utils/test_term.py,sha256=-Wn2C1jyOLfkvhcKmKWT-Jms7yqLwx5ok91gYJNcGWc,2028
922
926
  tests/models/webbEtAl2012AndSintermannEtAl2012/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
923
927
  tests/models/webbEtAl2012AndSintermannEtAl2012/test_nh3ToAirOrganicFertiliser.py,sha256=qi2FNXS5Af2WDtm7nq_FsprH3BfCF0XxnE0XHmC4aIY,2244
924
- hestia_earth_models-0.44.5.dist-info/LICENSE,sha256=EFSZhfUdZCTsCIYdHzTGewMKfRfp7X9t1s2aaKxm8O0,1154
925
- hestia_earth_models-0.44.5.dist-info/METADATA,sha256=ZVk9OwQg-Y2xYmgw2PqTnHpAC-x3tI3n6O6LaWXTRUg,3192
926
- hestia_earth_models-0.44.5.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
927
- hestia_earth_models-0.44.5.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
928
- hestia_earth_models-0.44.5.dist-info/RECORD,,
928
+ hestia_earth_models-0.44.7.dist-info/LICENSE,sha256=EFSZhfUdZCTsCIYdHzTGewMKfRfp7X9t1s2aaKxm8O0,1154
929
+ hestia_earth_models-0.44.7.dist-info/METADATA,sha256=FVLQ7WFHs3bn6q2b2j-Dzjanz9_fRIlt1fL2ms6MBsM,3192
930
+ hestia_earth_models-0.44.7.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
931
+ hestia_earth_models-0.44.7.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
932
+ hestia_earth_models-0.44.7.dist-info/RECORD,,
@@ -9,7 +9,7 @@ fixtures_folder = f"{fixtures_path}/{MODEL}/excretaKgN"
9
9
 
10
10
 
11
11
  @patch(f"{class_path}._get_nitrogen_content", return_value=10)
12
- @patch(f"{class_path}.get_excreta_terms", return_value=[])
12
+ @patch(f"{class_path}.get_excreta_N_terms", return_value=[])
13
13
  @patch(f"{class_path}.get_feed_nitrogen", return_value=0)
14
14
  @patch(f"{class_path}.animal_produced", return_value=0)
15
15
  @patch(f"{class_path}._get_excreta_n_term", return_value='excretaKgN')
@@ -59,7 +59,7 @@ def test_should_run(mock_get_excreta_term, mock_animal_produced, mock_get_feed,
59
59
  assert not should_run
60
60
 
61
61
 
62
- @patch(f"{class_path}.get_excreta_terms", return_value=[])
62
+ @patch(f"{class_path}.get_excreta_N_terms", return_value=[])
63
63
  @patch(f"{class_path}._new_product", side_effect=fake_new_product)
64
64
  def test_run(*args):
65
65
  with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
@@ -72,7 +72,7 @@ def test_run(*args):
72
72
  assert value == expected
73
73
 
74
74
 
75
- @patch(f"{class_path}.get_excreta_terms", return_value=[])
75
+ @patch(f"{class_path}.get_excreta_N_terms", return_value=[])
76
76
  @patch(f"{class_path}._new_product", side_effect=fake_new_product)
77
77
  def test_run_with_liveweight(*args):
78
78
  with open(f"{fixtures_folder}/with-liveweight/cycle.jsonld", encoding='utf-8') as f:
@@ -85,7 +85,7 @@ def test_run_with_liveweight(*args):
85
85
  assert value == expected
86
86
 
87
87
 
88
- @patch(f"{class_path}.get_excreta_terms", return_value=[])
88
+ @patch(f"{class_path}.get_excreta_N_terms", return_value=[])
89
89
  @patch(f"{class_path}._new_product", side_effect=fake_new_product)
90
90
  def test_run_with_carcass(*args):
91
91
  with open(f"{fixtures_folder}/with-carcass/cycle.jsonld", encoding='utf-8') as f:
@@ -98,7 +98,7 @@ def test_run_with_carcass(*args):
98
98
  assert value == expected
99
99
 
100
100
 
101
- @patch(f"{class_path}.get_excreta_terms", return_value=[])
101
+ @patch(f"{class_path}.get_excreta_N_terms", return_value=[])
102
102
  @patch(f"{class_path}._new_product", side_effect=fake_new_product)
103
103
  def test_run_with_head(*args):
104
104
  with open(f"{fixtures_folder}/with-head/cycle.jsonld", encoding='utf-8') as f:
@@ -111,7 +111,7 @@ def test_run_with_head(*args):
111
111
  assert value == expected
112
112
 
113
113
 
114
- @patch(f"{class_path}.get_excreta_terms", return_value=[])
114
+ @patch(f"{class_path}.get_excreta_N_terms", return_value=[])
115
115
  @patch(f"{class_path}._new_product", side_effect=fake_new_product)
116
116
  def test_run_with_liveAquaticSpecies(*args):
117
117
  with open(f"{fixtures_folder}/with-liveAquaticSpecies/cycle.jsonld", encoding='utf-8') as f:
@@ -9,7 +9,7 @@ fixtures_folder = f"{fixtures_path}/{MODEL}/excretaKgVs"
9
9
 
10
10
 
11
11
  @patch(f"{class_path}._get_excreta_n_term", return_value='')
12
- @patch(f"{class_path}.get_excreta_terms", return_value=[])
12
+ @patch(f"{class_path}.get_excreta_VS_terms", return_value=[])
13
13
  @patch(f"{class_path}.get_feed_carbon", return_value=5)
14
14
  @patch(f"{class_path}._get_carbonContent", return_value=5)
15
15
  @patch(f"{class_path}._get_conv_aq_ocsed", return_value=0.35)
@@ -63,7 +63,7 @@ def test_should_run(*args):
63
63
  assert should_run is True
64
64
 
65
65
 
66
- @patch(f"{class_path}.get_excreta_terms", return_value=[])
66
+ @patch(f"{class_path}.get_excreta_VS_terms", return_value=[])
67
67
  @patch(f"{class_path}._new_product", side_effect=fake_new_product)
68
68
  def test_run(*args):
69
69
  with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
@@ -76,7 +76,7 @@ def test_run(*args):
76
76
  assert value == expected
77
77
 
78
78
 
79
- @patch(f"{class_path}.get_excreta_terms", return_value=[])
79
+ @patch(f"{class_path}.get_excreta_VS_terms", return_value=[])
80
80
  @patch(f"{class_path}._new_product", side_effect=fake_new_product)
81
81
  def test_run_excretaKgN(*args):
82
82
  with open(f"{fixtures_folder}/with-excretaKgN/cycle.jsonld", encoding='utf-8') as f:
@@ -0,0 +1,31 @@
1
+ from unittest.mock import patch
2
+ import json
3
+ from tests.utils import fixtures_path, fake_new_measurement
4
+
5
+ from hestia_earth.models.site.cationExchangeCapacityPerKgSoil import MODEL, TERM_ID, run, _should_run
6
+
7
+ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
8
+ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
9
+
10
+
11
+ @patch(f"{class_path}.find_term_match")
12
+ def test_should_run(mock_find):
13
+ # no measurement => no run
14
+ mock_find.return_value = None
15
+ assert not _should_run({}, [])
16
+
17
+ # with measurement => run
18
+ mock_find.return_value = {'value': [10]}
19
+ assert _should_run({}, []) is True
20
+
21
+
22
+ @patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
23
+ def test_run(*args):
24
+ with open(f"{fixtures_folder}/site.jsonld", encoding='utf-8') as f:
25
+ site = json.load(f)
26
+
27
+ with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
28
+ expected = json.load(f)
29
+
30
+ value = run(site)
31
+ assert value == expected
@@ -0,0 +1,31 @@
1
+ from unittest.mock import patch
2
+ import json
3
+ from tests.utils import fixtures_path, fake_new_measurement
4
+
5
+ from hestia_earth.models.site.organicCarbonPerHa import MODEL, TERM_ID, run, _should_run
6
+
7
+ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
8
+ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
9
+
10
+
11
+ @patch(f"{class_path}.find_term_match")
12
+ def test_should_run(mock_find):
13
+ # no measurement => no run
14
+ mock_find.return_value = {}
15
+ assert not _should_run({}, [])
16
+
17
+ # with measurement => run
18
+ mock_find.return_value = {'value': [10], 'depthUpper': 0, 'depthLower': 10}
19
+ assert _should_run({}, []) is True
20
+
21
+
22
+ @patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
23
+ def test_run(*args):
24
+ with open(f"{fixtures_folder}/site.jsonld", encoding='utf-8') as f:
25
+ site = json.load(f)
26
+
27
+ with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
28
+ expected = json.load(f)
29
+
30
+ value = run(site)
31
+ assert value == expected
@@ -1,8 +1,8 @@
1
1
  from unittest.mock import patch
2
2
 
3
3
  from hestia_earth.models.utils.term import (
4
- get_liquid_fuel_terms, get_irrigation_terms, get_urea_terms, get_excreta_terms, get_generic_crop,
5
- get_rice_paddy_terms, get_tillage_terms, get_crop_residue_terms
4
+ get_liquid_fuel_terms, get_irrigation_terms, get_urea_terms, get_excreta_N_terms, get_excreta_VS_terms,
5
+ get_generic_crop, get_rice_paddy_terms, get_tillage_terms, get_crop_residue_terms
6
6
  )
7
7
 
8
8
  class_path = 'hestia_earth.models.utils.term'
@@ -30,10 +30,17 @@ def test_get_urea_terms(mock_find_node):
30
30
 
31
31
 
32
32
  @patch(f"{class_path}.find_node")
33
- def test_get_excreta_terms(mock_find_node):
33
+ def test_get_excreta_N_terms(mock_find_node):
34
34
  id = 'term-id'
35
35
  mock_find_node.return_value = [{'@id': id}]
36
- assert get_excreta_terms() == [id]
36
+ assert get_excreta_N_terms() == [id]
37
+
38
+
39
+ @patch(f"{class_path}.find_node")
40
+ def test_get_excreta_VS_terms(mock_find_node):
41
+ id = 'term-id'
42
+ mock_find_node.return_value = [{'@id': id}]
43
+ assert get_excreta_VS_terms() == [id]
37
44
 
38
45
 
39
46
  @patch(f"{class_path}.find_node")