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 and implement `geco_2022_geography_bridge` and `geco_2022_technology_bridge` #22

Closed cjyetman closed 5 months ago

cjyetman commented 5 months ago

There's still the unit gCO2/pkm issue, which I'm not sure if I should fix or not?

source("data-raw/prepare_raw_data.R")
devtools::load_all()
#> ℹ Loading pacta.scenario.data.preparation

geco_2022_path <- "~/data/pactarawdata/scenario-sources/geco_2022"
geco_2022_automotive_filename <- "geco2022_automotive_stocks_geco2021_retirement_rates_CORRECTED.csv"
geco_2022_aviation_filename <- "GECO2022_Aviation_processed_data.csv"
geco_2022_fossil_fuels_15c_filename <- "geco2022_15c_ff_rawdata.csv"
geco_2022_fossil_fuels_ndc_filename <- "geco2022_ndc_ff_rawdata.csv"
geco_2022_fossil_fuels_ref_filename <- "geco2022_ref_ff_rawdata.csv"
geco_2022_power_15c_filename <- "geco2022_15c_power_rawdata_region.csv"
geco_2022_power_ndc_filename <- "geco2022_ndc_power_rawdata_region.csv"
geco_2022_power_ref_filename <- "geco2022_ref_power_rawdata_region.csv"
geco_2022_steel_filename <- "GECO2022_Steel_processed_data.csv"

geco_2022_automotive_raw <-
  readr::read_csv(file.path(geco_2022_path, geco_2022_automotive_filename), show_col_types = FALSE)
geco_2022_aviation_raw <-
  readr::read_csv(file.path(geco_2022_path, geco_2022_aviation_filename), show_col_types = FALSE)
geco_2022_fossil_fuels_15c_raw <-
  readr::read_csv(file.path(geco_2022_path, geco_2022_fossil_fuels_15c_filename), show_col_types = FALSE)
#> New names:
#> • `` -> `...1`
geco_2022_fossil_fuels_ndc_raw <-
  readr::read_csv(file.path(geco_2022_path, geco_2022_fossil_fuels_ndc_filename), show_col_types = FALSE)
#> New names:
#> • `` -> `...1`
geco_2022_fossil_fuels_ref_raw <-
  readr::read_csv(file.path(geco_2022_path, geco_2022_fossil_fuels_ref_filename), show_col_types = FALSE)
#> New names:
#> • `` -> `...1`
geco_2022_power_15c_raw <-
  readr::read_csv(file.path(geco_2022_path, geco_2022_power_15c_filename), show_col_types = FALSE)
geco_2022_power_ndc_raw <-
  readr::read_csv(file.path(geco_2022_path, geco_2022_power_ndc_filename), show_col_types = FALSE)
geco_2022_power_ref_raw <-
  readr::read_csv(file.path(geco_2022_path, geco_2022_power_ref_filename), show_col_types = FALSE)
geco_2022_steel_raw <-
  readr::read_csv(file.path(geco_2022_path, geco_2022_steel_filename), show_col_types = FALSE)

geco_2022_automotive <- prepare_geco_2022_automotive_scenario(
  geco_2022_automotive_raw
)

geco_2022_fossil_fuels <- prepare_geco_2022_fossil_fuels_scenario(
  geco_2022_fossil_fuels_15c_raw,
  geco_2022_fossil_fuels_ndc_raw,
  geco_2022_fossil_fuels_ref_raw
)

geco_2022_power <- prepare_geco_2022_power_scenario(
  geco_2022_power_15c_raw,
  geco_2022_power_ndc_raw,
  geco_2022_power_ref_raw
)

geco_2022_steel <- prepare_geco_2022_steel_scenario(
  geco_2022_steel_raw
)

geco_2022_aviation <- prepare_geco_2022_aviation_scenario(
  geco_2022_aviation_raw
)

geco_2022 <- prepare_geco_2022_scenario(
  geco_2022_automotive_raw,
  geco_2022_aviation_raw,
  geco_2022_fossil_fuels_15c_raw,
  geco_2022_fossil_fuels_ndc_raw,
  geco_2022_fossil_fuels_ref_raw,
  geco_2022_power_15c_raw,
  geco_2022_power_ndc_raw,
  geco_2022_power_ref_raw,
  geco_2022_steel_raw
)

waldo::compare(
  tolerance = 1e-15,
  pacta.scenario.preparation::geco_2022,
  geco_2022
)
#> ✔ No differences

pacta.data.validation::validate_intermediate_scenario_output(pacta.scenario.preparation::geco_2022)
#> Error in base::tryCatch(base::withCallingHandlers({: 1 assertions failed:
#>  * Variable 'data$units': must contain only valid unit names, but has
#>  * additional element "gCO2/pkm".
pacta.data.validation::validate_intermediate_scenario_output(geco_2022)
#> Error in base::tryCatch(base::withCallingHandlers({: 1 assertions failed:
#>  * Variable 'data$units': must contain only valid unit names, but has
#>  * additional element "gCO2/pkm".
jdhoffa commented 5 months ago

@cjyetman can you explain specifically what this issue is? e.g.: For the sector aviation we don't know what emissions intensity unit to use, options: gCO2/pkm or ...?

I will try to get an answer :-)

(Also in general, I would say since the waldo regression test passes, this isn't a blocking point for THIS PR, but rather we should open a new issue for it)

cjyetman commented 5 months ago

@cjyetman can you explain specifically what this issue is? e.g.: For the sector aviation we don't know what emissions intensity unit to use, options: gCO2/pkm or ...?

I will try to get an answer :-)

(Also in general, I would say since the waldo regression test passes, this isn't a blocking point for THIS PR, but rather we should open a new issue for it)

I agree, maybe that should be a separate issue/PR, but for reference, apparently GECO 2022 was prepared wrong last year and it should be tCO2/pkm not gCO2/pkm... https://github.com/RMI-PACTA/pacta.scenario.preparation/pull/133#issuecomment-1967261799

jdhoffa commented 5 months ago

@cjyetman can you explain specifically what this issue is? e.g.: For the sector aviation we don't know what emissions intensity unit to use, options: gCO2/pkm or ...? I will try to get an answer :-) (Also in general, I would say since the waldo regression test passes, this isn't a blocking point for THIS PR, but rather we should open a new issue for it)

I agree, maybe that should be a separate issue/PR, but for reference, apparently GECO 2022 was prepared wrong last year and it should be tCO2/pkm not gCO2/pkm... RMI-PACTA/pacta.scenario.preparation#133 (comment)

Yup agreed. See #23