calculate_p_ex_product: Calculate total primary energy by product

View source: R/tes_tfc_functions.R

calculate_p_ex_productR Documentation

Calculate total primary energy by product

Description

Calculate the total energy supply (TES) in primary energy terms by product. This metric was formerly called the total primary energy supply (TPES). This function first uses the uses Recca::find_p_industry_names() function, with a user-supplied set of primary industry prefixes p_industry_prefixes to identify the primary industries desired for analysis. The Recca::primary_aggregates() function is then applied to .sutdata data frame by product, to calculate the total energy supply across all flows for each product.

Usage

calculate_p_ex_product(
  .sutdata,
  p_industry_prefixes,
  country_colname = IEATools::iea_cols$country,
  method_colname = IEATools::iea_cols$method,
  energy_type_colname = IEATools::iea_cols$energy_type,
  year_colname = IEATools::iea_cols$year,
  flow_colname = PFUWorkflow::sea_cols$flow_colname,
  e_product_colname = PFUWorkflow::sea_cols$e_product_colname,
  stage_colname = PFUWorkflow::sea_cols$stage_colname,
  gross_net_colname = PFUWorkflow::sea_cols$gross_net_colname,
  agg_by_colname = PFUWorkflow::sea_cols$agg_by_colname,
  p_ind_comp_colname = PFUWorkflow::sea_cols$p_ind_comp_colname,
  p_ind_prefix_colname = PFUWorkflow::sea_cols$p_ind_prefix_colname,
  ex_colname = PFUWorkflow::sea_cols$ex_colname,
  ex_p_colname = PFUWorkflow::sea_cols$ex_p_colname,
  primary_value = IEATools::all_stages$primary,
  all_value = PFUWorkflow::agg_metadata$all_value,
  product_value = PFUWorkflow::agg_metadata$product_value
)

Arguments

.sutdata

A data frame containing Physical Supply-Use Table (PSUT) matrices.

p_industry_prefixes

A character vector of primary energy industry prefixes. Usually "Resources", "Imports", and "Stock changes".

country_colname, method_colname, energy_type_colname, year_colname

See IEATools::iea_cols.

flow_colname, e_product_colname, stage_colname, gross_net_colname, agg_by_colname, p_ind_comp_colname, p_ind_prefix_colname, ex_colname, ex_p_colname

See PFUWorkflow::sea_cols.

primary_value

The string "Primary", representing the Primary stage of the energy conversion chain, see IEATools::all_stages.

all_value, product_value

See PFUWorkflow::agg_metadata.

Value

A data frame containing aggregate primary energy/exergy data by product

Examples

library(Recca)
total_energy_supply <- Recca::UKEnergy2000mats %>%
                         tidyr::pivot_wider(names_from = matrix.name,
                                            values_from = matrix) %>%
                         dplyr::mutate(Method = "PCM") %>%
     calculate_p_ex_product(p_industry_prefixes = list(c("Resources", "Imports")))


MatthewHeun/SEAPSUTWorkflow documentation built on April 22, 2022, 2:21 p.m.