hestia-earth-models 0.73.0__py3-none-any.whl → 0.73.2__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 (59) hide show
  1. hestia_earth/models/akagiEtAl2011/utils.py +4 -2
  2. hestia_earth/models/aware/scarcityWeightedWaterUse.py +8 -7
  3. hestia_earth/models/cache_sites.py +8 -4
  4. hestia_earth/models/chaudharyBrooks2018/damageToTerrestrialEcosystemsLandTransformation.py +14 -11
  5. hestia_earth/models/chaudharyBrooks2018/utils.py +4 -2
  6. hestia_earth/models/config/Cycle.json +35 -37
  7. hestia_earth/models/config/Site.json +26 -24
  8. hestia_earth/models/cycle/completeness/electricityFuel.py +1 -1
  9. hestia_earth/models/cycle/completeness/freshForage.py +1 -1
  10. hestia_earth/models/cycle/input/hestiaAggregatedData.py +1 -2
  11. hestia_earth/models/cycle/product/economicValueShare.py +1 -1
  12. hestia_earth/models/environmentalFootprintV3_1/environmentalFootprintSingleOverallScore.py +1 -1
  13. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandOccupation.py +11 -11
  14. hestia_earth/models/environmentalFootprintV3_1/soilQualityIndexLandTransformation.py +14 -11
  15. hestia_earth/models/faostat2018/utils.py +26 -13
  16. hestia_earth/models/geospatialDatabase/utils.py +13 -10
  17. hestia_earth/models/hestia/aboveGroundCropResidue.py +6 -5
  18. hestia_earth/models/hestia/cropResidueManagement.py +3 -2
  19. hestia_earth/models/hestia/default_emissions.py +1 -1
  20. hestia_earth/models/hestia/default_resourceUse.py +1 -1
  21. hestia_earth/models/hestia/excretaKgMass.py +7 -9
  22. hestia_earth/models/hestia/seed_emissions.py +1 -1
  23. hestia_earth/models/hestia/stockingDensityAnimalHousingAverage.py +1 -1
  24. hestia_earth/models/hestia/waterSalinity.py +1 -1
  25. hestia_earth/models/ipcc2019/aboveGroundBiomass.py +2 -4
  26. hestia_earth/models/ipcc2019/belowGroundBiomass.py +2 -4
  27. hestia_earth/models/ipcc2019/biomass_utils.py +1 -1
  28. hestia_earth/models/ipcc2019/ch4ToAirAquacultureSystems.py +1 -1
  29. hestia_earth/models/ipcc2019/ch4ToAirOrganicSoilCultivation.py +3 -4
  30. hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +2 -4
  31. hestia_earth/models/ipcc2019/co2ToAirOrganicSoilCultivation.py +2 -3
  32. hestia_earth/models/ipcc2019/n2OToAirCropResidueBurningDirect.py +1 -1
  33. hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +2 -3
  34. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1.py +2 -3
  35. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2.py +3 -4
  36. hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py +2 -3
  37. hestia_earth/models/mocking/search-results.json +1582 -1582
  38. hestia_earth/models/pooreNemecek2018/freshwaterWithdrawalsDuringCycle.py +43 -5
  39. hestia_earth/models/site/grouped_measurement.py +1 -1
  40. hestia_earth/models/utils/background_emissions.py +1 -1
  41. hestia_earth/models/utils/impact_assessment.py +29 -14
  42. hestia_earth/models/utils/lookup.py +5 -1
  43. hestia_earth/models/utils/measurement.py +0 -1
  44. hestia_earth/models/version.py +1 -1
  45. {hestia_earth_models-0.73.0.dist-info → hestia_earth_models-0.73.2.dist-info}/METADATA +3 -2
  46. {hestia_earth_models-0.73.0.dist-info → hestia_earth_models-0.73.2.dist-info}/RECORD +54 -59
  47. tests/models/geospatialDatabase/test_utils.py +12 -1
  48. tests/models/ipcc2019/test_organicCarbonPerHa_tier_2.py +1 -1
  49. tests/models/pooreNemecek2018/test_freshwaterWithdrawalsDuringCycle.py +12 -0
  50. tests/models/utils/test_array_builders.py +1 -1
  51. tests/models/utils/test_impact_assessment.py +29 -13
  52. hestia_earth/models/utils/array_builders.py +0 -590
  53. hestia_earth/models/utils/descriptive_stats.py +0 -49
  54. hestia_earth/models/utils/stats.py +0 -429
  55. tests/models/utils/test_descriptive_stats.py +0 -50
  56. tests/models/utils/test_stats.py +0 -186
  57. {hestia_earth_models-0.73.0.dist-info → hestia_earth_models-0.73.2.dist-info}/LICENSE +0 -0
  58. {hestia_earth_models-0.73.0.dist-info → hestia_earth_models-0.73.2.dist-info}/WHEEL +0 -0
  59. {hestia_earth_models-0.73.0.dist-info → hestia_earth_models-0.73.2.dist-info}/top_level.txt +0 -0
@@ -3,7 +3,7 @@ from hestia_earth.utils.model import filter_list_term_type, find_term_match
3
3
  from hestia_earth.utils.tools import non_empty_list, list_sum
4
4
 
5
5
  from hestia_earth.models.log import debugValues, logRequirements, logShouldRun
6
- from hestia_earth.models.utils import get_kg_term_id, get_kg_N_term_id, get_kg_VS_term_id
6
+ from hestia_earth.models.utils import get_kg_term_id, get_kg_N_term_id, get_kg_VS_term_id, _filter_list_term_unit
7
7
  from hestia_earth.models.utils.term import download_term
8
8
  from hestia_earth.models.utils.constant import Units
9
9
  from hestia_earth.models.utils.product import _new_product, convert_product_to_unit
@@ -31,12 +31,12 @@ RETURNS = {
31
31
  MODEL_KEY = 'excretaKgMass'
32
32
 
33
33
  UNITS = [
34
- Units.KG_N.value,
35
- Units.KG_VS.value
34
+ Units.KG_N,
35
+ Units.KG_VS
36
36
  ]
37
37
 
38
38
 
39
- def _product(value: float, term_id: str):
39
+ def _product(term_id: str, value: float = None):
40
40
  product = _new_product(term_id, value, MODEL)
41
41
  return product
42
42
 
@@ -80,17 +80,15 @@ def _run_product(cycle: dict, product_term_id: str):
80
80
  # use existing product if exist, else create new one
81
81
  existing_product = find_term_match(cycle.get('products', []), product_term_id)
82
82
 
83
- return (existing_product | _product(value, product_term_id)) if value else None
83
+ return (existing_product | _product(product_term_id, value)) if value else _product(product_term_id)
84
84
 
85
85
 
86
86
  def _should_run(cycle: dict):
87
87
  node_type = cycle.get('type', cycle.get('@type'))
88
88
  excreta_products = filter_list_term_type(cycle.get('products', []), TermTermType.EXCRETA)
89
89
  kg_term_ids = list(set([
90
- get_kg_term_id(p.get('term', {}).get('@id')) for p in excreta_products if all([
91
- p.get('term', {}).get('units') in UNITS,
92
- p.get('value', [])
93
- ])
90
+ get_kg_term_id(p.get('term', {}).get('@id'))
91
+ for p in _filter_list_term_unit(excreta_products, UNITS)
94
92
  ]))
95
93
  gap_fill_term_ids = [
96
94
  term_id for term_id in kg_term_ids if not find_term_match(excreta_products, term_id).get('value', [])
@@ -14,7 +14,7 @@ from hestia_earth.models.utils.site import valid_site_type
14
14
  from hestia_earth.models.utils.cycle import cycle_end_year
15
15
  from hestia_earth.models.utils.crop import get_crop_grouping_faostat_production, get_landCover_term_id
16
16
  from hestia_earth.models.utils.completeness import _is_term_type_complete
17
- from hestia_earth.models.utils.blank_node import get_lookup_value
17
+ from hestia_earth.models.utils.term import get_lookup_value
18
18
  from hestia_earth.models.utils.lookup import get_region_lookup_value
19
19
  from . import MODEL
20
20
 
@@ -3,7 +3,7 @@ from hestia_earth.utils.model import filter_list_term_type
3
3
 
4
4
  from hestia_earth.models.log import logRequirements, logShouldRun, log_as_table
5
5
  from hestia_earth.models.utils import weighted_average
6
- from hestia_earth.models.utils.blank_node import get_lookup_value
6
+ from hestia_earth.models.utils.term import get_lookup_value
7
7
  from hestia_earth.models.utils.practice import _new_practice
8
8
  from . import MODEL
9
9
 
@@ -5,7 +5,7 @@ from hestia_earth.utils.tools import safe_parse_float
5
5
  from hestia_earth.models.log import logRequirements, logShouldRun, log_as_table
6
6
  from hestia_earth.models.utils.measurement import _new_measurement
7
7
  from hestia_earth.models.utils.site import related_cycles
8
- from hestia_earth.models.utils.blank_node import get_lookup_value
8
+ from hestia_earth.models.utils.term import get_lookup_value
9
9
  from . import MODEL
10
10
 
11
11
  REQUIREMENTS = {
@@ -3,20 +3,18 @@ from functools import reduce
3
3
  from numpy import average, copy, random, vstack
4
4
  from numpy.typing import NDArray
5
5
  from typing import Optional, Union
6
-
7
6
  from hestia_earth.schema import (
8
7
  MeasurementMethodClassification,
9
8
  MeasurementStatsDefinition,
10
9
  SiteSiteType
11
10
  )
12
-
13
11
  from hestia_earth.utils.tools import non_empty_list
12
+ from hestia_earth.utils.stats import gen_seed
13
+ from hestia_earth.utils.descriptive_stats import calc_descriptive_stats
14
14
 
15
15
  from hestia_earth.models.log import log_as_table, logRequirements, logShouldRun
16
16
  from hestia_earth.models.utils import pairwise
17
- from hestia_earth.models.utils.array_builders import gen_seed
18
17
  from hestia_earth.models.utils.blank_node import group_nodes_by_year
19
- from hestia_earth.models.utils.descriptive_stats import calc_descriptive_stats
20
18
  from hestia_earth.models.utils.ecoClimateZone import EcoClimateZone, get_eco_climate_zone_value
21
19
  from hestia_earth.models.utils.source import get_source
22
20
  from hestia_earth.models.utils.measurement import _new_measurement
@@ -3,20 +3,18 @@ from functools import reduce
3
3
  from numpy import average, copy, random, vstack
4
4
  from numpy.typing import NDArray
5
5
  from typing import Optional, Union
6
-
7
6
  from hestia_earth.schema import (
8
7
  MeasurementMethodClassification,
9
8
  MeasurementStatsDefinition,
10
9
  SiteSiteType
11
10
  )
12
-
13
11
  from hestia_earth.utils.tools import non_empty_list
12
+ from hestia_earth.utils.stats import gen_seed
13
+ from hestia_earth.utils.descriptive_stats import calc_descriptive_stats
14
14
 
15
15
  from hestia_earth.models.log import log_as_table, logRequirements, logShouldRun
16
16
  from hestia_earth.models.utils import pairwise
17
- from hestia_earth.models.utils.array_builders import gen_seed
18
17
  from hestia_earth.models.utils.blank_node import group_nodes_by_year
19
- from hestia_earth.models.utils.descriptive_stats import calc_descriptive_stats
20
18
  from hestia_earth.models.utils.ecoClimateZone import EcoClimateZone, get_eco_climate_zone_value
21
19
  from hestia_earth.models.utils.source import get_source
22
20
  from hestia_earth.models.utils.measurement import _new_measurement
@@ -9,7 +9,7 @@ from hestia_earth.schema import TermTermType
9
9
  from hestia_earth.utils.blank_node import get_node_value
10
10
  from hestia_earth.utils.model import filter_list_term_type
11
11
 
12
- from hestia_earth.models.utils.array_builders import repeat_single, truncated_normal_1d
12
+ from hestia_earth.utils.stats import repeat_single, truncated_normal_1d
13
13
  from hestia_earth.models.utils.blank_node import node_term_match, validate_start_date_end_date
14
14
  from hestia_earth.models.utils.ecoClimateZone import EcoClimateZone, get_ecoClimateZone_lookup_grouped_value
15
15
  from hestia_earth.models.utils.term import get_cover_crop_property_terms, get_lookup_value
@@ -3,7 +3,7 @@ from hestia_earth.utils.model import find_term_match
3
3
  from hestia_earth.utils.tools import safe_parse_float, non_empty_list
4
4
 
5
5
  from hestia_earth.models.log import logRequirements, logShouldRun
6
- from hestia_earth.models.utils.blank_node import get_lookup_value
6
+ from hestia_earth.models.utils.term import get_lookup_value
7
7
  from hestia_earth.models.utils.emission import _new_emission
8
8
  from . import MODEL
9
9
 
@@ -1,15 +1,14 @@
1
1
  import numpy as np
2
2
  import numpy.typing as npt
3
3
  from typing import Callable, Union
4
-
5
4
  from hestia_earth.schema import EmissionMethodTier, EmissionStatsDefinition
6
-
7
5
  from hestia_earth.models.log import logRequirements, logShouldRun
8
- from hestia_earth.models.utils.array_builders import (
6
+ from hestia_earth.utils.stats import (
9
7
  discrete_uniform_1d, gen_seed, normal_1d, repeat_single, triangular_1d
10
8
  )
9
+ from hestia_earth.utils.descriptive_stats import calc_descriptive_stats
10
+
11
11
  from hestia_earth.models.utils.cycle import land_occupation_per_ha
12
- from hestia_earth.models.utils.descriptive_stats import calc_descriptive_stats
13
12
  from hestia_earth.models.utils.ecoClimateZone import EcoClimateZone, get_eco_climate_zone_value
14
13
  from hestia_earth.models.utils.emission import _new_emission
15
14
  from hestia_earth.models.utils.measurement import most_relevant_measurement_value
@@ -2,7 +2,6 @@
2
2
  Utilities for calculating CO2 emissions based on changes in carbon stocks (e.g., `organicCarbonPerHa`,
3
3
  `aboveGroundBiomass` and `belowGroundBiomass`).
4
4
  """
5
-
6
5
  from datetime import datetime, timedelta
7
6
  from enum import Enum
8
7
  from functools import reduce
@@ -11,22 +10,21 @@ from numpy import array, random, mean
11
10
  from numpy.typing import NDArray
12
11
  from pydash.objects import merge
13
12
  from typing import Any, Callable, NamedTuple, Optional, Union
14
-
15
13
  from hestia_earth.schema import (
16
14
  EmissionMethodTier, EmissionStatsDefinition, MeasurementMethodClassification
17
15
  )
18
16
  from hestia_earth.utils.date import diff_in_days, YEAR
19
17
  from hestia_earth.utils.tools import flatten, non_empty_list, safe_parse_date
18
+ from hestia_earth.utils.stats import correlated_normal_2d, gen_seed
19
+ from hestia_earth.utils.descriptive_stats import calc_descriptive_stats
20
20
 
21
21
  from hestia_earth.models.log import log_as_table
22
22
  from hestia_earth.models.utils import pairwise
23
- from hestia_earth.models.utils.array_builders import correlated_normal_2d, gen_seed
24
23
  from hestia_earth.models.utils.blank_node import (
25
24
  _gapfill_datestr, _get_datestr_format, DatestrGapfillMode, DatestrFormat, group_nodes_by_year, node_term_match,
26
25
  split_node_by_dates
27
26
  )
28
27
  from hestia_earth.models.utils.constant import Units, get_atomic_conversion
29
- from hestia_earth.models.utils.descriptive_stats import calc_descriptive_stats
30
28
  from hestia_earth.models.utils.emission import min_emission_method_tier
31
29
  from hestia_earth.models.utils.measurement import (
32
30
  group_measurements_by_method_classification, min_measurement_method_classification,
@@ -1,13 +1,12 @@
1
1
  import numpy as np
2
2
  import numpy.typing as npt
3
3
  from typing import Callable, Union
4
-
5
4
  from hestia_earth.schema import EmissionMethodTier, EmissionStatsDefinition
5
+ from hestia_earth.utils.stats import gen_seed, repeat_single, truncated_normal_1d
6
+ from hestia_earth.utils.descriptive_stats import calc_descriptive_stats
6
7
 
7
8
  from hestia_earth.models.log import logRequirements, logShouldRun
8
- from hestia_earth.models.utils.array_builders import gen_seed, repeat_single, truncated_normal_1d
9
9
  from hestia_earth.models.utils.cycle import land_occupation_per_ha
10
- from hestia_earth.models.utils.descriptive_stats import calc_descriptive_stats
11
10
  from hestia_earth.models.utils.ecoClimateZone import EcoClimateZone, get_eco_climate_zone_value
12
11
  from hestia_earth.models.utils.emission import _new_emission
13
12
  from hestia_earth.models.utils.measurement import most_relevant_measurement_value
@@ -2,7 +2,7 @@ from hestia_earth.schema import EmissionMethodTier
2
2
 
3
3
  from hestia_earth.models.log import logRequirements, logShouldRun
4
4
  from hestia_earth.models.utils.emission import _new_emission
5
- from hestia_earth.models.utils.blank_node import get_lookup_value
5
+ from hestia_earth.models.utils.term import get_lookup_value
6
6
  from hestia_earth.models.utils.cropResidue import get_crop_residue_burnt_value
7
7
  from . import MODEL
8
8
 
@@ -4,15 +4,14 @@ from itertools import product
4
4
  import numpy as np
5
5
  import numpy.typing as npt
6
6
  from typing import Any, Callable, Literal, Optional, TypedDict, Union
7
-
8
7
  from hestia_earth.schema import EmissionMethodTier, EmissionStatsDefinition, SiteSiteType
9
8
  from hestia_earth.utils.lookup import download_lookup, get_table_value, column_name
10
9
  from hestia_earth.utils.tools import safe_parse_float
10
+ from hestia_earth.utils.stats import gen_seed, repeat_single, truncated_normal_1d
11
+ from hestia_earth.utils.descriptive_stats import calc_descriptive_stats
11
12
 
12
13
  from hestia_earth.models.log import debugMissingLookup, log_as_table, logRequirements, logShouldRun
13
- from hestia_earth.models.utils.array_builders import gen_seed, repeat_single, truncated_normal_1d
14
14
  from hestia_earth.models.utils.blank_node import group_nodes_by_year
15
- from hestia_earth.models.utils.descriptive_stats import calc_descriptive_stats
16
15
  from hestia_earth.models.utils.ecoClimateZone import EcoClimateZone, get_eco_climate_zone_value
17
16
  from hestia_earth.models.utils.emission import _new_emission
18
17
  from hestia_earth.models.utils.lookup import get_region_lookup_value
@@ -4,20 +4,19 @@ from numpy import empty_like, random, vstack
4
4
  from numpy.typing import NDArray
5
5
  from pydash.objects import merge
6
6
  from typing import Callable, Literal, Optional, Union
7
-
8
7
  from hestia_earth.schema import MeasurementMethodClassification, SiteSiteType, TermTermType
9
8
  from hestia_earth.utils.blank_node import get_node_value
10
9
  from hestia_earth.utils.model import find_term_match, filter_list_term_type
11
10
  from hestia_earth.utils.tools import non_empty_list
11
+ from hestia_earth.utils.stats import gen_seed
12
+ from hestia_earth.utils.descriptive_stats import calc_descriptive_stats
12
13
 
13
14
  from hestia_earth.models.utils import split_on_condition
14
- from hestia_earth.models.utils.array_builders import gen_seed
15
15
  from hestia_earth.models.utils.blank_node import (
16
16
  cumulative_nodes_match, cumulative_nodes_lookup_match, cumulative_nodes_term_match, group_by_term,
17
17
  node_lookup_match, node_term_match, group_nodes_by_year, validate_start_date_end_date
18
18
  )
19
19
  from hestia_earth.models.utils.ecoClimateZone import EcoClimateZone, get_eco_climate_zone_value
20
- from hestia_earth.models.utils.descriptive_stats import calc_descriptive_stats
21
20
  from hestia_earth.models.utils.measurement import _new_measurement
22
21
  from hestia_earth.models.utils.property import get_node_property
23
22
  from hestia_earth.models.utils.term import get_residue_removed_or_burnt_terms, get_upland_rice_land_cover_terms
@@ -3,23 +3,22 @@ from numpy import array, empty, exp, minimum, random, where, vstack
3
3
  from numpy.typing import NDArray
4
4
  from pydash.objects import merge
5
5
  from typing import Any, Callable, Union
6
-
7
6
  from hestia_earth.schema import (
8
7
  CycleFunctionalUnit, MeasurementMethodClassification, SiteSiteType, TermTermType
9
8
  )
10
9
  from hestia_earth.utils.model import find_term_match, filter_list_term_type
11
10
  from hestia_earth.utils.tools import flatten, list_sum, non_empty_list
12
11
  from hestia_earth.utils.blank_node import get_node_value
13
-
14
- from hestia_earth.models.utils.array_builders import (
12
+ from hestia_earth.utils.stats import (
15
13
  avg_run_in_columnwise, gen_seed, grouped_avg, repeat_1d_array_as_columns
16
14
  )
15
+ from hestia_earth.utils.descriptive_stats import calc_descriptive_stats
16
+
17
17
  from hestia_earth.models.utils.blank_node import (
18
18
  cumulative_nodes_lookup_match, cumulative_nodes_term_match, group_nodes_by_year, group_nodes_by_year_and_month,
19
19
  GroupNodesByYearMode, node_lookup_match, node_term_match
20
20
  )
21
21
  from hestia_earth.models.utils.cycle import check_cycle_site_ids_identical
22
- from hestia_earth.models.utils.descriptive_stats import calc_descriptive_stats
23
22
  from hestia_earth.models.utils.measurement import _new_measurement
24
23
  from hestia_earth.models.utils.property import get_node_property
25
24
  from hestia_earth.models.utils.site import related_cycles
@@ -2,14 +2,13 @@ from enum import Enum
2
2
  from numpy import inf
3
3
  from numpy.typing import NDArray
4
4
  from typing import NamedTuple, Optional
5
-
6
5
  from hestia_earth.schema import MeasurementStatsDefinition, SiteSiteType
6
+ from hestia_earth.utils.stats import calc_z_critical
7
7
 
8
- from hestia_earth.models.utils.array_builders import (
8
+ from hestia_earth.utils.stats import (
9
9
  repeat_single, truncated_normal_1d
10
10
  )
11
11
  from hestia_earth.models.utils.blank_node import cumulative_nodes_term_match, node_term_match
12
- from hestia_earth.models.utils.stats import calc_z_critical
13
12
  from hestia_earth.models.utils.term import get_cover_crop_property_terms, get_irrigated_terms
14
13
 
15
14
  STATS_DEFINITION = MeasurementStatsDefinition.SIMULATED.value