IEooc_Methods5_Software1: IPython notebook for MRIO analysis
1. Load and check data
import numpy as np
import scipy.io
# Specify path of data file IEooc_Methods5_Software1_Data_EXIOBASEv3_3R_11P_ITC.mat. If you only specify the file name as below, the data file must be in the same directory and the notebook.
Filestring_Matlab_in = 'IEooc_Methods5_Software1_Data_EXIOBASEv3_3R_11P_ITC.mat'
MRIO_L = scipy.io.loadmat(Filestring_Matlab_in)['L'] # The Leontief inverse
MRIO_S = scipy.io.loadmat(Filestring_Matlab_in)['S'] # The stressor matrix
MRIO_Y = scipy.io.loadmat(Filestring_Matlab_in)['Y'] # The final demand matrix
MRIO_FY = scipy.io.loadmat(Filestring_Matlab_in)['F_Y'] # Emissions of final demand sectors
MRIO_Re = scipy.io.loadmat(Filestring_Matlab_in)['Region_List'] # List of regions
MRIO_Pr = scipy.io.loadmat(Filestring_Matlab_in)['Product_Names'] # List of 11 products, aggregated from 200 original products
MRIO_In = scipy.io.loadmat(Filestring_Matlab_in)['Industry_Names'] # List of 11 industries, aggregated from 163 original products
MRIO_Ex = scipy.io.loadmat(Filestring_Matlab_in)['Extensions_Labels'] # List of 170 extensions
MRIO_Ca = scipy.io.loadmat(Filestring_Matlab_in)['Midpoints_Names'] # List of 5 characterisation categories (for climate change)
MRIO_CU = scipy.io.loadmat(Filestring_Matlab_in)['Midpoints_Units'] # List of 5 characterisation categories units
MRIO_Cf = scipy.io.loadmat(Filestring_Matlab_in)['C'] # Matrix of characterisation factors
scipy.io.loadmat(Filestring_Matlab_in).keys() # Display all variable names in MRIO data file
We have 11 industries/products, 3 regions, 170 emissions, and 5 midpoint indicators. That gives the following shapes:
Y: (33 x 3): 33 products (3 regions of production with 11 products each) x 3 regions of consumption
L: (33 x 33): 33 products (3 regions of production with 11 products each) x 33 industries (3 regions of consumption with 11 industries each)
S: (170 x 33): 170 environmental stressors from 33 industries (3 regions with 11 industries each)
C: (5 x 170): 5 environmental midpoints calculated as weighted sum of the 170 stressors
2. The Y vector:
Y is not a vector but a matrix, where for each of the 3 regions the final demand is recorded:
For regional footprint calculations we slice the Y vector.
For example, to obtain the final demand of the EU27, we specify:
Y_EU27 = MRIO_Y[:,0]
Y_EU27.sum() # Total final demand of the EU27 in MEUR.
11560141.591469785
This is because the EU27 is no. 1 (0 in Python) in the country list, so there are two other countries (China and RoW) with a final demand column each.
The first column of MRIO_Y is the column for total final demand in the EU27. This column contains the final demand of all consumers, for all products and from all regions. For example, final demand for product no. 4 (3 in Python), manufactured goods, is fullfilled both with domestic production and with imports from the other regions:
Y_EU27_MaGo = Y_EU27[3::11]
Y_EU27_MaGo.shape
ind = Y_EU27_MaGo.argsort() # sort
for m in range(0,3):
print(MRIO_Re[ind[2-m]], ' ', Y_EU27_MaGo[ind[2-m]], 'MEUR')
EU27 1348186.15573 MEUR
Rest of the world 207581.82449 MEUR
China 74440.3135556 MEUR
3. First MRIO analyses with EXIOBASE2:
- Obtain entire global emissions:
GlobalFootprint_ByRegion = MRIO_S.dot(MRIO_L).dot(MRIO_Y)
GlobalFootprint_ByRegion.shape
(170, 3)
The result is a 170 emissions by 3 final demand regions array. The global total emissions are obtained by selecting specific rows:
print(MRIO_Ex[0])
print(str(GlobalFootprint_ByRegion[0,:].sum()/1e9) + ' Mt')
['CO2 - combustion', 'air', 'kg']
24542.9919123 Mt
Footprint_EU27 = GlobalFootprint_ByRegion[0,0] # first emissions line, first region
print(Footprint_EU27/1e9) # CO2 - combustion', 'air', 'Mt'
780.67881489
- Aggregate emissions to midpoint indicators
Done by multiplying the emissions array with the matrix of characterisation factors. We choose the global warming potential with 100 year time horizon taken from the CML method.
MRIO_MidPoints = MRIO_Cf.dot(GlobalFootprint_ByRegion)
MRIO_MidPoints.shape
print(MRIO_Ca[4])
MRIO_MidPoints[4,:].sum()/1e12 # 2007 global carbon emissions in Gt of CO2-eq
Global Warming Potential 100
31.820460778824611
3.Product-specific footprints, example: EU27 final consumption.
The equation is as follows, the hat symbolizes matrix diagonalisation.
c=C⋅S⋅L⋅Y
Y_EU27_expanded = np.diag(MRIO_Y[:,0]) # That is Y^
Y_EU27_expanded.shape
Y^
MRIO_MidPoints_EU27_Productspecific = MRIO_Cf.dot(MRIO_S).dot(MRIO_L).dot(Y_EU27_expanded)
MRIO_MidPoints_EU27_Productspecific.shape
print(MRIO_MidPoints_EU27_Productspecific[4,3::11].sum()/1e9)
# Carbon footprint of
# producing all manufactured goods
# bought by EU27 final consumers, 2007, Mt of CO2-eq
MidPoints_EU27_MaGo = MRIO_MidPoints_EU27_Productspecific[4,3::11]
ind = MidPoints_EU27_MaGo.argsort() # sort
for m in range(0,3):
print(MRIO_Re[ind[2-m]], ' ', MidPoints_EU27_MaGo[ind[2-m]]/1e9, 'Mt of CO2-eq')
EU27 876.172026335 Mt of CO2-eq
China 236.56138626 Mt of CO2-eq
Rest of the world 229.507592849 Mt of CO2-eq
The results above show where in the world the emissions in the supply chain of manufactured goods consumed in the EU27 occur. Next, we display the footprints by region and product group for all products:
GWP_EU27_ByProduct = MRIO_MidPoints_EU27_Productspecific[4,:]
# GWP by product consumed and region where product was produced and imported from.
ind = GWP_EU27_ByProduct.argsort() # sort
for m in range(0,33):
print(MRIO_Re[ind[32-m] // 11], ', ',
MRIO_Pr[ind[32-m] % 11][0:30], ': ',
GWP_EU27_ByProduct[ind[32-m]]/1e9, 'Mt of CO2-eq')
EU27 , Services : 3018.45118207 Mt of CO2-eq
EU27 , Manufactured goods : 876.172026335 Mt of CO2-eq
EU27 , Energy : 823.932610578 Mt of CO2-eq
EU27 , Food : 285.195259854 Mt of CO2-eq
China , Manufactured goods : 236.56138626 Mt of CO2-eq
EU27 , Materials : 233.605927194 Mt of CO2-eq
Rest of the world , Manufactured goods : 229.507592849 Mt of CO2-eq
Rest of the world , Materials : 206.748138529 Mt of CO2-eq
China , Materials : 138.835060898 Mt of CO2-eq
Rest of the world , Energy : 116.783524239 Mt of CO2-eq
EU27 , Crops : 81.8779934981 Mt of CO2-eq
Rest of the world , Services : 55.208925035 Mt of CO2-eq
Rest of the world , Food : 30.63698456 Mt of CO2-eq
Rest of the world , Ores : 23.6069814121 Mt of CO2-eq
China , Services : 17.6124735753 Mt of CO2-eq
EU27 , Energy recovery services : 15.0568204723 Mt of CO2-eq
Rest of the world , Crops : 15.0056764239 Mt of CO2-eq
EU27 , Landfilling services : 11.788474204 Mt of CO2-eq
EU27 , Recycling services : 10.517360726 Mt of CO2-eq
China , Food : 6.8633184641 Mt of CO2-eq
EU27 , Ores : 6.80963628425 Mt of CO2-eq
China , Crops : 3.62796526961 Mt of CO2-eq
China , Ores : 0.196146819806 Mt of CO2-eq
Rest of the world , Energy recovery services : 0.194612033363 Mt of CO2-eq
Rest of the world , Recycling services : 0.190291286218 Mt of CO2-eq
Rest of the world , Landfilling services : 0.135683773346 Mt of CO2-eq
China , Energy : 0.0434908951208 Mt of CO2-eq
EU27 , Waste : 0.0 Mt of CO2-eq
China , Waste : 0.0 Mt of CO2-eq
China , Recycling services : 0.0 Mt of CO2-eq
China , Energy recovery services : 0.0 Mt of CO2-eq
China , Landfilling services : 0.0 Mt of CO2-eq
Rest of the world , Waste : 0.0 Mt of CO2-eq
The results above show which products contribute most to the EU27 total GWP, and where these products were produced (= where they were imported from). Services generated within the EU27 contribute with more than 3000 Mt, almost half of the total. Serives imported from ROW only contribute with 55 Mt, but manufactured goods from China still with ca. 240 Mt.
Efficient calculation of consumption-based env. accounts with MRIO
The common textbook application of the Leontief input output (IO) model uses several matrix multiplications to calculated an environmental footprint c of a final demand y:
c = C*S*L*y
Here, L is the Leontief inverse, S the emissions by industry stressor matrix and C the midpoint by emissions matrix of characterization factors. the equation contains three matrix multiplications, which sum up over the product dimension L*y, industry dimension S*L and emissions dimension C*S. If one wants to know more about the composition of the footprint, which instruies contribute most to it, the summation must be suppressed. The common way to do that is to diagonalise the intermediate results, to take the vectors that are computed as intermediate results, by x = L*y, and diagonalise them to get one extra dimension.
Another common task is to get a regional breakdown of emissions in a multiregional IO calculation. In the standard setup of MRIO tables, things are a bit tricky, as the region dimension is nested with the product dimension (columns are the consumption side= and with the industry dimension (rows are the production side).
Here, it is shown how these questions can be answered elegantly by organising the footprints as multidimensional arrays instead of using tables with multi-indices. To perform these calculations, two elegant and powerful numpy functions are used: reshape and einsum.
The result of the work will be an account of the territorial,
export, import, and consumption-based emissions of the EU in 2011, broken down
by industries or products, as shown in the figure below.
Note 1: For a more systematic evaluation of results, using unit-tested software, please have a look and the open MRIO analysis class pymrio: https://github.com/konstantinstadler/pymrio
Calculate footprints
The final demand matrix Y has the indices (region of production rp x product p) x (region of consumption rc x final demand category y).
The Leontief inverse L has the indices (region of industry location ri x industry i) x (region of production rp x product p).
The stressor matrix S has the indices (environmental extension e) x (region of industry location ri x industry i).
The characterisation factor matrix C has the indices environmental midpoint m x environmental extension e
The most detailed result we can obtain from the EE-MRIO model is the footprint of midpoint m of region of consumption rc, broken down into:
- emission type e
- emitting industry i
- location of emitting industry ri
- region of production of final commodities consumes rp
- product consumed p
- final demand category y
When matrix-multiplying L and Y the (region of production rp x product p) index is summed up. Since we want to keep it explicit to study footprint by products, we have to suppress the summing up of the index. In numpy, this matrix multiplication without summation is best done with numpy.einsum.
- Get link
- Other Apps
- Get link
- Other Apps
Comments
Post a Comment