knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(dplyr) library(IEATools) library(magrittr)
The IEA extended energy balance data include some Flow
s 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 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(FlowAggregationPoint == "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(FlowAggregationPoint == "Total primary energy supply", Product %in% coal_and_coal_products) %>% select(Country, FlowAggregationPoint, Flow, Product) %>% unique()
There are two problems with the IEA's approach to energy industry own use (EIOU).
Production
(as the IEA does)
means that some EIOU is routed to an industry that does not produce
anything. In the example above, Electricity
is routed to
Coal mines (energy)
, but coal is produced by Production
.Production
, there will be problems with "upstream swims" in an
Input-Output analysis: demand for one primary energy carrier will
imply proportional demand for all other primary energy carriers.To solve these problems, the following fixed need to be implemented:
Production
Flow
s need to be specified. In the
example above, coal_and_coal_product
s should be produced by
Coal mines
, not the generic Production
industry. Likewise,
oil_product
s should be produced by Oil extraction
, and
gas_product
s by Natural gas extraction
. For all other products,
the production industry is named as Manufacture [of product]
.Production
Flow
s need to come from resources
industries, which supply resource-products, that are then used in
each of the manufacturing industries (Coal mines
,
Oil and gas extraction
, and Manufacture [of product]
) for
manufacturing the actual products.The specify_primary_production()
function accomplishes these tasks.
specify_primary_production()
)By default, the specify_primary_produciton()
function performs the
following actions:
First, Production
Flow
s for a given Product
are duplicated.
Second, the first duplicate of Production
Flow
s for a given
Product
are replaced by a Resource [of Product]
Flow
, which
produces Product [from Resources]
.
Third, the second duplicate of Production
Flow
s for a given
Product
are replaced by a manufacturing industry flow, that takes
as input the Product [from Resources]
supplied by the new
Resource [of Product]
Flow
, and that supplies as output the
actual Product
. The manufacturing industry is named:
Coal mines
in the case of coal_and_coal_products
;Oil extraction
in the case of oil_products
;Natural gas extraction
in the case of natural_gas_products
;Manufacture [of Product]
for all other products.The code below demonstrates specify_primary_production()
. Note that
the Resources
Flow
s 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, -LastStage, -EnergyType, -LedgerSide, -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(FlowAggregationPoint == "Energy industry own use" ) %>% select(Country, Year, Flow, Product, Edot, matnames) %>% as.data.frame()
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()
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 Flow
s by Product
, we run
into trouble in the PSUT framework:
Product
s being produced even if
only one is needed andTo solve these problems, specify_interface_industries()
adds a suffix
(Product)
to each of these interface industries.
Note that "Production
" Flow
s 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()
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:
The specify_tp_eiou
function enables to deal with these
inconsistencies. Effectively, it is a convenience function that bundles
together several other functions:
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()
Details can be found in the documentation of each function, but essentially they do the following:
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.route_pumped_storage()
function routes the "Pumped storage
plants" EIOU flow to "Main activity producer electricity plants."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.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".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.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).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()
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:
.tidy_iea_df
) all
Transformation processes
that consume energy (negative value for
Edot
). Energy consumption can be for the transformation process
itself or for Energy industry own use..tidy_iea_df
) all
Transformation processes
that produce energy (positive value for
Edot
).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"), Edot = c(-1, 1, 2), stringsAsFactors = FALSE) %>% dplyr::mutate( Country = "A country", FlowAggregationPoint = "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")
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"), FlowAggregationPoint = 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"), Edot = c(-1, 1, -2, 8), stringsAsFactors = FALSE ) %>% mutate( Method = "PCM", LastStage = "Final", EnergyType = "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()
specify_all()
)specify_all()
is a convenience function that bundles several others:
specify_primary_production()
specify_production_to_resources()
specify_tp_eiou()
specify_interface_industries()
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)
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.