IndEcol / pymrio

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

Calculating consumption based GHG emission intensities #117

Closed larrydsouza closed 11 months ago

larrydsouza commented 11 months ago

I am new to python, the exiobase database and using pymrio. I tried looking at the documentation but being very new to it I was not able to figure out how to get the desired output.

After multiple attempts and using chatgpt ;) I ended up with this script but not able to successfully extract the desired output. I would like to "Calculate the consumption based emission intensities of all the 200 products for all the 49 regions for just a single impact 'GHG emissions AR5 (GWP100) | GWP100 (IPCC, 2010)'

I would like to use the data for my research to calculate GHG Emissions impacts from purchased products and services (GHG protocol Scope 3 category 1 and category 2)

Any help is appreciated. Thanks!

import pymrio

# Replace 'path_to_data_folder' with the path to the folder containing the Exiobase data files
exio3 = pymrio.parse_exiobase3(path=r"C:/Users/guess/IOT_2022_pxp.zip")

# The 'exio3' variable now contains the parsed Exiobase data in the pymrio format

# Load all relevant matrices from the Exiobase data
exio3.load_all()

# Step 2: Calculate direct emissions
direct_emissions = exio3.S.dot(exio3.F)

# Step 3: Calculate total emissions
total_emissions = exio3.A.dot(direct_emissions)

# Step 4: Calculate consumption-based emissions
consumption_based_emissions = exio3.M.dot(total_emissions)

# Step 5: Adjust for Imports and Exports
consumption_based_emissions -= exio3.D_imp_reg.dot(exio3.M.dot(exio3.D_exp_reg.T))

# Step 6: Calculate consumption-based emission intensities
consumption_based_emission_intensities = consumption_based_emissions / exio3.Y

# Print the result
print(consumption_based_emission_intensities)

# Save the results to a CSV file if needed
# Replace 'path_to_output_file' with the desired output file path
consumption_based_emission_intensities.to_csv(path=r"C:/Users/purchased goods and services/output.csv")
larrydsouza commented 11 months ago

@konstantinstadler

konstantinstadler commented 11 months ago

Hi, exio3 = pymrio.parse_exiobase3(path=r"C:/Users/guess/IOT_2022_pxp.zip") exio3.calc_all() exio3.impacts.D_cba_reg holds the impacts aggregated to regions

see the docs/terminology for the naming of the different tables, all indexing can be done via pandas