gcam-core icon indicating copy to clipboard operation
gcam-core copied to clipboard

GCAMDATA user modification for `read from file` data

Open choiHenry opened this issue 1 year ago • 0 comments

Hi all. I want to modify energy/Dooley_Cstorage_RG3_MtCO2 writing codes as below.

usermod_cstorage <- function(command, ...) {
  if(command == driver.DECLARE_MODIFY) {
    return(c(FILE = "energy/Dooley_Cstorage_RG3_MtCO2"))
  } else if(command == driver.DECLARE_INPUTS) {
    return()
  } else if(command == driver.MAKE) {
    all_data <- list(...)[[1]]
    df <- get_data(all_data, "energy/Dooley_Cstorage_RG3_MtCO2")

    # Make some changes...
    df[df$region_GCAM3 == "South Korea", "Deep Saline Formation On-shore"] <- 999


    return_modified("energy/Dooley_Cstorage_RG3_MtCO2" = df)
  } else {
    stop("Unknown command")
  }
}

driver_drake(user_modifications = c("usermod_cstorage"), xml_suffix="_1")

I found the result message in RStudio that ▶ target Cstorage.xml and ▶ target xml.Cstorage.xml are not provoked by the last command driver_drake(user_modifications = c("usermod_cstorage"), xml_suffix="_1").

GCAM Data System v5.1
Found 441 chunks
Found 4636 chunk data requirements
Found 2623 chunk data products
1563 chunk data input(s) not accounted for
▶ target usermod_cstorage
▶ target energy.Dooley_Cstorage_RG3_MtCO2__0
▶ target module_energy_L161.Cstorage
All done.

But when I modified manually the Dooley_Cstorage_RG3_MtCO2.csv as I intended, the Cstorage.xml changed actually. I want to ask how can I modify this file without manually editing the ext file in gcamdata

choiHenry avatar Jan 06 '25 05:01 choiHenry