hestia-earth-models 0.59.2__py3-none-any.whl → 0.59.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of hestia-earth-models might be problematic. Click here for more details.

@@ -0,0 +1,83 @@
1
+ from hestia_earth.schema import EmissionMethodTier, EmissionStatsDefinition, TermTermType
2
+
3
+ from hestia_earth.models.log import logRequirements, logShouldRun, debugValues, log_as_table
4
+ from hestia_earth.models.utils.constant import Units, get_atomic_conversion
5
+ from hestia_earth.models.utils.completeness import _is_term_type_complete
6
+ from hestia_earth.models.utils.emission import _new_emission
7
+ from hestia_earth.models.utils.cycle import get_crop_residue_decomposition_N_total
8
+ from hestia_earth.models.utils.product import has_flooded_rice
9
+ from .utils import N2O_FACTORS
10
+ from . import MODEL
11
+
12
+ REQUIREMENTS = {
13
+ "Cycle": {
14
+ "completeness.cropResidue": "True",
15
+ "products": [{
16
+ "@type": "Product",
17
+ "value": "",
18
+ "term.termType": "cropResidue",
19
+ "properties": [{"@type": "Property", "value": "", "term.@id": "nitrogenContent"}]
20
+ }],
21
+ "optional": {
22
+ "products": [{"@type": "Product", "term.@id": "riceGrainInHuskFlooded"}]
23
+ }
24
+ }
25
+ }
26
+ RETURNS = {
27
+ "Emission": [{
28
+ "value": "",
29
+ "min": "",
30
+ "max": "",
31
+ "methodTier": "tier 1",
32
+ "statsDefinition": "modelled"
33
+ }]
34
+ }
35
+ LOOKUPS = {
36
+ "cropResidue": "decomposesOnField"
37
+ }
38
+ TERM_ID = 'n2OToAirCropResidueDecompositionDirect'
39
+ TIER = EmissionMethodTier.TIER_1.value
40
+
41
+
42
+ def _emission(value: float, min: float, max: float):
43
+ emission = _new_emission(TERM_ID, MODEL)
44
+ emission['value'] = [value]
45
+ emission['min'] = [min]
46
+ emission['max'] = [max]
47
+ emission['methodTier'] = TIER
48
+ emission['statsDefinition'] = EmissionStatsDefinition.MODELLED.value
49
+ return emission
50
+
51
+
52
+ def _run(cycle: dict, N_total: float):
53
+ flooded_rice = has_flooded_rice(cycle.get('products', []))
54
+
55
+ converted_N_total = N_total * get_atomic_conversion(Units.KG_N2O, Units.TO_N)
56
+ factors = N2O_FACTORS['flooded_rice'] if flooded_rice else N2O_FACTORS['default']
57
+
58
+ debugValues(cycle, model=MODEL, term=TERM_ID,
59
+ has_flooded_rice=flooded_rice,
60
+ factors_used=log_as_table(factors))
61
+
62
+ value = converted_N_total * factors['value']
63
+ min = converted_N_total * factors['min']
64
+ max = converted_N_total * factors['max']
65
+ return [_emission(value, min, max)]
66
+
67
+
68
+ def _should_run(cycle: dict):
69
+ term_type_complete = _is_term_type_complete(cycle, TermTermType.CROPRESIDUE)
70
+ N_crop_residue = get_crop_residue_decomposition_N_total(cycle)
71
+
72
+ logRequirements(cycle, model=MODEL, term=TERM_ID,
73
+ term_type_cropResidue_complete=term_type_complete,
74
+ N_crop_residue=N_crop_residue)
75
+
76
+ should_run = all([N_crop_residue is not None, term_type_complete])
77
+ logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
78
+ return should_run, N_crop_residue
79
+
80
+
81
+ def run(cycle: dict):
82
+ should_run, N_total = _should_run(cycle)
83
+ return _run(cycle, N_total) if should_run else []
@@ -2,6 +2,18 @@ from hestia_earth.utils.model import find_primary_product
2
2
 
3
3
  COEFF_NH3NOX_N2O = 0.01
4
4
  COEFF_NO3_N2O = 0.0075
5
+ N2O_FACTORS = {
6
+ 'default': {
7
+ 'value': 0.01,
8
+ 'min': 0.003,
9
+ 'max': 0.03
10
+ },
11
+ 'flooded_rice': {
12
+ 'value': 0.003,
13
+ 'min': 0,
14
+ 'max': 0.006
15
+ }
16
+ }
5
17
 
6
18
 
7
19
  def get_N_N2O_excreta_coeff_from_primary_product(cycle: dict):
@@ -0,0 +1,112 @@
1
+ from hestia_earth.schema import EmissionMethodTier, EmissionStatsDefinition, TermTermType
2
+ from hestia_earth.utils.model import filter_list_term_type, find_term_match
3
+ from hestia_earth.utils.tools import list_sum
4
+
5
+ from hestia_earth.models.log import logRequirements, logShouldRun, debugValues, log_as_table
6
+ from hestia_earth.models.utils.blank_node import get_N_total
7
+ from hestia_earth.models.utils.constant import Units, get_atomic_conversion
8
+ from hestia_earth.models.utils.completeness import _is_term_type_complete
9
+ from hestia_earth.models.utils.emission import _new_emission
10
+ from hestia_earth.models.utils.cycle import get_inorganic_fertiliser_N_total
11
+ from hestia_earth.models.utils.term import get_lookup_value
12
+ from . import MODEL
13
+
14
+ REQUIREMENTS = {
15
+ "Cycle": {
16
+ "completeness.fertiliser": "True",
17
+ "inputs": [
18
+ {
19
+ "@type": "Input",
20
+ "value": "",
21
+ "term.termType": "inorganicFertiliser",
22
+ "optional": {
23
+ "properties": [{"@type": "Property", "value": "", "term.@id": "nitrogenContent"}]
24
+ }
25
+ }
26
+ ]
27
+ }
28
+ }
29
+ RETURNS = {
30
+ "Emission": [{
31
+ "value": "",
32
+ "sd": "",
33
+ "min": "",
34
+ "max": "",
35
+ "methodTier": "tier 1",
36
+ "statsDefinition": "modelled",
37
+ "methodModelDescription": ["Aggregated version", "Disaggragated version"]
38
+ }]
39
+ }
40
+ LOOKUPS = {
41
+ "inorganicFertiliser": ["IPCC_2019_FRACGASF_NH3-N", "IPCC_2019_FRACGASF_NH3-N-min", "IPCC_2019_FRACGASF_NH3-N-max"]
42
+ }
43
+ TERM_ID = 'nh3ToAirInorganicFertiliser'
44
+ TIER = EmissionMethodTier.TIER_1.value
45
+ TERM_TYPE = TermTermType.INORGANICFERTILISER
46
+ UNSPECIFIED_TERM_ID = 'inorganicNitrogenFertiliserUnspecifiedKgN'
47
+
48
+
49
+ def _emission(value: float, min: float, max: float, aggregated: bool = False):
50
+ emission = _new_emission(TERM_ID, MODEL)
51
+ emission['value'] = [value]
52
+ emission['min'] = [min]
53
+ emission['max'] = [max]
54
+ emission['methodTier'] = TIER
55
+ emission['statsDefinition'] = EmissionStatsDefinition.MODELLED.value
56
+ emission['methodModelDescription'] = 'Aggregated version' if aggregated else 'Disaggregated version'
57
+ return emission
58
+
59
+
60
+ def _input_values(input: dict):
61
+ N_total = list_sum(get_N_total([input]))
62
+ lookups = LOOKUPS[TERM_TYPE.value]
63
+ return {
64
+ 'id': input.get('term', {}).get('@id'),
65
+ 'N': N_total,
66
+ 'value': get_lookup_value(input.get('term', {}), lookups[0]),
67
+ 'min': get_lookup_value(input.get('term', {}), lookups[1]),
68
+ 'max': get_lookup_value(input.get('term', {}), lookups[2])
69
+ }
70
+
71
+
72
+ def _filter_input_values(values: list, key: str): return [value for value in values if value.get(key)]
73
+
74
+
75
+ def _run(cycle: dict):
76
+ inputs = filter_list_term_type(cycle.get('inputs', []), TERM_TYPE)
77
+ input_values = list(map(_input_values, inputs))
78
+
79
+ debugValues(cycle, model=MODEL, term=TERM_ID,
80
+ input_values=log_as_table(input_values))
81
+
82
+ value = list_sum([
83
+ v.get('N', 0) * v.get('value', 0) for v in _filter_input_values(input_values, 'value')
84
+ ]) * get_atomic_conversion(Units.KG_NH3, Units.TO_N)
85
+
86
+ min = list_sum([
87
+ v.get('N', 0) * v.get('min', 0) for v in _filter_input_values(input_values, 'min')
88
+ ]) * get_atomic_conversion(Units.KG_NH3, Units.TO_N)
89
+
90
+ max = list_sum([
91
+ v.get('N', 0) * v.get('max', 0) for v in _filter_input_values(input_values, 'max')
92
+ ]) * get_atomic_conversion(Units.KG_NH3, Units.TO_N)
93
+
94
+ aggregated = list_sum(find_term_match(inputs, UNSPECIFIED_TERM_ID).get('value', [0])) > 0
95
+
96
+ return [_emission(value, min, max, aggregated=aggregated)]
97
+
98
+
99
+ def _should_run(cycle: dict):
100
+ N_inorganic_fertiliser = get_inorganic_fertiliser_N_total(cycle)
101
+ fertiliser_complete = _is_term_type_complete(cycle, 'fertiliser')
102
+
103
+ logRequirements(cycle, model=MODEL, term=TERM_ID,
104
+ N_inorganic_fertiliser=N_inorganic_fertiliser,
105
+ term_type_fertiliser_complete=fertiliser_complete)
106
+
107
+ should_run = all([N_inorganic_fertiliser is not None, fertiliser_complete])
108
+ logShouldRun(cycle, MODEL, TERM_ID, should_run)
109
+ return should_run
110
+
111
+
112
+ def run(cycle: dict): return _run(cycle) if _should_run(cycle) else []
@@ -66,6 +66,9 @@ def _input_values(input: dict):
66
66
  }
67
67
 
68
68
 
69
+ def _filter_input_values(values: list, key: str): return [value for value in values if value.get(key)]
70
+
71
+
69
72
  def _run(cycle: dict):
70
73
  inputs = filter_list_term_type(cycle.get('inputs', []), TermTermType.ORGANICFERTILISER)
71
74
  input_values = list(map(_input_values, inputs))
@@ -74,15 +77,15 @@ def _run(cycle: dict):
74
77
  input_values=log_as_table(input_values))
75
78
 
76
79
  value = list_sum([
77
- v.get('N', 0) * v.get('value', 0) for v in input_values
80
+ v.get('N', 0) * v.get('value', 0) for v in _filter_input_values(input_values, 'value')
78
81
  ]) * get_atomic_conversion(Units.KG_NH3, Units.TO_N)
79
82
 
80
83
  min = list_sum([
81
- v.get('N', 0) * v.get('min', 0) for v in input_values
84
+ v.get('N', 0) * v.get('min', 0) for v in _filter_input_values(input_values, 'min')
82
85
  ]) * get_atomic_conversion(Units.KG_NH3, Units.TO_N)
83
86
 
84
87
  max = list_sum([
85
- v.get('N', 0) * v.get('max', 0) for v in input_values
88
+ v.get('N', 0) * v.get('max', 0) for v in _filter_input_values(input_values, 'max')
86
89
  ]) * get_atomic_conversion(Units.KG_NH3, Units.TO_N)
87
90
 
88
91
  return [_emission(value, min, max)]
@@ -0,0 +1,112 @@
1
+ from hestia_earth.schema import EmissionMethodTier, EmissionStatsDefinition, TermTermType
2
+ from hestia_earth.utils.model import filter_list_term_type, find_term_match
3
+ from hestia_earth.utils.tools import list_sum
4
+
5
+ from hestia_earth.models.log import logRequirements, logShouldRun, debugValues, log_as_table
6
+ from hestia_earth.models.utils.blank_node import get_N_total
7
+ from hestia_earth.models.utils.constant import Units, get_atomic_conversion
8
+ from hestia_earth.models.utils.completeness import _is_term_type_complete
9
+ from hestia_earth.models.utils.emission import _new_emission
10
+ from hestia_earth.models.utils.cycle import get_inorganic_fertiliser_N_total
11
+ from hestia_earth.models.utils.term import get_lookup_value
12
+ from . import MODEL
13
+
14
+ REQUIREMENTS = {
15
+ "Cycle": {
16
+ "completeness.fertiliser": "True",
17
+ "inputs": [
18
+ {
19
+ "@type": "Input",
20
+ "value": "",
21
+ "term.termType": "inorganicFertiliser",
22
+ "optional": {
23
+ "properties": [{"@type": "Property", "value": "", "term.@id": "nitrogenContent"}]
24
+ }
25
+ }
26
+ ]
27
+ }
28
+ }
29
+ RETURNS = {
30
+ "Emission": [{
31
+ "value": "",
32
+ "sd": "",
33
+ "min": "",
34
+ "max": "",
35
+ "methodTier": "tier 1",
36
+ "statsDefinition": "modelled",
37
+ "methodModelDescription": ["Aggregated version", "Disaggragated version"]
38
+ }]
39
+ }
40
+ LOOKUPS = {
41
+ "inorganicFertiliser": ["IPCC_2019_FRACGASF_NOx-N", "IPCC_2019_FRACGASF_NOx-N-min", "IPCC_2019_FRACGASF_NOx-N-max"]
42
+ }
43
+ TERM_ID = 'noxToAirInorganicFertiliser'
44
+ TIER = EmissionMethodTier.TIER_1.value
45
+ TERM_TYPE = TermTermType.INORGANICFERTILISER
46
+ UNSPECIFIED_TERM_ID = 'inorganicNitrogenFertiliserUnspecifiedKgN'
47
+
48
+
49
+ def _emission(value: float, min: float, max: float, aggregated: bool = False):
50
+ emission = _new_emission(TERM_ID, MODEL)
51
+ emission['value'] = [value]
52
+ emission['min'] = [min]
53
+ emission['max'] = [max]
54
+ emission['methodTier'] = TIER
55
+ emission['statsDefinition'] = EmissionStatsDefinition.MODELLED.value
56
+ emission['methodModelDescription'] = 'Aggregated version' if aggregated else 'Disaggregated version'
57
+ return emission
58
+
59
+
60
+ def _input_values(input: dict):
61
+ N_total = list_sum(get_N_total([input]))
62
+ lookups = LOOKUPS[TERM_TYPE.value]
63
+ return {
64
+ 'id': input.get('term', {}).get('@id'),
65
+ 'N': N_total,
66
+ 'value': get_lookup_value(input.get('term', {}), lookups[0]),
67
+ 'min': get_lookup_value(input.get('term', {}), lookups[1]),
68
+ 'max': get_lookup_value(input.get('term', {}), lookups[2])
69
+ }
70
+
71
+
72
+ def _filter_input_values(values: list, key: str): return [value for value in values if value.get(key)]
73
+
74
+
75
+ def _run(cycle: dict):
76
+ inputs = filter_list_term_type(cycle.get('inputs', []), TERM_TYPE)
77
+ input_values = list(map(_input_values, inputs))
78
+
79
+ debugValues(cycle, model=MODEL, term=TERM_ID,
80
+ input_values=log_as_table(input_values))
81
+
82
+ value = list_sum([
83
+ v.get('N', 0) * v.get('value', 0) for v in _filter_input_values(input_values, 'value')
84
+ ]) * get_atomic_conversion(Units.KG_NOX, Units.TO_N)
85
+
86
+ min = list_sum([
87
+ v.get('N', 0) * v.get('min', 0) for v in _filter_input_values(input_values, 'min')
88
+ ]) * get_atomic_conversion(Units.KG_NOX, Units.TO_N)
89
+
90
+ max = list_sum([
91
+ v.get('N', 0) * v.get('max', 0) for v in _filter_input_values(input_values, 'max')
92
+ ]) * get_atomic_conversion(Units.KG_NOX, Units.TO_N)
93
+
94
+ aggregated = list_sum(find_term_match(inputs, UNSPECIFIED_TERM_ID).get('value', [0])) > 0
95
+
96
+ return [_emission(value, min, max, aggregated=aggregated)]
97
+
98
+
99
+ def _should_run(cycle: dict):
100
+ N_inorganic_fertiliser = get_inorganic_fertiliser_N_total(cycle)
101
+ fertiliser_complete = _is_term_type_complete(cycle, 'fertiliser')
102
+
103
+ logRequirements(cycle, model=MODEL, term=TERM_ID,
104
+ N_inorganic_fertiliser=N_inorganic_fertiliser,
105
+ term_type_fertiliser_complete=fertiliser_complete)
106
+
107
+ should_run = all([N_inorganic_fertiliser is not None, fertiliser_complete])
108
+ logShouldRun(cycle, MODEL, TERM_ID, should_run)
109
+ return should_run
110
+
111
+
112
+ def run(cycle: dict): return _run(cycle) if _should_run(cycle) else []
@@ -66,6 +66,9 @@ def _input_values(input: dict):
66
66
  }
67
67
 
68
68
 
69
+ def _filter_input_values(values: list, key: str): return [value for value in values if value.get(key)]
70
+
71
+
69
72
  def _run(cycle: dict):
70
73
  inputs = filter_list_term_type(cycle.get('inputs', []), TermTermType.ORGANICFERTILISER)
71
74
  input_values = list(map(_input_values, inputs))
@@ -74,15 +77,15 @@ def _run(cycle: dict):
74
77
  input_values=log_as_table(input_values))
75
78
 
76
79
  value = list_sum([
77
- v.get('N', 0) * v.get('value', 0) for v in input_values
80
+ v.get('N', 0) * v.get('value', 0) for v in _filter_input_values(input_values, 'value')
78
81
  ]) * get_atomic_conversion(Units.KG_NOX, Units.TO_N)
79
82
 
80
83
  min = list_sum([
81
- v.get('N', 0) * v.get('min', 0) for v in input_values
84
+ v.get('N', 0) * v.get('min', 0) for v in _filter_input_values(input_values, 'min')
82
85
  ]) * get_atomic_conversion(Units.KG_NOX, Units.TO_N)
83
86
 
84
87
  max = list_sum([
85
- v.get('N', 0) * v.get('max', 0) for v in input_values
88
+ v.get('N', 0) * v.get('max', 0) for v in _filter_input_values(input_values, 'max')
86
89
  ]) * get_atomic_conversion(Units.KG_NOX, Units.TO_N)
87
90
 
88
91
  return [_emission(value, min, max)]
@@ -107,7 +107,14 @@ REQUIREMENTS = {
107
107
  "value": "",
108
108
  "startDate": "",
109
109
  "endDate": "",
110
- "term.@id": "organicFertiliserOrSoilCarbonIncreasingAmendmentUsed"
110
+ "term.@id": "organicFertiliserUsed"
111
+ },
112
+ {
113
+ "@type": "Management",
114
+ "value": "",
115
+ "startDate": "",
116
+ "endDate": "",
117
+ "term.@id": "amendmentIncreasingSoilCarbonUsed"
111
118
  },
112
119
  {"@type": "Management", "value": "", "startDate": "", "endDate": "", "term.@id": "shortBareFallow"}
113
120
  ]
@@ -238,7 +245,8 @@ IMPROVED_PASTURE_TERM_ID = "improvedPasture"
238
245
  SHORT_BARE_FALLOW_TERM_ID = "shortBareFallow"
239
246
  ANIMAL_MANURE_USED_TERM_ID = "animalManureUsed"
240
247
  INORGANIC_NITROGEN_FERTILISER_USED_TERM_ID = "inorganicNitrogenFertiliserUsed"
241
- ORGANIC_FERTILISER_USED_TERM_ID = "organicFertiliserOrSoilCarbonIncreasingAmendmentUsed"
248
+ ORGANIC_FERTILISER_USED_TERM_ID = "organicFertiliserUsed"
249
+ SOIL_AMENDMENT_USED_TERM_ID = "amendmentIncreasingSoilCarbonUsed"
242
250
 
243
251
  CLAY_CONTENT_MAX = 8
244
252
  SAND_CONTENT_MIN = 70
@@ -3301,7 +3309,7 @@ def _get_carbon_input_kwargs(
3301
3309
 
3302
3310
  has_organic_fertiliser_or_soil_amendment_used = any(
3303
3311
  get_node_value(node) for node in land_use_management_nodes
3304
- if node_term_match(node, ORGANIC_FERTILISER_USED_TERM_ID)
3312
+ if node_term_match(node, [ORGANIC_FERTILISER_USED_TERM_ID, SOIL_AMENDMENT_USED_TERM_ID])
3305
3313
  )
3306
3314
 
3307
3315
  has_practice_increasing_c_input = cumulative_nodes_match(
@@ -1 +1 @@
1
- VERSION = '0.59.2'
1
+ VERSION = '0.59.3'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hestia-earth-models
3
- Version: 0.59.2
3
+ Version: 0.59.3
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
@@ -3,7 +3,7 @@ hestia_earth/models/__init__.py,sha256=qEFeq3yuf3lQKVseALmL8aPM8fpCS54B_5pry00M3
3
3
  hestia_earth/models/cache_sites.py,sha256=kp_3D09P-JdAn9vt7eU-KKTwd6BAXWKQL_0UQCDsH2s,4798
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=58Yl5t5ON-GW8LlDihjO_US-BZGFRvSNjAnjUrGJ5wQ,19
6
+ hestia_earth/models/version.py,sha256=CbLC-bytMU-XpY8CM5H7SMZR8Ap_SRMUQNvt55nruo0,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
@@ -202,6 +202,7 @@ hestia_earth/models/ipcc2006/aboveGroundCropResidueRemoved.py,sha256=6FDgMH5eiO1
202
202
  hestia_earth/models/ipcc2006/aboveGroundCropResidueTotal.py,sha256=vD_kpvOJmjTOjDEnlqSYBSZxjuPGvzpmCr0JIC84GKE,3431
203
203
  hestia_earth/models/ipcc2006/belowGroundCropResidue.py,sha256=KzeRphJb1IWB_EPVcxa9tbCoNmEe80D9lKxgQOqfKoU,4138
204
204
  hestia_earth/models/ipcc2006/co2ToAirOrganicSoilCultivation.py,sha256=8AzFuqRprk6o-uyyI3XYsTGl2dP_ALgYJXWCseYEBQ8,3029
205
+ hestia_earth/models/ipcc2006/n2OToAirCropResidueDecompositionDirect.py,sha256=_2oTngpspikbFwgFTtOWs-SgEVF8LzznvITGITTtol4,2913
205
206
  hestia_earth/models/ipcc2006/n2OToAirCropResidueDecompositionIndirect.py,sha256=kf4WjdMzs6d8h433LFuUH9LJKJ_aMHTqEHDToGY5-Xk,2315
206
207
  hestia_earth/models/ipcc2006/n2OToAirExcretaDirect.py,sha256=VvQTIh58JyhrdPk5FdJQBkjBDr5-Cv7CnGkNEcco3P4,1986
207
208
  hestia_earth/models/ipcc2006/n2OToAirExcretaIndirect.py,sha256=me1MLX2WI5A_VZ11774CRxwRC6seOaxgMg_GGYCckIk,2243
@@ -210,7 +211,7 @@ hestia_earth/models/ipcc2006/n2OToAirInorganicFertiliserIndirect.py,sha256=MNFyX
210
211
  hestia_earth/models/ipcc2006/n2OToAirOrganicFertiliserDirect.py,sha256=MZUmA3ajGkpi4wr020OU6m4WJdujjKkRhUVsbPgUVb8,2094
211
212
  hestia_earth/models/ipcc2006/n2OToAirOrganicFertiliserIndirect.py,sha256=pgNG18EwgTA7kmVw9QFtucMn8ScVeEKJAsSPxcExbI8,2801
212
213
  hestia_earth/models/ipcc2006/n2OToAirOrganicSoilCultivationDirect.py,sha256=0J6ntZxYyLg3pUQeSQelDe36fb0nQtbMLjIBtwzHUyc,3038
213
- hestia_earth/models/ipcc2006/utils.py,sha256=7-0rfkjgm8tH0dx5nfi-9sFP07L9Dli_2UCZf6eL2qU,541
214
+ hestia_earth/models/ipcc2006/utils.py,sha256=flB7HWrynzOorKlmrpbETGD63NMv45H8Wxjj3RCav98,739
214
215
  hestia_earth/models/ipcc2013ExcludingFeedbacks/__init__.py,sha256=v4Qe-X4w3tqIHGJBNnEAK81x4ZuQMwYxQYXRncugmcU,427
215
216
  hestia_earth/models/ipcc2013ExcludingFeedbacks/gwp100.py,sha256=8VRg-Vvzc86_CQmBH-iHNhaSnAFHew2swAMecT0aXW4,979
216
217
  hestia_earth/models/ipcc2013IncludingFeedbacks/__init__.py,sha256=VJ16KIGQQHybzZiTvu3mpZy_3j0xcd06RHHCfPrCMgU,427
@@ -235,14 +236,16 @@ hestia_earth/models/ipcc2019/n2OToAirInorganicFertiliserDirect.py,sha256=NfS6EiE
235
236
  hestia_earth/models/ipcc2019/n2OToAirInorganicFertiliserIndirect.py,sha256=iNjwTyktLqD0HpwfwAEnAHbQUDNQmT7ekONF_lJobzE,3715
236
237
  hestia_earth/models/ipcc2019/n2OToAirOrganicFertiliserDirect.py,sha256=pMyl6UtUVgPWfczgA_cdm1RUdMGi4Ln16qWrw1eesv4,4138
237
238
  hestia_earth/models/ipcc2019/n2OToAirOrganicFertiliserIndirect.py,sha256=9YbaR8h7P-4rLHgcwtDLnQ_hT7cKzyELjCVJ9lWV2jI,3701
238
- hestia_earth/models/ipcc2019/nh3ToAirOrganicFertiliser.py,sha256=fsuc4pojyOfNrfnwLpVlfUWScm6SznJ5s_rbxhB6zJg,3717
239
+ hestia_earth/models/ipcc2019/nh3ToAirInorganicFertiliser.py,sha256=IASHAUO_tV043qLxll9M7Bp9WM5N290lkmkh1yQr-1U,4226
240
+ hestia_earth/models/ipcc2019/nh3ToAirOrganicFertiliser.py,sha256=mPAoC6mRc4F7bXRt02JQWqhJvds-bEIEnk2XbdJzmEU,3911
239
241
  hestia_earth/models/ipcc2019/nitrogenContent.py,sha256=6fGG7diDp9zAidVH75gXz9c8uxURx0Q2COo8KrkT3I4,7191
240
242
  hestia_earth/models/ipcc2019/no3ToGroundwaterCropResidueDecomposition.py,sha256=8NOjbqJuQ-wnLz3bYmwaygSzKBdaF3N7hoELGNnO4YQ,3115
241
243
  hestia_earth/models/ipcc2019/no3ToGroundwaterExcreta.py,sha256=mJUXLGtg9EOZq9LH0KFOKvzER1ypCUucs0ZMaNYMShc,2991
242
244
  hestia_earth/models/ipcc2019/no3ToGroundwaterInorganicFertiliser.py,sha256=wTvMBthqmiKMn4nLbL4VD6_8_gGI2WGR3OYz3KK8sXs,3105
243
245
  hestia_earth/models/ipcc2019/no3ToGroundwaterOrganicFertiliser.py,sha256=zOhp6NhYUuUNU_LMMwhZBP78YC2XRWRlGnajBUX2AN8,3095
244
- hestia_earth/models/ipcc2019/noxToAirOrganicFertiliser.py,sha256=VK3F0GUBG5CYJj0tLercVryj1ezj58PxaFi_zqijHvE,3717
245
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py,sha256=ADn2kv6uzfJb71ti8ydI3aGiGQMj0HsIZDjgxdU2Aic,142289
246
+ hestia_earth/models/ipcc2019/noxToAirInorganicFertiliser.py,sha256=D-UyzY55mOiIcXRzEtvPY-r1bDFgb9YqA08SmHsQeNA,4226
247
+ hestia_earth/models/ipcc2019/noxToAirOrganicFertiliser.py,sha256=SVgVNp76bIv9oUjrZZuI6xYLo4Gw2DRU5tbp14gydOE,3911
248
+ hestia_earth/models/ipcc2019/organicCarbonPerHa.py,sha256=9zWmAolHbFuvw2dxK4zZ8bW-1VDy7j44DYPmspJ0U-M,142577
246
249
  hestia_earth/models/ipcc2019/pastureGrass.py,sha256=CpDEtdnbKd_8eaDLcflJ-dGik3t879HIoEIzuaHNmC0,23168
247
250
  hestia_earth/models/ipcc2019/utils.py,sha256=MSDMu15D9DnilFUgi4_6jYXC0FaKso3OODauGTMB6hs,6229
248
251
  hestia_earth/models/ipcc2021/__init__.py,sha256=VTgGFKhwMmk_nuI1RRq0in27fHYVPBonlXlPK00K8no,409
@@ -724,6 +727,7 @@ tests/models/ipcc2006/test_aboveGroundCropResidueRemoved.py,sha256=5F7eU4qWYfTZA
724
727
  tests/models/ipcc2006/test_aboveGroundCropResidueTotal.py,sha256=FrSR1xBTRtJ99pXAklXLtDRC00FSW1vXSAvQNeBoXTQ,1725
725
728
  tests/models/ipcc2006/test_belowGroundCropResidue.py,sha256=cFqLDFy5pcgOyzKC9l-RClEP6CWCdVNnq48S90SITVM,1720
726
729
  tests/models/ipcc2006/test_co2ToAirOrganicSoilCultivation.py,sha256=wM1BYFcK28aiNVP6JUEWdc90kCd3w4rjOnpxzwuYV_o,1609
730
+ tests/models/ipcc2006/test_n2OToAirCropResidueDecompositionDirect.py,sha256=rmL8K9ToJa9SAO-kxSd8Zz3cl5bTWrDRDxsPAMMTmCo,1626
727
731
  tests/models/ipcc2006/test_n2OToAirCropResidueDecompositionIndirect.py,sha256=cxn5rX_pZqbl7m8rhJARuyjG2P5O-BQbufeEcTmO06k,1357
728
732
  tests/models/ipcc2006/test_n2OToAirExcretaDirect.py,sha256=tm6Lm90_4qEkCU6UIFsOD6yhrMrq69lkF1LvCjXPjE4,2132
729
733
  tests/models/ipcc2006/test_n2OToAirExcretaIndirect.py,sha256=712I87Wkpp4KcHfHaK1kgfD6nfHGo3iZqKIwfMG9a6A,1282
@@ -756,14 +760,16 @@ tests/models/ipcc2019/test_n2OToAirInorganicFertiliserDirect.py,sha256=ffk-aom1B
756
760
  tests/models/ipcc2019/test_n2OToAirInorganicFertiliserIndirect.py,sha256=RnU8CkUCYBBO1bgJALnoVgjTHLL1L1sja2nsyeVA_cg,2113
757
761
  tests/models/ipcc2019/test_n2OToAirOrganicFertiliserDirect.py,sha256=XQpzdEFT7qSw6KKRYEZ6Cmzkc_xLyG98FHH1PSfOUo0,2403
758
762
  tests/models/ipcc2019/test_n2OToAirOrganicFertiliserIndirect.py,sha256=hW84sTlhB8mKRSFJX_iQS4gYo74zCtY-9zr1VHLC5GU,2111
763
+ tests/models/ipcc2019/test_nh3ToAirInorganicFertiliser.py,sha256=xmRHSTmyh--EZX29Z5NHD4LqEZl7Lkc5HntBCXlIRHE,1537
759
764
  tests/models/ipcc2019/test_nh3ToAirOrganicFertiliser.py,sha256=Z4a20I2UnZdzm6FqHnlHRXXVCY993_SHT7nG-zAhx-c,1104
760
765
  tests/models/ipcc2019/test_nitrogenContent.py,sha256=rKl_05PCC0OSsAhG0cHJOqnt9LsCaFnRpJorkm1TShA,3704
761
766
  tests/models/ipcc2019/test_no3ToGroundwaterCropResidueDecomposition.py,sha256=4__3HDUDWt5KjQGcXEFXHBgP_jT0rxvIzpBLH_mP9WE,1729
762
767
  tests/models/ipcc2019/test_no3ToGroundwaterExcreta.py,sha256=Z-pCBQvlUf0ttmCERgezW-6e3KlX45YEVccOwthf5lU,1588
763
768
  tests/models/ipcc2019/test_no3ToGroundwaterInorganicFertiliser.py,sha256=e7REnQ9r9a8xroq5aPp0NIzmkad_6MyTuceRTYoKdkE,1613
764
769
  tests/models/ipcc2019/test_no3ToGroundwaterOrganicFertiliser.py,sha256=e1ZViD12qB3bLdH3TJw3GbBP8iqMen-UJbcFkytb3VQ,1609
770
+ tests/models/ipcc2019/test_noxToAirInorganicFertiliser.py,sha256=NZBSBJLM_j2PEpHRON2ysgKNF8x5sHfQVoAKQdGsfzk,1537
765
771
  tests/models/ipcc2019/test_noxToAirOrganicFertiliser.py,sha256=LR5pjV5vRbgSSQAw8kYRp_ij4CHInzgaDS6EggQuBiw,1104
766
- tests/models/ipcc2019/test_organicCarbonPerHa.py,sha256=lsg148KPupjF4ds8yUy1Cl2hcVXaGT9AIgkGycbHqXI,21643
772
+ tests/models/ipcc2019/test_organicCarbonPerHa.py,sha256=g6EYKDiotsmod8zup2316g3auvy3cdGncaZ_2rO03Fg,21876
767
773
  tests/models/ipcc2019/test_pastureGrass.py,sha256=pE4PWdR541v4xWDYihP7Dou8V1iqg5GwD5_rjGRzrds,2292
768
774
  tests/models/ipcc2021/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
769
775
  tests/models/ipcc2021/test_gwp100.py,sha256=JRklKMSg-OXopb9ZufGgl94deuMuJSsfNXRZDBtOZrE,1119
@@ -1007,7 +1013,7 @@ tests/models/transformation/product/test_excreta.py,sha256=Q9OQpk8qVPv3alIz2i5XQ
1007
1013
  tests/models/usetoxV2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1008
1014
  tests/models/usetoxV2/test_freshwaterEcotoxicityPotentialCtue.py,sha256=eq7Gcmfya9g0eOKKkuBhz8vq7xi_CmZ_LTSxueBwZt4,835
1009
1015
  tests/models/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1010
- tests/models/utils/test_blank_node.py,sha256=xlyddD7moTRvjiHq2Z9uKJODV05WW8YZkliUOCHy4b8,31488
1016
+ tests/models/utils/test_blank_node.py,sha256=T1-JRrWcK6oFavYAEy7gt2iojnTdNgoX2WDc08-4h-I,31333
1011
1017
  tests/models/utils/test_cropResidueManagement.py,sha256=RQt8lexeJzCyxZceIutgDpw7BpcqmjsUB0C0yZC2QpY,930
1012
1018
  tests/models/utils/test_currency.py,sha256=BPsojPsY9QW2aj8vgbjkPQXU8GU6wDwwtPZ3HdC4KTU,277
1013
1019
  tests/models/utils/test_cycle.py,sha256=evTHH73ftNVhv5vHlYE2973msKE4pSCd3D0GfX1ZPUA,465
@@ -1027,8 +1033,8 @@ tests/models/utils/test_source.py,sha256=mv3vHZV5cjpoLA2I1109-YUkuzAiuhbRSnv_76_
1027
1033
  tests/models/utils/test_term.py,sha256=JJmzyHnhVGeQ7tG-T6DjE7CoIJPH0guH-y2kjGeZiJY,3756
1028
1034
  tests/models/webbEtAl2012AndSintermannEtAl2012/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1029
1035
  tests/models/webbEtAl2012AndSintermannEtAl2012/test_nh3ToAirOrganicFertiliser.py,sha256=qi2FNXS5Af2WDtm7nq_FsprH3BfCF0XxnE0XHmC4aIY,2244
1030
- hestia_earth_models-0.59.2.dist-info/LICENSE,sha256=EFSZhfUdZCTsCIYdHzTGewMKfRfp7X9t1s2aaKxm8O0,1154
1031
- hestia_earth_models-0.59.2.dist-info/METADATA,sha256=-qJ0J6ITtaF7C2fKg8Y38GtdFxZq0FMtcW4XO-H1pkA,3134
1032
- hestia_earth_models-0.59.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1033
- hestia_earth_models-0.59.2.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
1034
- hestia_earth_models-0.59.2.dist-info/RECORD,,
1036
+ hestia_earth_models-0.59.3.dist-info/LICENSE,sha256=EFSZhfUdZCTsCIYdHzTGewMKfRfp7X9t1s2aaKxm8O0,1154
1037
+ hestia_earth_models-0.59.3.dist-info/METADATA,sha256=gyNoaOgImXrijST_O_SKIa6sDSY9vSDOJA0716l11uU,3134
1038
+ hestia_earth_models-0.59.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1039
+ hestia_earth_models-0.59.3.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
1040
+ hestia_earth_models-0.59.3.dist-info/RECORD,,
@@ -0,0 +1,50 @@
1
+ from unittest.mock import patch
2
+ import json
3
+ from tests.utils import fixtures_path, fake_new_emission
4
+
5
+ from hestia_earth.models.ipcc2006.n2OToAirCropResidueDecompositionDirect 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}._is_term_type_complete", return_value=False)
12
+ @patch(f"{class_path}.get_crop_residue_decomposition_N_total", return_value=0)
13
+ def test_should_run(mock_N_total, mock_complete):
14
+ # no N => no run
15
+ should_run, *args = _should_run({})
16
+ assert not should_run
17
+
18
+ # with N => no run
19
+ mock_N_total.return_value = 10
20
+ should_run, *args = _should_run({})
21
+ assert not should_run
22
+
23
+ # is complete => run
24
+ mock_complete.return_value = True
25
+ should_run, *args = _should_run({})
26
+ assert should_run is True
27
+
28
+
29
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
30
+ def test_run(*args):
31
+ with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
32
+ cycle = json.load(f)
33
+
34
+ with open(f"{fixtures_folder}/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}._new_emission", side_effect=fake_new_emission)
42
+ def test_run_flooded_rice(*args):
43
+ with open(f"{fixtures_folder}/with-flooded-rice/cycle.jsonld", encoding='utf-8') as f:
44
+ cycle = json.load(f)
45
+
46
+ with open(f"{fixtures_folder}/with-flooded-rice/result.jsonld", encoding='utf-8') as f:
47
+ expected = json.load(f)
48
+
49
+ value = run(cycle)
50
+ assert value == expected
@@ -0,0 +1,47 @@
1
+ from unittest.mock import patch
2
+ import json
3
+ from tests.utils import fixtures_path, fake_new_emission
4
+
5
+ from hestia_earth.models.ipcc2019.nh3ToAirInorganicFertiliser 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}._is_term_type_complete", return_value=False)
12
+ @patch(f"{class_path}.get_inorganic_fertiliser_N_total", return_value=0)
13
+ def test_should_run(mock_N_total, mock_complete, *args):
14
+ # no N => no run
15
+ assert not _should_run({})
16
+
17
+ # with N => no run
18
+ mock_N_total.return_value = 10
19
+ assert not _should_run({})
20
+
21
+ # is complete => run
22
+ mock_complete.return_value = True
23
+ assert _should_run({}) is True
24
+
25
+
26
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
27
+ def test_run_aggregated(*args):
28
+ with open(f"{fixtures_folder}/aggregated/cycle.jsonld", encoding='utf-8') as f:
29
+ cycle = json.load(f)
30
+
31
+ with open(f"{fixtures_folder}/aggregated/result.jsonld", encoding='utf-8') as f:
32
+ expected = json.load(f)
33
+
34
+ value = run(cycle)
35
+ assert value == expected
36
+
37
+
38
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
39
+ def test_run_disaggregated(*args):
40
+ with open(f"{fixtures_folder}/disaggregated/cycle.jsonld", encoding='utf-8') as f:
41
+ cycle = json.load(f)
42
+
43
+ with open(f"{fixtures_folder}/disaggregated/result.jsonld", encoding='utf-8') as f:
44
+ expected = json.load(f)
45
+
46
+ value = run(cycle)
47
+ assert value == expected
@@ -0,0 +1,47 @@
1
+ from unittest.mock import patch
2
+ import json
3
+ from tests.utils import fixtures_path, fake_new_emission
4
+
5
+ from hestia_earth.models.ipcc2019.noxToAirInorganicFertiliser 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}._is_term_type_complete", return_value=False)
12
+ @patch(f"{class_path}.get_inorganic_fertiliser_N_total", return_value=0)
13
+ def test_should_run(mock_N_total, mock_complete, *args):
14
+ # no N => no run
15
+ assert not _should_run({})
16
+
17
+ # with N => no run
18
+ mock_N_total.return_value = 10
19
+ assert not _should_run({})
20
+
21
+ # is complete => run
22
+ mock_complete.return_value = True
23
+ assert _should_run({}) is True
24
+
25
+
26
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
27
+ def test_run_aggregated(*args):
28
+ with open(f"{fixtures_folder}/aggregated/cycle.jsonld", encoding='utf-8') as f:
29
+ cycle = json.load(f)
30
+
31
+ with open(f"{fixtures_folder}/aggregated/result.jsonld", encoding='utf-8') as f:
32
+ expected = json.load(f)
33
+
34
+ value = run(cycle)
35
+ assert value == expected
36
+
37
+
38
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
39
+ def test_run_disaggregated(*args):
40
+ with open(f"{fixtures_folder}/disaggregated/cycle.jsonld", encoding='utf-8') as f:
41
+ cycle = json.load(f)
42
+
43
+ with open(f"{fixtures_folder}/disaggregated/result.jsonld", encoding='utf-8') as f:
44
+ expected = json.load(f)
45
+
46
+ value = run(cycle)
47
+ assert value == expected
@@ -438,7 +438,12 @@ CARBON_INPUT_CATEGORY_PARAMS = [
438
438
  IpccCarbonInputCategory.CROPLAND_HIGH_WITH_MANURE
439
439
  ),
440
440
  (
441
- "cropland-high-without-manure",
441
+ "cropland-high-without-manure/organic-fertiliser", # Closes issue 743
442
+ IpccManagementCategory.FULL_TILLAGE,
443
+ IpccCarbonInputCategory.CROPLAND_HIGH_WITHOUT_MANURE
444
+ ),
445
+ (
446
+ "cropland-high-without-manure/soil-amendment", # Closes issue 743
442
447
  IpccManagementCategory.FULL_TILLAGE,
443
448
  IpccCarbonInputCategory.CROPLAND_HIGH_WITHOUT_MANURE
444
449
  ),
@@ -815,13 +815,13 @@ def test_group_nodes_by_year_scenario_d():
815
815
  "value": 100
816
816
  },
817
817
  {
818
- "term.@id": "organicFertiliserOrSoilCarbonIncreasingAmendmentUsed",
818
+ "term.@id": "organicFertiliserUsed",
819
819
  "endDate": "2000-11",
820
820
  "startDate": "2000-09",
821
821
  "value": True
822
822
  },
823
823
  {
824
- "term.@id": "organicFertiliserOrSoilCarbonIncreasingAmendmentUsed",
824
+ "term.@id": "organicFertiliserUsed",
825
825
  "endDate": "2002-06",
826
826
  "startDate": "2001-07",
827
827
  "value": True
@@ -838,7 +838,7 @@ def test_group_nodes_by_year_scenario_d():
838
838
  "fraction_of_node_duration": 0.9153005464480874
839
839
  },
840
840
  {
841
- "term.@id": "organicFertiliserOrSoilCarbonIncreasingAmendmentUsed",
841
+ "term.@id": "organicFertiliserUsed",
842
842
  "endDate": "2000-11",
843
843
  "startDate": "2000-09",
844
844
  "value": True,
@@ -872,7 +872,7 @@ def test_group_nodes_by_year_scenario_d():
872
872
  "fraction_of_node_duration": 0.8315217391304348
873
873
  },
874
874
  {
875
- "term.@id": "organicFertiliserOrSoilCarbonIncreasingAmendmentUsed",
875
+ "term.@id": "organicFertiliserUsed",
876
876
  "endDate": "2002-06",
877
877
  "startDate": "2001-07",
878
878
  "value": True,
@@ -882,7 +882,7 @@ def test_group_nodes_by_year_scenario_d():
882
882
  ],
883
883
  2002: [
884
884
  {
885
- "term.@id": "organicFertiliserOrSoilCarbonIncreasingAmendmentUsed",
885
+ "term.@id": "organicFertiliserUsed",
886
886
  "endDate": "2002-06",
887
887
  "startDate": "2001-07",
888
888
  "value": True,