R/convertStrefler2021.R

Defines functions convertStrefler2021

convertStrefler2021 <- function(x, subtype) {

  # remove global dimension
  x <- x["GLO", , , invert = TRUE]

  map <- toolGetMapping(type = "regional", name = "regionmappingH12.csv", returnPathOnly = TRUE, where = "madrat")

  if (grepl("intensive", subtype)) {
    # No weight for disaggregation because it's prices
    y <- toolAggregate(x, map)

  } else if (grepl("extensive", subtype)) {
    # Use population of 2010 as weight for disaggregation
    pop <- calcOutput("Population", aggregate = FALSE)
    y <- toolAggregate(x, map, weight = pop[, 2010, 1])

  } else {
    stop("Unknown subtype ", subtype)
  }

  return(y)
}
pik-piam/mrland documentation built on Nov. 23, 2024, 11:37 a.m.