Skip to content

Commit

Permalink
Merge pull request #640 from orichters/units
Browse files Browse the repository at this point in the history
bugfix compareScenConf.R, harmonize some units
  • Loading branch information
orichters authored Aug 9, 2024
2 parents b6ae623 + de9ea7d commit 940c3a4
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '229184956'
ValidationKey: '229216392'
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: 'remind2: The REMIND R package (2nd generation)'
version: 1.149.2
date-released: '2024-08-08'
version: 1.149.3
date-released: '2024-08-09'
abstract: Contains the REMIND-specific routines for data and model output manipulation.
authors:
- family-names: Rodrigues
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: remind2
Title: The REMIND R package (2nd generation)
Version: 1.149.2
Date: 2024-08-08
Version: 1.149.3
Date: 2024-08-09
Authors@R: c(
person("Renato", "Rodrigues", , "[email protected]", role = c("aut", "cre")),
person("Lavinia", "Baumstark", role = "aut"),
Expand Down
27 changes: 15 additions & 12 deletions R/compareScenConf.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,21 @@ compareScenConf <- function(fileList = NULL, remindPath = "/p/projects/rd3mod/gi
if (! is.null(remindPath)) {
cfg <- gms::readDefaultConfig(remindPath)
# enable script to match default data not in gms
try(cfg$gms[["output"]] <- paste0(cfg$output, collapse = ","))
try(cfg$gms[["model"]] <- cfg$model)
try(cfg$gms[["regionmapping"]] <- cfg$regionmapping)
try(cfg$gms[["inputRevision"]] <- cfg$inputRevision)
cfg$gms[["output"]] <- paste0(cfg$output, collapse = ",")
for (switch in setdiff(names(cfg), c("output", "gms"))) {
cfg$gms[[switch]] <- cfg[[switch]]
}
}

readCheckScenarioConfig <- function(csvFile, ...) {
return(read.csv2(csvFile, stringsAsFactors = FALSE, row.names = row.names,
comment.char = "#", na.strings = "", dec = "."))
}
if (expanddata) {
message("Loading R helper functions from remindmodel.") # overwrite readCheckScenarioConfig
message("Loading R helper functions from ", remindPath, ".") # overwrite readCheckScenarioConfig
remindRscripts <- list.files(file.path(remindPath, "scripts", "start"), pattern = "\\.R$", full.names = TRUE)
invisible(sapply(remindRscripts, source, local = TRUE))
invisible(sapply(remindRscripts, source))
} else {
readCheckScenarioConfig <- function(csvFile, ...) {
return(read.csv2(csvFile, stringsAsFactors = FALSE, row.names = row.names,
comment.char = "#", na.strings = "", dec = "."))
}
}
settings1 <- readCheckScenarioConfig(fileList[[1]], remindPath = remindPath, fillWithDefault = TRUE, testmode = TRUE)
settings2 <- readCheckScenarioConfig(fileList[[2]], remindPath = remindPath, fillWithDefault = TRUE, testmode = TRUE)
Expand Down Expand Up @@ -119,9 +120,11 @@ compareScenConf <- function(fileList = NULL, remindPath = "/p/projects/rd3mod/gi
for (c in jointCols) {
# print only if different, if description was changed print only this fact
if (! identical(toString(settings1[sold, c]), toString(settings2[s, c]))) {
defaultinfo <- if (c %in% names(cfg$gms)) paste0(" (default: ", cfg$gms[[c]], ")")
m <- c(m, paste0(" ", ifelse(c %in% renamedCols, paste(names(which(renamedCols == c)), "-> "), ""), c,
": ", ifelse(c == "description", "was changed", paste0(settings1[sold, c], " -> ", settings2[s, c])),
ifelse(is.null(remindPath) || is.null(cfg$gms[[c]]), "", paste0(" (default: ", cfg$gms[[c]], ")"))))
": ", ifelse(c == "description", "was changed",
paste0(ifelse(c %in% addedCols, "NA", settings1[sold, c]), " -> ", settings2[s, c])),
defaultinfo))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion R/reportCosts.R
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060,
if(!is.null(cost_mag)) {tmp <- mbind(tmp,setNames(cost_mag * 1000, "Costs|Biomass|MAgPIE (billion US$2005/yr)"))}
tmp <- mbind(tmp,setNames(cost_emu_pre * 1000, "Costs|Biomass|Price integral presolve (billion US$2005/yr)"))
tmp <- mbind(tmp,setNames(cost_emu * 1000, "Costs|Biomass|Price integral (billion US$2005/yr)"))
tmp <- mbind(tmp,setNames(bio_cost_adjfac, "Costs|Biomass|Adjfactor (-)"))
tmp <- mbind(tmp,setNames(bio_cost_adjfac, "Costs|Biomass|Adjfactor (unitless)"))

if(!is.null(totLUcosts)) {tmp <- mbind(tmp,setNames(totLUcosts * 1000, "Costs|Land Use (billion US$2005/yr)"))}
if(!is.null(totLUcostsWithMAC)) {tmp <- mbind(tmp,setNames(totLUcostsWithMAC * 1000, "Costs|Land Use with MAC-costs from MAgPIE (billion US$2005/yr)"))}
Expand Down
2 changes: 1 addition & 1 deletion R/reportCrossVariables.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ reportCrossVariables <- function(gdx, output = NULL, regionSubsetList = NULL,
+ dimSums(mselect(tmp, list(variable = 'SE|Electricity|Net Imports (EJ/yr)')),
dim = 3)
),
"Secondary Energy|Electricity|Share of renewables in gross demand|Estimation (Percent)"))
"Secondary Energy|Electricity|Share of renewables in gross demand|Estimation (%)"))

# Energy expenditures
tmp <- mbind(tmp,setNames(
Expand Down
8 changes: 4 additions & 4 deletions R/reportPolicyCosts.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ reportPolicyCosts <- function(gdx,gdx_ref,regionSubsetList=NULL,t=c(seq(2005,206
####### calculate reporting parameters ############
tmp <- NULL
tmp <- mbind(tmp,setNames((cons_bau - cons) * 1000, "Policy Cost|Consumption Loss (billion US$2005/yr)" ))
tmp <- mbind(tmp,setNames((cons_bau - cons)/(cons_bau + 1e-10) * 100, "Policy Cost|Consumption Loss|Relative to Reference Consumption (percent)"))
tmp <- mbind(tmp,setNames((cons_bau - cons)/(cons_bau + 1e-10) * 100, "Policy Cost|Consumption Loss|Relative to Reference Consumption (%)"))
tmp <- mbind(tmp,setNames((gdp_bau - gdp) * 1000, "Policy Cost|GDP Loss (billion US$2005/yr)" ))
tmp <- mbind(tmp,setNames((gdp_bau - gdp)/(gdp_bau + 1e-10) * 100, "Policy Cost|GDP Loss|Relative to Reference GDP (percent)"))
tmp <- mbind(tmp,setNames((gdp_bau - gdp)/(gdp_bau + 1e-10) * 100, "Policy Cost|GDP Loss|Relative to Reference GDP (%)"))
tmp <- mbind(tmp,setNames((v_costfu +v_costin + v_costom - (v_costfu_bau + v_costin_bau + v_costom_bau)) * 1000, "Policy Cost|Additional Total Energy System Cost (billion US$2005/yr)" ))
# Policy costs calculated as consumption losses net the effect of climate-policy induced changes in the current account
# Policy costs calculated as consumption losses net the effect of climate-policy induced changes in the current account
tmp <- mbind(tmp,setNames(((cons_bau + currAcc_bau) - (cons + currAcc)) * 1000, "Policy Cost|Consumption + Current Account Loss (billion US$2005/yr)" ))
tmp <- mbind(tmp,setNames(((cons_bau + currAcc_bau) - (cons + currAcc))/(cons_bau + currAcc_bau + 1e-10) * 100, "Policy Cost|Consumption + Current Account Loss|Relative to Reference Consumption + Current Account (percent)" ))
tmp <- mbind(tmp,setNames(((cons_bau + currAcc_bau) - (cons + currAcc))/(cons_bau + currAcc_bau + 1e-10) * 100, "Policy Cost|Consumption + Current Account Loss|Relative to Reference Consumption + Current Account (%)" ))

# add other region aggregations
if (!is.null(regionSubsetList))
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The REMIND R package (2nd generation)

R package **remind2**, version **1.149.2**
R package **remind2**, version **1.149.3**

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

Expand Down Expand Up @@ -49,7 +49,7 @@ In case of questions / problems please contact Renato Rodrigues <renato.rodrigue

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

Rodrigues R, Baumstark L, Benke F, Dietrich J, Dirnaichner A, Duerrwaechter J, Führlich P, Giannousakis A, Hasse R, Hilaire J, Klein D, Koch J, Kowalczyk K, Levesque A, Malik A, Merfort A, Merfort L, Morena-Leiva S, Pehl M, Pietzcker R, Rauner S, Richters O, Rottoli M, Schötz C, Schreyer F, Siala K, Sörgel B, Spahr M, Strefler J, Verpoort P, Weigmann P, Rüter T (2024). _remind2: The REMIND R package (2nd generation)_. R package version 1.149.2, <https://github.com/pik-piam/remind2>.
Rodrigues R, Baumstark L, Benke F, Dietrich J, Dirnaichner A, Duerrwaechter J, Führlich P, Giannousakis A, Hasse R, Hilaire J, Klein D, Koch J, Kowalczyk K, Levesque A, Malik A, Merfort A, Merfort L, Morena-Leiva S, Pehl M, Pietzcker R, Rauner S, Richters O, Rottoli M, Schötz C, Schreyer F, Siala K, Sörgel B, Spahr M, Strefler J, Verpoort P, Weigmann P, Rüter T (2024). _remind2: The REMIND R package (2nd generation)_. R package version 1.149.3, <https://github.com/pik-piam/remind2>.

A BibTeX entry for LaTeX users is

Expand All @@ -58,7 +58,7 @@ A BibTeX entry for LaTeX users is
title = {remind2: The REMIND R package (2nd generation)},
author = {Renato Rodrigues and Lavinia Baumstark and Falk Benke and Jan Philipp Dietrich and Alois Dirnaichner and Jakob Duerrwaechter and Pascal Führlich and Anastasis Giannousakis and Robin Hasse and Jérome Hilaire and David Klein and Johannes Koch and Katarzyna Kowalczyk and Antoine Levesque and Aman Malik and Anne Merfort and Leon Merfort and Simón Morena-Leiva and Michaja Pehl and Robert Pietzcker and Sebastian Rauner and Oliver Richters and Marianna Rottoli and Christof Schötz and Felix Schreyer and Kais Siala and Björn Sörgel and Mike Spahr and Jessica Strefler and Philipp Verpoort and Pascal Weigmann and Tonn Rüter},
year = {2024},
note = {R package version 1.149.2},
note = {R package version 1.149.3},
url = {https://github.com/pik-piam/remind2},
}
```

0 comments on commit 940c3a4

Please sign in to comment.