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.
In [18]:
# plot gdp: plotting GDP and haveing the abosulte CO2 sectoral production as the color scale
world_SUT.plot_gdp(extension='CO2',extension_value='absolute',path='gdp.html')
In [19]:
# looking at metadata history
world_SUT.meta_history
[11:53:37] Table added into metadata with value equal to SUT. [11:53:37] Price added into metadata with value equal to None. [11:53:37] Source added into metadata with value equal to Exiobase Monetary Multi Regional Supply and Use Table (https://www.exiobase.eu/). [11:53:37] Year added into metadata with value equal to None. [11:53:37] Database successfully imported. [11:53:37] Number of Region = 49 [11:53:37] Number of Consumption category = 7 [11:53:37] Number of Satellite account = 1 [11:53:37] Number of Factor of production = 12 [11:53:37] Number of Sector = 363 [11:53:37] Number of Activity = 163 [11:53:37] Number of Commodity = 200 [11:54:09] original matrices changed to the aggregated level based on the inputs from sut_agg.xlsx [11:54:09] Region aggregated from 49 levels to 2 levels [11:54:09] Consumption category aggregated from 7 levels to 1 levels [11:54:09] Satellite account aggregated from 1 levels to 1 levels [11:54:09] Factor of production aggregated from 12 levels to 3 levels [11:54:09] Sector aggregated from 363 levels to 363 levels [11:54:09] Activity aggregated from 163 levels to 3 levels [11:54:09] Commodity aggregated from 200 levels to 3 levels [11:54:09] baseline deleted from the database [11:54:09] Modification: new 'Satellite account' added to the database as follow: ['CH4', 'CO2', 'Employment', 'N2O']