Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pik-piam/remind2 into Emi…
Browse files Browse the repository at this point in the history
…_LULUCF_fix
  • Loading branch information
Felix Schreyer committed Jul 5, 2023
2 parents 5b96735 + cde5892 commit e989240
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '217223782'
ValidationKey: '217533133'
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.112.2
date-released: '2023-06-23'
version: 1.113.1
date-released: '2023-07-05'
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.112.2
Date: 2023-06-23
Version: 1.113.1
Date: 2023-07-05
Authors@R: c(
person("Renato", "Rodrigues", , "[email protected]", role = c("aut", "cre")),
person("Lavinia", "Baumstark", role = "aut"),
Expand Down
450 changes: 274 additions & 176 deletions R/reportEmi.R

Large diffs are not rendered by default.

35 changes: 17 additions & 18 deletions R/reportTechnology.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(
)
}

## Check realisations
# Check realisations ----
module2realisation <- readGDX(gdx, "module2realisation", react = "silent")
tran_mod <- module2realisation[module2realisation$modules == "transport", 2]

Expand All @@ -45,7 +45,7 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(
sety <- readGDX(gdx, c("entySe", "sety"), format = "first_found")
te <- readGDX(gdx, "te")

# calculate maximal temporal resolution
# calculate maximal temporal resolution ----
p_dataeta <- readGDX(gdx, name = c("pm_dataeta", "p_dataeta"), format = "first_found")
p_eta_conv <- readGDX(gdx, name = c("pm_eta_conv", "p_eta_conv"), format = "first_found")
pm_inco0_t <- readGDX(gdx, name = c("pm_inco0_t", "p_inco0_t"), format = "first_found")
Expand Down Expand Up @@ -97,7 +97,7 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(
v_adjustteinv_avg <- v_investcost[,,]*0
}

############ build reporting #####################
# build reporting ----

techmap <- c(
"bioigccc" = "Electricity|Biomass|Gasification Combined Cycle w/ CC",
Expand Down Expand Up @@ -156,7 +156,6 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(
techmap <- append(techmap, c("MeOH" = "Liquids|Hydrogen",
"h22ch4" = "Gases|Hydrogen"))


if (CDR_mod != "off") {
cdrmap <- c("dac" = "DAC",
"ccsinje" = "CO2 Storage")
Expand Down Expand Up @@ -213,7 +212,7 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(
## For cars (technically a Energy Service), we use FEs.
int2ext <- c()
if (all(map %in% techmap)) {
for (label in techmap) {
for (label in map) {
int2ext[[report_str(label, category, unit)]] <- report_str(label, unit = "EJ/yr", predicate = "SE")
}
## storage needs a special mapping
Expand Down Expand Up @@ -244,7 +243,7 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(

tmp <- NULL

### capital costs ###
## capital costs ----

category <- "Capital Costs"
unit <- "US$2005/kW"
Expand All @@ -253,7 +252,7 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(
tmp <- bind_category(tmp, v_investcost, category, unit, factor, techmap)
int2ext <- get_global_mapping(category, unit, techmap)

### Capital cost including adjustment cost ###
### Capital cost including adjustment cost ----
if (!is.null(v_adjustteinv_avg)) {
category <- "Capital Costs|w/ Adj Costs"
unit <- "US$2005/kW"
Expand All @@ -276,7 +275,7 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(
int2ext <- c(int2ext, get_global_mapping(category, unit, cdrmap))
}

### efficiency ###
## efficiency ----
## efficiency variables can be found in both p_dataeta and p_eta_conv, so do it one-by-one
## for cars, efficiencies are not given

Expand All @@ -286,18 +285,19 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(

in_dataeta <- c("bioigccc", "bioigcc", "igccc", "igcc", "pc", "ngccc", "ngcc", "ngt")

for (key in names(techmap)) {
tech_exclude <- techmap[setdiff(names(techmap), 'tnrs')] # exclude nuclear

for (key in names(tech_exclude)) {
if (key %in% in_dataeta) {
tmp <- bind_element(tmp, p_dataeta, key, category, unit, factor)
} else {
tmp <- bind_element(tmp, p_eta_conv, key, category, unit, factor)
}
}

int2ext <- c(int2ext, get_global_mapping(category, unit, techmap))
int2ext <- c(int2ext, get_global_mapping(category, unit, tech_exclude))


### lifetime ###
## lifetime ----

category <- "Lifetime"
unit <- "years"
Expand All @@ -316,7 +316,7 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(



### o&m fix costs ###
## o&m fix costs ----
category <- "OM Cost|fixed"
unit <- "US$2005/kW/yr"
tmp <- bind_category(tmp, omf * v_investcost, category, unit, 1000.)
Expand All @@ -330,7 +330,6 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(
int2ext <- c(int2ext, get_global_mapping(category, unit, carmap))
}


if (CDR_mod != "off") {
## op costs for CDR technologies ###
category <- "OM Cost|fixed"
Expand All @@ -339,22 +338,22 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(
int2ext <- c(int2ext, get_global_mapping(category, unit, cdrmap))
}

### o&m variable costs ###
## o&m variable costs ----
category <- "OM Cost|variable"
unit <- "US$2005/GJ"
tmp <- bind_category(tmp, omv, category, unit, 1000. / 31.7098)
int2ext <- c(int2ext, get_global_mapping(category, unit, techmap))


### write to output ###
# write to output ----
## substitute NA by 1E-30 to avoid that if in 2005, 2010, 2015, 2130, 2150,
## output is 0 in each region, the sum is returned by speed_aggregate
output[is.na(output) | output == 0] <- 1E-30
## delete "+" and "++" from variable names
output <- deletePlus(output)


# add global values
# add global values ----
map <- data.frame(region = getRegions(tmp), world = "GLO", stringsAsFactors = FALSE)
y <- Reduce(intersect, list(getYears(tmp), getYears(output)))
tmp <- tmp[, y, ]
Expand All @@ -365,7 +364,7 @@ reportTechnology <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(
}
tmp <- mbind(tmp, tmp_GLO)

# add other region aggregations
# add other region aggregations ----
if (!is.null(regionSubsetList)) {
tmp_RegAgg <- new.magpie(names(regionSubsetList), getYears(tmp), magclass::getNames(tmp), fill = 0)
for (region in names(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.112.2**
R package **remind2**, version **1.113.1**

[![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, 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 (2023). _remind2: The REMIND R package (2nd generation)_. R package version 1.112.2, <https://github.com/pik-piam/remind2>.
Rodrigues R, Baumstark L, Benke F, Dietrich J, Dirnaichner A, 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 (2023). _remind2: The REMIND R package (2nd generation)_. R package version 1.113.1, <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 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},
year = {2023},
note = {R package version 1.112.2},
note = {R package version 1.113.1},
url = {https://github.com/pik-piam/remind2},
}
```
7 changes: 7 additions & 0 deletions inst/markdown/compareScenarios2/cs2_09_carbon_management.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ showAreaAndBarPlotsPlus(data, "Carbon Management|Usage", scales = "fixed")
```{r carbon management share}
showLinePlots(data, "Carbon Management|Share of Stored CO2 from Captured CO2")
```

```{r}
showAreaAndBarPlots(data,
vars = c('Carbon Management|Storage',
'Carbon Management|Usage'),
tot = 'Carbon Management|Carbon Capture')
```
1 change: 0 additions & 1 deletion tests/testthat/test-piamInterfaces-Ariadne.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
skip()
library(gdx)

test_that("Test if REMIND reporting produces mandatory variables for Ariadne reporting", {
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-piamInterfaces-NAVIGATE.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
skip()
library(gdx)

test_that("Test if REMIND reporting produces mandatory variables for NAVIGATE reporting", {
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-piamInterfaces-NGFS.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
skip()
library(gdx)

test_that("Test if REMIND reporting produces mandatory variables for NGFS reporting", {
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-piamInterfaces-SHAPE.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
skip()
library(gdx)

test_that("Test if REMIND reporting produces mandatory variables for SHAPE reporting", {
Expand Down

0 comments on commit e989240

Please sign in to comment.