Beispiel #1
0
def test_parse_exio3(fix_testmrio_calc):
    exio3_mockpath = os.path.join(testpath, "mock_mrios", "exio3_mock")

    test_mrio = fix_testmrio_calc.testmrio

    exio3 = pymrio.parse_exiobase3(exio3_mockpath)
    exio3.calc_all()

    assert np.allclose(exio3.A, test_mrio.A)
    assert np.allclose(exio3.satellite.D_cba, test_mrio.emissions.D_cba)

    # Test the renaming of the regions - depends on the correct pseudo
    # naming in the mock mrio
    assert list(exio3.get_regions()) == ["AU", "BR", "FI", "FR", "KR", "WF"]
Beispiel #2
0
def test_parse_exio3(fix_testmrio_calc):
    exio3_mockpath = os.path.join(testpath, 'mock_mrios', 'exio3_mock')

    test_mrio = fix_testmrio_calc.testmrio

    exio3 = pymrio.parse_exiobase3(exio3_mockpath)
    exio3.calc_all()

    assert np.allclose(exio3.A, test_mrio.A)
    assert np.allclose(exio3.satellite.D_cba, test_mrio.emissions.D_cba)

    # Test the renaming of the regions - depends on the correct pseudo
    # naming in the mock mrio
    assert list(exio3.get_regions()) == ['AU', 'BR', 'FI', 'FR', 'KR', 'WF']
##########################
###### Chargement de la base MRIO
##########################
###### Chargement de la base EORA
#eora_storage = DATA_PATH+'Eora26_2015_bp'
#io_orig = pymrio.parse_eora26(year=2015, path=eora_storage)

###### Chargement de la base EXIOBASE
## Donné par Antoine
exiobase_storage = DATA_PATH + 'IOT_2015_basic.zip'
#maybe unnecessary to get the full path: if so when could keep
#exiobase_storage = data_folder + os.sep + 'IOT_2015_basic.zip'
## Download from exiobase Zenodo
##exiobase_storage = DATA_PATH+'IOT_2015_pxp.zip'
io_orig = pymrio.parse_exiobase3(exiobase_storage)

### Repartition de la combustion des ménages MtCO2 (désagrégation suivant coefficient emissions IMACLIM2010)
F_Y_sec = pd.read_csv(DATA_PATH + 'F_Y_sec.txt',
                      header=[0, 1],
                      index_col=0,
                      sep="\t")

#allocate impact of F_Y_sec to regions of origin proportionaly to origin of final demand
sum_Y_on_region_of_origin = io_orig.Y.sum(level='sector')
#first attempt with Kronecker product but this is actually useless
##Kronecker product with index regions
#nb_regions = io_orig.get_regions().size
#kron_sum_Y_on_region_of_origin =pd.concat([sum_Y_on_region_of_origin] * nb_regions, axis=0, keys=io_orig.get_regions(),names=['region','category','sub_category','sector'])
#kron_F_Y_sec =pd.concat([F_Y_sec] * nb_regions, axis=0, keys=io_orig.get_regions(),names=['region','sector'])
#F_Y_sec_and_reg_2 = (io_orig.Y / kron_sum_Y_on_region_of_origin) * kron_F_Y_sec
Beispiel #4
0
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 22 17:53:35 2020

@author: nigolred
"""

import pymrio
import pywtm as wtm

exiobase3_path = r'C:\Users\Gollinucci\Desktop\Nicolò\Lavoro\FEEM\Databases\exiobase_3.4_iot_2011_ixi.zip'
Agg = r'Inputs\Aggregation.xlsx'
World = pymrio.parse_exiobase3(exiobase3_path)
World.calc_all()

#%% Choose aggregations and factors
wtm.aggregate(World, Agg)
World.calc_all()

#%% Building the needed matrices
wtm.prepare(World)

#%% Running the model and saving the results
import pandas as pd

Cases = ['Baseline',
         'EU_CT',
         'EU_ETS']

allCases = Cases + ['Exiobase']
Sectors = list(World.get_sectors())
Beispiel #5
0
import pandas as pd
import os
import matplotlib.pyplot as plt
# import random
import glob
import numpy as np
# import glob
from numpy.linalg import inv
import zipfile
cwd = os.getcwd()
cwd
import pymrio
# atver atzipotu datu masību
exio3 = pymrio.parse_exiobase3(path=r'C:\tmp\mrios\exio3\2011')
exio3.calc_all()
# final deman vector
exio3.y = exio3.Y.groupby('region', as_index=False).agg("sum")
D_cba = exio3.satellite.M * exio3.y.T