Prerequisites
Installation check list:
- R
 
- RStudio (or alternative IDE)
 
- 
required
R-libraries
 Seevignette("install")for installation details.
To import PyPSA input-datasets and translate them to Switch and/or energyRt:
- PyPSA input datasets
To import and compare results of PyPSA, Switch, energyRt
- PyPSA solved scenarios
 
- Switch solved scenarios
 
- energyRt solved scenarios
(re)install revaluation
To install or re-install revaluation from GitHub library
use:
remotes::install_github("https://github.com/opendecarbonization/revaluation")While the project is in active development phase, re-install regularly for updates.
Configuration file for each country
To execute the scripts for a particular country, yaml-file must be created and configured for each country. To create a prototype-file run:
# copy `config_{ISO3c}.yml` file to the project working directory
revaluation::rev_write_yaml(iso3c = "BGD", overwrite = FALSE)Currently the example file is provided for Bangladesh
(iso3c = "BGD") only. The iso3c name is used
for the yaml-file name only (config_{iso3c}.yml). Once
created, review and edit the yaml file with key parameters:
- 
iso3c,iso2c- country iso-codes
 
- (optional) countryname. If not supplied, will be used from countrycodes library.
 
- 
dir(optional) change path to the projectdata, temporary (tmp) and other directories.
 
- 
pypsa- path to the pypsa model directory and key files.- 
filespaths to the model input (network), bus-mapping in gis-file (busmap).
 
- 
Reports
Maps for the model
#1. assign country
# iso3c <- "COL"
# iso3c <- "CHN"
# iso3c <- "IND"
# iso3c <- "CHL"
# iso3c <- "THA"
# iso3c <- "VNM"
# iso3c <- "MYS"
# iso3c <- "KAZ"
iso3c <- "BGD"
#2. Copy a vignette file from installed `revaluation` package
file.copy(from = system.file("doc", "map.rmd", package = "revaluation"), 
          to = "my_map.Rmd", overwrite = F)
#2.a Alternatively, download the same file from GitHub (might be a newer version)
if (F) {
  f <- "https://github.com/opendecarbonization/revaluation/blob/master/vignettes/map.Rmd"
  download.file(f, "my_map.Rmd") # (!) replaces existing file
  # to open the file for editing:
  usethis::edit_file("my_map.Rmd", open = T)
}
#3. render report for the country
rmarkdown::render(
  input = "my_map.Rmd", 
  output_file = paste0("model_maps_", iso3c, ".pdf"), 
  output_format = "pdf_document", 
  params = list(
    iso3c = iso3c, # country
    yaml_path = getwd(), # path to the YAML-file
    echo = FALSE # show R-script in reports
    )
  )Importing PyPSA model
And building Switch and energyRt models.
#1. assign country
# iso3c <- "COL"
# iso3c <- "CHN"
# iso3c <- "IND"
# iso3c <- "CHL"
# iso3c <- "THA"
# iso3c <- "VNM"
# iso3c <- "MYS"
# iso3c <- "KAZ"
iso3c <- "BGD"
#2. Copy the rmd-file
file.copy(from = system.file("doc", "import_pypsa_model.Rmd", 
                             package = "revaluation"), 
          to = "my_import_pypsa_model.Rmd", overwrite = F)
#2.a Alternatively, download the same file from GitHub (might be a newer version)
if (F) {
  f <- 
  "https://github.com/opendecarbonization/revaluation/blob/master/vignettes/import_pypsa_model.rmd"
  download.file(f, "my_import_pypsa_model.Rmd") # (!) replaces existing file
  # to open the file for editing:
  usethis::edit_file("my_import_pypsa_model.Rmd", open = T)
}
rmarkdown::render(
  "my_import_pypsa_model.Rmd", 
  output_file = paste0("import_pypsa_model_", iso3c, ".pdf"), 
  output_format = "pdf_document", 
  params = list(
    iso3c = iso3c, # country code, 3-letter
    echo = FALSE, # show R-script in reports
    yaml_path = getwd(), # path to the YAML-file
    save_csv = FALSE, # save raw PyPSA-datasets in csv format
    build_switch = T, # write Switch-model files
    build_energyRt = T, # write energyRt-model files
    echo = F
    )
  )tbc