hestia-earth-models 0.73.1__py3-none-any.whl → 0.73.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.
Files changed (49) hide show
  1. hestia_earth/models/akagiEtAl2011/utils.py +3 -1
  2. hestia_earth/models/config/Cycle.json +35 -37
  3. hestia_earth/models/config/Site.json +26 -24
  4. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandOccupation.py +3 -2
  5. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandTransformation.py +1 -1
  6. hestia_earth/models/frischknechtEtAl2000/ionisingRadiationKbqU235Eq.py +10 -6
  7. hestia_earth/models/geospatialDatabase/utils.py +20 -6
  8. hestia_earth/models/hestia/aboveGroundCropResidue.py +6 -5
  9. hestia_earth/models/hestia/cropResidueManagement.py +3 -2
  10. hestia_earth/models/hestia/default_emissions.py +1 -0
  11. hestia_earth/models/hestia/default_resourceUse.py +3 -2
  12. hestia_earth/models/hestia/excretaKgMass.py +1 -1
  13. hestia_earth/models/hestia/excretaKgN.py +1 -1
  14. hestia_earth/models/hestia/excretaKgVs.py +1 -1
  15. hestia_earth/models/hestia/landCover.py +1 -1
  16. hestia_earth/models/hestia/waterSalinity.py +13 -6
  17. hestia_earth/models/ipcc2019/aboveGroundBiomass.py +2 -4
  18. hestia_earth/models/ipcc2019/belowGroundBiomass.py +2 -4
  19. hestia_earth/models/ipcc2019/biomass_utils.py +1 -1
  20. hestia_earth/models/ipcc2019/ch4ToAirOrganicSoilCultivation.py +3 -4
  21. hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +2 -4
  22. hestia_earth/models/ipcc2019/co2ToAirOrganicSoilCultivation.py +2 -3
  23. hestia_earth/models/ipcc2019/n2OToAirCropResidueBurningDirect.py +8 -7
  24. hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +2 -3
  25. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1.py +2 -3
  26. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2.py +3 -4
  27. hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py +2 -3
  28. hestia_earth/models/mocking/search-results.json +1568 -1568
  29. hestia_earth/models/schmidt2007/utils.py +2 -2
  30. hestia_earth/models/utils/__init__.py +1 -1
  31. hestia_earth/models/utils/cycle.py +2 -2
  32. hestia_earth/models/utils/impact_assessment.py +14 -14
  33. hestia_earth/models/utils/lookup.py +30 -10
  34. hestia_earth/models/version.py +1 -1
  35. {hestia_earth_models-0.73.1.dist-info → hestia_earth_models-0.73.3.dist-info}/METADATA +3 -2
  36. {hestia_earth_models-0.73.1.dist-info → hestia_earth_models-0.73.3.dist-info}/RECORD +44 -49
  37. tests/models/environmentalFootprintV3_1/test_soilQualityIndexLandOccupation.py +3 -3
  38. tests/models/frischknechtEtAl2000/test_ionisingRadiationKbqU235Eq.py +85 -31
  39. tests/models/geospatialDatabase/test_utils.py +12 -1
  40. tests/models/ipcc2019/test_organicCarbonPerHa_tier_2.py +1 -1
  41. tests/models/utils/test_array_builders.py +1 -1
  42. hestia_earth/models/utils/array_builders.py +0 -590
  43. hestia_earth/models/utils/descriptive_stats.py +0 -49
  44. hestia_earth/models/utils/stats.py +0 -429
  45. tests/models/utils/test_descriptive_stats.py +0 -50
  46. tests/models/utils/test_stats.py +0 -186
  47. {hestia_earth_models-0.73.1.dist-info → hestia_earth_models-0.73.3.dist-info}/LICENSE +0 -0
  48. {hestia_earth_models-0.73.1.dist-info → hestia_earth_models-0.73.3.dist-info}/WHEEL +0 -0
  49. {hestia_earth_models-0.73.1.dist-info → hestia_earth_models-0.73.3.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,10 @@
1
1
  import json
2
- import pytest
3
2
  from unittest.mock import patch
4
- from tests.utils import fixtures_path, fake_new_indicator
3
+
4
+ import pytest
5
5
 
6
6
  from hestia_earth.models.frischknechtEtAl2000.ionisingRadiationKbqU235Eq import MODEL, TERM_ID, run, _should_run
7
+ from tests.utils import fixtures_path, fake_new_indicator
7
8
 
8
9
  class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
9
10
  fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
@@ -15,32 +16,80 @@ uranium234_input = {"@id": "uranium234", "termType": "waste", "units": "kg"}
15
16
  iodine129_input = {"@id": "iodine129", "termType": "waste", "units": "kg"}
16
17
  no_cf_input = {"@id": "oilPalmMillEffluentWaste", "termType": "waste", "units": "kg"}
17
18
 
18
- wrong_indicator = {"term": {"@id": "co2ToAirSoilOrganicCarbonStockChangeManagementChange", "termType": "emission"},
19
- "value": 3, "inputs": [hydrogen3_input]}
20
-
21
- indicator_no_inputs = {"term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
22
- "value": 3, "inputs": []}
23
-
24
- indicator_2_inputs = {"term": {"@id": "ionisingCompoundsToWaterInputsProduction", "termType": "emission"},
25
- "value": 3, "inputs": [cesium134_input, cesium137_input]}
26
-
27
- indicator_no_unit = {"term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
28
- "value": 3, "inputs": [{"@id": "hydrogen3", "termType": "waste"}]}
29
-
30
- indicator_wrong_unit = {"term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
31
- "value": 3, "inputs": [{"@id": "hydrogen3", "termType": "waste", "units": "not_a_unit"}]}
32
-
33
- indicator_no_cf_input = {"term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
34
- "value": 3, "inputs": [no_cf_input]}
35
-
36
- indicator_hydrogen3_input = {"term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
37
- "value": 3, "inputs": [hydrogen3_input]}
38
-
39
- indicator_cesium137_input = {"term": {"@id": "ionisingCompoundsToWaterInputsProduction", "termType": "emission"},
40
- "value": 3, "inputs": [cesium137_input]}
41
-
42
- indicator_uranium234_input = {"term": {"@id": "ionisingCompoundsToSaltwaterInputsProduction", "termType": "emission"},
43
- "value": 3, "inputs": [uranium234_input]}
19
+ wrong_indicator = {
20
+ "term": {
21
+ "@id": "co2ToAirSoilOrganicCarbonStockChangeManagementChange",
22
+ "termType": "emission",
23
+ },
24
+ "value": 3,
25
+ "inputs": [hydrogen3_input],
26
+ }
27
+
28
+ indicator_no_inputs = {
29
+ "term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
30
+ "value": 3,
31
+ "inputs": [],
32
+ }
33
+
34
+ indicator_2_inputs = {
35
+ "term": {"@id": "ionisingCompoundsToWaterInputsProduction", "termType": "emission"},
36
+ "value": 3,
37
+ "inputs": [cesium134_input, cesium137_input],
38
+ }
39
+
40
+ indicator_no_unit = {
41
+ "term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
42
+ "value": 3,
43
+ "inputs": [{"@id": "hydrogen3", "termType": "waste"}],
44
+ }
45
+
46
+ indicator_wrong_unit = {
47
+ "term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
48
+ "value": 3,
49
+ "inputs": [{"@id": "hydrogen3", "termType": "waste", "units": "not_a_unit"}],
50
+ }
51
+
52
+ indicator_no_cf_input = {
53
+ "term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
54
+ "value": 3,
55
+ "inputs": [no_cf_input],
56
+ }
57
+
58
+ indicator_hydrogen3_input = {
59
+ "term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
60
+ "value": 3,
61
+ "inputs": [hydrogen3_input],
62
+ }
63
+
64
+ indicator_cesium137_water = {
65
+ "term": {"@id": "ionisingCompoundsToWaterInputsProduction", "termType": "emission"},
66
+ "value": 3,
67
+ "inputs": [cesium137_input],
68
+ }
69
+
70
+ indicator_cesium137_air = {
71
+ "term": {"@id": "ionisingCompoundsToAirInputsProduction", "termType": "emission"},
72
+ "value": 3,
73
+ "inputs": [cesium137_input],
74
+ }
75
+
76
+ indicator_cesium137_salt_water = {
77
+ "term": {
78
+ "@id": "ionisingCompoundsToSaltwaterInputsProduction",
79
+ "termType": "emission",
80
+ },
81
+ "value": 3,
82
+ "inputs": [cesium137_input],
83
+ }
84
+
85
+ indicator_uranium234_input = {
86
+ "term": {
87
+ "@id": "ionisingCompoundsToSaltwaterInputsProduction",
88
+ "termType": "emission",
89
+ },
90
+ "value": 3,
91
+ "inputs": [uranium234_input],
92
+ }
44
93
 
45
94
 
46
95
  @pytest.mark.parametrize(
@@ -54,9 +103,11 @@ indicator_uranium234_input = {"term": {"@id": "ionisingCompoundsToSaltwaterInput
54
103
  ([indicator_wrong_unit], False, 0),
55
104
  ([indicator_no_cf_input], True, 0),
56
105
  ([indicator_hydrogen3_input], True, 1),
57
- ([indicator_cesium137_input], True, 1),
106
+ ([indicator_cesium137_water], True, 1),
58
107
  ([indicator_uranium234_input], True, 1),
59
- ([indicator_cesium137_input, indicator_no_cf_input], True, 1),
108
+ ([indicator_cesium137_water, indicator_no_cf_input], True, 1),
109
+ ([indicator_cesium137_water, indicator_cesium137_water], True, 2),
110
+ ([indicator_cesium137_water, indicator_cesium137_salt_water, indicator_cesium137_air], True, 3),
60
111
  ],
61
112
  ids=["No emissionsResourceUse => run, empty input",
62
113
  "Wrong indicator termid => run, empty input",
@@ -68,7 +119,10 @@ indicator_uranium234_input = {"term": {"@id": "ionisingCompoundsToSaltwaterInput
68
119
  "Good input ionisingCompoundsToAirInputsProduction => run, 1 input",
69
120
  "Good input ionisingCompoundsToWaterInputsProduction => run, 1 input",
70
121
  "Good input ionisingCompoundsToSaltwaterInputsProduction => run, 1 input",
71
- "One good input => run, 1 input"]
122
+ "One good input => run, 1 input",
123
+ "2 identical indicators => run 2 input",
124
+ "3 different indicators common input => run 3 input",
125
+ ]
72
126
  )
73
127
  def test_should_run(resources, expected, num_inputs):
74
128
  with open(f"{fixtures_folder}/impact-assessment.jsonld", encoding='utf-8') as f:
@@ -1,9 +1,13 @@
1
+ import json
1
2
  from unittest.mock import patch
2
3
  from hestia_earth.schema import TermTermType
4
+ from tests.utils import fixtures_path
3
5
 
4
- from hestia_earth.models.geospatialDatabase.utils import get_region_factor, get_area_size
6
+ from hestia_earth.models.geospatialDatabase import MODEL
7
+ from hestia_earth.models.geospatialDatabase.utils import get_region_factor, get_area_size, _get_boundary_area_size
5
8
 
6
9
  class_path = 'hestia_earth.models.geospatialDatabase.utils'
10
+ fixtures_folder = f"{fixtures_path}/{MODEL}/utils"
7
11
 
8
12
  AREA = 1000
9
13
  COUNTRY = {
@@ -26,3 +30,10 @@ def test_get_area_size(*args):
26
30
  site['boundary'] = {'type': 'Polygon'}
27
31
  site['boundaryArea'] = AREA
28
32
  assert get_area_size(site) == AREA
33
+
34
+
35
+ def test_get_boundary_area_size():
36
+ with open(f"{fixtures_folder}/site.jsonld", encoding='utf-8') as f:
37
+ site = json.load(f)
38
+
39
+ assert _get_boundary_area_size(boundary=site.get('boundary')) == 4896.1559583013795
@@ -3,7 +3,7 @@ from numpy.testing import assert_array_almost_equal
3
3
  from numpy.typing import NDArray
4
4
  from pytest import mark
5
5
 
6
- from hestia_earth.models.utils.array_builders import discrete_uniform_2d, repeat_single
6
+ from hestia_earth.utils.stats import discrete_uniform_2d, repeat_single
7
7
 
8
8
  from hestia_earth.models.ipcc2019.organicCarbonPerHa import MODEL, TERM_ID
9
9
  from hestia_earth.models.ipcc2019.organicCarbonPerHa_tier_2 import (
@@ -3,7 +3,7 @@ from numpy.testing import assert_array_equal, assert_allclose
3
3
  from numpy.typing import NDArray
4
4
  from pytest import mark
5
5
 
6
- from hestia_earth.models.utils.array_builders import (
6
+ from hestia_earth.utils.stats import (
7
7
  avg_run_in_columnwise, avg_run_in_rowwise, correlated_normal_2d, discrete_uniform_1d, discrete_uniform_2d,
8
8
  gen_seed, grouped_avg, normal_1d, normal_2d, plus_minus_uncertainty_to_normal_1d,
9
9
  plus_minus_uncertainty_to_normal_2d, repeat_1d_array_as_columns, repeat_array_as_columns, repeat_array_as_rows,