Skip to content

Commit

Permalink
Change ADB scenarios
Browse files Browse the repository at this point in the history
Harmonize past with future instead of the otherway around. (ADB projections now appear as-is in the scenarios.)
  • Loading branch information
johanneskoch94 committed Nov 13, 2024
1 parent a045211 commit a574dc7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions R/calcDriver.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ calcHarmonizedData <- function(driver, scenario) {
"pastAndGrowth" = toolHarmonizePast(past, future, method = "growth"),
"pastAndTransition" = toolHarmonizePast(past, future, method = "transition", yEnd = 2100),
"PopSSPs" = toolHarmonizeWithPEAPandFuture(past, future),
"PopADBs" = toolHarmonizePopulationADBs(past, future),
"PopISIMIP" = toolHarmonizePast(past, future, method = "transition", yEnd = 2030),
"GDPpcSSPs" = toolHarmonizeGDPpcSSPs(past, future, yEnd = 2100),
"GDPpcSDPs" = toolBuildGDPpcSDPs(),
Expand Down
4 changes: 4 additions & 0 deletions R/readADB.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ readADB <- function() {
#' @param x MAgPIE object returned from readADB
#' @param subtype A string, either "all", "gdppc", "pop"
convertADB <- function(x, subtype = "all") {
if (!subtype %in% c("all", "gdppc", "pop")) {
stop("Bad input for readADB. Invalid 'subtype' argument. Available subtypes are 'all', 'gdppc', and 'pop'.")
}

# Filter for subtype in the convert Function to use common read cache
if (subtype == "gdppc") {
x <- mselect(x,
Expand Down
2 changes: 1 addition & 1 deletion R/toolGetScenarioDefinition.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ toolGetScenarioDefinition <- function(driver = NULL, scen = NULL, aslist = FALSE
"Population", "SSP2EU", "WDI-UN_PopDiv-MI", "SSP2EU-UN_PopDiv", "PopSSPs",
"Population", "SDPs", "WDI-UN_PopDiv-MI", "SDPs-UN_PopDiv", "PopSSPs",
"Population", "ISIMIP", "UN_PopDiv-MI", "SSPs-UN_PopDiv", "PopISIMIP",
"Population", "ADBs", "WDI-UN_PopDiv-MI", "ADBs-SSP2-UN_PopDiv", "PopSSPs",
"Population", "ADBs", "WDI-UN_PopDiv-MI", "ADBs-SSP2-UN_PopDiv", "PopADBs",
# Labour Scenarios
"Labour", "SSPs", "WDI-UN_PopDiv", "SSPs-UN_PopDiv", "pastAndLevel",
"Labour", "SSP2", "WDI-UN_PopDiv", "SSP2-UN_PopDiv", "pastAndLevel",
Expand Down
10 changes: 5 additions & 5 deletions R/toolHarmonizeGDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ toolDivideGDPbyPop <- function(scenario) {
toolHarmonizeGDPpcADBs <- function(past, future) {
ssp2Data <- calcOutput("GDPpc", scenario = "SSP2", extension2150 = "none", average2020 = FALSE, aggregate = FALSE)

# For ADBs: transition IND from past to future by 2030
dataIND <- toolHarmonizePast(past, future, method = "transition", yEnd = 2030)

combined <- purrr::map(getNames(dataIND$x), function(x) {
# For both ADB scenarios, overwrite SSP2 IND data with ADB IND data
combined <- purrr::map(getNames(future$x), function(x) {
y <- setNames(ssp2Data, x)
y["IND", , ] <- 0
y["IND", getYears(dataIND$x), ] <- dataIND$x["IND", , x]
# Transition IND from past to future. Here keep future as is, and use growth rates from past.
dataIND <- toolHarmonizeFuture(past$x["IND", , ], future$x["IND", , x], method = "growth")
y["IND", getYears(dataIND), ] <- dataIND
y
}) %>%
mbind()
Expand Down
20 changes: 20 additions & 0 deletions R/toolHarmonizePop.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ toolHarmonizeWithPEAPandFuture <- function(past, future) {
and growth rates from {future$description} thereafter."))
}

toolHarmonizePopulationADBs <- function(past, future) {
ssp2Data <- calcOutput("Population", scenario = "SSP2", extension2150 = "none", aggregate = FALSE)

# For both ADB scenarios, overwrite SSP2 IND data with ADB IND data
combined <- purrr::map(getNames(future$x), function(x) {
y <- setNames(ssp2Data, x)
y["IND", , ] <- 0
# Transition IND from past to future. Here keep future as is, and use growth rates from past.
dataIND <- toolHarmonizeFuture(past$x["IND", , ], future$x["IND", , x], method = "growth")
y["IND", getYears(dataIND), ] <- dataIND
y
}) %>%
mbind()

list(x = combined,
description = glue("equal to SSP2 in all countries except for IND. \\
For IND use {past$description} until {max(getYears(past$x, as.integer = TRUE))}, \\
and converge to {future$description} by 2030."))
}

toolHarmonizeLabourADBs <- function() {
pop2 <- calcOutput("Population", scenario = "SSP2", naming = "scenario", extension2150 = "none", aggregate = FALSE)
lab2 <- calcOutput("Labour", scenario = "SSP2", naming = "scenario", extension2150 = "none", aggregate = FALSE)
Expand Down

0 comments on commit a574dc7

Please sign in to comment.