
Automatic calculation of emissions for batches of reservoirs
Input data is defined in JSON file whilst outputs data configuration is specified in YAML config file.
This notebook demonstrates how to:
Read input data in JSON format and output configuration YAML file
Instantiate the emission model object from input data output configuration file
Calculate emissions
Display model ouptputs
< Manual Step-By-Step Calculations | Contents | Saving Results To JSON >
Import the required libraries and RE-Emission classes
[1]:
from os.path import exists
import pathlib
import gdown
import pprint
# Import reemission
try:
    import reemission
except ImportError:
    %pip install git+https://github.com/tomjanus/reemission.git --quiet
# Import package file loader
from reemission.utils import get_package_file
# Import from the model module
from reemission.model import EmissionModel
# Import from the input module
from reemission.input import Inputs
1. Read input data and output configuration YAML file
[2]:
if not exists(pathlib.Path('./inputs.json')):
    # Download the required input file from an external link
    !gdown 1T9Pal8h9Ce6phw1qdPM5AkuZM_hnvBGT
input_data = Inputs.fromfile('inputs.json')
output_config = get_package_file('config', 'outputs.yaml').as_posix()
2. Instantiate the emission model object from input data output configuration file
[3]:
model = EmissionModel(inputs=input_data, presenter_config=output_config, p_model='g-res')
3. Calculate emissions
[4]:
model.calculate()
4. Display outputs dictionary
[5]:
pprint.pprint(model.outputs)
{'Reservoir 1': {'ch4_degassing': 0.0,
                 'ch4_diffusion': 229.50728895021928,
                 'ch4_ebullition': 321.2319562880549,
                 'ch4_net': 550.7392452382742,
                 'ch4_preimp': 0.0,
                 'ch4_profile': [1075.7638713949952,
                                 983.3228492856958,
                                 883.5313487045227,
                                 726.8036292777338,
                                 613.7600723593921,
                                 532.224745950718,
                                 473.41547248304676,
                                 414.4537841630906,
                                 378.33609877105505,
                                 350.9395594718922],
                 'ch4_total_lifetime': 88.33857493621919,
                 'ch4_total_per_year': 883.3857493621919,
                 'co2_diffusion': 572.7646642529623,
                 'co2_diffusion_nonanthro': 393.12744599578104,
                 'co2_minus_nonanthro': 179.6372182571813,
                 'co2_net': 313.103884923848,
                 'co2_preimp': -133.4666666666667,
                 'co2_profile': [1537.2783464521954,
                                 796.8483727272558,
                                 580.8307965527008,
                                 408.98093357353525,
                                 325.2415499478169,
                                 272.2680978453252,
                                 234.50567817918972,
                                 193.5204959761715,
                                 163.50804922594176,
                                 133.4666666666667],
                 'co2_total_lifetime': 50.22186314178522,
                 'co2_total_per_year': 502.21863141785224,
                 'n2o_mean': 0.04569849137014073,
                 'n2o_methodA': 0.043280912406044016,
                 'n2o_methodB': 0.048116070334237454,
                 'n2o_profile': [0.043280912406044016,
                                 0.043280912406044016,
                                 0.043280912406044016,
                                 0.043280912406044016,
                                 0.043280912406044016,
                                 0.043280912406044016,
                                 0.043280912406044016,
                                 0.043280912406044016,
                                 0.043280912406044016,
                                 0.043280912406044016],
                 'n2o_total_lifetime': 0.00694225834992946,
                 'n2o_total_per_year': 0.0694225834992946},
 'Reservoir 2': {'ch4_degassing': 0.0,
                 'ch4_diffusion': 136.10915204619948,
                 'ch4_ebullition': 90.94433704616341,
                 'ch4_net': 227.0534890923629,
                 'ch4_preimp': 0.0,
                 'ch4_profile': [538.4190104073056,
                                 483.5969209166755,
                                 424.4156348335686,
                                 331.46836030085456,
                                 264.42795061792253,
                                 216.0734770408248,
                                 181.1966747364153,
                                 146.2294829005942,
                                 124.80991250234145,
                                 108.56241225925223],
                 'ch4_total_lifetime': 394.5735533447083,
                 'ch4_total_per_year': 3945.7355334470826,
                 'co2_diffusion': 796.9654854957547,
                 'co2_diffusion_nonanthro': 547.0117579064897,
                 'co2_minus_nonanthro': 249.953727589265,
                 'co2_net': 378.8003942559317,
                 'co2_preimp': -128.8466666666667,
                 'co2_profile': [2082.161049955455,
                                 1051.8999840865445,
                                 751.3253096762252,
                                 512.2071900900598,
                                 395.68918070233053,
                                 321.98000203239394,
                                 269.43600446933124,
                                 212.40773846209936,
                                 170.6473337304127,
                                 128.8466666666667],
                 'co2_total_lifetime': 658.279325137958,
                 'co2_total_per_year': 6582.79325137958,
                 'n2o_mean': 0.3184910807620064,
                 'n2o_methodA': 0.35553527541406443,
                 'n2o_methodB': 0.2814468861099484,
                 'n2o_profile': [0.35553527541406443,
                                 0.35553527541406443,
                                 0.35553527541406443,
                                 0.35553527541406443,
                                 0.35553527541406443,
                                 0.35553527541406443,
                                 0.35553527541406443,
                                 0.35553527541406443,
                                 0.35553527541406443,
                                 0.35553527541406443],
                 'n2o_total_lifetime': 0.6178492016145611,
                 'n2o_total_per_year': 6.178492016145611},
 'Reservoir 3': {'ch4_degassing': 0.0,
                 'ch4_diffusion': 238.65463850593412,
                 'ch4_ebullition': 210.60761679419937,
                 'ch4_net': 449.26225530013346,
                 'ch4_preimp': 0.0,
                 'ch4_profile': [995.2125078401448,
                                 899.0871132371035,
                                 795.3182760637874,
                                 632.3439435502227,
                                 514.7948699013089,
                                 430.0098334933974,
                                 368.8566301924427,
                                 307.5449373217607,
                                 269.9877286146468,
                                 241.49926006681994],
                 'ch4_total_lifetime': 1985.4696110734096,
                 'ch4_total_per_year': 19854.696110734098,
                 'co2_diffusion': 1001.8691408378094,
                 'co2_diffusion_nonanthro': 687.6511089825283,
                 'co2_minus_nonanthro': 314.2180318552811,
                 'co2_net': 701.7846985219478,
                 'co2_preimp': -387.5666666666667,
                 'co2_profile': [2843.0875625989893,
                                 1547.941426805347,
                                 1170.087559492952,
                                 869.4910225180519,
                                 723.0156731059005,
                                 630.3555104641342,
                                 564.302198679944,
                                 492.6116914899196,
                                 440.11448606382885,
                                 387.5666666666667],
                 'co2_total_lifetime': 3101.4672966478965,
                 'co2_total_per_year': 31014.672966478964,
                 'n2o_mean': 2.929791544898492,
                 'n2o_methodA': 3.6100903829982802,
                 'n2o_methodB': 2.2494927067987036,
                 'n2o_profile': [3.6100903829982802,
                                 3.6100903829982802,
                                 3.6100903829982802,
                                 3.6100903829982802,
                                 3.6100903829982802,
                                 3.6100903829982802,
                                 3.6100903829982802,
                                 3.6100903829982802,
                                 3.6100903829982802,
                                 3.6100903829982802],
                 'n2o_total_lifetime': 15.954433438622601,
                 'n2o_total_per_year': 159.544334386226},
 'Reservoir 4': {'ch4_degassing': 0.0,
                 'ch4_diffusion': 114.55798902807442,
                 'ch4_ebullition': 35.770362020378734,
                 'ch4_net': 150.32835104845316,
                 'ch4_preimp': 0.0,
                 'ch4_profile': [412.3930795276272,
                                 366.25137463895084,
                                 316.44069681271134,
                                 238.2104478101028,
                                 181.7850392212071,
                                 141.08688505429816,
                                 111.73238334991092,
                                 82.30180415336366,
                                 64.27375186018486,
                                 50.5988378180367],
                 'ch4_total_lifetime': 3972.0508555777537,
                 'ch4_total_per_year': 39720.50855577754,
                 'co2_diffusion': 556.5994481893181,
                 'co2_diffusion_nonanthro': 382.0321559024945,
                 'co2_minus_nonanthro': 174.5672922868236,
                 'co2_net': 349.0749589534903,
                 'co2_preimp': -174.5076666666667,
                 'co2_profile': [1538.6993759255602,
                                 819.1666594028836,
                                 609.245777054511,
                                 442.2460564443576,
                                 360.8700609845472,
                                 309.3916859221016,
                                 272.6950402310161,
                                 232.8665884743208,
                                 203.70118714535295,
                                 174.5076666666667],
                 'co2_total_lifetime': 9223.433102948598,
                 'co2_total_per_year': 92234.33102948598,
                 'n2o_mean': 0.0035568256933053745,
                 'n2o_methodA': 0.003956510851593258,
                 'n2o_methodB': 0.0031571405350174914,
                 'n2o_profile': [0.003956510851593258,
                                 0.003956510851593258,
                                 0.003956510851593258,
                                 0.003956510851593258,
                                 0.003956510851593258,
                                 0.003956510851593258,
                                 0.003956510851593258,
                                 0.003956510851593258,
                                 0.003956510851593258,
                                 0.003956510851593258],
                 'n2o_total_lifetime': 0.10454090797622287,
                 'n2o_total_per_year': 1.0454090797622286}}