Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camp scens mrremind #440

Merged
merged 4 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '33534842'
ValidationKey: '33623730'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'mrremind: MadRat REMIND Input Data Package'
version: 0.170.6
date-released: '2023-10-27'
version: 0.171.0
date-released: '2023-11-02'
abstract: The mrremind packages contains data preprocessing for the REMIND model.
authors:
- family-names: Baumstark
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: mrremind
Title: MadRat REMIND Input Data Package
Version: 0.170.6
Date: 2023-10-27
Version: 0.171.0
Date: 2023-11-02
Authors@R: c(
person("Lavinia", "Baumstark", , "[email protected]", role = c("aut", "cre")),
person("Renato", "Rodrigues", role = "aut"),
Expand Down
16 changes: 9 additions & 7 deletions R/calcEDGETrData.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ calcEDGETrData <- function() {
expand_grid(
SSP_scen = c("SSP1", "SSP2", "SSP5", "SSP2EU", "SDP"),
tech_scen = c("Mix1", "Mix2", "Mix3", "Mix4"),
DEM_scenario = c("default", "SSP2EU_lowdem")),
DEM_scenario = c("default", "SSP2EU_demRedWeak", "SSP2EU_demRedStrong")),

## SHAPE scenarios are coupled to specific technologies
tribble(
Expand All @@ -34,17 +34,19 @@ calcEDGETrData <- function() {
'SDP_RC', 'Mix3', 'default',
'SSP2EU', 'HydrHype4', 'default',
'SSP2EU', 'ECEMF_HighEl_HighEff', 'default',
'SSP2EU', 'ECEMF_HighEl_LifestCha', 'SSP2EU_lowdem',
'SSP2EU', 'ECEMF_HighEl_LifestCha', 'SSP2EU_demRedStrong',
'SSP2EU', 'ECEMF_HighEl_ModEff', 'default',
'SSP2EU', 'ECEMF_HighH2_HighEff', 'default',
'SSP2EU', 'ECEMF_HighH2_LifestCha', 'SSP2EU_lowdem',
'SSP2EU', 'ECEMF_HighH2_LifestCha', 'SSP2EU_demRedStrong',
'SSP2EU', 'ECEMF_HighH2_ModEff', 'default',
'SSP2EU', 'NAV_act', 'SSP2EU_lowdem',
'SSP2EU', 'NAV_act', 'SSP2EU_demRedStrong',
'SSP2EU', 'NAV_tec', 'default',
'SSP2EU', 'NAV_ele', 'default',
'SSP2EU', 'NAV_all', 'SSP2EU_lowdem',
'SSP2EU', 'NAV_lce', 'SSP2EU_lowdem',
'SSP2EU', 'PhOP', 'default'
'SSP2EU', 'NAV_all', 'SSP2EU_demRedStrong',
'SSP2EU', 'NAV_lce', 'SSP2EU_demRedStrong',
'SSP2EU', 'PhOP', 'default',
'SSP2EU', 'CAMP_lscWeak', 'SSP2EU_demRedWeak',
'SSP2EU', 'CAMP_lscStrong', 'SSP2EU_demRedStrong'
)
)

Expand Down
15 changes: 8 additions & 7 deletions R/calcFEdemand.R
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ calcFEdemand <- function(subtype = "FE", use_ODYM_RECC = FALSE) {

# remove missing Navigate scenarios
if (subtype %in% c("FE_buildings", "UE_buildings")) {
reminditems <- reminditems[, , grep("SSP2EU_NAV_.{3}\\.rcp", getItems(reminditems, 3), value = TRUE), invert = TRUE]
reminditems <- reminditems[, , grep("SSP2EU_(NAV|CAMP)_[a-z]*\\.rcp", getItems(reminditems, 3), value = TRUE), invert = TRUE]
}

#Change the scenario names for consistency with REMIND sets
Expand Down Expand Up @@ -1982,18 +1982,19 @@ calcFEdemand <- function(subtype = "FE", use_ODYM_RECC = FALSE) {
description_out <- "useful energy demand in buildings"
}
if (subtype == "FE") {
# duplicate SSP2EU scenarios of industry for Navigate scenarios
# duplicate SSP2EU scenarios of industry for Navigate and Campaigners scenarios
industryItems <- grep("(.*i$)|chemicals|steel|otherInd|cement",
getItems(reminditems, 3.2), value = TRUE)
nonIndustryItems <- setdiff(getItems(reminditems, 3.2), industryItems)
navigateScenarios <- grep("SSP2EU_NAV_", getItems(reminditems, 3.1), value = TRUE)
nonNavigateScenarios <- setdiff(getItems(reminditems, 3.1), navigateScenarios)
duplScenarios <- grep("SSP2EU_(NAV|CAMP)_", getItems(reminditems, 3.1), value = TRUE)
nonDuplScenarios <- setdiff(getItems(reminditems, 3.1), duplScenarios)
reminditems <- mbind(
mselect(reminditems, scenario = nonNavigateScenarios),
mselect(reminditems, scenario = navigateScenarios, item = nonIndustryItems),
mselect(reminditems, scenario = nonDuplScenarios),
mselect(reminditems, scenario = duplScenarios, item = nonIndustryItems),
addDim(mselect(reminditems, scenario = "gdp_SSP2EU", item = industryItems,
collapseNames = TRUE),
paste0("gdp_SSP2EU_NAV_", c("act", "tec", "ele", "lce", "all")),
c(paste0("gdp_SSP2EU_NAV_", c("act", "tec", "ele", "lce", "all")),
paste0("gdp_SSP2EU_CAMP_", c("weak", "strong"))),
"scenario", 3.1)
)
}
Expand Down
53 changes: 24 additions & 29 deletions R/convertEDGE.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,28 @@ 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", "lce", "all"))),
paste0("SSP2EU_NAV_", c("act", "tec", "ele", "lce", "all")),
paste0("SSP2EU_CAMP_", c("weak", "strong"))),
function(s) setNames(x, paste(s, getNames(x), sep = "."))
))
}

duplScens <- function(x, scens = NULL) {
if (is.null(scens)) {
scens <- list(
gdp_SSP2EU = paste0("gdp_SSP2EU_",
c("NAV_act", "NAV_ele", "NAV_tec", "NAV_lce", "NAV_all",
"CAMP_weak", "CAMP_strong")),
gdp_SSP2 = "gdp_SSP2_lowEn"
)
}
mbind(x, do.call(mbind, lapply(names(scens), function(from) {
do.call(mbind, lapply(scens[[from]], function(to) {
setItems(x[, , from], 3, to)
}))
})))
}

renameExtraWeights <- function(magObj, magWeight, mapping) {
do.call("mbind", lapply(mapping[["EDGEitems"]], function(itemIN) {
if (itemIN %in% getNames(magObj, dim = "item")) {
Expand Down Expand Up @@ -89,15 +106,8 @@ convertEDGE <- function(x, subtype = "FE_stationary") {
#--- Load the Weights
#--- First load the GDP data. Set average2020 to False to get yearly data as far as possible.
wg <- calcOutput("GDP", average2020 = FALSE, aggregate = FALSE)
# 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", "lce", "all")),
function(navScen) {
setItems(wg[,, "gdp_SSP2EU"], 3, navScen)
})),
setItems(wg[,, "gdp_SSP2"], 3, "gdp_SSP2_lowEn")
)
# duplicate SSP2 for SSP2_lowEn an SSP2EU for Navigate and Campaigners scenarios
wg <- duplScens(wg)
getNames(wg) <- gsub("gdp_", "", getNames(wg))


Expand Down Expand Up @@ -323,16 +333,8 @@ convertEDGE <- function(x, subtype = "FE_stationary") {
select_years = intersect(getYears(x,as.integer = T),rem_years_hist)
wg <- calcOutput("GDP", years = select_years, aggregate = FALSE)

# 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", "lce", "all")),
function(navScen) {
setItems(wg[,, "gdp_SSP2EU"], 3, navScen)
})),
setItems(wg[,, "gdp_SSP2"], 3, "gdp_SSP2_lowEn")
)

# duplicate SSP2 for SSP2_lowEn an SSP2EU for Navigate and Campaigners scenarios
wg <- duplScens(wg)
getNames(wg) = gsub("gdp_","", getNames(wg))

x = toolAggregate(x[,select_years,],mappingfile, weight = wg[,,getNames(x,dim=1)], from = region_col, to = iso_col )
Expand All @@ -349,15 +351,8 @@ convertEDGE <- function(x, subtype = "FE_stationary") {
wp <- calcOutput("Population", years = rem_years_hist, aggregate = FALSE)
getSets(wp) <- gsub("variable", "scenario", getSets(wp))
getItems(wp, "scenario") <- gsub("pop_", "gdp_", getItems(wp, "scenario"))
# 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", "lce", "all")),
function(navScen) {
setItems(wp[,, "gdp_SSP2EU"], 3, navScen)
})),
setItems(wp[,, "gdp_SSP2"], 3, "gdp_SSP2_lowEn")
)
# duplicate SSP2 for SSP2_lowEn an SSP2EU for Navigate and Campaigners scenarios
wp <- duplScens(wp)

x <- toolAggregate(x[, rem_years_hist, ], mappingfile, weight = wp,
from = region_col, to = iso_col )
Expand Down
4 changes: 3 additions & 1 deletion R/readEDGE.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ readEDGE <- function(subtype = c("FE_stationary", "FE_buildings", "Capital", "Ca
ver <- "1.12"
scenarios <- list(
SSPs = paste0("SSP", 1:5),
SSP2s = paste0("SSP2", c("EU", "_lowEn", paste0("EU_NAV_", c("act", "tec", "ele", "lce", "all")))),
SSP2s = paste0("SSP2", c("EU", "_lowEn",
paste0("EU_NAV_", c("act", "tec", "ele", "lce", "all")),
paste0("EU_CAMP_", c("weak", "strong")))),
SDPs = paste0("SDP", c("", "_EI", "_MC", "_RC")))

addDim <- function(x, addnm, dim, dimCode = 3.2) {
Expand Down
14 changes: 9 additions & 5 deletions R/readEDGETransport.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,19 @@ readEDGETransport <- function(subtype = "logit_exponent") {
, 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][
dt[.("gdp_SSP2EU_demRedStrong", "gdp_SSP2EU", "NAV_act"), nomatch=NULL][
, DEM_scenario := "gdp_SSP2EU_NAV_act"],
dt[.("gdp_SSP2EU_lowdem", "gdp_SSP2EU", "NAV_all"), nomatch=NULL][
dt[.("gdp_SSP2EU_demRedStrong", "gdp_SSP2EU", "NAV_all"), nomatch=NULL][
, DEM_scenario := "gdp_SSP2EU_NAV_all"],
dt[.("gdp_SSP2EU_lowdem", "gdp_SSP2EU", "NAV_lce"), nomatch=NULL][
, DEM_scenario := "gdp_SSP2EU_NAV_lce"]
dt[.("gdp_SSP2EU_demRedStrong", "gdp_SSP2EU", "NAV_lce"), nomatch=NULL][
, DEM_scenario := "gdp_SSP2EU_NAV_lce"],
dt[.("gdp_SSP2EU_demRedWeak", "gdp_SSP2EU", "CAMP_lscWeak"), nomatch=NULL][
, DEM_scenario := "gdp_SSP2EU_CAMP_weak"],
dt[.("gdp_SSP2EU_demRedStrong", "gdp_SSP2EU", "CAMP_lscStrong"), nomatch=NULL][
, DEM_scenario := "gdp_SSP2EU_CAMP_strong"]
)
setkeyv(dt, "DEM_scenario")
dt[.("gdp_SSP2EU_lowdem"), DEM_scenario := "gdp_SSP2_lowEn"]
dt[.("gdp_SSP2EU_demRedStrong"), DEM_scenario := "gdp_SSP2_lowEn"]
scens <- unique(dt$DEM_scenario)
return(dt)
}
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.170.6**
R package **mrremind**, version **0.171.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/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, Fuchs S, Mandaroux R (2023). _mrremind: MadRat REMIND Input Data Package_. R package version 0.170.6, <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, Fuchs S, Mandaroux R (2023). _mrremind: MadRat REMIND Input Data Package_. R package version 0.171.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 and Sophie Fuchs and Rahel Mandaroux},
year = {2023},
note = {R package version 0.170.6},
note = {R package version 0.171.0},
url = {https://github.com/pik-piam/mrremind},
}
```
Loading