Add Extensions
Add Extension¶
Reading Satellite account from Exiobase3 and adding extensions to Exiobase MRSUT
In [1]:
# importing parser functions
from mario import parse_exiobase_3,parse_exiobase_sut
import pandas as pd
In [2]:
# defining the path of files in the your local storage
sut_path = r'MRSUT_2021.zip'
iot_path = r'IOT_2021_ixi.zip'
# parse database
world_IOT = parse_exiobase_3(path= iot_path,version='3.8.1')
world_SUT = parse_exiobase_sut(path= sut_path)
In [3]:
# Checking the configuration of the IOT database
print(world_IOT)
name = None table = IOT scenarios = ['baseline'] Factor of production = 9 Satellite account = 1104 Consumption category = 7 Region = 49 Sector = 163
In [4]:
# Checking the configuration of the SUT database
print(world_SUT)
name = None table = SUT scenarios = ['baseline'] Activity = 163 Commodity = 200 Factor of production = 12 Satellite account = 1 Consumption category = 7 Region = 49
In [6]:
# creating the excel for the aggregation
world_IOT.get_aggregation_excel(path=r'iot_agg.xlsx')
world_SUT.get_aggregation_excel(path=r'sut_agg.xlsx')
aggregate databases to the same level using excel files to (The structure of excel aggregation generated by mario)¶
In [7]:
# reading aggregation file after filling
world_IOT.aggregate(r'iot_agg.xlsx')
world_SUT.aggregate(r'sut_agg.xlsx')
['unused'] does not found in Satellite account and can not be removed. ['unused'] does not found in Satellite account and can not be removed.
In [8]:
# new configuration of database
print(world_IOT)
name = None table = IOT scenarios = ['baseline'] Factor of production = 3 Satellite account = 4 Consumption category = 1 Region = 2 Sector = 3
In [9]:
# new configuration of database
print(world_SUT)
name = None table = SUT scenarios = ['baseline'] Activity = 3 Commodity = 3 Factor of production = 3 Satellite account = 1 Consumption category = 1 Region = 2
In [10]:
# Taking Satellite account from world_IOT
sat_IOT = world_IOT.E
# Taking Satellite account from world_SUT (is empty)
sat_SUT = world_SUT.E
In [11]:
print(sat_IOT)
OECD RoW \ Level Sector Sector Primary Secondary Services Primary Employment 3.247781e+04 1.267968e+05 4.772136e+05 1.519881e+06 CO2 9.345101e+11 6.590698e+12 1.993111e+12 2.101140e+12 CH4 1.254902e+08 6.015730e+08 3.410832e+08 4.609233e+08 N2O 2.589037e+07 1.873298e+08 6.841114e+07 4.911396e+07 Level Secondary Services Employment 7.571914e+05 1.152171e+06 CO2 1.493025e+13 2.048917e+12 CH4 2.841726e+09 8.739974e+08 N2O 4.310659e+08 5.742075e+07
In [12]:
# Creating a dataframe of extensions
new_sat_SUT = pd.DataFrame(0, index=sat_IOT.index, columns=sat_SUT.columns)
In [13]:
# assigning the values to the dataframe
new_sat_SUT.loc[:,(slice(None),'Activity')] = sat_IOT.values
In [14]:
# taking the units from world_IOT satellite
new_units= world_IOT.units['Satellite account']
In [15]:
print(new_units)
unit Employment 1000 p CO2 kg CH4 kg N2O kg
In [16]:
# add extension using the add_extensions function
world_SUT.add_extensions(io= new_sat_SUT,
matrix= 'E',
units= new_units,
inplace=True, # implementing the changes on the database
)
Using add extensions will rewrite the new results on the baseline and delete other scenarios baseline deleted from the database
In [17]:
# plotting the Footprints (F) for extension CP2
world_SUT.plot_matrix(matrix= 'F',
x= 'Activity_to',
color= 'Region_to',
facet_col = 'Satellite account',
filter_Satellite_account = ['CO2'],
path = 'CO2.html',
)
Database: to calculate F following matrices are need. ['f'].Trying to calculate dependencies. Database: to calculate f following matrices are need. ['w'].Trying to calculate dependencies.