R/zchunk_L232.industry_korea.R

Defines functions module_gcam.korea_L232.industry_korea

#' module_gcam.korea_L232.industry_korea
#'
#' Prepare level 2 industry sector files for Korea
#'
#' @param command API command to execute
#' @param ... other optional parameters, depending on command
#' @return Depends on \code{command}: either a vector of required inputs,
#' a vector of output names, or (if \code{command} is "MAKE") all
#' the generated outputs: \code{L232.DeleteSupplysector_koreaInd}, \code{L232.DeleteFinalDemand_koreaInd},
#' \code{object}, \code{L232.StubTechCalInput_indenergy_korea}, \code{L232.StubTechCalInput_indfeed_korea},
#' \code{L232.StubTechProd_industry_korea}, \code{L232.StubTechCoef_industry_korea},
#' \code{L232.StubTechMarket_ind_korea}, \code{L232.StubTechSecMarket_ind_korea}, \code{L232.BaseService_ind_korea}. The corresponding file in the
#' original data system was \code{L232.industry_korea.R} (gcam-korea level2).
#' @details Prepare level 2 industry sector files for Korea
#' @importFrom assertthat assert_that
#' @importFrom dplyr filter mutate select
#' @importFrom tidyr gather spread
#' @author S. Jeon
module_gcam.korea_L232.industry_korea <- function(command, ...) {
  if(command == driver.DECLARE_INPUTS) {
    return(c(FILE = "gcam-korea/states_subregions",
             FILE = "energy/A32.demand",
             FILE = "energy/A32.globaltech_eff",
             FILE = "energy/calibrated_techs",
             FILE = "gcam-korea/kor_ind_inc_elasticity_for_realitycheck",
             "L232.Supplysector_ind",
             "L232.StubTech_ind",
             "L232.PerCapitaBased_ind",
             "L132.in_EJ_korea_indnochp_F",
             "L132.in_EJ_korea_indfeed_F",
             "L132.in_EJ_korea_indchp_F",
             "L232.Supplysector_ind",
             "L232.FinalEnergyKeyword_ind",
             "L232.SubsectorLogit_ind",
             "L232.SubsectorShrwtFllt_ind",
             "L232.SubsectorInterp_ind",
             "L232.StubTech_ind",
             "L232.StubTechInterp_ind",
             "L232.PerCapitaBased_ind",
             "L232.PriceElasticity_ind",
             "L232.IncomeElasticity_ind_gcam3"))
  } else if(command == driver.DECLARE_OUTPUTS) {
    return(c("L232.DeleteSupplysector_koreaInd",
             "L232.DeleteFinalDemand_koreaInd",
             "L232.StubTechCalInput_indenergy_korea",
             "L232.StubTechCalInput_indfeed_korea",
             "L232.StubTechProd_industry_korea",
             "L232.StubTechCoef_industry_korea",
             "L232.StubTechMarket_ind_korea",
             "L232.StubTechSecMarket_ind_korea",
             "L232.BaseService_ind_korea",
             "L232.Supplysector_ind_korea",
             "L232.FinalEnergyKeyword_ind_korea",
             "L232.SubsectorLogit_ind_korea",
             "L232.SubsectorShrwtFllt_ind_korea",
             "L232.SubsectorInterp_ind_korea",
             "L232.StubTech_ind_korea",
             "L232.StubTechInterp_ind_korea",
             "L232.PerCapitaBased_ind_korea",
             "L232.PriceElasticity_ind_korea",
             "L232.IncomeElasticity_ind_gcam3_korea"))
  } else if(command == driver.MAKE) {

    year <- value <- output_tot <- grid_region <- market.name <-
      calOutputValue <- calibrated.value <- calibration <- technology <-
      efficiency <- fuel <- minicam.energy.input <- object <-
      output_tot <- region <- secondary.output <- sector <- state <-
      subs.share.weight <- subsector <- supplysector <- value <- x <- NULL

    all_data <- list(...)[[1]]

    # Load required inputs
    states_subregions <- get_data(all_data, "gcam-korea/states_subregions")
    A32.demand <- get_data(all_data, "energy/A32.demand")
    A32.globaltech_eff <- get_data(all_data, "energy/A32.globaltech_eff")
    calibrated_techs <- get_data(all_data, "energy/calibrated_techs")
    L232.Supplysector_ind <- get_data(all_data, "L232.Supplysector_ind")
    L232.StubTech_ind <- get_data(all_data, "L232.StubTech_ind")
    L232.PerCapitaBased_ind <- get_data(all_data, "L232.PerCapitaBased_ind")
    L132.in_EJ_korea_indnochp_F <- get_data(all_data, "L132.in_EJ_korea_indnochp_F")
    L132.in_EJ_korea_indfeed_F <- get_data(all_data, "L132.in_EJ_korea_indfeed_F")
    L132.in_EJ_korea_indchp_F <- get_data(all_data, "L132.in_EJ_korea_indchp_F")
    L232.Supplysector_ind <- get_data(all_data, "L232.Supplysector_ind")
    L232.FinalEnergyKeyword_ind <- get_data(all_data, "L232.FinalEnergyKeyword_ind")
    L232.SubsectorLogit_ind <- get_data(all_data, "L232.SubsectorLogit_ind")
    L232.SubsectorShrwtFllt_ind <- get_data(all_data, "L232.SubsectorShrwtFllt_ind")
    L232.SubsectorInterp_ind <- get_data(all_data, "L232.SubsectorInterp_ind")
    L232.StubTech_ind <- get_data(all_data, "L232.StubTech_ind")
    L232.StubTechInterp_ind <- get_data(all_data, "L232.StubTechInterp_ind")
    L232.PerCapitaBased_ind <- get_data(all_data, "L232.PerCapitaBased_ind")
    L232.PriceElasticity_ind <- get_data(all_data, "L232.PriceElasticity_ind")
    L232.IncomeElasticity_ind_gcam3 <- get_data(all_data, "L232.IncomeElasticity_ind_gcam3")
    kor_ind_inc_elasticity_for_realitycheck <- get_data(all_data, "gcam-korea/kor_ind_inc_elasticity_for_realitycheck")

    # ===================================================

    # convert to long form
    A32.globaltech_eff %>%
      gather_years -> A32.globaltech_eff

    # delete industry sectors in the USA region (energy-final-demands and supplysectors)
    L232.Supplysector_ind %>%
      mutate(region = region) %>% # strip attributes from object
      filter(region == gcamkorea.REGION) %>%
      select(LEVEL2_DATA_NAMES[["DeleteSupplysector"]]) ->
      L232.DeleteSupplysector_koreaInd  ## OUTPUT

    # deleting energy final demand sectors in the full USA region")
    L232.PerCapitaBased_ind %>%
      mutate(region = region) %>% # strip attributes from object
      filter(region == gcamkorea.REGION) %>%
      select(LEVEL2_DATA_NAMES[["DeleteFinalDemand"]]) ->
      L232.DeleteFinalDemand_koreaInd  ## OUTPUT

    # The industry_korea_processing function is used in place of a for loop in the old data sytem.
    # This function checks to see if the input data needs to be expanded to all states or used as
    # is.

    # industry_korea_processing: is a function that
    industry_korea_processing <- function(data) {

      # Subset the input data frame for the USA region. The subsetted data will be used
      # to check to see if the data frame needs to be processed, it's assumed that if the USA
      # is not found in the region column that regions have already been processed.

      check_kor <- filter(data, region == gcamkorea.REGION)

      if(nrow(check_kor) == 0) {

        # This does not change the entries of the data frame but will strip the attributes
        # from the input data frame.
        new_data <- mutate(data, region = region)

      } else {

        # If the input data frame contains USA region information
        # then expand the input data to all states.

        data %>%
          filter(region == gcamkorea.REGION) %>%
          write_to_all_states(names = names(data), region_states=gcamkorea.STATES) ->
          new_data

      }

      return(new_data)
    } # end of function

    L232.Supplysector_ind_korea <- industry_korea_processing(L232.Supplysector_ind)
    L232.FinalEnergyKeyword_ind_korea <- industry_korea_processing(L232.FinalEnergyKeyword_ind)
    L232.SubsectorLogit_ind_korea <- industry_korea_processing(L232.SubsectorLogit_ind)
    L232.SubsectorShrwtFllt_ind_korea <- industry_korea_processing(L232.SubsectorShrwtFllt_ind)
    L232.SubsectorInterp_ind_korea <- industry_korea_processing(L232.SubsectorInterp_ind)
    L232.StubTech_ind_korea <- industry_korea_processing(L232.StubTech_ind)
    L232.StubTechInterp_ind_korea <- industry_korea_processing(L232.StubTechInterp_ind)
    L232.PerCapitaBased_ind_korea <- industry_korea_processing(L232.PerCapitaBased_ind)
    L232.PriceElasticity_ind_korea <- industry_korea_processing(L232.PriceElasticity_ind)
    L232.IncomeElasticity_ind_gcam3_korea <- industry_korea_processing(L232.IncomeElasticity_ind_gcam3)


    ## Written by Jeon ## Start
    # Make historical tredns plausible
    L232.IncomeElasticity_ind_gcam3_korea %>%
      left_join(kor_ind_inc_elasticity_for_realitycheck, by = c("region", "energy.final.demand", "year")) %>%
      mutate( income.elasticity = ifelse( is.na(income.elasticity.y),
                                          income.elasticity.x,
                                          income.elasticity.y)) %>%
      select(region, energy.final.demand, year, income.elasticity) -> L232.IncomeElasticity_ind_gcam3_korea
    ## Written by Jeon ## Start



    # get calibrated input of industrial energy use technologies, including cogen
    L132.in_EJ_korea_indnochp_F %>%
      bind_rows(L132.in_EJ_korea_indchp_F) %>%
      complete(nesting(state, sector, fuel), year = c(year, MODEL_BASE_YEARS)) %>%
      group_by(state, sector, fuel) %>% mutate(value = approx_fun(year, value)) %>%
      ungroup %>% filter(year %in% MODEL_BASE_YEARS) %>%
      rename(region = state) %>%
      left_join_keep_first_only(calibrated_techs, by = c("sector", "fuel")) %>%
      rename(stub.technology = technology) ->
      L232.in_EJ_korea_indenergy_F_Yh
    L232.in_EJ_korea_indenergy_F_Yh %>% select(LEVEL2_DATA_NAMES[["StubTechYr"]], "value") %>%
      left_join_keep_first_only(select(A32.globaltech_eff, subsector, technology, minicam.energy.input),
                                by = c("subsector", "stub.technology" = "technology")) %>%
      mutate(calibrated.value = round(value, energy.DIGITS_CALOUTPUT),
             share.weight.year = year,
             tech.share.weight = if_else(calibrated.value > 0, 1, 0)) %>%
      group_by(region, supplysector, subsector, year) %>%
      mutate(x = sum(calibrated.value),
             subs.share.weight = if_else(x > 0, 1, 0)) %>% ungroup %>%
      # ^^ sets up variable (x) for defining subsector shareweight
      select(LEVEL2_DATA_NAMES[["StubTechCalInput"]]) ->
      L232.StubTechCalInput_indenergy_korea  ## OUTPUT

    # get calibrated input of industrial feedstock technologies
    L132.in_EJ_korea_indfeed_F %>%
      complete(nesting(state, sector, fuel), year = c(year, MODEL_BASE_YEARS)) %>%
      group_by(state, sector, fuel) %>% mutate(value = approx_fun(year, value)) %>%
      ungroup %>% filter(year %in% MODEL_BASE_YEARS) %>%
      rename(region = state) %>%
      left_join_keep_first_only(calibrated_techs, by = c("sector", "fuel")) %>%
      select(-calibration, -secondary.output) %>%
      rename(stub.technology = technology) ->
      L232.in_EJ_korea_indfeed_F_Yh
    L232.in_EJ_korea_indfeed_F_Yh %>% select(LEVEL2_DATA_NAMES[["StubTechYr"]], "value") %>%
      left_join_keep_first_only(select(A32.globaltech_eff, subsector, technology, minicam.energy.input),
                                by = c("subsector", "stub.technology" = "technology")) %>%
      mutate(calibrated.value = round(value, energy.DIGITS_CALOUTPUT),
             share.weight.year = year,
             tech.share.weight = if_else(calibrated.value > 0, 1, 0)) %>%
      group_by(region, supplysector, subsector, year) %>% mutate(x = sum(calibrated.value)) %>%
      # ^^ sets up variable (x) for defining subsector shareweight
      mutate(subs.share.weight = if_else(x > 0, 1, 0)) %>% ungroup %>%
      select(LEVEL2_DATA_NAMES[["StubTechCalInput"]]) ->
      L232.StubTechCalInput_indfeed_korea  ## OUTPUT

    # get industrial sector calibrated output
    A32.globaltech_eff %>%
      complete(nesting(supplysector, subsector, technology, minicam.energy.input, secondary.output),
               year = c(year, MODEL_BASE_YEARS)) %>%
      group_by(supplysector, subsector, technology, minicam.energy.input, secondary.output) %>%
      mutate(value = approx_fun(year, value)) %>% ungroup %>%
      filter(year %in% MODEL_BASE_YEARS) %>%
      rename(efficiency = value) %>%
      mutate(efficiency = round(efficiency, energy.DIGITS_EFFICIENCY)) ->
      A32.globaltech_eff_interp

    L232.in_EJ_korea_indenergy_F_Yh %>%
      bind_rows(L232.in_EJ_korea_indfeed_F_Yh) %>%
      left_join_keep_first_only(select(A32.globaltech_eff_interp, supplysector, subsector, technology, year, efficiency),
                                by = c("supplysector", "subsector", "stub.technology" = "technology", "year")) %>%
      mutate(calOutputValue = round(value * efficiency, energy.DIGITS_CALOUTPUT)) ->
      L232.out_EJ_korea_ind_serv_F_Yh
      # ^^ service output, by technology, for energy-use and feedstocks

    L232.out_EJ_korea_ind_serv_F_Yh %>%
      group_by(region, year) %>%
      summarise(calOutputValue = sum(calOutputValue)) %>% ungroup %>%
      # ^^ aggregate to get output of industrial sector in each region
      mutate(supplysector = "industry",
             subsector = "industry",
             stub.technology = "industry",
             share.weight.year = year,
             subs.share.weight = if_else(calOutputValue > 0, 1, 0),
             tech.share.weight = subs.share.weight) %>%
      select(LEVEL2_DATA_NAMES[["StubTechProd"]]) ->
      L232.StubTechProd_industry_korea  ## OUTPUT

    # get calibrated output of industrial sector
    L232.out_EJ_korea_ind_serv_F_Yh %>%
      group_by(region, supplysector, year) %>%
      summarise(calOutputValue = sum(calOutputValue)) %>% ungroup %>%
      # ^^ aggregate service output by sector
      left_join_keep_first_only(L232.StubTechProd_industry_korea %>%
                                  rename(output_tot = calOutputValue) %>% select(region, year, output_tot),
                                by = c("region", "year")) %>%
      mutate(coefficient = round(calOutputValue / output_tot, energy.DIGITS_COEFFICIENT)) %>%
      # ^^ get coefficient
      rename(minicam.energy.input = supplysector) %>%
      mutate(supplysector = "industry",
             subsector = "industry",
             stub.technology = "industry",
             market.name = region) ->
      L232.StubTechCoef_industry_korea_base
    # ^^ covers only base years

    L232.StubTechCoef_industry_korea_base %>%
      filter(year == max(MODEL_BASE_YEARS)) %>% select(-year) %>%
      repeat_add_columns(tibble(year = MODEL_FUTURE_YEARS)) ->
      L232.StubTechCoef_industry_korea_fut
    # ^^ future years copied from final base year
    # note: this is not typical, but is suitable here as no energy:feedstock evolution in the industrial...
    # ... sector is expected for USA

    bind_rows(L232.StubTechCoef_industry_korea_base, L232.StubTechCoef_industry_korea_fut) %>%
      select(LEVEL2_DATA_NAMES$StubTechCoef) ->
      L232.StubTechCoef_industry_korea  ## OUTPUT

    # Get markets for fuels consumed by the state industrial sectors
    L232.StubTech_ind %>% filter(region == gcamkorea.REGION) %>% select(-region) %>%
      write_to_all_states(names = c(names(L232.StubTech_ind), "region"), region_states=gcamkorea.STATES) %>%
      repeat_add_columns(tibble(year = MODEL_YEARS)) %>%
      left_join_keep_first_only(A32.globaltech_eff %>% select(supplysector, subsector, technology, minicam.energy.input),
                                by = c("supplysector", "subsector", "stub.technology" = "technology")) %>%
      filter(is.na(minicam.energy.input) == FALSE) %>%
      # ^^ includes generic industrial technology that is not required here...
      mutate(market.name = gcamkorea.REGION) %>%
      select(LEVEL2_DATA_NAMES[["StubTechMarket"]]) %>%
      left_join_error_no_match(states_subregions %>% select(state, grid_region), by = c("region" = "state")) %>%
      mutate(market.name = if_else(minicam.energy.input %in% gcamkorea.REGIONAL_FUEL_MARKETS & gcamkorea.USE_REGIONAL_FUEL_MARKETS == TRUE,
                                   grid_region, market.name)) %>% select(-grid_region) %>%
      mutate(market.name = if_else(grepl("elect_td", minicam.energy.input), region, market.name)) ->
      L232.StubTechMarket_ind_korea  ## OUTPUT

    # markets for the cogenerated electricity (secondary output)
    A32.globaltech_eff %>%
      filter(is.na(secondary.output) == FALSE) %>%
      select(supplysector, subsector, technology) ->
      L232.chp_techs
    L232.StubTechMarket_ind_korea %>%
      # ^^ electricity is consumed from state markets
      semi_join(L232.chp_techs, by = c("supplysector", "subsector", "stub.technology" = "technology")) %>%
      # ^^ filters for rows contained in L232.chp_techs
      mutate(secondary.output = "electricity") %>%
      select(LEVEL2_DATA_NAMES[["StubTechYr"]], "secondary.output", "market.name") %>%
      mutate(market.name = gcamkorea.REGION) %>%
      # ^^ over-ride regional market names
      left_join_error_no_match(states_subregions %>% select(state, grid_region), by = c("region" = "state")) %>%
      mutate(x = gcamkorea.USE_REGIONAL_ELEC_MARKETS,
             market.name = if_else(x == TRUE, grid_region, market.name)) %>% select(-x, -grid_region) ->
      L232.StubTechSecMarket_ind_korea  ## OUTPUT

    # base-year service output of industry final demand
    L232.StubTechProd_industry_korea %>%
      select(region, year, calOutputValue) %>%
      rename(base.service = calOutputValue) %>%
      mutate(energy.final.demand = A32.demand$energy.final.demand) ->
      L232.BaseService_ind_korea  # base service is equal to the output of the industry supplysector


    # OUTPUTS...

    L232.DeleteSupplysector_koreaInd %>%
      add_title("USA industry supply sectors") %>%
      add_units("NA") %>%
      add_comments("Generated by deselecting industry sectors from input") %>%
      add_legacy_name("L232.DeleteSupplysector_koreaInd") %>%
      add_precursors("L232.Supplysector_ind") ->
      L232.DeleteSupplysector_koreaInd

    L232.DeleteFinalDemand_koreaInd %>%
      add_title("USA final energy demand table for industry") %>%
      add_units("NA") %>%
      add_comments("Generated by deselecting final demand sectors") %>%
      add_legacy_name("L232.DeleteFinalDemand_koreaInd") %>%
      add_precursors("L232.PerCapitaBased_ind") ->
      L232.DeleteFinalDemand_koreaInd

    L232.StubTechCalInput_indenergy_korea %>%
      add_title("calibrated input of industrial energy use technologies (including cogen)") %>%
      add_units("Unitless") %>%
      add_comments("Shareweights generated from calibrated values") %>%
      add_legacy_name("L232.StubTechCalInput_indenergy_korea") %>%
      add_precursors("L132.in_EJ_korea_indnochp_F",
                     "L132.in_EJ_korea_indchp_F",
                     "energy/calibrated_techs",
                     "energy/A32.globaltech_eff") ->
      L232.StubTechCalInput_indenergy_korea

    L232.StubTechCalInput_indfeed_korea %>%
      add_title("Calibrated input of industrial feedstock technologies") %>%
      add_units("Unitless") %>%
      add_comments("Shareweights generated from calibrated values") %>%
      add_legacy_name("L232.StubTechCalInput_indfeed_korea") %>%
      add_precursors("L132.in_EJ_korea_indfeed_F",
                     "energy/calibrated_techs",
                     "energy/A32.globaltech_eff") ->
      L232.StubTechCalInput_indfeed_korea

    L232.StubTechProd_industry_korea %>%
      add_title("industrial sector output") %>%
      add_units("Unitless") %>%
      add_comments("Service output aggregated to industrial sector for each region") %>%
      add_legacy_name("L232.StubTechProd_industry_korea") %>%
      add_precursors("energy/A32.globaltech_eff",
                     "L132.in_EJ_korea_indnochp_F",
                     "L132.in_EJ_korea_indfeed_F") ->
      L232.StubTechProd_industry_korea

    L232.StubTechCoef_industry_korea %>%
      add_title("industrial sector calibrated output") %>%
      add_units("Unitless") %>%
      add_comments("Generated by bind base and future year coefficients") %>%
      add_legacy_name("L232.StubTechCoef_industry_korea") %>%
      add_precursors("energy/A32.globaltech_eff",
                     "L132.in_EJ_korea_indnochp_F",
                     "L132.in_EJ_korea_indfeed_F") ->
      L232.StubTechCoef_industry_korea

    L232.StubTechMarket_ind_korea %>%
      add_title("Markets for the fuels consumed by the state industrial sectors") %>%
      add_units("NA") %>%
      add_comments("") %>%
      add_legacy_name("L232.StubTechMarket_ind_korea") %>%
      add_precursors("L232.StubTech_ind",
                     "energy/A32.globaltech_eff",
                     "gcam-korea/states_subregions") ->
      L232.StubTechMarket_ind_korea

    L232.StubTechSecMarket_ind_korea %>%
      add_title("markets for the cogenerated electricity (secondary output)") %>%
      add_units("NA") %>%
      add_comments("derived from L232.StubTechMarket_ind_korea") %>%
      add_legacy_name("L232.StubTechSecMarket_ind_korea") %>%
      add_precursors("L232.StubTech_ind",
                     "energy/A32.globaltech_eff",
                     "gcam-korea/states_subregions") ->
      L232.StubTechSecMarket_ind_korea

    L232.BaseService_ind_korea %>%
      add_title("base-year service output of industry final demand") %>%
      add_units("NA") %>%
      add_comments("base service is equal to the output of the industry supplysector") %>%
      add_legacy_name("L232.BaseService_ind_korea") %>%
      add_precursors("energy/A32.globaltech_eff",
                     "L132.in_EJ_korea_indnochp_F",
                     "L132.in_EJ_korea_indfeed_F",
                     "energy/A32.demand") ->
      L232.BaseService_ind_korea


    L232.Supplysector_ind_korea %>%
      add_title("Supply sector information for industry sector") %>%
      add_units("NA") %>%
      add_comments("For industry sector, the supply sector information (output.unit, input.unit, price.unit, logit.year.fillout, logit.exponent) from A32.sector is expanded for GCAM-USA") %>%
      add_legacy_name("L232.Supplysector_ind_korea") %>%
      add_precursors("L232.Supplysector_ind") ->
      L232.Supplysector_ind_korea

    L232.FinalEnergyKeyword_ind_korea %>%
      add_title("Supply sector keywords for industry sector") %>%
      add_units("NA") %>%
      add_comments("Set supply sector keywords for industry sector for all GCAM-USA regions") %>%
      add_legacy_name("L232.FinalEnergyKeyword_ind_korea") %>%
      add_precursors("L232.FinalEnergyKeyword_ind") ->
      L232.FinalEnergyKeyword_ind_korea

    L232.SubsectorLogit_ind_korea %>%
      add_title("Subsector logit exponents of industry sector") %>%
      add_units("Unitless") %>%
      add_comments("For industry sector, the subsector logit exponents from A32.subsector_logit are expanded into all GCAM-USA regions with non-existent heat subsectors removed") %>%
      add_legacy_name("L232.SubsectorLogit_ind_korea") %>%
      add_precursors("L232.SubsectorLogit_ind") ->
      L232.SubsectorLogit_ind_korea

    L232.SubsectorShrwtFllt_ind_korea %>%
      add_title("Subsector shareweights of industry sector") %>%
      add_units("Unitless") %>%
      add_comments("For industry sector, the subsector shareweights from A32.subsector_shrwt are expanded into all GCAM-USA regions with non-existent heat technologies") %>%
      add_legacy_name("L232.SubsectorShrwtFllt_ind_korea") %>%
      add_precursors("L232.SubsectorShrwtFllt_ind") ->
      L232.SubsectorShrwtFllt_ind_korea

    L232.SubsectorInterp_ind_korea %>%
      add_title("Subsector shareweight interpolation of industry sector") %>%
      add_units("NA") %>%
      add_comments("For industry sector, the subsector shareweight interpolation function infromation from A32.subsector_interp is expanded into all GCAM-USA regions with non-existent heat technologies removed") %>%
      add_legacy_name("L232.SubsectorInterp_ind_korea") %>%
      add_precursors("L232.SubsectorInterp_ind") ->
      L232.SubsectorInterp_ind_korea

    L232.StubTech_ind_korea %>%
      add_title("Identification of stub technologies of industrial sector") %>%
      add_units("NA") %>%
      add_comments("For industry sector, the stub technologies from A32.globaltech_shrwt are expanded into all GCAM-USA regions with non-existent heat technologies removed") %>%
      add_legacy_name("L232.StubTech_ind_korea") %>%
      add_precursors("L232.StubTech_ind") ->
      L232.StubTech_ind_korea

    L232.StubTechInterp_ind_korea %>%
      add_title("Shareweight interpolation of global industrial sector technologies") %>%
      add_units("NA") %>%
      add_comments("For industry sector, the interpolation function from A32.globaltech_interp are expanded into all GCAM regions") %>%
      add_legacy_name("L232.StubTechInterp_ind_korea") %>%
      add_precursors("L232.StubTechInterp_ind") ->
      L232.StubTechInterp_ind_korea

    L232.PerCapitaBased_ind_korea %>%
      add_title("Per-capita based flag for industry final demand") %>%
      add_units("NA") %>%
      add_comments("Extracted per-capita based flag for industry final demand from A32.demand") %>%
      add_legacy_name("L232.PerCapitaBased_ind_korea") %>%
      add_precursors("L232.PerCapitaBased_ind") ->
      L232.PerCapitaBased_ind_korea

    L232.PriceElasticity_ind_korea %>%
      add_title("Price elasticity of industry final demand") %>%
      add_units("Unitless") %>%
      add_comments("Extracted price elasticity of industry final demand from A32.demand") %>%
      add_comments("Price elasticities are only applied to future periods. Application in base years will cause solution failure") %>%
      add_legacy_name("L232.PriceElasticity_ind_korea") %>%
      add_precursors("L232.PriceElasticity_ind") ->
      L232.PriceElasticity_ind_korea

    L232.IncomeElasticity_ind_gcam3_korea %>%
      add_title("Income elasticity of industry - GCAM3") %>%
      add_units("Unitless") %>%
      add_comments("First calculate industrial output as the base-year industrial output times the GDP ratio raised to the income elasticity") %>%
      add_comments("Then back out the appropriate income elasticities from industrial output") %>%
      add_comments("Note lower income elasticities for SSP1 are hard-coded.") %>%
      add_legacy_name("L232.IncomeElasticity_ind_gcam3_korea") %>%
      add_precursors("L232.IncomeElasticity_ind_gcam3",
                     "gcam-korea/kor_ind_inc_elasticity_for_realitycheck") ->
      L232.IncomeElasticity_ind_gcam3_korea


    return_data(L232.DeleteSupplysector_koreaInd,
                L232.DeleteFinalDemand_koreaInd,
                L232.StubTechCalInput_indenergy_korea,
                L232.StubTechCalInput_indfeed_korea,
                L232.StubTechProd_industry_korea,
                L232.StubTechCoef_industry_korea,
                L232.StubTechMarket_ind_korea,
                L232.StubTechSecMarket_ind_korea,
                L232.BaseService_ind_korea,
                L232.Supplysector_ind_korea,
                L232.FinalEnergyKeyword_ind_korea,
                L232.SubsectorLogit_ind_korea,
                L232.SubsectorShrwtFllt_ind_korea,
                L232.SubsectorInterp_ind_korea,
                L232.StubTech_ind_korea,
                L232.StubTechInterp_ind_korea,
                L232.PerCapitaBased_ind_korea,
                L232.PriceElasticity_ind_korea,
                L232.IncomeElasticity_ind_gcam3_korea)
  } else {
    stop("Unknown command")
  }
}
rohmin9122/gcam-korea-release documentation built on Nov. 26, 2020, 8:11 a.m.