knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(dplyr) library(Recca) library(ECCTools) library(EROITools)
The R
package EROITools
provides tools to aggregate Energy Return On Investment (EROI) values previously calculated using a Physical Supply Use Table (PSUT) framework to represent the Energy Conversion Chain (see @Heun:2018). Previous to using the EROITools
package, the World Energy Extended Balances (WEEB) from the International Energy Agency (IEA) can be loaded and tidied using the IEATools
and ECCTools
R
packages. The Recca
R
package then allows analysts to calculate a wide range of EROIs at the product and industry levels, and the EROITools
package provides tools aggregate the calculated EROIs by product group. Important features of the EROITools
package include the following:
The vignettes available for this package detail how to conduct the following tasks:
We use the same example than the one used to describe the ECCTools
package: welcome back to the fictitious AB world (consisting of country A and country B)!
The Energy Conversion Chain of country A is shown in the figure below:
Next figure shows the Energy Conversion Chain of country B.
Let's now have a look to the AB data organised in a .tidy_iea_df
as provided by the ECCTools
package.
# Fix product-level balances within each country ECCTools::tidy_AB_data %>% dplyr::glimpse()
Let us first modify the Energy Conversion Chain to make it compliant with the Domestic Technology Assumption (see the vignettes of the ECCTools
package for more information --- the basic idea is to avoid taking into consideration imports in the supply mix of a given country).
# Transforming Energy Conversion Chain to Domestic Technology Assumption tidy_AB_dta <- ECCTools::tidy_AB_data %>% IEATools::add_psut_matnames() %>% ECCTools::transform_to_dta(requirement_matrices_list = c("U_feed"), select_dta_observations = FALSE) %>% dplyr::glimpse()
Then, we construct the Input-Output matrices needed to conduct the calculations.
# Calculating associated Input-Output matrices tidy_io_AB_dta <- tidy_AB_dta %>% IEATools::prep_psut() %>% Recca::calc_io_mats(method_q_calculation = "sum_R_V_cols") %>% dplyr::glimpse()
Then, we calculate the product-level EROIs in a matrix format.
# Calculating EROI vectors (matrix format) tidy_AB_erois_matrices_dta <- tidy_io_AB_dta %>% Recca::calc_E_EIOU() %>% Recca::calc_erois() %>% dplyr::glimpse()
Last, we can drop the matrix format and extract the product-level EROIs in a tidy data frame format.
# Extracting EROI values to a tidy data frame format tidy_AB_erois_dta <- tidy_AB_erois_matrices_dta %>% EROITools::extract_tidy_product_erois() %>% dplyr::mutate( Eroi.method = "DTA" ) %>% dplyr::relocate(tidyselect::all_of("Eroi.method"), .after = Year) %>% dplyr::glimpse()
Alternatively, we can modify the Energy Conversion Chain to describe energy flows across countries using a Multi-Regional Physical Supply Use Table framework (see @mr_psut_paper). For the sake of simplicity, we use here the Global Market Assumption to demonstrate calculations with the multi-regional framework.
# Transforming Energy Conversion Chain to Global Market Assumption tidy_AB_data_gma <- ECCTools::tidy_AB_data %>% IEATools::add_psut_matnames() %>% ECCTools::transform_to_gma() %>% dplyr::glimpse()
Then, we construct the Input-Output matrices needed to conduct the calculations.
# Calculating associated Input-Output matrices tidy_io_AB_gma <- tidy_AB_data_gma %>% IEATools::prep_psut() %>% Recca::calc_io_mats(method_q_calculation = "sum_R_V_cols") %>% dplyr::glimpse()
Then, we calculate the product-level EROIs in a matric format.
# Calculating EROI vectors (matrix format) tidy_AB_erois_matrices_gma <- tidy_io_AB_gma %>% Recca::calc_E_EIOU() %>% Recca::calc_erois() %>% dplyr::glimpse()
Last, we can drop the matrix format and extract the product-level EROIs in a tidy data frame format.
# Extracting EROI values to a tidy data frame format tidy_AB_erois_gma <- tidy_AB_erois_matrices_gma %>% EROITools::extract_tidy_product_erois() %>% dplyr::mutate( Eroi.method = "GMA" ) %>% dplyr::relocate(tidyselect::all_of("Eroi.method"), .after = Year) %>% dplyr::glimpse()
It can be seen that in the Global Market Assumption, there is only one region ("World"), and that the EROI of each product is specified in function of the region of production (not consumption!) of the product --- information contained in the product name ("Product" column).
The rest of the vignettes will demonstrate the EROITools
package based on the tidy_AB_erois_dta
and tidy_AB_erois_gma
data frames.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.