Skip to content
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: '2495988'
ValidationKey: '2684630'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
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: 'mrindustry: input data generation for the REMIND industry module'
version: 1.2.1
date-released: '2026-06-24'
version: 1.3.0
date-released: '2026-07-17'
abstract: The mrindustry packages contains data preprocessing for the REMIND model.
authors:
- family-names: Benke
Expand Down
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: mrindustry
Title: input data generation for the REMIND industry module
Version: 1.2.1
Date: 2026-06-24
Version: 1.3.0
Date: 2026-07-17
Authors@R: c(
person(given = "Falk", family = "Benke", email = "benke@pik-potsdam.de",
role = c("aut", "cre")),
Expand Down Expand Up @@ -55,3 +55,4 @@ Suggests:
testthat,
Encoding: UTF-8
Config/roxygen2/version: 8.0.0
RoxygenNote: 7.3.3
15 changes: 11 additions & 4 deletions R/convertStegmann2022.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
#' @title convertStegmann2022
#' @description Converts data from Stegmann2022
#' @param x unconverted magpie object from read-script
#' @param subtype Character. "FEweighted" disaggregates all variables based on
#' FE; "PopWeighted" disaggregates all variables based on Population.
#'
#' @return magpie object with a completed dataset.
#'

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

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

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

out <- toolAggregate(x, regmapping, from = "RegionAbbreviation", to = "CountryCode", weight = fe)
if (subtype == "PopWeighted") {
weight <- calcOutput("Population", scenario = "SSP2", aggregate = FALSE)[unique(regmapping$CountryCode), getYears(x), ]
} else if (subtype == "FEweighted") {
weight <- calcOutput("FE", aggregate = FALSE)[unique(regmapping$CountryCode), 2016, "FE (EJ/yr)"]
} else {
stop("Unknown subtype '", subtype, "'. Use 'PopWeighted' or 'FEweighted'.")
}
out <- toolAggregate(x, regmapping, from = "RegionAbbreviation", to = "CountryCode", weight = weight)
out <- toolCountryFill(out, fill = 0, verbosity = 2)

return(out)
Expand Down
18 changes: 15 additions & 3 deletions R/readIEA_Petrochem.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#' \item RouteCTS: Fig 5.10 Petro Prod Route CTS (Clean Technology Scenario) for HVCs, Ammonia, Methanol
#' \item production3type: Fig 4.1 Petrochem Production for HVCs, Ammonia, Methanol
#' \item production5type: Fig A.1 Petrochem Prod Region for Ethylene, Propylene, BTX, Ammonia, Methanol
#' \item plastics: Fig 4.2 Production of key thermoplastics in the RTS
#' }
#'
#' Different products to read. Available types are:
Expand Down Expand Up @@ -99,6 +100,12 @@ readIEA_Petrochem <- function(subtype) {
ColumnsName = "Route",
ColumnsRange = c(3:7)
),
"plastics" = list(
sheet_name = "Fig 4.2 Prod Thermoplastics RTS",
ranges = c(All = "A1:I16"),
ColumnsName = "Year",
ColumnsRange = c(2:16)
),
stop("Invalid subtype combination")
)

Expand Down Expand Up @@ -128,11 +135,10 @@ readIEA_Petrochem <- function(subtype) {
# ---------------------------------------------------------------------------
# Set Column Names and Clean Data
# - Use the first row as column names, ensure they are unique and syntactically valid,
# and rename the first column to "Country". Remove the first row afterwards.
# Remove the first row afterwards.
# ---------------------------------------------------------------------------
colnames(data) <- as.character(unlist(data[1, ]))
colnames(data) <- make.names(colnames(data), unique = TRUE)
colnames(data)[1] <- "Country"
data <- data[-1, ]

# ---------------------------------------------------------------------------
Expand All @@ -150,7 +156,13 @@ readIEA_Petrochem <- function(subtype) {
# - Replace NA values with 0.
# - Add the concatenated subtype string as a comment to the object.
# ---------------------------------------------------------------------------
data <- as.magpie(data, spatial = 1, temporal = 2)
if (subtype[1] == "plastics") {
colnames(data)[1] <- "type"
data <- as.magpie(data, temporal = 2)
} else {
colnames(data)[1] <- "Country"
data <- as.magpie(data, spatial = 1, temporal = 2)
}
data[is.na(data)] <- 0
subtype <- paste(subtype, collapse = "_")
getComment(data) <- subtype
Expand Down
7 changes: 5 additions & 2 deletions R/readStegmann2022.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
#' Link to SI:
#' https://static-content.springer.com/esm/art%3A10.1038%2Fs41586-022-05422-5/MediaObjects/41586_2022_5422_MOESM1_ESM.xlsx #nolint
#'
#' @param subtype Character. "FEweighted" disaggregates all variables based on
#' FE; "PopWeighted" disaggregates all variables based on Population
#' (case distinction in convertStegmann2022)
#' @return a magpie object of the data
#' @author Falk Benke, Simón Moreno
#' @author Falk Benke, Simón Moreno, Leonie Schweiger
#'
readStegmann2022 <- function() {
readStegmann2022 <- function(subtype) {
readxl::read_xlsx("41586_2022_5422_MOESM1_ESM.xlsx", sheet = "Data") %>%
tidyr::pivot_longer(tidyselect::starts_with("2"), names_to = "period") %>%
as.magpie(spatial = "Region", temporal = "period", tidy = TRUE)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# input data generation for the REMIND industry module

R package **mrindustry**, version **1.2.1**
R package **mrindustry**, version **1.3.0**

[![R build status](https://github.com/pik-piam/mrindustry/workflows/check/badge.svg)](https://github.com/pik-piam/mrindustry/actions) [![codecov](https://codecov.io/gh/pik-piam/mrindustry/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrindustry) [![r-universe](https://pik-piam.r-universe.dev/badges/mrindustry)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -39,17 +39,17 @@ In case of questions / problems please contact Falk Benke <benke@pik-potsdam.de>

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

Benke F, Dürrwächter J, Rodrigues R, Moreno-Leiva S, Baumstark L, Pehl M, Weiss B (2026). "mrindustry: input data generation for the REMIND industry module." Version: 1.2.1, <https://github.com/pik-piam/mrindustry>.
Benke F, Dürrwächter J, Rodrigues R, Moreno-Leiva S, Baumstark L, Pehl M, Weiss B (2026). "mrindustry: input data generation for the REMIND industry module." Version: 1.3.0, <https://github.com/pik-piam/mrindustry>.

A BibTeX entry for LaTeX users is

```latex
@Misc{,
title = {mrindustry: input data generation for the REMIND industry module},
author = {Falk Benke and Jakob Dürrwächter and Renato Rodrigues and Simón Moreno-Leiva and Lavinia Baumstark and Michaja Pehl and Bennet Weiss},
date = {2026-06-24},
date = {2026-07-17},
year = {2026},
url = {https://github.com/pik-piam/mrindustry},
note = {Version: 1.2.1},
note = {Version: 1.3.0},
}
```
5 changes: 4 additions & 1 deletion man/convertStegmann2022.Rd

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

1 change: 1 addition & 0 deletions man/readIEA_Petrochem.Rd

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

9 changes: 7 additions & 2 deletions man/readStegmann2022.Rd

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

Loading