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
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
# Import from the presenter module
from reemission.presenter import LatexWriter, JSONWriter
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, 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': 3857.2376263191973,
'ch4_diffusion': 222.12962473141053,
'ch4_ebullition': 321.2319562880549,
'ch4_net': 4400.599207338662,
'ch4_preimp': 0.0,
'ch4_profile': [np.float64(13754.635020558859),
np.float64(12109.157167073025),
np.float64(10332.78676548272),
np.float64(7542.772342928074),
np.float64(5530.277560390243),
np.float64(4078.6236843295933),
np.float64(3031.5158882251035),
np.float64(1981.6110779040414),
np.float64(1338.4164647378564),
np.float64(850.476475450426)],
'ch4_total_lifetime': 705.8561128571215,
'ch4_total_per_year': 7058.561128571215,
'co2_diffusion': 572.839572429027,
'co2_diffusion_nonanthro': 393.12744599578104,
'co2_minus_nonanthro': 179.712126433246,
'co2_net': 311.712126433246,
'co2_preimp': -132.00000000000003,
'co2_profile': [1535.8116797855287,
795.3817060605891,
579.3641298860341,
407.51426690686856,
323.7748832811502,
270.8014311786585,
233.03901151252305,
192.05382930950483,
162.0413825592751,
132.00000000000003],
'co2_total_lifetime': 49.99862507989266,
'co2_total_per_year': 499.9862507989266,
'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': 751.4220477369057,
'ch4_diffusion': 131.73383296375653,
'ch4_ebullition': 90.94433704616341,
'ch4_net': 974.1002177468256,
'ch4_preimp': 0.0,
'ch4_profile': [np.float64(3008.368815130247),
np.float64(2651.0022030825776),
np.float64(2265.209369296882),
np.float64(1659.2758910516159),
np.float64(1222.2065467257914),
np.float64(906.9415568774284),
np.float64(679.5359628315111),
np.float64(451.52478924976106),
np.float64(311.84157206727167),
np.float64(205.87636817515)],
'ch4_total_lifetime': 1692.7913584004336,
'ch4_total_per_year': 16927.913584004335,
'co2_diffusion': 797.0697154432896,
'co2_diffusion_nonanthro': 547.0117579064897,
'co2_minus_nonanthro': 250.0579575367999,
'co2_net': 378.9046242034666,
'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.4604559407842,
'co2_total_per_year': 6584.604559407842,
'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': 769.7628401575995,
'ch4_diffusion': 230.9829266609136,
'ch4_ebullition': 210.60761679419937,
'ch4_net': 1211.3533836127126,
'ch4_preimp': 0.0,
'ch4_profile': [np.float64(3525.449120482008),
np.float64(3119.3946631651015),
np.float64(2681.0423075216954),
np.float64(1992.5607473180307),
np.float64(1495.9510318779244),
np.float64(1137.7406978071517),
np.float64(879.3594387292871),
np.float64(620.2919252626856),
np.float64(461.58447760503304),
np.float64(341.18846577804305)],
'ch4_total_lifetime': 5353.455143538023,
'ch4_total_per_year': 53534.55143538022,
'co2_diffusion': 1002.0001688056286,
'co2_diffusion_nonanthro': 687.6511089825283,
'co2_minus_nonanthro': 314.34905982310033,
'co2_net': 701.915726489767,
'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': 3102.046361648877,
'co2_total_per_year': 31020.463616488767,
'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': 441.2296262388797,
'ch4_diffusion': 110.87544639294957,
'ch4_ebullition': 35.770362020378734,
'ch4_net': 587.875434652208,
'ch4_preimp': 0.0,
'ch4_profile': [np.float64(1862.7298542455721),
np.float64(1638.9361799869444),
np.float64(1397.3415485860921),
np.float64(1017.8894874055144),
np.float64(744.185747655355),
np.float64(546.7596565210829),
np.float64(404.3536319392729),
np.float64(261.56901399718686),
np.float64(174.0973982293762),
np.float64(107.74089337245681)],
'ch4_total_lifetime': 15533.138672097968,
'ch4_total_per_year': 155331.38672097967,
'co2_diffusion': 556.6722422216051,
'co2_diffusion_nonanthro': 382.0321559024945,
'co2_minus_nonanthro': 174.6400863191106,
'co2_net': 347.2300863191106,
'co2_preimp': -172.59000000000003,
'co2_profile': [1536.7817092588934,
817.248992736217,
607.3281103878444,
440.3283897776909,
358.95239431788053,
307.47401925543494,
270.77737356434943,
230.94892180765413,
201.78352047868628,
172.59000000000003],
'co2_total_lifetime': 9174.686955766701,
'co2_total_per_year': 91746.86955766701,
'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}}