hestia-earth-models 0.62.4__py3-none-any.whl → 0.62.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hestia-earth-models might be problematic. Click here for more details.
- hestia_earth/models/emepEea2019/co2ToAirFuelCombustion.py +2 -10
- hestia_earth/models/emepEea2019/n2OToAirFuelCombustionDirect.py +2 -10
- hestia_earth/models/emepEea2019/nh3ToAirExcreta.py +2 -9
- hestia_earth/models/emepEea2019/nh3ToAirInorganicFertiliser.py +2 -9
- hestia_earth/models/emepEea2019/noxToAirFuelCombustion.py +2 -10
- hestia_earth/models/emepEea2019/pm10ToAirAnimalHousing.py +57 -0
- hestia_earth/models/emepEea2019/pm25ToAirAnimalHousing.py +57 -0
- hestia_earth/models/emepEea2019/so2ToAirFuelCombustion.py +2 -10
- hestia_earth/models/emepEea2019/tspToAirAnimalHousing.py +57 -0
- hestia_earth/models/emepEea2019/utils.py +60 -1
- hestia_earth/models/ipcc2019/animal/pastureGrass.py +2 -2
- hestia_earth/models/ipcc2019/pastureGrass.py +2 -2
- hestia_earth/models/ipcc2019/pastureGrass_utils.py +1 -10
- hestia_earth/models/mocking/search-results.json +11 -11
- hestia_earth/models/site/management.py +7 -5
- hestia_earth/models/utils/cycle.py +10 -1
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.62.4.dist-info → hestia_earth_models-0.62.5.dist-info}/METADATA +1 -1
- {hestia_earth_models-0.62.4.dist-info → hestia_earth_models-0.62.5.dist-info}/RECORD +33 -27
- tests/models/emepEea2019/test_co2ToAirFuelCombustion.py +3 -2
- tests/models/emepEea2019/test_n2OToAirFuelCombustionDirect.py +3 -2
- tests/models/emepEea2019/test_nh3ToAirExcreta.py +2 -1
- tests/models/emepEea2019/test_nh3ToAirInorganicFertiliser.py +4 -3
- tests/models/emepEea2019/test_noxToAirFuelCombustion.py +3 -2
- tests/models/emepEea2019/test_pm10ToAirAnimalHousing.py +21 -0
- tests/models/emepEea2019/test_pm25ToAirAnimalHousing.py +21 -0
- tests/models/emepEea2019/test_so2ToAirFuelCombustion.py +3 -2
- tests/models/emepEea2019/test_tspToAirAnimalHousing.py +21 -0
- tests/models/emepEea2019/test_utils.py +198 -1
- tests/models/site/test_management.py +1 -0
- {hestia_earth_models-0.62.4.dist-info → hestia_earth_models-0.62.5.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.62.4.dist-info → hestia_earth_models-0.62.5.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.62.4.dist-info → hestia_earth_models-0.62.5.dist-info}/top_level.txt +0 -0
|
@@ -2,8 +2,7 @@ from hestia_earth.schema import EmissionMethodTier
|
|
|
2
2
|
from hestia_earth.utils.tools import list_sum
|
|
3
3
|
|
|
4
4
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
5
|
-
from
|
|
6
|
-
from .utils import get_fuel_values
|
|
5
|
+
from .utils import get_fuel_values, _emission
|
|
7
6
|
from . import MODEL
|
|
8
7
|
|
|
9
8
|
REQUIREMENTS = {
|
|
@@ -32,16 +31,9 @@ TERM_ID = 'co2ToAirFuelCombustion'
|
|
|
32
31
|
TIER = EmissionMethodTier.TIER_1.value
|
|
33
32
|
|
|
34
33
|
|
|
35
|
-
def _emission(value: float):
|
|
36
|
-
emission = _new_emission(TERM_ID, MODEL)
|
|
37
|
-
emission['value'] = [value]
|
|
38
|
-
emission['methodTier'] = TIER
|
|
39
|
-
return emission
|
|
40
|
-
|
|
41
|
-
|
|
42
34
|
def _run(fuel_values: list):
|
|
43
35
|
value = list_sum(fuel_values)
|
|
44
|
-
return [_emission(value)]
|
|
36
|
+
return [_emission(value=value, tier=TIER, term_id=TERM_ID)]
|
|
45
37
|
|
|
46
38
|
|
|
47
39
|
def _should_run(cycle: dict):
|
|
@@ -2,8 +2,7 @@ from hestia_earth.schema import EmissionMethodTier
|
|
|
2
2
|
from hestia_earth.utils.tools import list_sum
|
|
3
3
|
|
|
4
4
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
5
|
-
from
|
|
6
|
-
from .utils import get_fuel_values
|
|
5
|
+
from .utils import get_fuel_values, _emission
|
|
7
6
|
from . import MODEL
|
|
8
7
|
|
|
9
8
|
REQUIREMENTS = {
|
|
@@ -32,16 +31,9 @@ TERM_ID = 'n2OToAirFuelCombustionDirect'
|
|
|
32
31
|
TIER = EmissionMethodTier.TIER_1.value
|
|
33
32
|
|
|
34
33
|
|
|
35
|
-
def _emission(value: float):
|
|
36
|
-
emission = _new_emission(TERM_ID, MODEL)
|
|
37
|
-
emission['value'] = [value]
|
|
38
|
-
emission['methodTier'] = TIER
|
|
39
|
-
return emission
|
|
40
|
-
|
|
41
|
-
|
|
42
34
|
def _run(fuel_values: list):
|
|
43
35
|
value = list_sum(fuel_values)
|
|
44
|
-
return [_emission(value)]
|
|
36
|
+
return [_emission(value=value, tier=TIER, term_id=TERM_ID)]
|
|
45
37
|
|
|
46
38
|
|
|
47
39
|
def _should_run(cycle: dict):
|
|
@@ -7,9 +7,9 @@ from hestia_earth.models.log import logRequirements, debugMissingLookup, logShou
|
|
|
7
7
|
from hestia_earth.models.utils import _filter_list_term_unit
|
|
8
8
|
from hestia_earth.models.utils.constant import Units, get_atomic_conversion
|
|
9
9
|
from hestia_earth.models.utils.completeness import _is_term_type_complete
|
|
10
|
-
from hestia_earth.models.utils.emission import _new_emission
|
|
11
10
|
from hestia_earth.models.utils.input import total_excreta_tan
|
|
12
11
|
from . import MODEL
|
|
12
|
+
from .utils import _emission
|
|
13
13
|
|
|
14
14
|
REQUIREMENTS = {
|
|
15
15
|
"Cycle": {
|
|
@@ -40,13 +40,6 @@ TERM_ID = 'nh3ToAirExcreta'
|
|
|
40
40
|
TIER = EmissionMethodTier.TIER_2.value
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
def _emission(value: float):
|
|
44
|
-
emission = _new_emission(TERM_ID, MODEL)
|
|
45
|
-
emission['value'] = [value]
|
|
46
|
-
emission['methodTier'] = TIER
|
|
47
|
-
return emission
|
|
48
|
-
|
|
49
|
-
|
|
50
43
|
def _get_nh3_factor(term_id: str, input: dict):
|
|
51
44
|
input_term_id = input.get('term', {}).get('@id')
|
|
52
45
|
lookup_name = f"{list(LOOKUPS.keys())[0]}.csv"
|
|
@@ -57,7 +50,7 @@ def _get_nh3_factor(term_id: str, input: dict):
|
|
|
57
50
|
|
|
58
51
|
def _run(excreta_EF_product: float):
|
|
59
52
|
value = excreta_EF_product * get_atomic_conversion(Units.KG_NH3, Units.TO_N)
|
|
60
|
-
return [_emission(value)]
|
|
53
|
+
return [_emission(value=value, tier=TIER, term_id=TERM_ID)]
|
|
61
54
|
|
|
62
55
|
|
|
63
56
|
def _should_run(cycle: dict):
|
|
@@ -10,7 +10,7 @@ from hestia_earth.models.utils.inorganicFertiliser import (
|
|
|
10
10
|
get_NH3_emission_factor, get_terms, get_term_lookup, get_country_breakdown, get_cycle_inputs
|
|
11
11
|
)
|
|
12
12
|
from hestia_earth.models.utils.constant import Units
|
|
13
|
-
from
|
|
13
|
+
from .utils import _emission
|
|
14
14
|
from hestia_earth.models.utils.measurement import most_relevant_measurement_value
|
|
15
15
|
from . import MODEL
|
|
16
16
|
|
|
@@ -58,13 +58,6 @@ TIER = EmissionMethodTier.TIER_2.value
|
|
|
58
58
|
UNSPECIFIED_TERM_ID = 'inorganicNitrogenFertiliserUnspecifiedKgN'
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
def _emission(value: float):
|
|
62
|
-
emission = _new_emission(TERM_ID, MODEL)
|
|
63
|
-
emission['value'] = [value]
|
|
64
|
-
emission['methodTier'] = TIER
|
|
65
|
-
return emission
|
|
66
|
-
|
|
67
|
-
|
|
68
61
|
def _input_with_factor(soilPh: float, temperature: float):
|
|
69
62
|
def get_value(input: dict):
|
|
70
63
|
term_id = input.get('term', {}).get('@id')
|
|
@@ -151,4 +144,4 @@ def _should_run(cycle: dict):
|
|
|
151
144
|
def run(cycle: dict):
|
|
152
145
|
should_run, N_inputs_with_factor = _should_run(cycle)
|
|
153
146
|
value = list_sum([i.get('value') * i.get('factor') for i in N_inputs_with_factor]) if should_run else None
|
|
154
|
-
return [_emission(value)] if value is not None else []
|
|
147
|
+
return [_emission(value=value, tier=TIER, term_id=TERM_ID)] if value is not None else []
|
|
@@ -2,8 +2,7 @@ from hestia_earth.schema import EmissionMethodTier
|
|
|
2
2
|
from hestia_earth.utils.tools import list_sum
|
|
3
3
|
|
|
4
4
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
5
|
-
from
|
|
6
|
-
from .utils import get_fuel_values
|
|
5
|
+
from .utils import get_fuel_values, _emission
|
|
7
6
|
from . import MODEL
|
|
8
7
|
|
|
9
8
|
REQUIREMENTS = {
|
|
@@ -32,16 +31,9 @@ TERM_ID = 'noxToAirFuelCombustion'
|
|
|
32
31
|
TIER = EmissionMethodTier.TIER_1.value
|
|
33
32
|
|
|
34
33
|
|
|
35
|
-
def _emission(value: float):
|
|
36
|
-
emission = _new_emission(TERM_ID, MODEL)
|
|
37
|
-
emission['value'] = [value]
|
|
38
|
-
emission['methodTier'] = TIER
|
|
39
|
-
return emission
|
|
40
|
-
|
|
41
|
-
|
|
42
34
|
def _run(fuel_values: list):
|
|
43
35
|
value = list_sum(fuel_values)
|
|
44
|
-
return [_emission(value)]
|
|
36
|
+
return [_emission(value=value, tier=TIER, term_id=TERM_ID)]
|
|
45
37
|
|
|
46
38
|
|
|
47
39
|
def _should_run(cycle: dict):
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""
|
|
2
|
+
When `otherSites` are provided, `otherSitesDuration` must be set as well so we know the length of time the animals
|
|
3
|
+
spend on each Site.
|
|
4
|
+
"""
|
|
5
|
+
from hestia_earth.schema import EmissionMethodTier
|
|
6
|
+
|
|
7
|
+
from .utils import _emission, get_live_animal_emission_value, should_run_animal
|
|
8
|
+
from . import MODEL
|
|
9
|
+
|
|
10
|
+
REQUIREMENTS = {
|
|
11
|
+
"Cycle": {
|
|
12
|
+
"completeness.animalPopulation": "True",
|
|
13
|
+
"site": {"@type": "Site"},
|
|
14
|
+
"siteDuration": "",
|
|
15
|
+
"animals": [
|
|
16
|
+
{
|
|
17
|
+
"@type": "Animal",
|
|
18
|
+
"term.termType": "liveAnimal",
|
|
19
|
+
"value": "",
|
|
20
|
+
"referencePeriod": "average"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"optional": {
|
|
24
|
+
"otherSites": [{"@type": "Site"}],
|
|
25
|
+
"otherSitesDuration": ""
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
RETURNS = {
|
|
30
|
+
"Emission": [{
|
|
31
|
+
"value": "",
|
|
32
|
+
"methodTier": "tier 1"
|
|
33
|
+
}]
|
|
34
|
+
}
|
|
35
|
+
LOOKUPS = {
|
|
36
|
+
"liveAnimal": "pm10ToAirEea2019",
|
|
37
|
+
"operation": "pm10ToAirAnimalHousingEmepEea2019"
|
|
38
|
+
}
|
|
39
|
+
TERM_ID = 'pm10ToAirAnimalHousing'
|
|
40
|
+
TIER = EmissionMethodTier.TIER_1.value
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _run(animals: list[dict], total_duration: float):
|
|
44
|
+
return [
|
|
45
|
+
_emission(
|
|
46
|
+
value=get_live_animal_emission_value(animals, total_duration, lookup_col=LOOKUPS["liveAnimal"]),
|
|
47
|
+
tier=TIER,
|
|
48
|
+
term_id=TERM_ID
|
|
49
|
+
)
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def run(cycle: dict):
|
|
54
|
+
should_run, animals, total_duration = should_run_animal(
|
|
55
|
+
cycle=cycle, model=MODEL, term=TERM_ID, tier=TIER
|
|
56
|
+
)
|
|
57
|
+
return _run(animals, total_duration) if should_run else []
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""
|
|
2
|
+
When `otherSites` are provided, `otherSitesDuration` must be set as well so we know the length of time the animals
|
|
3
|
+
spend on each Site.
|
|
4
|
+
"""
|
|
5
|
+
from hestia_earth.schema import EmissionMethodTier
|
|
6
|
+
|
|
7
|
+
from .utils import _emission, get_live_animal_emission_value, should_run_animal
|
|
8
|
+
from . import MODEL
|
|
9
|
+
|
|
10
|
+
REQUIREMENTS = {
|
|
11
|
+
"Cycle": {
|
|
12
|
+
"completeness.animalPopulation": "True",
|
|
13
|
+
"site": {"@type": "Site"},
|
|
14
|
+
"siteDuration": "",
|
|
15
|
+
"animals": [
|
|
16
|
+
{
|
|
17
|
+
"@type": "Animal",
|
|
18
|
+
"term.termType": "liveAnimal",
|
|
19
|
+
"value": "",
|
|
20
|
+
"referencePeriod": "average"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"optional": {
|
|
24
|
+
"otherSites": [{"@type": "Site"}],
|
|
25
|
+
"otherSitesDuration": ""
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
RETURNS = {
|
|
30
|
+
"Emission": [{
|
|
31
|
+
"value": "",
|
|
32
|
+
"methodTier": "tier 1"
|
|
33
|
+
}]
|
|
34
|
+
}
|
|
35
|
+
LOOKUPS = {
|
|
36
|
+
"liveAnimal": "pm25ToAirEea2019",
|
|
37
|
+
"operation": "pm25ToAirAnimalHousingEmepEea2019"
|
|
38
|
+
}
|
|
39
|
+
TERM_ID = 'pm25ToAirAnimalHousing'
|
|
40
|
+
TIER = EmissionMethodTier.TIER_1.value
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _run(animals: list[dict], total_duration: float):
|
|
44
|
+
return [
|
|
45
|
+
_emission(
|
|
46
|
+
value=get_live_animal_emission_value(animals, total_duration, lookup_col=LOOKUPS["liveAnimal"]),
|
|
47
|
+
tier=TIER,
|
|
48
|
+
term_id=TERM_ID
|
|
49
|
+
)
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def run(cycle: dict):
|
|
54
|
+
should_run, animals, total_duration = should_run_animal(
|
|
55
|
+
cycle=cycle, model=MODEL, term=TERM_ID, tier=TIER
|
|
56
|
+
)
|
|
57
|
+
return _run(animals, total_duration) if should_run else []
|
|
@@ -2,8 +2,7 @@ from hestia_earth.schema import EmissionMethodTier
|
|
|
2
2
|
from hestia_earth.utils.tools import list_sum
|
|
3
3
|
|
|
4
4
|
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
5
|
-
from
|
|
6
|
-
from .utils import get_fuel_values
|
|
5
|
+
from .utils import get_fuel_values, _emission
|
|
7
6
|
from . import MODEL
|
|
8
7
|
|
|
9
8
|
REQUIREMENTS = {
|
|
@@ -32,16 +31,9 @@ TERM_ID = 'so2ToAirFuelCombustion'
|
|
|
32
31
|
TIER = EmissionMethodTier.TIER_1.value
|
|
33
32
|
|
|
34
33
|
|
|
35
|
-
def _emission(value: float):
|
|
36
|
-
emission = _new_emission(TERM_ID, MODEL)
|
|
37
|
-
emission['value'] = [value]
|
|
38
|
-
emission['methodTier'] = TIER
|
|
39
|
-
return emission
|
|
40
|
-
|
|
41
|
-
|
|
42
34
|
def _run(fuel_values: list):
|
|
43
35
|
value = list_sum(fuel_values)
|
|
44
|
-
return [_emission(value)]
|
|
36
|
+
return [_emission(value=value, tier=TIER, term_id=TERM_ID)]
|
|
45
37
|
|
|
46
38
|
|
|
47
39
|
def _should_run(cycle: dict):
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""
|
|
2
|
+
When `otherSites` are provided, `otherSitesDuration` must be set as well so we know the length of time the animals
|
|
3
|
+
spend on each Site.
|
|
4
|
+
"""
|
|
5
|
+
from hestia_earth.schema import EmissionMethodTier
|
|
6
|
+
|
|
7
|
+
from .utils import _emission, get_live_animal_emission_value, should_run_animal
|
|
8
|
+
from . import MODEL
|
|
9
|
+
|
|
10
|
+
REQUIREMENTS = {
|
|
11
|
+
"Cycle": {
|
|
12
|
+
"completeness.animalPopulation": "True",
|
|
13
|
+
"site": {"@type": "Site"},
|
|
14
|
+
"siteDuration": "",
|
|
15
|
+
"animals": [
|
|
16
|
+
{
|
|
17
|
+
"@type": "Animal",
|
|
18
|
+
"term.termType": "liveAnimal",
|
|
19
|
+
"value": "",
|
|
20
|
+
"referencePeriod": "average"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"optional": {
|
|
24
|
+
"otherSites": [{"@type": "Site"}],
|
|
25
|
+
"otherSitesDuration": ""
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
RETURNS = {
|
|
30
|
+
"Emission": [{
|
|
31
|
+
"value": "",
|
|
32
|
+
"methodTier": "tier 1"
|
|
33
|
+
}]
|
|
34
|
+
}
|
|
35
|
+
LOOKUPS = {
|
|
36
|
+
"liveAnimal": "tspToAirEea2019",
|
|
37
|
+
"operation": "tspToAirAnimalHousingEmepEea2019"
|
|
38
|
+
}
|
|
39
|
+
TERM_ID = 'tspToAirAnimalHousing'
|
|
40
|
+
TIER = EmissionMethodTier.TIER_1.value
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _run(animals: list[dict], total_duration: float):
|
|
44
|
+
return [
|
|
45
|
+
_emission(
|
|
46
|
+
value=get_live_animal_emission_value(animals, total_duration, lookup_col=LOOKUPS["liveAnimal"]),
|
|
47
|
+
tier=TIER,
|
|
48
|
+
term_id=TERM_ID
|
|
49
|
+
)
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def run(cycle: dict):
|
|
54
|
+
should_run, animals, total_duration = should_run_animal(
|
|
55
|
+
cycle=cycle, model=MODEL, term=TERM_ID, tier=TIER
|
|
56
|
+
)
|
|
57
|
+
return _run(animals, total_duration) if should_run else []
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
from hestia_earth.schema import TermTermType
|
|
1
|
+
from hestia_earth.schema import TermTermType, SiteSiteType
|
|
2
2
|
from hestia_earth.utils.model import filter_list_term_type
|
|
3
3
|
from hestia_earth.utils.lookup import extract_grouped_data
|
|
4
4
|
from hestia_earth.utils.tools import list_sum, safe_parse_float, non_empty_list
|
|
5
5
|
|
|
6
|
+
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
6
7
|
from hestia_earth.models.utils.completeness import _is_term_type_complete
|
|
7
8
|
from hestia_earth.models.utils.term import get_lookup_value
|
|
9
|
+
from hestia_earth.models.utils.cycle import get_animals_by_period
|
|
10
|
+
from hestia_earth.models.utils.emission import _new_emission
|
|
8
11
|
from . import MODEL
|
|
9
12
|
|
|
10
13
|
|
|
14
|
+
def _emission(value: float, tier: str, term_id: str):
|
|
15
|
+
emission = _new_emission(term_id, MODEL)
|
|
16
|
+
emission['value'] = [value]
|
|
17
|
+
emission['methodTier'] = tier
|
|
18
|
+
return emission
|
|
19
|
+
|
|
20
|
+
|
|
11
21
|
def _get_fuel_input_value(term_id: str, lookup_col: str):
|
|
12
22
|
def get_value(input: dict):
|
|
13
23
|
input_term = input.get('term', {})
|
|
@@ -33,3 +43,52 @@ def get_fuel_values(term_id: str, cycle: dict, lookup_col: str):
|
|
|
33
43
|
len(values) == 0,
|
|
34
44
|
_is_term_type_complete(cycle, 'electricityFuel')
|
|
35
45
|
]) else values
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _get_emissions_factor(animal: dict, lookup_col: str) -> float:
|
|
49
|
+
return safe_parse_float(
|
|
50
|
+
get_lookup_value(animal.get("term", {}), lookup_col, model=MODEL, term=animal.get("term", ""))
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _duration_in_housing(cycle: dict) -> int:
|
|
55
|
+
other_sites = cycle.get("otherSites", [])
|
|
56
|
+
other_durations = cycle.get("otherSitesDuration", [])
|
|
57
|
+
return list_sum([
|
|
58
|
+
cycle.get("siteDuration", cycle.get("cycleDuration", 0))
|
|
59
|
+
if cycle.get("site", {}).get("siteType", "") == SiteSiteType.ANIMAL_HOUSING.value else 0
|
|
60
|
+
] + ([
|
|
61
|
+
other_durations[x]
|
|
62
|
+
for x in range(len(other_sites))
|
|
63
|
+
if other_sites[x].get("siteType", "") == SiteSiteType.ANIMAL_HOUSING.value
|
|
64
|
+
] if len(other_sites) == len(other_durations) else []))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def get_live_animal_emission_value(animals: list[dict], duration: float, lookup_col: str) -> float:
|
|
68
|
+
return list_sum([
|
|
69
|
+
animal.get('value') * _get_emissions_factor(animal=animal, lookup_col=lookup_col)
|
|
70
|
+
for animal in animals
|
|
71
|
+
]) * duration / 365
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def should_run_animal(cycle: dict, model: str, term: str, tier: str) -> tuple[list, bool]:
|
|
75
|
+
term_type_animalPopulation_complete = _is_term_type_complete(cycle=cycle, term="animalPopulation")
|
|
76
|
+
|
|
77
|
+
# models will be set as not relevant is primary `siteType` does not match, so check only `otherSites`.
|
|
78
|
+
|
|
79
|
+
total_duration = _duration_in_housing(cycle)
|
|
80
|
+
|
|
81
|
+
has_other_sites_and_duration = len(cycle.get("otherSites", [])) == len(cycle.get("otherSitesDuration", []))
|
|
82
|
+
|
|
83
|
+
animals = get_animals_by_period(cycle)
|
|
84
|
+
has_animals = len(animals) > 0
|
|
85
|
+
|
|
86
|
+
logRequirements(cycle, model=model, term=term,
|
|
87
|
+
term_type_animalPopulation_complete=term_type_animalPopulation_complete,
|
|
88
|
+
has_animals=has_animals,
|
|
89
|
+
has_other_sites_and_duration=has_other_sites_and_duration,
|
|
90
|
+
number_of_days_in_animal_housing=total_duration)
|
|
91
|
+
|
|
92
|
+
should_run = all([term_type_animalPopulation_complete, has_animals, has_other_sites_and_duration])
|
|
93
|
+
logShouldRun(cycle, model, term, should_run, methodTier=tier)
|
|
94
|
+
return should_run, animals, total_duration
|
|
@@ -18,6 +18,7 @@ from hestia_earth.models.utils.input import _new_input
|
|
|
18
18
|
from hestia_earth.models.utils.term import get_wool_terms, get_lookup_value
|
|
19
19
|
from hestia_earth.models.utils.completeness import _is_term_type_complete, _is_term_type_incomplete
|
|
20
20
|
from hestia_earth.models.utils.property import get_node_property
|
|
21
|
+
from hestia_earth.models.utils.cycle import get_animals_by_period
|
|
21
22
|
from .. import MODEL
|
|
22
23
|
from ..pastureGrass_utils import (
|
|
23
24
|
practice_input_id,
|
|
@@ -29,7 +30,6 @@ from ..pastureGrass_utils import (
|
|
|
29
30
|
calculate_NEfeed,
|
|
30
31
|
calculate_GE,
|
|
31
32
|
product_wool_energy,
|
|
32
|
-
get_animals,
|
|
33
33
|
get_animal_values
|
|
34
34
|
)
|
|
35
35
|
|
|
@@ -308,7 +308,7 @@ def _should_run(cycle: dict, animals: list, practices: dict):
|
|
|
308
308
|
|
|
309
309
|
|
|
310
310
|
def run(cycle: dict):
|
|
311
|
-
animals =
|
|
311
|
+
animals = get_animals_by_period(cycle)
|
|
312
312
|
practices = list(filter(should_run_practice(cycle), cycle.get('practices', [])))
|
|
313
313
|
should_run, meanDE, meanECHHV, system = _should_run(cycle, animals, practices)
|
|
314
314
|
return list(map(_run_animal(cycle, meanDE, meanECHHV, system, practices), animals)) if should_run else []
|
|
@@ -17,6 +17,7 @@ from hestia_earth.models.utils.blank_node import lookups_logs, properties_logs
|
|
|
17
17
|
from hestia_earth.models.utils.input import _new_input
|
|
18
18
|
from hestia_earth.models.utils.term import get_wool_terms
|
|
19
19
|
from hestia_earth.models.utils.completeness import _is_term_type_complete, _is_term_type_incomplete
|
|
20
|
+
from hestia_earth.models.utils.cycle import get_animals_by_period
|
|
20
21
|
from . import MODEL
|
|
21
22
|
from .pastureGrass_utils import (
|
|
22
23
|
practice_input_id,
|
|
@@ -28,7 +29,6 @@ from .pastureGrass_utils import (
|
|
|
28
29
|
calculate_NEfeed,
|
|
29
30
|
calculate_GE,
|
|
30
31
|
product_wool_energy,
|
|
31
|
-
get_animals,
|
|
32
32
|
get_animal_values
|
|
33
33
|
)
|
|
34
34
|
|
|
@@ -164,7 +164,7 @@ def calculate_NEwool(cycle: dict) -> float:
|
|
|
164
164
|
|
|
165
165
|
|
|
166
166
|
def _run_practice(cycle: dict, meanDE: float, meanECHHV: float, system: dict):
|
|
167
|
-
animals =
|
|
167
|
+
animals = get_animals_by_period(cycle)
|
|
168
168
|
REM = calculate_REM(meanDE)
|
|
169
169
|
REG = calculate_REG(meanDE)
|
|
170
170
|
NEwool = calculate_NEwool(cycle)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from hestia_earth.schema import TermTermType
|
|
1
|
+
from hestia_earth.schema import TermTermType
|
|
2
2
|
from hestia_earth.utils.api import download_hestia
|
|
3
3
|
from hestia_earth.utils.lookup import download_lookup, get_table_value, column_name, extract_grouped_data
|
|
4
4
|
from hestia_earth.utils.tools import list_sum, safe_parse_float
|
|
@@ -341,12 +341,3 @@ def should_run_practice(cycle: dict):
|
|
|
341
341
|
return all([len(value) > 0, term_id == MODEL_KEY, key_term_type in KEY_TERM_TYPES])
|
|
342
342
|
|
|
343
343
|
return should_run
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
def get_animals(cycle: dict):
|
|
347
|
-
return [
|
|
348
|
-
a for a in cycle.get('animals', []) if all([
|
|
349
|
-
a.get('value'),
|
|
350
|
-
a.get('referencePeriod') == AnimalReferencePeriod.AVERAGE.value
|
|
351
|
-
])
|
|
352
|
-
]
|
|
@@ -1486,7 +1486,7 @@
|
|
|
1486
1486
|
"@type": "Term",
|
|
1487
1487
|
"name": "Generic crop, seed",
|
|
1488
1488
|
"@id": "genericCropSeed",
|
|
1489
|
-
"_score":
|
|
1489
|
+
"_score": 26.312824
|
|
1490
1490
|
}
|
|
1491
1491
|
]
|
|
1492
1492
|
},
|
|
@@ -1722,61 +1722,61 @@
|
|
|
1722
1722
|
"@type": "Term",
|
|
1723
1723
|
"name": "Glass or high accessible cover",
|
|
1724
1724
|
"@id": "glassOrHighAccessibleCover",
|
|
1725
|
-
"_score":
|
|
1725
|
+
"_score": 59.49422
|
|
1726
1726
|
},
|
|
1727
1727
|
{
|
|
1728
1728
|
"@type": "Term",
|
|
1729
1729
|
"name": "River or stream",
|
|
1730
1730
|
"@id": "riverOrStream",
|
|
1731
|
-
"_score": 50.
|
|
1731
|
+
"_score": 50.673336
|
|
1732
1732
|
},
|
|
1733
1733
|
{
|
|
1734
1734
|
"@type": "Term",
|
|
1735
1735
|
"name": "Other natural vegetation",
|
|
1736
1736
|
"@id": "otherNaturalVegetation",
|
|
1737
|
-
"_score": 40.
|
|
1737
|
+
"_score": 40.97334
|
|
1738
1738
|
},
|
|
1739
1739
|
{
|
|
1740
1740
|
"@type": "Term",
|
|
1741
1741
|
"name": "Natural forest",
|
|
1742
1742
|
"@id": "naturalForest",
|
|
1743
|
-
"_score": 31.
|
|
1743
|
+
"_score": 31.583748
|
|
1744
1744
|
},
|
|
1745
1745
|
{
|
|
1746
1746
|
"@type": "Term",
|
|
1747
1747
|
"name": "Permanent pasture",
|
|
1748
1748
|
"@id": "permanentPasture",
|
|
1749
|
-
"_score":
|
|
1749
|
+
"_score": 28.25857
|
|
1750
1750
|
},
|
|
1751
1751
|
{
|
|
1752
1752
|
"@type": "Term",
|
|
1753
1753
|
"name": "Animal housing",
|
|
1754
1754
|
"@id": "animalHousing",
|
|
1755
|
-
"_score":
|
|
1755
|
+
"_score": 27.218006
|
|
1756
1756
|
},
|
|
1757
1757
|
{
|
|
1758
1758
|
"@type": "Term",
|
|
1759
1759
|
"name": "Root or tuber crop plant",
|
|
1760
1760
|
"@id": "rootOrTuberCropPlant",
|
|
1761
|
-
"_score":
|
|
1761
|
+
"_score": 25.098145
|
|
1762
1762
|
},
|
|
1763
1763
|
{
|
|
1764
1764
|
"@type": "Term",
|
|
1765
1765
|
"name": "High intensity grazing pasture",
|
|
1766
1766
|
"@id": "highIntensityGrazingPasture",
|
|
1767
|
-
"_score": 23.
|
|
1767
|
+
"_score": 23.833916
|
|
1768
1768
|
},
|
|
1769
1769
|
{
|
|
1770
1770
|
"@type": "Term",
|
|
1771
1771
|
"name": "Permanent cropland",
|
|
1772
1772
|
"@id": "permanentCropland",
|
|
1773
|
-
"_score": 20.
|
|
1773
|
+
"_score": 20.639563
|
|
1774
1774
|
},
|
|
1775
1775
|
{
|
|
1776
1776
|
"@type": "Term",
|
|
1777
1777
|
"name": "Forest",
|
|
1778
1778
|
"@id": "forest",
|
|
1779
|
-
"_score":
|
|
1779
|
+
"_score": 20.246805
|
|
1780
1780
|
}
|
|
1781
1781
|
]
|
|
1782
1782
|
},
|
|
@@ -18,7 +18,7 @@ from functools import reduce
|
|
|
18
18
|
from hestia_earth.schema import SchemaType, TermTermType, SiteSiteType
|
|
19
19
|
from hestia_earth.utils.api import download_hestia
|
|
20
20
|
from hestia_earth.utils.model import filter_list_term_type, linked_node
|
|
21
|
-
from hestia_earth.utils.tools import safe_parse_float, flatten
|
|
21
|
+
from hestia_earth.utils.tools import safe_parse_float, flatten, non_empty_list
|
|
22
22
|
from hestia_earth.utils.blank_node import get_node_value
|
|
23
23
|
|
|
24
24
|
from hestia_earth.models.log import logRequirements, logShouldRun, log_blank_nodes_id
|
|
@@ -48,7 +48,8 @@ REQUIREMENTS = {
|
|
|
48
48
|
"waterRegime",
|
|
49
49
|
"tillage",
|
|
50
50
|
"cropResidueManagement",
|
|
51
|
-
"landUseManagement"
|
|
51
|
+
"landUseManagement",
|
|
52
|
+
"system"
|
|
52
53
|
],
|
|
53
54
|
"units": ["% area", "boolean"],
|
|
54
55
|
"value": ""
|
|
@@ -72,7 +73,7 @@ RETURNS = {
|
|
|
72
73
|
"Management": [{
|
|
73
74
|
"@type": "Management",
|
|
74
75
|
"term.termType": [
|
|
75
|
-
"landCover", "waterRegime", "tillage", "cropResidueManagement", "landUseManagement"
|
|
76
|
+
"landCover", "waterRegime", "tillage", "cropResidueManagement", "landUseManagement", "system"
|
|
76
77
|
],
|
|
77
78
|
"value": "",
|
|
78
79
|
"endDate": "",
|
|
@@ -247,7 +248,7 @@ def _should_run_all_products(cycles: list, site_type: str):
|
|
|
247
248
|
for product in list(filter(_get_landCover_term_id, [i for i in products_crop_forage]))
|
|
248
249
|
] if site_type else []
|
|
249
250
|
dates = sorted(list(set(
|
|
250
|
-
flatten([[cycle.get('startDate'), cycle.get('endDate')] for cycle in cycles])
|
|
251
|
+
non_empty_list(flatten([[cycle.get('startDate'), cycle.get('endDate')] for cycle in cycles]))
|
|
251
252
|
))) if site_type not in _SKIP_LAND_COVER_SITE_TYPES else []
|
|
252
253
|
site_type_term = download_hestia(get_landCover_term_id_from_site_type(site_type)) if all([
|
|
253
254
|
len(dates) >= 2,
|
|
@@ -286,7 +287,8 @@ def _should_run(site: dict):
|
|
|
286
287
|
TermTermType.WATERREGIME,
|
|
287
288
|
TermTermType.TILLAGE,
|
|
288
289
|
TermTermType.CROPRESIDUEMANAGEMENT,
|
|
289
|
-
TermTermType.LANDUSEMANAGEMENT
|
|
290
|
+
TermTermType.LANDUSEMANAGEMENT,
|
|
291
|
+
TermTermType.SYSTEM
|
|
290
292
|
]
|
|
291
293
|
)
|
|
292
294
|
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from hestia_earth.schema import CycleFunctionalUnit, SiteSiteType, TermTermType
|
|
1
|
+
from hestia_earth.schema import CycleFunctionalUnit, SiteSiteType, TermTermType, AnimalReferencePeriod
|
|
2
2
|
from hestia_earth.utils.model import filter_list_term_type, find_term_match, find_primary_product
|
|
3
3
|
from hestia_earth.utils.tools import list_sum, safe_parse_float, safe_parse_date
|
|
4
4
|
|
|
@@ -455,3 +455,12 @@ def check_cycle_site_ids_identical(cycles: list[dict]) -> bool:
|
|
|
455
455
|
Whether or not all of the cycles associated site ids are identical.
|
|
456
456
|
"""
|
|
457
457
|
return len(set(cycle.get('site', {}).get('@id', None) for cycle in cycles)) <= 1
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
def get_animals_by_period(cycle: dict, period: AnimalReferencePeriod = AnimalReferencePeriod.AVERAGE):
|
|
461
|
+
return [
|
|
462
|
+
a for a in cycle.get('animals', []) if all([
|
|
463
|
+
a.get('value'),
|
|
464
|
+
a.get('referencePeriod') == period.value
|
|
465
|
+
])
|
|
466
|
+
]
|
hestia_earth/models/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = '0.62.
|
|
1
|
+
VERSION = '0.62.5'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hestia-earth-models
|
|
3
|
-
Version: 0.62.
|
|
3
|
+
Version: 0.62.5
|
|
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
|
|
@@ -4,7 +4,7 @@ hestia_earth/models/cache_sites.py,sha256=KQp9cUKE-aIcYJoMWEtKFYS8gBFfsx5LKQhqoW
|
|
|
4
4
|
hestia_earth/models/log.py,sha256=DbfNcGzaC5hzkuMDxQqW6XYoNBI4Uxw4SIoOYoZA6og,3474
|
|
5
5
|
hestia_earth/models/preload_requests.py,sha256=y_okcYzSbqODvmzkw-wOK2cOZEzkJq3pmRfxRsPsUw0,1012
|
|
6
6
|
hestia_earth/models/requirements.py,sha256=eU4yT443fx7BnaokhrLB_PCizJI7Y6m4auyo8vQauNg,17363
|
|
7
|
-
hestia_earth/models/version.py,sha256=
|
|
7
|
+
hestia_earth/models/version.py,sha256=nhEXCAlUUnEUnxeP_S43AOWaQmufkzv4hRSHjCAeqR0,19
|
|
8
8
|
hestia_earth/models/agribalyse2016/__init__.py,sha256=WvK0qCQbnYtg9oZxrACd1wGormZyXibPtpCnIQeDqbw,415
|
|
9
9
|
hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=tnGxBmJdPfPFfehLUQcefEqy1lHvzsSpx_s7O8nf3Zs,4412
|
|
10
10
|
hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=_Rbngu0DzHKa62JwBl58ZC_ui1zLF2que_nB7ukhOQc,3392
|
|
@@ -114,13 +114,16 @@ hestia_earth/models/ecoinventV3/utils.py,sha256=HqtD8MzK9C_RCJ-ME-5G4J1KoCn5FqmA
|
|
|
114
114
|
hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py,sha256=XYFDUNpQpzbjPgLus0YlM3UdiXX7LLwn-XJqjrH9ywM,5801
|
|
115
115
|
hestia_earth/models/ecoinventV3AndEmberClimate/utils.py,sha256=INWB7gyhzk49GQ0KAcBS-Kzwdoyd5MQJcsCtuT6XxZA,1352
|
|
116
116
|
hestia_earth/models/emepEea2019/__init__.py,sha256=l90-pWrqIzt1ap1WNk0gF4iZeF5_TSG62hE83bIi4rQ,412
|
|
117
|
-
hestia_earth/models/emepEea2019/co2ToAirFuelCombustion.py,sha256=
|
|
118
|
-
hestia_earth/models/emepEea2019/n2OToAirFuelCombustionDirect.py,sha256=
|
|
119
|
-
hestia_earth/models/emepEea2019/nh3ToAirExcreta.py,sha256=
|
|
120
|
-
hestia_earth/models/emepEea2019/nh3ToAirInorganicFertiliser.py,sha256=
|
|
121
|
-
hestia_earth/models/emepEea2019/noxToAirFuelCombustion.py,sha256=
|
|
122
|
-
hestia_earth/models/emepEea2019/
|
|
123
|
-
hestia_earth/models/emepEea2019/
|
|
117
|
+
hestia_earth/models/emepEea2019/co2ToAirFuelCombustion.py,sha256=ib_xzEbIg-iQwvW2L4BosD9lV6EYOXAiIs8gYhSD9GE,1431
|
|
118
|
+
hestia_earth/models/emepEea2019/n2OToAirFuelCombustionDirect.py,sha256=H4dgGqDuvYN4S7TRxYsX3hms1xMWr8clR2gkyyO8T18,1438
|
|
119
|
+
hestia_earth/models/emepEea2019/nh3ToAirExcreta.py,sha256=HNz3w35V0X1Av7if4ZPlDxozrSMurjiy7Hl4iAVEoNg,3590
|
|
120
|
+
hestia_earth/models/emepEea2019/nh3ToAirInorganicFertiliser.py,sha256=n_lpGX6pnJdOy1GJoVSLgA9LnnnWOb_ZHBueZAEDCbk,6041
|
|
121
|
+
hestia_earth/models/emepEea2019/noxToAirFuelCombustion.py,sha256=2--8lI6C6WaYtd9LQe-WZnhvW1eUsjBVAgzT8jclcsc,1431
|
|
122
|
+
hestia_earth/models/emepEea2019/pm10ToAirAnimalHousing.py,sha256=ZxiyoKpT0JbwgEnK9HlselO5-nIq_CTpcGK5a8X5UkM,1527
|
|
123
|
+
hestia_earth/models/emepEea2019/pm25ToAirAnimalHousing.py,sha256=MYMRoFrmu3lhqS9aYE-GCWHfE-NFIgk9Q3Uj1osTlKA,1527
|
|
124
|
+
hestia_earth/models/emepEea2019/so2ToAirFuelCombustion.py,sha256=8B1GVsn5gEXVW3iZYBct-s_OTRaH-asXo6JvGW_jls0,1431
|
|
125
|
+
hestia_earth/models/emepEea2019/tspToAirAnimalHousing.py,sha256=hHHhu_EZWhxAKhGJgrHY3vNI7Kuy6h8-JyOuas7KRXk,1524
|
|
126
|
+
hestia_earth/models/emepEea2019/utils.py,sha256=oTHjbRRwJZv_tpO9MOlfpyQRmN0a1kvEZsVHUPliZpQ,4014
|
|
124
127
|
hestia_earth/models/emissionNotRelevant/__init__.py,sha256=nIuPIkQR1ghv_T_Ab4Ckq5wmGdWVmgbaOjhtKfIJ-WE,2183
|
|
125
128
|
hestia_earth/models/environmentalFootprintV3/__init__.py,sha256=lzg9qccwd9tbspw0lQ58YPprnvvSLTn3QV5T2-tPcC4,425
|
|
126
129
|
hestia_earth/models/environmentalFootprintV3/freshwaterEcotoxicityPotentialCtue.py,sha256=X62-4v0NJdM_Z5kLK3NuU4GNEeSrXlKlMZQB_o4JZ6c,1018
|
|
@@ -249,11 +252,11 @@ hestia_earth/models/ipcc2019/organicCarbonPerHa.py,sha256=iRUSVxMpBGgsVDkuBABPKI
|
|
|
249
252
|
hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1_utils.py,sha256=JxVJ9mRml63VhwNSNq7H3O7YQJoXLgP4j9fIRs3ms5o,82431
|
|
250
253
|
hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2_utils.py,sha256=A84r6u45HFk5jEb2nTWGTFTwX1qjq8F6qwkNUuiyH48,63542
|
|
251
254
|
hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py,sha256=jIhRks8ewCtQNIIN89N_4A4Tp529YMQnk4YmZV6FOCY,10668
|
|
252
|
-
hestia_earth/models/ipcc2019/pastureGrass.py,sha256=
|
|
253
|
-
hestia_earth/models/ipcc2019/pastureGrass_utils.py,sha256=
|
|
255
|
+
hestia_earth/models/ipcc2019/pastureGrass.py,sha256=4ZPbLlaIVf4-_ItoLU8fFhRhkWIUFIOcX2isSUOtLco,9550
|
|
256
|
+
hestia_earth/models/ipcc2019/pastureGrass_utils.py,sha256=KA5MAnaPXBgrNncBhcQtOF-cdLwEKI6O2F_DPEz5oTM,13502
|
|
254
257
|
hestia_earth/models/ipcc2019/utils.py,sha256=MSDMu15D9DnilFUgi4_6jYXC0FaKso3OODauGTMB6hs,6229
|
|
255
258
|
hestia_earth/models/ipcc2019/animal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
256
|
-
hestia_earth/models/ipcc2019/animal/pastureGrass.py,sha256=
|
|
259
|
+
hestia_earth/models/ipcc2019/animal/pastureGrass.py,sha256=fSsWwf6lBlro4DIwbcAHSv0L-UMFe-liljfNr-kXWYw,11476
|
|
257
260
|
hestia_earth/models/ipcc2019/animal/weightAtMaturity.py,sha256=5smSAmKVCIlELCD6S_3I16YuSWNFhcClGDOdvrIuYsE,3657
|
|
258
261
|
hestia_earth/models/ipcc2021/__init__.py,sha256=VTgGFKhwMmk_nuI1RRq0in27fHYVPBonlXlPK00K8no,409
|
|
259
262
|
hestia_earth/models/ipcc2021/gwp100.py,sha256=v-DYU-11XnWI1Ns1GEiKrJqL3JafxvhTsLmuBuFcxJU,1021
|
|
@@ -367,7 +370,7 @@ hestia_earth/models/linkedImpactAssessment/landTransformationFromPermanentPastur
|
|
|
367
370
|
hestia_earth/models/linkedImpactAssessment/utils.py,sha256=dGwGc2d-8_WQElTpfyPmz5vQtL-LHQRmiZnCTuPXMDs,1876
|
|
368
371
|
hestia_earth/models/mocking/__init__.py,sha256=n3Fkkrvh8zHNWiJZmnfQ7WZ91JRzAO9P6pSG1JpwtXo,687
|
|
369
372
|
hestia_earth/models/mocking/mock_search.py,sha256=dBCDRfbZmbMLKP21u_VYkxyimomqs-zztjX-_ZNKuuM,2036
|
|
370
|
-
hestia_earth/models/mocking/search-results.json,sha256=
|
|
373
|
+
hestia_earth/models/mocking/search-results.json,sha256=1hltFd6NwJIu9ThIGHJHatLsd3EflzRDnpShgM9vm60,46412
|
|
371
374
|
hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
|
|
372
375
|
hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=Qt-mel4dkhK6N5uUOutNOinCTFjbjtGzITaaI0LvYc4,2396
|
|
373
376
|
hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=JT0RybbvWVlo01FO8K0Yj41HrEaJT3Kj1xfayr2X-xw,2315
|
|
@@ -466,7 +469,7 @@ hestia_earth/models/site/brackishWater.py,sha256=vLEhIZv5PUKwzwvIuYrWi7K---fq7ZX
|
|
|
466
469
|
hestia_earth/models/site/cationExchangeCapacityPerKgSoil.py,sha256=0eH4A-tXJ0hvIkiYXWxlx8TfrdbIKUGYUDk97-yQJgg,3653
|
|
467
470
|
hestia_earth/models/site/flowingWater.py,sha256=v3g5722GIA4zQAUQI9yGFiZvFvI1QAVZqlQrY-6_B3A,1731
|
|
468
471
|
hestia_earth/models/site/freshWater.py,sha256=FXs3Vt8V4e-wn325_dwSTOKlZtn5ksNUpvYGDeLJShY,1255
|
|
469
|
-
hestia_earth/models/site/management.py,sha256=
|
|
472
|
+
hestia_earth/models/site/management.py,sha256=LlvXibkqJyHCQQarn1uGUp8HJRmA8PW208pp1wCuSWk,10772
|
|
470
473
|
hestia_earth/models/site/netPrimaryProduction.py,sha256=UIIQkYd911qVzrWjxBLrC37e-RARIVgDwLdARY9BuLw,1849
|
|
471
474
|
hestia_earth/models/site/organicCarbonPerHa.py,sha256=F2ShinHf0m9qKa1nCYBspsDkRY6jzOl0wM8mSDre22I,14916
|
|
472
475
|
hestia_earth/models/site/organicCarbonPerKgSoil.py,sha256=t--wAshiAKS-JvEKhLFRadGvgSBv5NFZ68jdyms_wh4,1945
|
|
@@ -536,7 +539,7 @@ hestia_earth/models/utils/crop.py,sha256=kG054fryqPSBpmzvJFBy_CLiOdjrt7RMk5uTItO
|
|
|
536
539
|
hestia_earth/models/utils/cropResidue.py,sha256=_0Q35CrliJeo31xGHsPWe8A2oHxijdIsOrf3gBEqhlA,612
|
|
537
540
|
hestia_earth/models/utils/cropResidueManagement.py,sha256=nIDFjf39rDD10UHSVudfDyu-EiL261g8jyrgS-2aDKw,347
|
|
538
541
|
hestia_earth/models/utils/currency.py,sha256=f_ArJANb--pZq4LL49SXQ1AMX_oKroqwBXKRRQqZwsM,578
|
|
539
|
-
hestia_earth/models/utils/cycle.py,sha256=
|
|
542
|
+
hestia_earth/models/utils/cycle.py,sha256=Q6NE5LWvoHng0l980r1i8lpmHWOL0HyMW6uXWhAf_Pw,16219
|
|
540
543
|
hestia_earth/models/utils/descriptive_stats.py,sha256=qOyG8_TpWYmaxZ0h99n9L71gDLLiVMrMf0ChtxnZLjw,8559
|
|
541
544
|
hestia_earth/models/utils/ecoClimateZone.py,sha256=NHFt-A9EiWXC6tUNIxkgOWUZOjj4I4uwJIP9ddDZegw,1112
|
|
542
545
|
hestia_earth/models/utils/emission.py,sha256=5Dz8Z4P6QXbYSvOzVcqJy3R_oZMrp77_Iwj5xZsxsKc,3769
|
|
@@ -667,13 +670,16 @@ tests/models/dammgen2009/test_noxToAirExcreta.py,sha256=RWd9QvzmJtN9M6UC6KDHkXwt
|
|
|
667
670
|
tests/models/deRuijterEtAl2010/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
668
671
|
tests/models/deRuijterEtAl2010/test_nh3ToAirCropResidueDecomposition.py,sha256=kS1nUBVohOSCb386g6Wq7iVclmx0haekUDYo7VQ4NCA,2030
|
|
669
672
|
tests/models/emepEea2019/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
670
|
-
tests/models/emepEea2019/test_co2ToAirFuelCombustion.py,sha256=
|
|
671
|
-
tests/models/emepEea2019/test_n2OToAirFuelCombustionDirect.py,sha256=
|
|
672
|
-
tests/models/emepEea2019/test_nh3ToAirExcreta.py,sha256=
|
|
673
|
-
tests/models/emepEea2019/test_nh3ToAirInorganicFertiliser.py,sha256=
|
|
674
|
-
tests/models/emepEea2019/test_noxToAirFuelCombustion.py,sha256=
|
|
675
|
-
tests/models/emepEea2019/
|
|
676
|
-
tests/models/emepEea2019/
|
|
673
|
+
tests/models/emepEea2019/test_co2ToAirFuelCombustion.py,sha256=z1H17R_Erox2dMg8xylGB0qt9BMZSwfLAoEMVv9z878,1518
|
|
674
|
+
tests/models/emepEea2019/test_n2OToAirFuelCombustionDirect.py,sha256=4uemriZAyJBSn-xMttRpxqVHOFNBXlboVODHQYl65zQ,1524
|
|
675
|
+
tests/models/emepEea2019/test_nh3ToAirExcreta.py,sha256=LsRynnkVjtkgxFjDS6CQBMUgN4O8qedQDuoNVClgdKQ,1425
|
|
676
|
+
tests/models/emepEea2019/test_nh3ToAirInorganicFertiliser.py,sha256=f623Pp6XTt9YPDr2QymAJEQ_yfx0_TZGndmawD8ZX98,2134
|
|
677
|
+
tests/models/emepEea2019/test_noxToAirFuelCombustion.py,sha256=HpuzWyFmfatFXwTZd8TVpHb6Kfj2Ru3IO1gHnSiuKtQ,1518
|
|
678
|
+
tests/models/emepEea2019/test_pm10ToAirAnimalHousing.py,sha256=xGlQeJkdP638zbHivxAqvliZCRpcogMFZYVCMWw6j3c,715
|
|
679
|
+
tests/models/emepEea2019/test_pm25ToAirAnimalHousing.py,sha256=cs3UaJ7ucCryOaQy0sbL9AiuC8l_N7uywmPZHcr3pC0,715
|
|
680
|
+
tests/models/emepEea2019/test_so2ToAirFuelCombustion.py,sha256=zRTyeeQM1fRdRVFWbtCNndaddDbKHU1xLzmp_psDceE,1518
|
|
681
|
+
tests/models/emepEea2019/test_tspToAirAnimalHousing.py,sha256=4MNDsxIeUk5_3IvZwEZslxgoPNyQN9OQFDNY3uGNX6E,714
|
|
682
|
+
tests/models/emepEea2019/test_utils.py,sha256=G6z8tEfWM0OPnUBaFCQgQyEi5-kRF_DqsqdYaPnzR_I,8761
|
|
677
683
|
tests/models/environmentalFootprintV3/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
678
684
|
tests/models/environmentalFootprintV3/test_freshwaterEcotoxicityPotentialCtue.py,sha256=lIgsdGh_0eDi-rPcCOrSSjVYNiET2GCSRkAHdugAkDk,851
|
|
679
685
|
tests/models/epa2014/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -1009,7 +1015,7 @@ tests/models/site/test_brackishWater.py,sha256=YGCp4glaWudKklYBSp-50KbfvIRtp3F4Q
|
|
|
1009
1015
|
tests/models/site/test_cationExchangeCapacityPerKgSoil.py,sha256=tNMhN998vcjQ15I-5mNnFh2d7mHzEBIBO6o1VSfQNUE,1075
|
|
1010
1016
|
tests/models/site/test_flowingWater.py,sha256=t_rxvdlmUVDsFBoDF20_zDM-0iiLKkNCV7knO9l1T7o,1370
|
|
1011
1017
|
tests/models/site/test_freshWater.py,sha256=GOeAxHhPW_2E1wQdQRX4W-r7mnb_LgmiAVLImitoApw,982
|
|
1012
|
-
tests/models/site/test_management.py,sha256=
|
|
1018
|
+
tests/models/site/test_management.py,sha256=eIZN1PKB3rlUVrHK_Bkwc3hald3-y68rIl8cRVGEDgk,14160
|
|
1013
1019
|
tests/models/site/test_netPrimaryProduction.py,sha256=JCxG0MODbKVvl3hOqmKzh4FjHYn3Xs9KsVod6LvKQII,1108
|
|
1014
1020
|
tests/models/site/test_organicCarbonPerHa.py,sha256=XtGrE7ZqthTF0x8lDxJ1slNd_GvYHEyEydcRgA46jEc,3207
|
|
1015
1021
|
tests/models/site/test_organicCarbonPerKgSoil.py,sha256=0M-NMg_T3UXzGT_VlKOKhSxg4cZ0_zhd3FRgY5Hpj6o,1087
|
|
@@ -1088,8 +1094,8 @@ tests/models/utils/test_source.py,sha256=mv3vHZV5cjpoLA2I1109-YUkuzAiuhbRSnv_76_
|
|
|
1088
1094
|
tests/models/utils/test_term.py,sha256=M5Sa26v2gzQYbZ4H_fo7DspnaCx__-WtL-MULGapCWk,3509
|
|
1089
1095
|
tests/models/webbEtAl2012AndSintermannEtAl2012/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
1090
1096
|
tests/models/webbEtAl2012AndSintermannEtAl2012/test_nh3ToAirOrganicFertiliser.py,sha256=qi2FNXS5Af2WDtm7nq_FsprH3BfCF0XxnE0XHmC4aIY,2244
|
|
1091
|
-
hestia_earth_models-0.62.
|
|
1092
|
-
hestia_earth_models-0.62.
|
|
1093
|
-
hestia_earth_models-0.62.
|
|
1094
|
-
hestia_earth_models-0.62.
|
|
1095
|
-
hestia_earth_models-0.62.
|
|
1097
|
+
hestia_earth_models-0.62.5.dist-info/LICENSE,sha256=AC7h7GAgCZGJK_Tzh6LUCrML9gQEfowWwecEw2w54QM,1154
|
|
1098
|
+
hestia_earth_models-0.62.5.dist-info/METADATA,sha256=OAujkDOEp9WGRnmAyJHbKMy1QeXRDfjmsedbSU3dwBo,3343
|
|
1099
|
+
hestia_earth_models-0.62.5.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
1100
|
+
hestia_earth_models-0.62.5.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
|
|
1101
|
+
hestia_earth_models-0.62.5.dist-info/RECORD,,
|
|
@@ -5,6 +5,7 @@ from tests.utils import fixtures_path, fake_new_emission
|
|
|
5
5
|
from hestia_earth.models.emepEea2019.co2ToAirFuelCombustion import MODEL, TERM_ID, run, _should_run
|
|
6
6
|
|
|
7
7
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
|
+
model_utils_path = f"hestia_earth.models.{MODEL}.utils"
|
|
8
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
10
|
|
|
10
11
|
|
|
@@ -21,7 +22,7 @@ def test_should_run(mock_get_fuel_values):
|
|
|
21
22
|
assert should_run is True
|
|
22
23
|
|
|
23
24
|
|
|
24
|
-
@patch(f"{
|
|
25
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
25
26
|
def test_run(*args):
|
|
26
27
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
27
28
|
cycle = json.load(f)
|
|
@@ -33,7 +34,7 @@ def test_run(*args):
|
|
|
33
34
|
assert value == expected
|
|
34
35
|
|
|
35
36
|
|
|
36
|
-
@patch(f"{
|
|
37
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
37
38
|
def test_run_data_complete(*args):
|
|
38
39
|
with open(f"{fixtures_folder}/no-input-data-complete/cycle.jsonld", encoding='utf-8') as f:
|
|
39
40
|
cycle = json.load(f)
|
|
@@ -5,6 +5,7 @@ from tests.utils import fixtures_path, fake_new_emission
|
|
|
5
5
|
from hestia_earth.models.emepEea2019.n2OToAirFuelCombustionDirect import MODEL, TERM_ID, run, _should_run
|
|
6
6
|
|
|
7
7
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
|
+
model_utils_path = f"hestia_earth.models.{MODEL}.utils"
|
|
8
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
10
|
|
|
10
11
|
|
|
@@ -21,7 +22,7 @@ def test_should_run(mock_get_fuel_values):
|
|
|
21
22
|
assert should_run is True
|
|
22
23
|
|
|
23
24
|
|
|
24
|
-
@patch(f"{
|
|
25
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
25
26
|
def test_run(*args):
|
|
26
27
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
27
28
|
cycle = json.load(f)
|
|
@@ -33,7 +34,7 @@ def test_run(*args):
|
|
|
33
34
|
assert value == expected
|
|
34
35
|
|
|
35
36
|
|
|
36
|
-
@patch(f"{
|
|
37
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
37
38
|
def test_run_data_complete(*args):
|
|
38
39
|
with open(f"{fixtures_folder}/no-input-data-complete/cycle.jsonld", encoding='utf-8') as f:
|
|
39
40
|
cycle = json.load(f)
|
|
@@ -5,6 +5,7 @@ from tests.utils import fixtures_path, fake_new_emission
|
|
|
5
5
|
from hestia_earth.models.emepEea2019.nh3ToAirExcreta import MODEL, TERM_ID, run, _should_run
|
|
6
6
|
|
|
7
7
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
|
+
model_utils_path = f"hestia_earth.models.{MODEL}.utils"
|
|
8
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
10
|
|
|
10
11
|
|
|
@@ -34,7 +35,7 @@ def test_should_run(mock_get_lookup_factor, mock_excreta, *args):
|
|
|
34
35
|
assert should_run is True
|
|
35
36
|
|
|
36
37
|
|
|
37
|
-
@patch(f"{
|
|
38
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
38
39
|
def test_run(*args):
|
|
39
40
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
40
41
|
cycle = json.load(f)
|
|
@@ -5,6 +5,7 @@ from tests.utils import fixtures_path, fake_new_emission
|
|
|
5
5
|
from hestia_earth.models.emepEea2019.nh3ToAirInorganicFertiliser import MODEL, TERM_ID, run, _should_run
|
|
6
6
|
|
|
7
7
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
|
+
model_utils_path = f"hestia_earth.models.{MODEL}.utils"
|
|
8
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
10
|
|
|
10
11
|
|
|
@@ -27,7 +28,7 @@ def test_should_run(mock_measurement, *args):
|
|
|
27
28
|
assert should_run is True
|
|
28
29
|
|
|
29
30
|
|
|
30
|
-
@patch(f"{
|
|
31
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
31
32
|
def test_run(*args):
|
|
32
33
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
33
34
|
cycle = json.load(f)
|
|
@@ -39,7 +40,7 @@ def test_run(*args):
|
|
|
39
40
|
assert value == expected
|
|
40
41
|
|
|
41
42
|
|
|
42
|
-
@patch(f"{
|
|
43
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
43
44
|
def test_run_with_unspecified(*args):
|
|
44
45
|
with open(f"{fixtures_folder}/with-unspecified/cycle.jsonld", encoding='utf-8') as f:
|
|
45
46
|
cycle = json.load(f)
|
|
@@ -51,7 +52,7 @@ def test_run_with_unspecified(*args):
|
|
|
51
52
|
assert value == expected
|
|
52
53
|
|
|
53
54
|
|
|
54
|
-
@patch(f"{
|
|
55
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
55
56
|
def test_run_complete(*args):
|
|
56
57
|
with open(f"{fixtures_folder}/is-complete/cycle.jsonld", encoding='utf-8') as f:
|
|
57
58
|
cycle = json.load(f)
|
|
@@ -5,6 +5,7 @@ from tests.utils import fixtures_path, fake_new_emission
|
|
|
5
5
|
from hestia_earth.models.emepEea2019.noxToAirFuelCombustion import MODEL, TERM_ID, run, _should_run
|
|
6
6
|
|
|
7
7
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
|
+
model_utils_path = f"hestia_earth.models.{MODEL}.utils"
|
|
8
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
10
|
|
|
10
11
|
|
|
@@ -21,7 +22,7 @@ def test_should_run(mock_get_fuel_values):
|
|
|
21
22
|
assert should_run is True
|
|
22
23
|
|
|
23
24
|
|
|
24
|
-
@patch(f"{
|
|
25
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
25
26
|
def test_run(*args):
|
|
26
27
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
27
28
|
cycle = json.load(f)
|
|
@@ -33,7 +34,7 @@ def test_run(*args):
|
|
|
33
34
|
assert value == expected
|
|
34
35
|
|
|
35
36
|
|
|
36
|
-
@patch(f"{
|
|
37
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
37
38
|
def test_run_data_complete(*args):
|
|
38
39
|
with open(f"{fixtures_folder}/no-input-data-complete/cycle.jsonld", encoding='utf-8') as f:
|
|
39
40
|
cycle = json.load(f)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
from tests.utils import fixtures_path, fake_new_emission
|
|
5
|
+
from hestia_earth.models.emepEea2019.pm10ToAirAnimalHousing import MODEL, TERM_ID, run
|
|
6
|
+
|
|
7
|
+
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
|
+
model_utils_path = f"hestia_earth.models.{MODEL}.utils"
|
|
9
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
13
|
+
def test_run(*args):
|
|
14
|
+
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
15
|
+
cycle = json.load(f)
|
|
16
|
+
|
|
17
|
+
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
18
|
+
expected = json.load(f)
|
|
19
|
+
|
|
20
|
+
value = run(cycle)
|
|
21
|
+
assert value == expected
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
from tests.utils import fixtures_path, fake_new_emission
|
|
5
|
+
from hestia_earth.models.emepEea2019.pm25ToAirAnimalHousing import MODEL, TERM_ID, run
|
|
6
|
+
|
|
7
|
+
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
|
+
model_utils_path = f"hestia_earth.models.{MODEL}.utils"
|
|
9
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
13
|
+
def test_run(*args):
|
|
14
|
+
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
15
|
+
cycle = json.load(f)
|
|
16
|
+
|
|
17
|
+
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
18
|
+
expected = json.load(f)
|
|
19
|
+
|
|
20
|
+
value = run(cycle)
|
|
21
|
+
assert value == expected
|
|
@@ -5,6 +5,7 @@ from tests.utils import fixtures_path, fake_new_emission
|
|
|
5
5
|
from hestia_earth.models.emepEea2019.so2ToAirFuelCombustion import MODEL, TERM_ID, run, _should_run
|
|
6
6
|
|
|
7
7
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
|
+
model_utils_path = f"hestia_earth.models.{MODEL}.utils"
|
|
8
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
10
|
|
|
10
11
|
|
|
@@ -21,7 +22,7 @@ def test_should_run(mock_get_fuel_values):
|
|
|
21
22
|
assert should_run is True
|
|
22
23
|
|
|
23
24
|
|
|
24
|
-
@patch(f"{
|
|
25
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
25
26
|
def test_run(*args):
|
|
26
27
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
27
28
|
cycle = json.load(f)
|
|
@@ -33,7 +34,7 @@ def test_run(*args):
|
|
|
33
34
|
assert value == expected
|
|
34
35
|
|
|
35
36
|
|
|
36
|
-
@patch(f"{
|
|
37
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
37
38
|
def test_run_data_complete(*args):
|
|
38
39
|
with open(f"{fixtures_folder}/no-input-data-complete/cycle.jsonld", encoding='utf-8') as f:
|
|
39
40
|
cycle = json.load(f)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
from tests.utils import fixtures_path, fake_new_emission
|
|
5
|
+
from hestia_earth.models.emepEea2019.tspToAirAnimalHousing import MODEL, TERM_ID, run
|
|
6
|
+
|
|
7
|
+
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
|
+
model_utils_path = f"hestia_earth.models.{MODEL}.utils"
|
|
9
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@patch(f"{model_utils_path}._new_emission", side_effect=fake_new_emission)
|
|
13
|
+
def test_run(*args):
|
|
14
|
+
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
15
|
+
cycle = json.load(f)
|
|
16
|
+
|
|
17
|
+
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
18
|
+
expected = json.load(f)
|
|
19
|
+
|
|
20
|
+
value = run(cycle)
|
|
21
|
+
assert value == expected
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from unittest.mock import patch
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.emepEea2019.utils import get_fuel_values, should_run_animal, _duration_in_housing
|
|
4
6
|
|
|
5
7
|
class_path = 'hestia_earth.models.emepEea2019.utils'
|
|
6
8
|
TERMS = [
|
|
@@ -53,3 +55,198 @@ def test_get_fuel_values(*args):
|
|
|
53
55
|
}
|
|
54
56
|
result = get_fuel_values('co2ToAirFuelCombustion', cycle, 'co2ToAirFuelCombustionEmepEea2019')
|
|
55
57
|
assert result == [317.0, 632.0, 475.5, 158.5]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@pytest.mark.parametrize(
|
|
61
|
+
"test_name,cycle,expected_duration",
|
|
62
|
+
[
|
|
63
|
+
(
|
|
64
|
+
"no sites => 0",
|
|
65
|
+
{"completeness": {"@type": "Completeness", "animalPopulation": False}},
|
|
66
|
+
0
|
|
67
|
+
),
|
|
68
|
+
(
|
|
69
|
+
"site and other sites have wrong type => 0",
|
|
70
|
+
{
|
|
71
|
+
"site": {"@type": "Site", "siteType": "permanent pasture"},
|
|
72
|
+
"siteDuration": 15,
|
|
73
|
+
"otherSites": [
|
|
74
|
+
{"@type": "Site", "siteType": "pond"},
|
|
75
|
+
{"@type": "Site", "siteType": "pond"},
|
|
76
|
+
{"@type": "Site", "siteType": "pond"},
|
|
77
|
+
],
|
|
78
|
+
"otherSitesDuration": [20, 21, 22],
|
|
79
|
+
},
|
|
80
|
+
0
|
|
81
|
+
),
|
|
82
|
+
(
|
|
83
|
+
"only second other site is animal housing => 12",
|
|
84
|
+
{
|
|
85
|
+
"site": {"@type": "Site", "siteType": "pond"},
|
|
86
|
+
"siteDuration": 20,
|
|
87
|
+
"otherSites": [
|
|
88
|
+
{"@type": "Site", "siteType": "pond"},
|
|
89
|
+
{"@type": "Site", "siteType": "animal housing"},
|
|
90
|
+
{"@type": "Site", "siteType": "pond"},
|
|
91
|
+
],
|
|
92
|
+
"otherSitesDuration": [11, 12, 13],
|
|
93
|
+
},
|
|
94
|
+
12
|
|
95
|
+
),
|
|
96
|
+
(
|
|
97
|
+
"only site is animal housing => 20",
|
|
98
|
+
{
|
|
99
|
+
"site": {"@type": "Site", "siteType": "animal housing"},
|
|
100
|
+
"otherSites": [
|
|
101
|
+
{"@type": "Site", "siteType": "forest"},
|
|
102
|
+
{"@type": "Site", "siteType": "forest"},
|
|
103
|
+
{"@type": "Site", "siteType": "forest"},
|
|
104
|
+
],
|
|
105
|
+
"siteDuration": 20,
|
|
106
|
+
"otherSitesDuration": [12, 13, 14],
|
|
107
|
+
},
|
|
108
|
+
20
|
|
109
|
+
),
|
|
110
|
+
(
|
|
111
|
+
"site and otherSites are animal housing, sum all values => 59",
|
|
112
|
+
{
|
|
113
|
+
"site": {"@type": "Site", "siteType": "animal housing"},
|
|
114
|
+
"otherSites": [
|
|
115
|
+
{"@type": "Site", "siteType": "animal housing"},
|
|
116
|
+
{"@type": "Site", "siteType": "animal housing"},
|
|
117
|
+
{"@type": "Site", "siteType": "animal housing"},
|
|
118
|
+
],
|
|
119
|
+
"siteDuration": 20,
|
|
120
|
+
"otherSitesDuration": [12, 13, 14],
|
|
121
|
+
},
|
|
122
|
+
59
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
]
|
|
126
|
+
)
|
|
127
|
+
def test_duration_in_housing(test_name, cycle, expected_duration):
|
|
128
|
+
assert _duration_in_housing(cycle) == expected_duration
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@pytest.mark.parametrize(
|
|
132
|
+
"test_name,cycle,expected_should_run",
|
|
133
|
+
[
|
|
134
|
+
(
|
|
135
|
+
"not complete => no run",
|
|
136
|
+
{"completeness": {"@type": "Completeness", "animalPopulation": False}},
|
|
137
|
+
False
|
|
138
|
+
),
|
|
139
|
+
(
|
|
140
|
+
"no site or other sites => no run",
|
|
141
|
+
{"completeness": {"@type": "Completeness", "animalPopulation": True}},
|
|
142
|
+
False
|
|
143
|
+
),
|
|
144
|
+
(
|
|
145
|
+
"no site or other sites with 'animal housing' type => no run",
|
|
146
|
+
{
|
|
147
|
+
"completeness": {"@type": "Completeness", "animalPopulation": True},
|
|
148
|
+
"site": {"@type": "Site", "siteType": "permanent pasture"},
|
|
149
|
+
"otherSites": [{"@type": "Site", "siteType": "pond"}]
|
|
150
|
+
},
|
|
151
|
+
False
|
|
152
|
+
),
|
|
153
|
+
(
|
|
154
|
+
"no site or other sites with 'animal housing' type and duration => no run",
|
|
155
|
+
{
|
|
156
|
+
"completeness": {"@type": "Completeness", "animalPopulation": True},
|
|
157
|
+
"site": {"@type": "Site", "siteType": "animal housing"},
|
|
158
|
+
"otherSites": [{"@type": "Site", "siteType": "pond"}],
|
|
159
|
+
"siteDuration": ""
|
|
160
|
+
},
|
|
161
|
+
False
|
|
162
|
+
),
|
|
163
|
+
(
|
|
164
|
+
"no animal values => no run",
|
|
165
|
+
{
|
|
166
|
+
"completeness": {"@type": "Completeness", "animalPopulation": True},
|
|
167
|
+
"site": {"@type": "Site", "siteType": "animal housing"},
|
|
168
|
+
"otherSites": [{"@type": "Site", "siteType": "pond"}],
|
|
169
|
+
"siteDuration": 150,
|
|
170
|
+
"animals": [
|
|
171
|
+
{"value": ""}
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
False
|
|
175
|
+
),
|
|
176
|
+
(
|
|
177
|
+
"animal values reference period is not 'average' => no run",
|
|
178
|
+
{
|
|
179
|
+
"completeness": {"@type": "Completeness", "animalPopulation": True},
|
|
180
|
+
"site": {"@type": "Site", "siteType": "animal housing"},
|
|
181
|
+
"otherSites": [{"@type": "Site", "siteType": "pond"}],
|
|
182
|
+
"siteDuration": 150,
|
|
183
|
+
"animals": [
|
|
184
|
+
{
|
|
185
|
+
"@type": "Animal",
|
|
186
|
+
"value": 1
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"@type": "Animal",
|
|
190
|
+
"value": 2,
|
|
191
|
+
"referencePeriod": ""
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"@type": "Animal",
|
|
195
|
+
"value": 3,
|
|
196
|
+
"referencePeriod": "start of Cycle"
|
|
197
|
+
},
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
False
|
|
201
|
+
),
|
|
202
|
+
(
|
|
203
|
+
"missing otherSitesDuration => no run",
|
|
204
|
+
{
|
|
205
|
+
"completeness": {"@type": "Completeness", "animalPopulation": True},
|
|
206
|
+
"site": {"@type": "Site", "siteType": "animal housing"},
|
|
207
|
+
"otherSites": [{"@type": "Site", "siteType": "pond"}],
|
|
208
|
+
"siteDuration": 150,
|
|
209
|
+
"animals": [
|
|
210
|
+
{
|
|
211
|
+
"@type": "Animal",
|
|
212
|
+
"value": 2,
|
|
213
|
+
"referencePeriod": ""
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"@type": "Animal",
|
|
217
|
+
"value": 3,
|
|
218
|
+
"referencePeriod": "average"
|
|
219
|
+
},
|
|
220
|
+
]
|
|
221
|
+
},
|
|
222
|
+
False
|
|
223
|
+
),
|
|
224
|
+
(
|
|
225
|
+
"all requirements met with otherSites => run",
|
|
226
|
+
{
|
|
227
|
+
"completeness": {"@type": "Completeness", "animalPopulation": True},
|
|
228
|
+
"site": {"@type": "Site", "siteType": "pond"},
|
|
229
|
+
"siteDuration": "",
|
|
230
|
+
"otherSites": [{"@type": "Site", "siteType": "animal housing"}],
|
|
231
|
+
"otherSitesDuration": [200],
|
|
232
|
+
"animals": [
|
|
233
|
+
{
|
|
234
|
+
"@type": "Animal",
|
|
235
|
+
"value": 2,
|
|
236
|
+
"referencePeriod": ""
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"@type": "Animal",
|
|
240
|
+
"value": 3,
|
|
241
|
+
"referencePeriod": "average"
|
|
242
|
+
},
|
|
243
|
+
]
|
|
244
|
+
},
|
|
245
|
+
True
|
|
246
|
+
),
|
|
247
|
+
|
|
248
|
+
]
|
|
249
|
+
)
|
|
250
|
+
def test_should_run_animal(test_name, cycle, expected_should_run):
|
|
251
|
+
should_run, *args = should_run_animal(cycle, 'model', 'term', 'tier')
|
|
252
|
+
assert should_run == expected_should_run, test_name
|
|
@@ -297,6 +297,7 @@ def test_should_run(mock_related_cycles, *args):
|
|
|
297
297
|
@pytest.mark.parametrize(
|
|
298
298
|
"test_name,fixture_path",
|
|
299
299
|
[
|
|
300
|
+
("Products and practices", f"{fixtures_folder}"),
|
|
300
301
|
("Example 1", f"{fixtures_folder}/inputs/example1"),
|
|
301
302
|
("Example 2", f"{fixtures_folder}/inputs/example2"),
|
|
302
303
|
("Example 3", f"{fixtures_folder}/inputs/example3"),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|