knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(dplyr)
library(IEATools)
library(magrittr)

Introduction

The IEA extended energy balance data include some Flows that are Energy industry own use (EIOU), the consumption of energy by energy-producing industries. This vignette demonstrates how to deal with the EIOU flows, especially if an analyst is moving toward performing Physical Supply-Use Table (PSUT) analyses with the IEA data. In particular, this vignette will identify some of the problems with using such flows (as they are present in data from the IEA) and how to use functions in the IEATools package to prepare for PSUT analysis.

We'll use data supplied with this package and accessed by the load_tidy_iea_df() function to illustrate.

The IEA approach to Energy Industry Own Use (EIOU) flows

The EIOU flows can be found as shown in the following code. The Flow column indicates the industry to which EIOU of type Product is flowing.

library(dplyr)
library(IEATools)
library(magrittr)
EIOU_flows <- load_tidy_iea_df() %>%
  filter(Flow.aggregation.point == "Energy industry own use")
EIOU_flows %>%
  select(Country, Year, Flow, Product)

And EIOU-consuming industries can be found by the following code.

EIOU_flows$Flow %>% unique()

Note that one of the industries that receives EIOU is Coal mines (energy), but coal is not produced by Coal mines (energy) in the IEA data. (The suffix (energy) indicates EIOU.) Rather, coal (of various types) first appears in rows where the Flow is Production.

load_tidy_iea_df() %>%
  filter(Flow.aggregation.point == "Total primary energy supply",
         Product %in% coal_and_coal_products) %>%
  select(Country, Flow.aggregation.point, Flow, Product) %>%
  unique()

Problems with the IEA approach to EIOU

There are two problems with the IEA's approach to energy industry own use (EIOU).

Solving the problems presented by the IEA's approach to EIOU

To solve these problems, the following fixed need to be implemented:

The specify_primary_production() function accomplishes these tasks.

Specify primary production (specify_primary_production())

By default, the specify_primary_produciton() function performs the following actions:

The code below demonstrates specify_primary_production(). Note that the Resources Flows are tagged as belonging to the Resources matrix (R) by the add_psut_matnames() function.

Specific_primary_production <- load_tidy_iea_df() %>%
  specify_primary_production() %>%
  add_psut_matnames()
Specific_primary_production %>%
  filter(Flow %in% c("Resources (Coal)", "Resources (Oil and natural gas)")) %>%
  select(-Method, -Last.stage, -Energy.type, -Ledger.side, -Unit) %>%
  as.data.frame()

Furthermore, the added flows from the Resource industries are tagged as Transformation processes and belong in the U_feed and V matrices. The EIOU flows are shown to belong in the U_EIOU matrix.

Specific_primary_production %>%
  filter(Flow %in% c("Coal mines", "Oil and gas extraction")) %>%
  as.data.frame()
Specific_primary_production %>%
  filter(Flow.aggregation.point == "Energy industry own use" ) %>%
  select(Country, Year, Flow, Product, E.dot, matnames) %>%
  as.data.frame()

Convert Production to Resources (specify_production_to_resources())

The IEA extended energy balances give resource extraction in rows where the Flow is "Production". specify_production_to_resources() changes the "Production" string to "Resources (product)", where product is the name of the energy carrier for this resource. specify_production_to_resources() should be called after specify_primary_production(), which adjusts for energy industry own use of some primary energy producing industries. If this function is called first, energy industry own use will not be accounted correctly.

load_tidy_iea_df() %>%
  specify_primary_production() %>%
  specify_production_to_resources() %>%
  filter(startsWith(Flow, "Resources")) %>%
  glimpse()

Be more specific about interface industries (specify_interface_industries())

An interface industry is one that moves energy carriers into or out of a country. When Flow is any of the interface industries, we need to be more specific. If we don't separate these Flows by Product, we run into trouble in the PSUT framework:

To solve these problems, specify_interface_industries() adds a suffix (Product) to each of these interface industries.

Note that "Production" Flows also needs to be specified, but that is accomplished in the specify_primary_production() and specify_production_to_resources() functions.

load_tidy_iea_df() %>%
  specify_interface_industries() %>%
  filter(starts_with_any_of(Flow, IEATools::interface_industries)) %>%
  glimpse()

Be more specific about Transformation process Energy industry own use (specify_tp_eiou())

The extended energy balance data from the IEA present some issues when linking "Energy Industry Own Use" (EIOU) flows to "Transformation processes" flows:

  1. In some instances the data includes "Energy industry own use" (EIOU) flows for industries that are not described as transformation processes. For instance, the "Nuclear industry" appears as an EIOU flow but does not appear as a transformation process.
  2. In some other instances the data includes transformation processes for which no "Energy Industry Own Use" flow is reported. For instance, the "Main activity producer electricity plants" is a transformation process, but no EIOU is associated.

The specify_tp_eiou function enables to deal with these inconsistencies. Effectively, it is a convenience function that bundles together several other functions:

  1. gather_producer_autoproducer()
  2. route_pumped_storage()
  3. split_oil_gas_extraction_eiou()
  4. route_own_use_elect_chp_heat()
  5. add_nuclear_industry()
  6. route_non_specified_eiou()
  7. route_non_specified_tp()

Details can be found in the documentation of each function, but essentially they do the following:

  1. The gather_producer_autoproducer() function gathers separately the transformation processes "Main activity producer plants" and "Autoproducer plants" for each of three types: electricity, heat, and CHP.
  2. The route_pumped_storage() function routes the "Pumped storage plants" EIOU flow to "Main activity producer electricity plants."
  3. The route_own_use_elect_chp_heat() routes the "Own use in electricity, heat and CHP plants" EIOU flow to "Main activity producer electricity plants", "Main activity producer CHP plants," and "Main activity producer heat plants." It does so according to either the input or output shares of each of the industries, depending on the arguments of the function.
  4. The split_oil_gas_extraction_eiou() function splits the EIOU of "Oil and gas extraction" in EIOU of "Oil extraction" and EIOU of "Natural gas extraction", by using the shares of production of each of these industries, meaning that the ratio EIOU to output is the same for "Oil extraction" and "Natural gas extraction".
  5. The add_nuclear_industry() function adds a nuclear industry in transformation processes, and modifies each of the "Main activity producer electricity plants" and "Main activity producer CHP plants" according to their inputs of nuclear fuel as reported by the IEA.
  6. The route_non_specified_eiou() function routes the "Non-specified" EIOU flow to the different EIOU industries. It performs the split according to the shares of use of EIOU of all EIOU industries (excluding the non-specified one).
  7. The route_non_specified_tp() function routes the "Non-specified" transformation processes flows to the different transformation processes industries. It performs the split according to the shares of use and supply of each product, by each transformation process industry (excluding the non-specified one).

The following two pieces of code are therefore equivalent:

load_tidy_iea_df() %>%
  specify_tp_eiou() %>%
  glimpse()

load_tidy_iea_df() %>% 
  gather_producer_autoproducer() %>% 
  route_pumped_storage() %>% 
  split_oil_gas_extraction_eiou() %>% 
  route_own_use_elect_chp_heat() %>% 
  add_nuclear_industry() %>% 
  route_non_specified_eiou() %>% 
  route_non_specified_tp() %>% 
  glimpse()

Identify Transformation process sinks and sources (tp_sinks_sources())

In the IEA extended energy balance data, transformation processes (tp) ought to both consume and produce energy. But some transformation processes consume energy without producing any energy; others produce without consuming. Such transformation processes can be called "transformation sinks" and "transformation sources," respectively. This function finds and identifies transformation processes that act as sinks or sources.

It is important to identify transformation sinks, because they cause two problems for physical supply-use table (PSUT) analysis. First, when swimming upstream, a PSUT analysis cannot "see" the sunk energy carriers, because they have no downstream effects. Thus, upstream swims cannot conserve energy. Second, when calculating embodied energy for each downstream energy carrier, the sunk energy carriers cannot be embodied in any final demand energy carriers. Thus, embodied energy calculations cannot conserve energy.

Transformation sources can also cause problems for physical supply-use table (PSUT) analysis. In particular, when swimming upstream, a PSUT analysis will "see" the final energy sources, but cannot see any associated primary energy carriers.

Transformation sinks and sources are identified by the following algorithm:

  1. Identify (per group in .tidy_iea_df) all Transformation processes that consume energy (negative value for E.dot). Energy consumption can be for the transformation process itself or for Energy industry own use.
  2. Identify (per group in .tidy_iea_df) all Transformation processes that produce energy (positive value for E.dot).
  3. Take the set difference between the two (consumers less producers for sinks and producers less consumers for sources). The set difference is the list of transformation sinks or sources, respectively.

tp_sinks_sources() is a function not unlike dplyr::summarise(); it returns a summary containing grouping variables and industries that are transformation sinks or sources. The various specify_*() functions should also be called before calling [tp_sinks_sources()]. The specify_*() functions clean up the IEA data, ensuring that energy is routed to the right places.

Note that this function only identifies transformation sinks or sources; it does not fix the problem. To solve the problem of transformation sinks, see the [tp_sinks_to_nonenergy()] function. tp_sinks_to_nonenergy() uses the output of tp_sinks_sources() to route energy consumed by transformation sinks to Non-energy use industry/transformation/energy. There is no function to solve the problem of transformation sources at this time.

tp_sinks_sources() returns metadata columns and the Flow column. The Flow column contains industries that are sinks or sources, depending on the value of the type argument.

# The included data sets to not have any transformation process sinks or sources.
# Demonstrate with a made-up data set.
data.frame(Flow = c("Automobiles", "Automobiles", "Furnaces"),
                   E.dot = c(-1, 1, 2),
                   stringsAsFactors = FALSE) %>%
  dplyr::mutate(
    Country = "A country",
    Flow.aggregation.point = "Transformation processes",
    Product = "A product"
  ) %>%
  # Automobiles both consume and produce energy,
  # so Automobiles are not reported by tp_sinks_sources.
  # However, Furnaces make Product without consuming any energy,
  # and are, therefore, a transformation source.
  tp_sinks_sources(type = "sources")

Convert Transformation process sinks to Non-energy flows (tp_sinks_to_nonenergy() )

This function reclassifies energy flowing into transformation process sinks as non_energy_flow, by default "Non-energy use in industry/transformation/energy". If there was already some Non-energy use, the new Non-energy use is added to the existing Non-energy use.

tp_sinks_to_nonenergy() uses the tp_sinks_sources() function internally to identify transformation process sinks.

DF <- data.frame(
  Ledger.side = c("Supply", "Supply", "Supply", "Consumption"),
  Flow.aggregation.point = c("Transformation processes",
                             "Transformation processes",
                             "Transformation processes",
                             "Non-energy use"),
  Flow = c("Automobiles", "Automobiles", "Furnaces",
           "Non-energy use industry/transformation/energy"),
  Product = c("Petrol", "MD", "Coal", "Coal"),
  E.dot = c(-1, 1, -2, 8),
  stringsAsFactors = FALSE
) %>%
  mutate(
    Method = "PCM",
    Last.stage = "Final",
    Energy.type = "E",
    Country = "Bogus",
    Year = 1971
  )
DF
# In this example, Furnaces are a transformation process sink:
# they consume Coal but produce nothing.
# There are already 8 units of Coal consumption for Non-energy uses.
# The 2 units of Coal are added to the existing 8 units
# Non-energy consumption to make 10 units of Non-energy consumption.
DF %>%
  tp_sinks_to_nonenergy() %>%
  as.data.frame()

Put it all together (specify_all())

specify_all() is a convenience function that bundles several others:

  1. specify_primary_production()
  2. specify_production_to_resources()
  3. specify_tp_eiou()
  4. specify_interface_industries()
  5. tp_sinks_to_nonenergy()

Each bundled function is called in turn using default arguments.

Simple <- load_tidy_iea_df() %>%
  specify_all()
Complicated <- load_tidy_iea_df() %>%
  specify_primary_production() %>%
  specify_production_to_resources() %>%
  specify_tp_eiou() %>%
  specify_interface_industries() %>%
  tp_sinks_to_nonenergy()
all(Simple == Complicated)

Conclusion

This vignette demonstrated how to specify details of primary and transformation process flows. The next step could be to prepare the IEA data for use within the PSUT framework. For details, see the Prep PSUT vignette.



MatthewHeun/IEATools documentation built on Feb. 6, 2024, 3:29 p.m.