Skip to content

Commit

Permalink
Merge pull request #320 from Loisel/feature
Browse files Browse the repository at this point in the history
Avoid duplication of scenarios due to imprecise filtering.
  • Loading branch information
Loisel authored Sep 28, 2022
2 parents 8a69d64 + 94d5761 commit 2d20da2
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions R/readEDGETransport.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' \dontrun{ a <- readSource(type="EDGETransport")
#' }
#' @importFrom magclass read.magpie
#' @importFrom data.table rbindlist fread setcolorder := setnames setkey
#' @importFrom data.table rbindlist fread setcolorder := setnames setkeyv
#' @importFrom rmndt approx_dt
#'

Expand Down Expand Up @@ -51,26 +51,27 @@ readEDGETransport <- function(subtype = "logit_exponent") {
}

create_copy_demscens <- function(dt) {
setkey(dt, "DEM_scenario")
setkeyv(dt, c("DEM_scenario", "GDP_scenario", "EDGE_scenario"))
## Workaround for NAVIGATE: copy-create demand scenarios which we do not supply by EDGE-T
dt <- rbind(dt,
dt["gdp_SSP2EU", nomatch=NULL][, DEM_scenario := "gdp_SSP2EU_NAV_ele"],
dt["gdp_SSP2EU", nomatch=NULL][, DEM_scenario := "gdp_SSP2EU_NAV_tec"],
dt["gdp_SSP2EU_lowdem", nomatch=NULL][, DEM_scenario := "gdp_SSP2EU_NAV_act"],
dt["gdp_SSP2EU_lowdem", nomatch=NULL][, DEM_scenario := "gdp_SSP2EU_NAV_all"],
dt["gdp_SSP2EU_lowdem", nomatch=NULL][, DEM_scenario := "gdp_SSP2_lowEn"]
dt[.("gdp_SSP2EU", "gdp_SSP2EU", "NAV_ele"), nomatch=NULL][
, DEM_scenario := "gdp_SSP2EU_NAV_ele"],
dt[.("gdp_SSP2EU", "gdp_SSP2EU", "NAV_tec"), nomatch=NULL][
, DEM_scenario := "gdp_SSP2EU_NAV_tec"],
dt[.("gdp_SSP2EU_lowdem", "gdp_SSP2EU", "NAV_act"), nomatch=NULL][
, DEM_scenario := "gdp_SSP2EU_NAV_act"],
dt[.("gdp_SSP2EU_lowdem", "gdp_SSP2EU", "NAV_all"), nomatch=NULL][
, DEM_scenario := "gdp_SSP2EU_NAV_all"]
)
setkey(dt, "DEM_scenario")
setkeyv(dt, "DEM_scenario")
dt[.("gdp_SSP2EU_lowdem"), DEM_scenario := "gdp_SSP2_lowEn"]
scens <- unique(dt$DEM_scenario)

## this scenario is not supported by REMIND
dt <- dt[scens["gdp_SSP2EU_lowdem" != scens]]
return(dt)
}

compress_magpie <- function(dt, ...) {
dt <- create_copy_demscens(dt)
setkey(dt, "EDGE_scenario", "DEM_scenario", "GDP_scenario")
setkeyv(dt, c("EDGE_scenario", "DEM_scenario", "GDP_scenario"))
mdata <- NULL
for (i in unique(dt$EDGE_scenario)) {
for (j in unique(dt$DEM_scenario)) {
Expand Down

0 comments on commit 2d20da2

Please sign in to comment.