hestia-earth-models 0.44.0__py3-none-any.whl → 0.44.1__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.

@@ -20,7 +20,8 @@ MODELS = list(map(lambda m: {'key': m, 'run': getattr(import_module(f".{m}", pac
20
20
  def _should_run_model(model, cycle: dict):
21
21
  is_complete = cycle.get('completeness', {}).get(model.get('key'))
22
22
  should_run = is_complete is False
23
- logShouldRun(cycle, MODEL, None, should_run, key=model.get('key'))
23
+ if should_run:
24
+ logShouldRun(cycle, MODEL, None, should_run, key=model.get('key'))
24
25
  return should_run
25
26
 
26
27
 
@@ -1,12 +1,12 @@
1
1
  """
2
- Animal feed
2
+ Completeness Animal feed
3
3
 
4
- This model checks if the site is a cropland and updates the
4
+ This model checks if we have the requirements below and updates the
5
5
  [Data Completeness](https://hestia.earth/schema/Completeness#animalFeed) value.
6
6
  """
7
7
  from hestia_earth.schema import SiteSiteType
8
8
 
9
- from hestia_earth.models.log import logger
9
+ from hestia_earth.models.log import logRequirements
10
10
  from . import MODEL
11
11
 
12
12
  REQUIREMENTS = {
@@ -33,6 +33,8 @@ ALLOWED_SITE_TYPES = [
33
33
  def run(cycle: dict):
34
34
  site_type = cycle.get('site', {}).get('siteType')
35
35
  site_type_allowed = site_type in ALLOWED_SITE_TYPES
36
- is_complete = all([site_type_allowed])
37
- logger.debug('model=%s, key=%s, value=%s', MODEL, MODEL_KEY, is_complete)
38
- return is_complete
36
+
37
+ logRequirements(cycle, model=MODEL, term=None, key=MODEL_KEY,
38
+ site_type_allowed=site_type_allowed)
39
+
40
+ return all([site_type_allowed])
@@ -1,12 +1,12 @@
1
1
  """
2
- Crop Residue
2
+ Completeness Crop Residue
3
3
 
4
- This model checks if we have all the [crop residue terms](https://hestia.earth/glossary?termType=cropResidue)
5
- and updates the [Data Completeness](https://hestia.earth/schema/Completeness#cropResidue) value.
4
+ This model checks if we have the requirements below and updates the
5
+ [Data Completeness](https://hestia.earth/schema/Completeness#cropResidue) value.
6
6
  """
7
7
  from hestia_earth.utils.model import find_term_match
8
8
 
9
- from hestia_earth.models.log import logger
9
+ from hestia_earth.models.log import logRequirements
10
10
  from hestia_earth.models.utils.term import get_crop_residue_terms
11
11
  from . import MODEL
12
12
 
@@ -44,11 +44,26 @@ def _optional_term_ids():
44
44
  return [term for term in terms if term not in REQUIRED_TERM_IDS]
45
45
 
46
46
 
47
+ def _has_product(products):
48
+ def has_product(term_id: str):
49
+ return (term_id, find_term_match(products, term_id, None) is not None)
50
+ return has_product
51
+
52
+
47
53
  def run(cycle: dict):
48
54
  products = cycle.get('products', [])
49
55
  # all required terms + at least one of the optional terms must be present
50
- required_valid = all([find_term_match(products, term_id, False) for term_id in REQUIRED_TERM_IDS])
51
- optional_valid = any([find_term_match(products, term_id, False) for term_id in _optional_term_ids()])
52
- is_complete = required_valid and optional_valid
53
- logger.debug('model=%s, key=%s, value=%s', MODEL, MODEL_KEY, is_complete)
54
- return is_complete
56
+ required_products_map = list(map(_has_product(products), REQUIRED_TERM_IDS))
57
+ optional_products_map = list(map(_has_product(products), _optional_term_ids()))
58
+
59
+ has_required_products = all([has_product for _term_id, has_product in required_products_map])
60
+ has_optional_product = any([has_product for _term_id, has_product in optional_products_map])
61
+
62
+ logRequirements(cycle, model=MODEL, term=None, key=MODEL_KEY,
63
+ **({
64
+ f'has_required_{term_id}': has_product for term_id, has_product in required_products_map
65
+ } | {
66
+ f'has_optional_{term_id}': has_product for term_id, has_product in optional_products_map
67
+ }))
68
+
69
+ return all([has_required_products, has_optional_product])
@@ -1,12 +1,12 @@
1
1
  """
2
- Excreta
2
+ Completeness Excreta
3
3
 
4
- This model checks if the site is a cropland and updates the
4
+ This model checks if we have the requirements below and updates the
5
5
  [Data Completeness](https://hestia.earth/schema/Completeness#excreta) value.
6
6
  """
7
7
  from hestia_earth.schema import SiteSiteType
8
8
 
9
- from hestia_earth.models.log import logger
9
+ from hestia_earth.models.log import logRequirements
10
10
  from . import MODEL
11
11
 
12
12
  REQUIREMENTS = {
@@ -33,6 +33,8 @@ ALLOWED_SITE_TYPES = [
33
33
  def run(cycle: dict):
34
34
  site_type = cycle.get('site', {}).get('siteType')
35
35
  site_type_allowed = site_type in ALLOWED_SITE_TYPES
36
- is_complete = all([site_type_allowed])
37
- logger.debug('model=%s, key=%s, value=%s', MODEL, MODEL_KEY, is_complete)
38
- return is_complete
36
+
37
+ logRequirements(cycle, model=MODEL, term=None, key=MODEL_KEY,
38
+ site_type_allowed=site_type_allowed)
39
+
40
+ return all([site_type_allowed])
@@ -1,13 +1,13 @@
1
1
  """
2
- Material
2
+ Completeness Material
3
3
 
4
- This model checks if the `machinery` Input has been added and updates the
4
+ This model checks if we have the requirements below and updates the
5
5
  [Data Completeness](https://hestia.earth/schema/Completeness#material) value.
6
6
  """
7
7
  from hestia_earth.schema import SiteSiteType
8
8
  from hestia_earth.utils.model import find_term_match
9
9
 
10
- from hestia_earth.models.log import logger
10
+ from hestia_earth.models.log import logRequirements
11
11
  from . import MODEL
12
12
 
13
13
  REQUIREMENTS = {
@@ -34,7 +34,12 @@ ALLOWED_SITE_TYPES = [
34
34
  def run(cycle: dict):
35
35
  site_type = cycle.get('site', {}).get('siteType')
36
36
  site_type_allowed = site_type in ALLOWED_SITE_TYPES
37
- input = find_term_match(cycle.get('inputs', []), 'machineryInfrastructureDepreciatedAmountPerCycle', None)
38
- is_complete = all([site_type_allowed, input])
39
- logger.debug('model=%s, key=%s, value=%s', MODEL, MODEL_KEY, is_complete)
40
- return is_complete
37
+ has_machinery_input = find_term_match(
38
+ cycle.get('inputs', []), 'machineryInfrastructureDepreciatedAmountPerCycle', None
39
+ ) is not None
40
+
41
+ logRequirements(cycle, model=MODEL, term=None, key=MODEL_KEY,
42
+ site_type_allowed=site_type_allowed,
43
+ has_machinery_input=has_machinery_input)
44
+
45
+ return all([site_type_allowed, has_machinery_input])
@@ -1,13 +1,13 @@
1
1
  """
2
- Other
2
+ Completeness Other
3
3
 
4
- This model checks if the `seed` or `saplings` Input has been added and updates the
4
+ This model checks if we have the requirements below and updates the
5
5
  [Data Completeness](https://hestia.earth/schema/Completeness#other) value.
6
6
  """
7
7
  from hestia_earth.schema import SiteSiteType
8
8
  from hestia_earth.utils.model import find_term_match, find_primary_product
9
9
 
10
- from hestia_earth.models.log import logger
10
+ from hestia_earth.models.log import logRequirements
11
11
  from hestia_earth.models.utils.crop import is_orchard
12
12
  from . import MODEL
13
13
 
@@ -48,6 +48,9 @@ def run(cycle: dict):
48
48
  term_id = product.get('term', {}).get('@id')
49
49
  has_saplings = find_term_match(cycle.get('inputs', []), 'saplings', None) and is_orchard(MODEL, term_id)
50
50
 
51
- is_complete = all([site_type_allowed, has_seed or has_saplings])
52
- logger.debug('model=%s, key=%s, value=%s', MODEL, MODEL_KEY, is_complete)
53
- return is_complete
51
+ logRequirements(cycle, model=MODEL, term=None, key=MODEL_KEY,
52
+ site_type_allowed=site_type_allowed,
53
+ has_seed=has_seed,
54
+ has_saplings=has_saplings)
55
+
56
+ return all([site_type_allowed, has_seed or has_saplings])
@@ -1,10 +1,10 @@
1
1
  """
2
- Soil Amendments
2
+ Completeness Soil Amendments
3
3
 
4
- This model checks if the `soilPh` from geospatial dataset is greater than `6.5` and updates the
4
+ This model checks if we have the requirements below and updates the
5
5
  [Data Completeness](https://hestia.earth/schema/Completeness#soilAmendments) value.
6
6
  """
7
- from hestia_earth.models.log import logger
7
+ from hestia_earth.models.log import logRequirements
8
8
  from hestia_earth.models.utils import is_from_model
9
9
  from hestia_earth.models.utils.measurement import most_relevant_measurement, measurement_value
10
10
  from . import MODEL
@@ -32,6 +32,12 @@ def run(cycle: dict):
32
32
  measurements = cycle.get('site', {}).get('measurements', [])
33
33
  soilPh_measurement = most_relevant_measurement(measurements, 'soilPh', end_date)
34
34
  soilPh = measurement_value(soilPh_measurement)
35
- is_complete = is_from_model(soilPh_measurement) and soilPh > 6.5
36
- logger.debug('model=%s, key=%s, value=%s', MODEL, MODEL_KEY, is_complete)
37
- return is_complete
35
+
36
+ soilPh_added = is_from_model(soilPh_measurement)
37
+ soilPh_above_6_5 = soilPh > 6.5
38
+
39
+ logRequirements(cycle, model=MODEL, term=None, key=MODEL_KEY,
40
+ soilPh_added=soilPh_added,
41
+ soilPh_above_6_5=soilPh_above_6_5)
42
+
43
+ return all([soilPh_added, soilPh_above_6_5])
@@ -317,12 +317,12 @@
317
317
  "excretaSheepAndGoatsKgN",
318
318
  "excretaDucksKgN",
319
319
  "excretaBeefCattleExceptFeedlotFedKgN",
320
+ "excretaSolidAndLiquidFishCrustaceansKgN",
321
+ "excretaBuffaloKgN",
320
322
  "excretaHorsesMulesAndAssesKgN",
321
323
  "excretaPigsKgN",
322
324
  "excretaCamelsKgN",
323
325
  "excretaDairyCattleKgN",
324
- "excretaSolidAndLiquidFishCrustaceansKgN",
325
- "excretaBuffaloKgN",
326
326
  "excretaLiquidFishCrustaceansKgN",
327
327
  "excretaTurkeysKgN",
328
328
  "excretaMixturesKgN",
@@ -348,13 +348,13 @@
348
348
  "waterDrainageCanal",
349
349
  "waterMarine",
350
350
  "waterSourceUnspecified",
351
- "waterIrrigationCanal",
352
351
  "waterMunicipalTap",
353
- "waterBrackish",
354
- "waterLakeOrReservoir",
352
+ "waterIrrigationCanal",
355
353
  "waterRiverStream",
354
+ "waterHarvestedRainfall",
356
355
  "waterPumpedGroundwater",
357
- "waterHarvestedRainfall"
356
+ "waterBrackish",
357
+ "waterLakeOrReservoir"
358
358
  ]
359
359
  },
360
360
  {
@@ -389,11 +389,11 @@
389
389
  }
390
390
  },
391
391
  "results": [
392
- "motorGasoline",
393
392
  "diesel1D",
393
+ "motorGasoline",
394
+ "gasolineTypeJetFuel",
394
395
  "diesel",
395
396
  "aviationGasoline",
396
- "gasolineTypeJetFuel",
397
397
  "en590Diesel",
398
398
  "diesel4D",
399
399
  "diesel2D"
@@ -426,14 +426,14 @@
426
426
  }
427
427
  },
428
428
  "results": [
429
+ "milkYieldPerCowRaw",
430
+ "milkYieldPerBuffaloFpcm",
429
431
  "milkYieldPerGoatRaw",
430
432
  "milkYieldPerSheepRaw",
431
- "milkYieldPerBuffaloFpcm",
432
- "milkYieldPerCowRaw",
433
433
  "milkYieldPerCowFpcm",
434
434
  "milkYieldPerSheepFpcm",
435
- "milkYieldPerBuffaloRaw",
436
- "milkYieldPerCamelRaw"
435
+ "milkYieldPerCamelRaw",
436
+ "milkYieldPerBuffaloRaw"
437
437
  ]
438
438
  },
439
439
  {
@@ -476,13 +476,13 @@
476
476
  "name": "tillage"
477
477
  },
478
478
  "results": [
479
+ "mulchTillage",
480
+ "stripTillage",
481
+ "deepTillage",
479
482
  "minimumTillage",
480
483
  "fullTillage",
481
484
  "ridgeTillage",
482
485
  "noTillage",
483
- "deepTillage",
484
- "mulchTillage",
485
- "stripTillage",
486
486
  "fullInversionTillage"
487
487
  ]
488
488
  },
@@ -494,10 +494,10 @@
494
494
  },
495
495
  "results": [
496
496
  "ureaKgN",
497
- "ureaFormaldehydeKgN",
498
- "ureaCalciumNitrateKgN",
499
- "sulphurCoatedUreaKgN",
500
497
  "ureaAmmoniumNitrateKgN",
498
+ "sulphurCoatedUreaKgN",
499
+ "ureaCalciumNitrateKgN",
500
+ "ureaFormaldehydeKgN",
501
501
  "ureaAmmoniumSulphateKgN"
502
502
  ]
503
503
  },
@@ -1 +1 @@
1
- VERSION = '0.44.0'
1
+ VERSION = '0.44.1'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hestia-earth-models
3
- Version: 0.44.0
3
+ Version: 0.44.1
4
4
  Summary: Hestia's set of modules for filling gaps in the activity data using external datasets (e.g. populating soil properties with a geospatial dataset using provided coordinates) and internal lookups (e.g. populating machinery use from fuel use). Includes rules for when gaps should be filled versus not (e.g. never gap fill yield, gap fill crop residue if yield provided etc.).
5
5
  Home-page: https://gitlab.com/hestia-earth/hestia-engine-models
6
6
  Author: Hestia Team
@@ -2,7 +2,7 @@ hestia_earth/__init__.py,sha256=G-d438vPx7m_ks5e9XTtM3u7LDRO5dSSukibukWmyPM,56
2
2
  hestia_earth/models/__init__.py,sha256=qEFeq3yuf3lQKVseALmL8aPM8fpCS54B_5pry00M3hk,76
3
3
  hestia_earth/models/log.py,sha256=rOgKa-gSrcS-Y1gO9eJXJaA3ofxcQW_45hGly2Lf00Y,2444
4
4
  hestia_earth/models/requirements.py,sha256=znNZJAhwX2iYiKcAQXPftY7z_1MsNa0QxCXkXyHm_U0,17363
5
- hestia_earth/models/version.py,sha256=eNf9EjggIZXy1ORbdnTcw7CvmcyFZVpX_loi322TU6Q,19
5
+ hestia_earth/models/version.py,sha256=_vVlCNH6wY4Hmj0gYEUhDwK6UFJdVkvCtP51PirWesQ,19
6
6
  hestia_earth/models/agribalyse2016/__init__.py,sha256=WvK0qCQbnYtg9oZxrACd1wGormZyXibPtpCnIQeDqbw,415
7
7
  hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=ztMnY6XTwsJD-lp62jJyzN2AUODvFHIs5d5CaFrlVGI,3567
8
8
  hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=10XV1fz_yBYlqmNJ3cxmT2I2Vp_0w7nT4zMIuBw2wCY,3294
@@ -52,13 +52,13 @@ hestia_earth/models/cycle/residueLeftOnField.py,sha256=PkpiuOWYlPZzWYw2Oqu0yM1dQ
52
52
  hestia_earth/models/cycle/residueRemoved.py,sha256=7_1pV0xWqp_IJSG-LSRPMksHaW9iUKzyynC7YI_dluM,2283
53
53
  hestia_earth/models/cycle/siteDuration.py,sha256=Hox20n3Y-tJ4ydmkrOreWOXAENxOnd827B7qH7_66T0,1058
54
54
  hestia_earth/models/cycle/transformation.py,sha256=06KTfVubh2I47dfnG9Iv6AbuUBbURM8BAVOkRu7XmHw,1255
55
- hestia_earth/models/cycle/completeness/__init__.py,sha256=EdutggDTWO-YKQCRamfphTq27lwdmzbdhgsGZ9BAMcg,1494
56
- hestia_earth/models/cycle/completeness/animalFeed.py,sha256=AHR7fzsNQlLdOaIEokvu9zMdQO0ELSFvEyEY7hrlyY4,965
57
- hestia_earth/models/cycle/completeness/cropResidue.py,sha256=1VKru7boaZJo8VTFtSJi9q9shgCVANjhWZhX3sPk6ew,1988
58
- hestia_earth/models/cycle/completeness/excreta.py,sha256=0ULg2FuHKUaes2Mau6farE42Wocgq_8UVXV_e_OMBRM,949
59
- hestia_earth/models/cycle/completeness/material.py,sha256=tAqvMQTDLluougRzIM2uCr5ZtRCLW6OasbcU5DAvEbQ,1214
60
- hestia_earth/models/cycle/completeness/other.py,sha256=VqigooEBnSZzzaVhcmHGyCEwjkzvNq_-CT_WnkXsg7w,1543
61
- hestia_earth/models/cycle/completeness/soilAmendments.py,sha256=Mspp9Ig4LwShlioWYuGJC5EiBN1gABTcj_0TlSgLOZM,1205
55
+ hestia_earth/models/cycle/completeness/__init__.py,sha256=rkwGtxIay_AleJCT7al_ngnix_xRqySVie7qvHXMQI0,1517
56
+ hestia_earth/models/cycle/completeness/animalFeed.py,sha256=8Fo1TqwSuiPudvd2vJ-LVxSyOdD8mDCOZMvjuj5W2uo,1012
57
+ hestia_earth/models/cycle/completeness/cropResidue.py,sha256=zSiu9h0NxEBDUWlaKBh1QcX4jDIklrs0BC2NWMCQQ80,2549
58
+ hestia_earth/models/cycle/completeness/excreta.py,sha256=2yVxcuWjAh4hoEukaMJ90VZpkCL7SfpwIgzigbjVaF4,996
59
+ hestia_earth/models/cycle/completeness/material.py,sha256=UQH2oRnUY-Q-_MVuOlTAYqQxc7wWDM5mi_iFmp9PlIQ,1362
60
+ hestia_earth/models/cycle/completeness/other.py,sha256=Hp3JbeapCvju1vSzdb1Dp9DIUiXSDf-ruRSY3fs4nlg,1652
61
+ hestia_earth/models/cycle/completeness/soilAmendments.py,sha256=fdnTT9mO-LMqJLovY5vxLP-o9GZWYg8QH27fxca_yw8,1338
62
62
  hestia_earth/models/cycle/feedConversionRatio/__init__.py,sha256=boQFf5q4DszxQ_D1hnd4jscG2BIBfphDmZCA105ikM8,2491
63
63
  hestia_earth/models/cycle/feedConversionRatio/feedConversionRatioCarbon.py,sha256=Oh680JRn5XNtR-lfHeLGYVofwjxs95-IbkY0bwfZX0Q,1317
64
64
  hestia_earth/models/cycle/feedConversionRatio/feedConversionRatioDryMatter.py,sha256=qjAuU0Ug96Br5AxOL7HCBOGNSv1A_3c2DH13AYG50r4,1712
@@ -315,7 +315,7 @@ hestia_earth/models/lcImpactCertainEffectsInfinite/damageToTerrestrialEcosystems
315
315
  hestia_earth/models/linkedImpactAssessment/__init__.py,sha256=x6xsPu-Rwh-7HKsvHuKmgM1YML6fQy2z9Hsy9_BeO2Y,3565
316
316
  hestia_earth/models/mocking/__init__.py,sha256=Y39V6yj_3M1q8v9ShCHwPeJOstypOVIvb_FldMEbF7g,766
317
317
  hestia_earth/models/mocking/mock_search.py,sha256=pJPIRn8zWtZvOay5Iq9Gc9TUHLiOIfQ2Mq0nnDb8-h4,1797
318
- hestia_earth/models/mocking/search-results.json,sha256=IhtH3ftibvUJuldn2Y0PV2PQl_i5jeJB6X-K3XMfNIU,14690
318
+ hestia_earth/models/mocking/search-results.json,sha256=JwfES0TxPyTByYf6yE7ExlrWDzNlw3Tl3Py7bcBWNqk,14690
319
319
  hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
320
320
  hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=trQBxjc8V77q96sxvK4Y9HfpD64zgyGuB5o5_o0lHts,2189
321
321
  hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=do9zHHR8VuqFcWNLnql5t3tV478SCVc7tC3mEs5cdUk,2184
@@ -921,8 +921,8 @@ tests/models/utils/test_site.py,sha256=deEIYptl2MHEklSfHbZV9qA59YKqZLQr8y5rWYiD4
921
921
  tests/models/utils/test_term.py,sha256=jcANyHzzLpkq7AQReFmTa16vtMlwgCNfhDbr9FLlYX4,1808
922
922
  tests/models/webbEtAl2012AndSintermannEtAl2012/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
923
923
  tests/models/webbEtAl2012AndSintermannEtAl2012/test_nh3ToAirOrganicFertiliser.py,sha256=qi2FNXS5Af2WDtm7nq_FsprH3BfCF0XxnE0XHmC4aIY,2244
924
- hestia_earth_models-0.44.0.dist-info/LICENSE,sha256=EFSZhfUdZCTsCIYdHzTGewMKfRfp7X9t1s2aaKxm8O0,1154
925
- hestia_earth_models-0.44.0.dist-info/METADATA,sha256=7gNyVqgXAL30j_crWzxt3GSmv1pC5TExX7kC6dLftiA,3192
926
- hestia_earth_models-0.44.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
927
- hestia_earth_models-0.44.0.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
928
- hestia_earth_models-0.44.0.dist-info/RECORD,,
924
+ hestia_earth_models-0.44.1.dist-info/LICENSE,sha256=EFSZhfUdZCTsCIYdHzTGewMKfRfp7X9t1s2aaKxm8O0,1154
925
+ hestia_earth_models-0.44.1.dist-info/METADATA,sha256=ORplFPloCt085BqrUYz_gmsCRPnPTzUqyobdot3UQp0,3192
926
+ hestia_earth_models-0.44.1.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
927
+ hestia_earth_models-0.44.1.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
928
+ hestia_earth_models-0.44.1.dist-info/RECORD,,