Skip to content

Commit

Permalink
Merge pull request #347 from robinhasse/NAV_lce
Browse files Browse the repository at this point in the history
Add buildings trajectory for new NAV_lce scenario
  • Loading branch information
robinhasse authored Jan 18, 2023
2 parents 50f17ce + 8ab0124 commit 9c683d2
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '29469375'
ValidationKey: '29643750'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "mrremind: MadRat REMIND Input Data Package",
"version": "0.152.1",
"version": "0.153.0",
"description": "<p>The mrremind packages contains data preprocessing for the\n REMIND model.<\/p>",
"creators": [
{
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: mrremind
Title: MadRat REMIND Input Data Package
Version: 0.152.1
Version: 0.153.0
Date: 2023-01-18
Authors@R: c(
person("Lavinia", "Baumstark", , "[email protected]", role = c("aut", "cre")),
Expand Down
2 changes: 1 addition & 1 deletion R/calcFEdemand.R
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,7 @@ calcFEdemand <- function(subtype = "FE") {
mselect(reminditems, scenario = navigateScenarios, item = nonIndustryItems),
addDim(mselect(reminditems, scenario = "gdp_SSP2EU", item = industryItems,
collapseNames = TRUE),
paste0("gdp_SSP2EU_NAV_", c("act", "tec", "ele", "all")),
paste0("gdp_SSP2EU_NAV_", c("act", "tec", "ele", "lce", "all")),
"scenario", 3.1)
)
}
Expand Down
12 changes: 6 additions & 6 deletions R/convertEDGE.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#' Convert IEA
#' Convert EDGE
#'
#' Convert EDGE data to data on ISO country level.
#'
#' @param subtype FE for final energy or Capital for capital projections
#' @param x MAgPIE object containing EDGE values at ISO country resolution
#' @return EDGE data as MAgPIE object aggregated to country level
#' @author Antoine Levesque
#' @author Antoine Levesque, Robin Hasse
#'
#' @importFrom magclass new.magpie getItems<- getNames getSets getYears mselect
#' mbind
Expand All @@ -18,7 +18,7 @@ convertEDGE <- function(x, subtype = "FE_stationary") {
addSSPnames <- function(x) {
do.call("mbind", lapply(c(paste0("SSP", c(1:5, "2EU", "2_lowEn")),
paste0("SDP", c("", "_EI", "_RC", "_MC")),
paste0("SSP2EU_NAV_", c("act", "tec", "ele", "all"))),
paste0("SSP2EU_NAV_", c("act", "tec", "ele", "lce", "all"))),
function(s) setNames(x, paste(s, getNames(x), sep = "."))
))
}
Expand Down Expand Up @@ -89,7 +89,7 @@ convertEDGE <- function(x, subtype = "FE_stationary") {
# duplicate SSP2 for SSP2_lowEn an SSP2EU for Navigate scenarios
wg <- mbind(
wg,
do.call("mbind", lapply(paste0("gdp_SSP2EU_NAV_", c("act", "tec", "ele", "all")),
do.call("mbind", lapply(paste0("gdp_SSP2EU_NAV_", c("act", "tec", "ele", "lce", "all")),
function(navScen) {
setItems(wg[,, "gdp_SSP2EU"], 3, navScen)
})),
Expand Down Expand Up @@ -319,7 +319,7 @@ convertEDGE <- function(x, subtype = "FE_stationary") {
# duplicate SSP2 for SSP2_lowEn an SSP2EU for Navigate scenarios
wg <- mbind(
wg,
do.call("mbind", lapply(paste0("gdp_SSP2EU_NAV_", c("act", "tec", "ele", "all")),
do.call("mbind", lapply(paste0("gdp_SSP2EU_NAV_", c("act", "tec", "ele", "lce", "all")),
function(navScen) {
setItems(wg[,, "gdp_SSP2EU"], 3, navScen)
})),
Expand All @@ -344,7 +344,7 @@ convertEDGE <- function(x, subtype = "FE_stationary") {
# duplicate SSP2 for SSP2_lowEn an SSP2EU for Navigate scenarios
wp <- mbind(
wp,
do.call("mbind", lapply(paste0("gdp_SSP2EU_NAV_", c("act", "tec", "ele", "all")),
do.call("mbind", lapply(paste0("gdp_SSP2EU_NAV_", c("act", "tec", "ele", "lce", "all")),
function(navScen) {
setItems(wp[,, "gdp_SSP2EU"], 3, navScen)
})),
Expand Down
22 changes: 12 additions & 10 deletions R/readEDGE.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ readEDGE <- function(subtype = c("FE_stationary", "FE_buildings", "Capital", "Ca
subtype <- match.arg(subtype)

# input data version
ver <- "1.10"
ver <- "1.11"
scenarios <- list(
SSPs = paste0("SSP", 1:5),
SSP2s = paste0("SSP2", c("EU", "_lowEn", paste0("_NAV_", c("act", "tec", "ele", "lce", "all")))),
SDPs = paste0("SDP", c("", "_EI", "_MC", "_RC")))

addDim <- function(x, addnm, dim, dimCode = 3.2) {
do.call("mbind", lapply(addnm, function(item) {
Expand All @@ -30,15 +34,12 @@ readEDGE <- function(subtype = c("FE_stationary", "FE_buildings", "Capital", "Ca
mstationary <- read.magpie(file.path(ver, "EDGE_TradMod.cs4r"))
mstationary[is.na(mstationary)] <- 0
getSets(mstationary) <- c("region", "year", "scenario", "item")
# duplicate: SSP2 -> SSP2EU, SSP2_lowEn and SSP1 -> SDPs
mstationarySPP2s <- addDim(
mselect(mstationary, scenario = "SSP2", collapseNames = TRUE),
c("SSP2EU", "SSP2_lowEn", "SSP2EU_NAV_act", "SSP2EU_NAV_tec", "SSP2EU_NAV_ele", "SSP2EU_NAV_all"),
"scenario", 3.1)
mstationarySDPs <- addDim(
mselect(mstationary, scenario = "SSP1", collapseNames = TRUE),
c("SDP", "SDP_EI", "SDP_RC", "SDP_MC"), "scenario", 3.1)
mstationary <- mbind(mstationary, mstationarySPP2s, mstationarySDPs)
mstationary <- mbind(
mstationary,
addDim(mselect(mstationary, scenario = "SSP2", collapseNames = TRUE),
scenarios$SSP2s, "scenario", 3.1),
addDim(mselect(mstationary, scenario = "SSP1", collapseNames = TRUE),
scenarios$SDPs, "scenario", 3.1))
return(mstationary)
},
FE_buildings = {
Expand All @@ -47,6 +48,7 @@ readEDGE <- function(subtype = c("FE_stationary", "FE_buildings", "Capital", "Ca
getNames(mbuilding) <- gsub("rcp", "", getNames(mbuilding))
getNames(mbuilding) <- gsub("NoC", "fixed", getNames(mbuilding))
getSets(mbuilding) <- c("region", "year", "scenario", "rcp", "item")
mbuilding <- mselect(mbuilding, scenario = Reduce(c, scenarios))
return(mbuilding)
},
Capital = {
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MadRat REMIND Input Data Package

R package **mrremind**, version **0.152.1**
R package **mrremind**, version **0.153.0**

[![CRAN status](https://www.r-pkg.org/badges/version/mrremind)](https://cran.r-project.org/package=mrremind) [![R build status](https://github.com/pik-piam/mrremind/workflows/check/badge.svg)](https://github.com/pik-piam/mrremind/actions) [![codecov](https://codecov.io/gh/pik-piam/mrremind/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrremind) [![r-universe](https://pik-piam.r-universe.dev/badges/mrremind)](https://pik-piam.r-universe.dev/ui#builds)

Expand Down Expand Up @@ -39,7 +39,7 @@ In case of questions / problems please contact Lavinia Baumstark <lavinia@pik-po

To cite package **mrremind** in publications use:

Baumstark L, Rodrigues R, Levesque A, Oeser J, Bertram C, Mouratiadou I, Malik A, Schreyer F, Soergel B, Rottoli M, Mishra A, Dirnaichner A, Pehl M, Giannousakis A, Klein D, Strefler J, Feldhaus L, Brecha R, Rauner S, Dietrich J, Bi S, Benke F, Weigmann P, Richters O, Hasse R (2023). _mrremind: MadRat REMIND Input Data Package_. R package version 0.152.1, <https://github.com/pik-piam/mrremind>.
Baumstark L, Rodrigues R, Levesque A, Oeser J, Bertram C, Mouratiadou I, Malik A, Schreyer F, Soergel B, Rottoli M, Mishra A, Dirnaichner A, Pehl M, Giannousakis A, Klein D, Strefler J, Feldhaus L, Brecha R, Rauner S, Dietrich J, Bi S, Benke F, Weigmann P, Richters O, Hasse R (2023). _mrremind: MadRat REMIND Input Data Package_. R package version 0.153.0, <https://github.com/pik-piam/mrremind>.

A BibTeX entry for LaTeX users is

Expand All @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is
title = {mrremind: MadRat REMIND Input Data Package},
author = {Lavinia Baumstark and Renato Rodrigues and Antoine Levesque and Julian Oeser and Christoph Bertram and Ioanna Mouratiadou and Aman Malik and Felix Schreyer and Bjoern Soergel and Marianna Rottoli and Abhijeet Mishra and Alois Dirnaichner and Michaja Pehl and Anastasis Giannousakis and David Klein and Jessica Strefler and Lukas Feldhaus and Regina Brecha and Sebastian Rauner and Jan Philipp Dietrich and Stephen Bi and Falk Benke and Pascal Weigmann and Oliver Richters and Robin Hasse},
year = {2023},
note = {R package version 0.152.1},
note = {R package version 0.153.0},
url = {https://github.com/pik-piam/mrremind},
}
```
4 changes: 2 additions & 2 deletions man/convertEDGE.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c683d2

Please sign in to comment.