IndEcol / pymrio

Multi-Regional Input-Output Analysis in Python.
http://pymrio.readthedocs.io/en/latest/
Other
155 stars 71 forks source link

Calculating the consumption-based footprint of a specific sector in a specific region #70

Open jbnsn opened 3 years ago

jbnsn commented 3 years ago

After running exio3.calc_all() the consumption-based footprint of a region can be calculated via consumption_based_footprint = exio3.et1_diag.D_cba.sum(axis=0).DE.reset_index(). Is there also a way to calculate the consumption-based footprint of just one specific sector in a specific region?

konstantinstadler commented 3 years ago

Regional footprints are immediatly available at exio3.EXTENSION.D_cba_reg For the specific calculations you can just filter the result D_cba with the sector you need - or do I misunderstand your questions

jbnsn commented 3 years ago

Hello and thank you for your swift response! I was thinking of another approach but yours is actually much more lean and straightforward. Thank you for your helpful response.

jbnsn commented 3 years ago

Sorry but I have to reopen this issue. After looking into this again, I realised that I am still unable to answer my question.

I would like to calculate the consumption-based footprint (and eventually also the production-based footprint) for the final demand of a specific sector in a specific region.

If I understand it correct, the consumption-based footprint of all sectors in all regions can be calculated via:

import pymrio
import pandas as pd

# %% Import Exiobase

exio3_path = '/IOT_2021_pxp/'
exio3 = pymrio.parse_exiobase3(path=exio3_path)
production_matrix_F = exio3.satellite.F 

# %% Determine target satellites

target_satellites = production_matrix_F.index[
    production_matrix_F.index.str.contains('Water Consumption Blue - Agriculture - rice')
    | production_matrix_F.index.str.contains('Water Consumption Blue - Agriculture - wheat')
    ]

# %% Create dict for saving results
results_consumption_based_footprint = {}

# %% For all target satellites
for i, target_satellite in enumerate(target_satellites):

    et1_diag = exio3.satellite.diag_stressor(
        (target_satellite),
        name = target_satellite
        )

    # Connect back to the system 
    exio3.et1_diag = et1_diag

    # Calulate all the stressor accounts 
    exio3.calc_all()

    # Save the consumption-based grouped footprint of a region to dict
    results_consumption_based_footprint[target_satellite] = exio3.et1_diag.D_cba.sum(axis=0)

You suggest to filter the resulting DF results_consumption_based_footprint for the intended region and sector. However, the result is a single value.

What I am interested is a list of all 9800 sectors in the exiobase-database and how much they contribute to the final demand of one single afore-defined sector. For this, I suppose, all values except of one in the final demand sector would need to be set to zero before the calculation. The result should be a vector with the dimension 9800 rows times 1 column for each satellite.

sy123354 commented 3 months ago

Hi, I'm having this problem too, have you solved it yet?