Skip to content

Commit

Permalink
Merge pull request #449 from mellamoSimon/add-incineration-trajectories
Browse files Browse the repository at this point in the history
Add trajectories for incineration rates for plastic waste
  • Loading branch information
mellamoSimon authored Nov 23, 2023
2 parents 510d6b0 + 12d2d61 commit 6e59361
Show file tree
Hide file tree
Showing 10 changed files with 396 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '33681888'
ValidationKey: '33856480'
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.171.2
date-released: '2023-11-13'
version: 0.172.0
date-released: '2023-11-23'
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.171.2
Date: 2023-11-13
Version: 0.172.0
Date: 2023-11-23
Authors@R: c(
person("Lavinia", "Baumstark", , "[email protected]", role = c("aut", "cre")),
person("Renato", "Rodrigues", role = "aut"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export(calcIndustry_EEK)
export(calcIndustry_Value_Added)
export(calcODYM_RECC)
export(calcOtherFossilInElectricity)
export(calcPlasticsEoL)
export(calcShareIndFE)
export(calcSteelStock)
export(calcSteel_Projections)
Expand Down
105 changes: 105 additions & 0 deletions R/calcPlasticsEoL.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#' calculates projections for the end of life fate of plastic waste
#' in particular, calculates the share that is incinerated
#'
#' @md
#' @return A list with a [`magpie`][magclass::magclass] object `x`, `weight`,
#' `unit`, `description`.
#'
#' @author Falk Benke, Simón Moreno Leiva
#'
#' @seealso [`calcOutput()`]
#'
#' @importFrom dplyr filter pull select
#' @importFrom madrat getISOlist toolFillYears
#' @importFrom magclass new.magpie getItems
#' @importFrom rlang .data
#' @importFrom tibble as_tibble
#' @importFrom quitte calc_addVariable
#'
#' @export
#'
calcPlasticsEoL <- function() {
# read source data ----

# read in projections for plastics end-of-life flows EJ/yr
x <- readSource("Stegmann2022")

# select variables that we are going to need to calculate incineration shares
selection <- c(
"Plastics|Waste|Buildings & Construction",
"Plastics|Waste|Consumer Products",
"Plastics|Waste|Electrical & Electronic (products)",
"Plastics|Waste|Industrial Machinery",
"Plastics|Waste|Other",
"Plastics|Waste|Packaging",
"Plastics|Waste|Textiles",
"Plastics|Waste|Transportation",
"Plastics|End of Life|Waste to Energy"
)

x <- x[, , selection, pmatch = TRUE]

y <- as.quitte(x)
# calculate total plastic waste
plasticsEoL <- y %>%
# we could have switches to include a circular scenario but it would probably
# require a different scenario to calibrate
filter(!!sym("scenario") %in% c("SSP2")) %>%
calc_addVariable(
"Plastics|Waste|Total" = "
`Plastics|Waste|Buildings & Construction` +
`Plastics|Waste|Consumer Products` +
`Plastics|Waste|Electrical & Electronic (products)` +
`Plastics|Waste|Industrial Machinery`+
`Plastics|Waste|Other`+
`Plastics|Waste|Packaging`+
`Plastics|Waste|Textiles`+
`Plastics|Waste|Transportation`
",
units = "PJ/yr"
)

# calculate share (0 to 1) of waste that gets incinerated
incinerationShares <- plasticsEoL %>%
calc_addVariable(
"Plastics|End of Life|Incineration share" = "
`Plastics|End of Life|Waste to Energy`/
`Plastics|Waste|Total`
",
units = "fraction", only.new = TRUE
) %>%
# remove unused dimensions
select(-"model", -"scenario", -"variable", -"unit") %>%
interpolate_missing_periods(seq(2050, 2060, 5), method = "linear")

# as magpie
x <- as.magpie(incinerationShares)

# fill post 2100 years
# post 2100 = 2100
xNew <- new.magpie(
cells_and_regions = getItems(x, dim = 1),
years = c(seq(2110, 2150, 20)),
names = getNames(x)
)

xNew[, c(seq(2110, 2150, 20)), ] <- x[, 2100, ]

x <- mbind(x, xNew) %>%
toolCountryFill(fill = 0) %>%
collapseDim()


# create weights ----

fe <- calcOutput("FE", source = "IEA", aggregate = FALSE)[, 2016, "FE (EJ/yr)"]

return(
list(
x = x,
weight = fe,
unit = "fraction",
description = "share of plastic waste that gets incinerated"
)
)
}
19 changes: 19 additions & 0 deletions R/convertStegmann2022.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#' @title convertStegmann2022
#' @description Converts data from Stegmann2022
#' @param x unconverted magpie object from read-script
#'
#' @return magpie object with a completed dataset.
#'

convertStegmann2022 <- function(x) {
x <- x[c("World"), , , invert = TRUE]

regmapping <- toolGetMapping("regionmapping_IMAGE_PBL_Stegmann2022.csv", where = "mrremind", type = "regional")

fe <- calcOutput("FE", source = "IEA", aggregate = FALSE)[unique(regmapping$CountryCode), 2016, "FE (EJ/yr)"]

out <- toolAggregate(x, regmapping, from = "RegionAbbreviation", to = "CountryCode", weight = fe)
out <- toolCountryFill(out, fill = 0)

return(out)
}
19 changes: 10 additions & 9 deletions R/fullREMIND.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ fullREMIND <- function(rev = 0) {
calcOutput("FEdemand", subtype = "FE", signif = 4, file = "f_fedemand.cs4r")
calcOutput("ExogDemScen", round = 8, file = "p47_exogDemScen.cs4r") # exogenous demand scenarios activated by cm_exogDem_scen
calcOutput(
type = 'Steel_Projections', subtype = 'secondary.steel.max.share',
file = 'p37_steel_secondary_max_share.cs4r',
match.steel.historic.values = TRUE, match.steel.estimates = 'IEA_ETP',
China_Production = readSource(type = 'ExpertGuess',
subtype = 'Chinese_Steel_Production',
type = "Steel_Projections", subtype = "secondary.steel.max.share",
file = "p37_steel_secondary_max_share.cs4r",
match.steel.historic.values = TRUE, match.steel.estimates = "IEA_ETP",
China_Production = readSource(type = "ExpertGuess",
subtype = "Chinese_Steel_Production",
convert = FALSE) %>%
madrat_mule())
calcOutput("FEdemand", subtype = "FE_buildings", round = 8, file = "f_fedemand_build.cs4r")
Expand All @@ -64,8 +64,8 @@ fullREMIND <- function(rev = 0) {
calcOutput("DevelopmentState", round = 4, file = "f_developmentState.cs3r")
calcOutput("Population", years = rem_years_hist, round = 8, file = "f50_pop.cs3r", aggregate = FALSE)
calcOutput("GDP", years = rem_years_hist, round = 8, file = "f50_gdp.cs3r", aggregate = FALSE)
calcOutput("TCdamage", subtype = "const", round=8, file="f50_TC_df_const.cs4r", aggregate=FALSE)
calcOutput("TCdamage", subtype = "tasK", round=8, file="f50_TC_df_tasK.cs4r", aggregate=FALSE)
calcOutput("TCdamage", subtype = "const", round = 8, file = "f50_TC_df_const.cs4r", aggregate = FALSE)
calcOutput("TCdamage", subtype = "tasK", round = 8, file = "f50_TC_df_tasK.cs4r", aggregate = FALSE)

#-------------- energy services parameter -----------------------------------------------------------
calcOutput("FEdemand", subtype = "EsUeFe_in", round = 8, file = "p36_serviceInputs.cs4r")
Expand Down Expand Up @@ -162,8 +162,9 @@ fullREMIND <- function(rev = 0) {
# calcOutput("GEA2012", subtype="bounds",datatype="decoffset", round=8, file="f31_decoffset.cs4r")
# calcOutput("GEA2012", subtype="bounds",datatype="exportbound", round=8, file="f31_Xport.cs4r")
# calcOutput("GEA2012", subtype="bounds",datatype="extraseed", round=8, file="f31_extraseed.cs4r")
calcOutput('industry_specific_FE_limits', aggregate = FALSE,
file = 'pm_energy_limit.csv')
calcOutput("industry_specific_FE_limits", aggregate = FALSE,
file = "pm_energy_limit.csv")
calcOutput("PlasticsEoL", round = 5, file = "f_incinerationShares.cs4r")

#---------------policy parameters--------------------------------------------------------------------
calcOutput("EmiTarget", sources = "UNFCCC_NDC", subtype = "Ghgshare2005", round = 4, file = "fm_2005shareTarget.cs3r")
Expand Down
30 changes: 30 additions & 0 deletions R/readStegmann2022.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#' Read PlasticsEoL
#'
#' Read-in data for the End-of-Life fate of plastics
#' from 1.Stegmann, P., Daioglou, V., Londo, M., van Vuuren,
#' D. P. & Junginger, M. Plastic futures and their CO2 emissions.
#' Nature 612, 272–276 (2022).
#' https://www.nature.com/articles/s41586-022-05422-5
#' Link to SI:
#' https://static-content.springer.com/esm/art%3A10.1038%2Fs41586-022-05422-5/MediaObjects/41586_2022_5422_MOESM1_ESM.xlsx #nolint
#'
#' @md
#' @return magpie object of the data
#' @author Falk Benke, Simón Moreno
#' @seealso \code{\link{readSource}}
#' @examples
#' \dontrun{
#' a <- readSource(type = "Stegmann2022")
#' }
#'
#' @importFrom readxl read_xlsx
#' @importFrom reshape2 melt

readStegmann2022 <- function() {

data <- read_xlsx("41586_2022_5422_MOESM1_ESM.xlsx", sheet = "Data")

reshape2::melt(data, id.vars = seq(1, 5), variable.name = "period") %>%
as.magpie(spatial = 3) %>%
return()
}
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.171.2**
R package **mrremind**, version **0.172.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.171.2, <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.172.0, <URL: 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.171.2},
note = {R package version 0.172.0},
url = {https://github.com/pik-piam/mrremind},
}
```
Loading

0 comments on commit 6e59361

Please sign in to comment.