RMI-PACTA / pacta.scenario.data.preparation

The goal of {pacta.scenario.data.preparation} is to prepare and format all scenario input datasets required to run the {pacta.portfolio.allocate} tool.
https://rmi-pacta.github.io/pacta.scenario.data.preparation/
Other
1 stars 0 forks source link

add `prepare_geco_2023_scenario()` #21

Closed cjyetman closed 5 months ago

cjyetman commented 5 months ago
library(readr)
library(readxl)
library(dplyr)
library(pacta.scenario.preparation)
library(waldo)
devtools::load_all()

# define paths -----------------------------------------------------------------

scenario_preparation_inputs_path <- "~/data/pactarawdata/scenario-sources"

geco_2023_raw_path <- "geco_2023-20240201"
geco_2023_15c_raw_filename <- "20240129_PACTA data request_GECO data template_15C_data.xlsx"
geco_2023_ndc_raw_filename <- "20240129_PACTA data request_GECO data template_NDC-LTS_data.xlsx"
geco_2023_ref_raw_filename <- "20240129_PACTA data request_GECO data template_Ref_data.xlsx"

geco_2023_supplement_path <- "geco_2023_supplemental-20240227/GECO2023_20231219"
geco_2023_supplement_15c_raw_filename <- "GECO2023_20231219_15C_Total.xlsx"
geco_2023_supplement_ndc_raw_filename <- "GECO2023_20231219_NDC_Total.xlsx"
geco_2023_supplement_ref_raw_filename <- "GECO2023_20231219_Ref_Total.xlsx"

geco_2023_raw_full_path <-
  file.path(
    scenario_preparation_inputs_path,
    geco_2023_raw_path
  )

geco_2023_supplement_full_path <-
  file.path(
    scenario_preparation_inputs_path,
    geco_2023_supplement_path
  )

# import data ------------------------------------------------------------------

geco_2023_aviation_15c_raw <-
  file.path(geco_2023_raw_full_path, geco_2023_15c_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "Aviation")

geco_2023_aviation_ndc_raw <-
  file.path(geco_2023_raw_full_path, geco_2023_ndc_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "Aviation")

geco_2023_aviation_ref_raw <-
  file.path(geco_2023_raw_full_path, geco_2023_ref_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "Aviation")

geco_2023_fossil_fuels_15c_raw <-
  file.path(geco_2023_raw_full_path, geco_2023_15c_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "Fossil Fuel Extraction")

geco_2023_fossil_fuels_ndc_raw <-
  file.path(geco_2023_raw_full_path, geco_2023_ndc_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "Fossil Fuel Extraction")

geco_2023_fossil_fuels_ref_raw <-
  file.path(geco_2023_raw_full_path, geco_2023_ref_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "Fossil Fuel Extraction")

geco_2023_power_cap_15c_raw <-
  file.path(geco_2023_raw_full_path, geco_2023_15c_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "Capacity")

geco_2023_power_cap_ndc_raw <-
  file.path(geco_2023_raw_full_path, geco_2023_ndc_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "Capacity")

geco_2023_power_cap_ref_raw <-
  file.path(geco_2023_raw_full_path, geco_2023_ref_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "Capacity")

geco_2023_steel_15c_raw <-
  file.path(geco_2023_raw_full_path, geco_2023_15c_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "Steel")

geco_2023_steel_ndc_raw <-
  file.path(geco_2023_raw_full_path, geco_2023_ndc_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "Steel")

geco_2023_steel_ref_raw <-
  file.path(geco_2023_raw_full_path, geco_2023_ref_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "Steel")

geco_2023_supplement_15c_raw <-
  file.path(geco_2023_supplement_full_path, geco_2023_supplement_15c_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "World", range = "A3:J109")

geco_2023_supplement_ndc_raw <-
  file.path(geco_2023_supplement_full_path, geco_2023_supplement_ndc_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "World", range = "A3:J109")

geco_2023_supplement_ref_raw <-
  file.path(geco_2023_supplement_full_path, geco_2023_supplement_ref_raw_filename) %>% 
  readxl::read_xlsx(na = "", sheet = "World", range = "A3:J109")

geco_2023_new <- prepare_geco_2023_scenario(
  geco_2023_aviation_15c_raw,
  geco_2023_aviation_ndc_raw,
  geco_2023_aviation_ref_raw,
  geco_2023_fossil_fuels_15c_raw,
  geco_2023_fossil_fuels_ndc_raw,
  geco_2023_fossil_fuels_ref_raw,
  geco_2023_power_cap_15c_raw,
  geco_2023_power_cap_ndc_raw,
  geco_2023_power_cap_ref_raw,
  geco_2023_steel_15c_raw,
  geco_2023_steel_ndc_raw,
  geco_2023_steel_ref_raw,
  geco_2023_supplement_15c_raw,
  geco_2023_supplement_ndc_raw,
  geco_2023_supplement_ref_raw
)

waldo::compare(
  pacta.scenario.preparation::geco_2023,
  geco_2023_new
)
#> ✔ No differences