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

@@ -21,27 +21,26 @@ def _emission(term_id: str, value: float, sd: float = None):
21
21
  return emission
22
22
 
23
23
 
24
- def _run(term_id: str, product_value: list):
25
- value = sum(product_value)
26
- term = {'termType': TermTermType.EMISSION.value, '@id': term_id}
27
- factor = get_lookup_value(term, LOOKUP_NAME)
28
- factor_sd = get_lookup_value(term, LOOKUP_NAME + '-sd')
29
- emission_value = multiply_values([value, factor])
30
- return [] if emission_value is None else [_emission(term_id, emission_value, multiply_values([value, factor_sd]))]
24
+ def _run(term_id: str, value: float, factor: float, factor_sd: float = None):
25
+ return [_emission(term_id, value * factor, multiply_values([value, factor_sd]))]
31
26
 
32
27
 
33
28
  def _should_run(term_id: str, cycle: dict):
34
29
  crop_residue_burnt_value = get_crop_residue_burnt_value(cycle)
35
- has_crop_residue_burnt = len(crop_residue_burnt_value) > 0
30
+ term = {'termType': TermTermType.EMISSION.value, '@id': term_id}
31
+ factor = get_lookup_value(term, LOOKUP_NAME)
32
+ factor_sd = get_lookup_value(term, LOOKUP_NAME + '-sd')
36
33
 
37
34
  logRequirements(cycle, model=MODEL, term=term_id,
38
- has_crop_residue_burnt=has_crop_residue_burnt)
35
+ crop_residue_burnt_value=crop_residue_burnt_value,
36
+ burning_factor=factor,
37
+ burning_factor_sd=factor_sd)
39
38
 
40
- should_run = all([has_crop_residue_burnt])
39
+ should_run = all([crop_residue_burnt_value is not None, factor is not None])
41
40
  logShouldRun(cycle, MODEL, term_id, should_run, methodTier=TIER)
42
- return should_run, crop_residue_burnt_value
41
+ return should_run, crop_residue_burnt_value, factor, factor_sd
43
42
 
44
43
 
45
44
  def run_emission(term_id: str, cycle: dict):
46
- should_run, crop_residue_burnt_value = _should_run(term_id, cycle)
47
- return _run(term_id, crop_residue_burnt_value) if should_run else []
45
+ should_run, value, factor, factor_sd = _should_run(term_id, cycle)
46
+ return _run(term_id, value, factor, factor_sd) if should_run else []
@@ -38,25 +38,19 @@ def _emission(value: float):
38
38
  return emission
39
39
 
40
40
 
41
- def _run(product_value: list, factor: float):
42
- value = sum(product_value)
43
- return [_emission(value * factor)]
44
-
45
-
46
41
  def _should_run(cycle: dict):
47
42
  crop_residue_burnt_value = get_crop_residue_burnt_value(cycle)
48
- has_crop_residue_burnt = len(crop_residue_burnt_value) > 0
49
43
  factor = get_lookup_value({'termType': 'emission', '@id': TERM_ID}, LOOKUPS['emission'][0])
50
44
 
51
45
  logRequirements(cycle, model=MODEL, term=TERM_ID,
52
- has_crop_residue_burnt=has_crop_residue_burnt,
46
+ crop_residue_burnt_value=crop_residue_burnt_value,
53
47
  burning_factor=factor)
54
48
 
55
- should_run = all([has_crop_residue_burnt, factor is not None])
49
+ should_run = all([crop_residue_burnt_value is not None, factor is not None])
56
50
  logShouldRun(cycle, MODEL, TERM_ID, should_run, methodTier=TIER)
57
51
  return should_run, crop_residue_burnt_value, factor
58
52
 
59
53
 
60
54
  def run(cycle: dict):
61
- should_run, crop_residue_burnt_value, factor = _should_run(cycle)
62
- return _run(crop_residue_burnt_value, factor) if should_run else []
55
+ should_run, value, factor = _should_run(cycle)
56
+ return [_emission(value * factor)] if should_run else []