Skip to content
Open
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: '44126740'
ValidationKey: '44316800'
AcceptedWarnings:
- Invalid URL: .*
- '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: 'mrremind: MadRat REMIND Input Data Package'
version: 0.219.1
date-released: '2025-02-21'
version: 0.220.0
date-released: '2025-02-25'
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.219.1
Date: 2025-02-21
Version: 0.220.0
Date: 2025-02-25
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 @@ -83,3 +83,4 @@ importFrom(rlang,syms)
importFrom(tibble,as_tibble)
importFrom(tibble,tibble)
importFrom(utils,read.csv)
importFrom(utils,read.table)
38 changes: 38 additions & 0 deletions R/calcGMPReduction.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#' Calculates Global Methane Pledge (GMP) pledged CH4 emissions reductions in 2030 for each region,
#' assuming 30% reduction relative to 2020 levels and using CEDS2020 emissions as weights.
#'
#' Information about the list of countries that have commited to the GMP
#' can be found under mrremind::readGlobalMethanePledge()
#'
#' @return MAgPIE object with regional pledged reduction fraction of 2020 emissions by all countries,
#' weighted by CEDS2020 emissions of pledged countries
#' @author Gabriel Abrahao
calcGMPReduction <- function() {
# 2020 emissions to use as aggregation weights
fullceds <- readSource("CEDS2024")[, 2020, "ch4"] # in MtCH4
emis2020 <- setYears(dimSums(fullceds, dim = 3), NULL)

# Binary data of all countries, with 1 if it has commited to the GMP
ismember <- readSource("GlobalMethanePledge")

# Preallocating with ismember
x <- ismember
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this?


x <- new.magpie(
cells_and_regions = getISOlist(),
years = NULL,
fill = 0
)

x[getRegions(ismember),,] <- x[getRegions(ismember),,] + ismember

# The GMP countries commit to reduce their emissions by 30% (relative to 2020 levels) until 2030
x[, , ] <- x[, , ] * 0.30

return(list(
x = x,
weight = emis2020,
unit = "fraction of 2020 emissions",
description = "Pledged reduction fraction of 2020 emissions by all countries, weighted by CEDS2020 emissions"
))
}
18 changes: 18 additions & 0 deletions R/readGlobalMethanePledge.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#' Countries that commited to the Global Methane Pledge by 23.02.2025
#'
#' Data scraped from the map at https://www.globalmethanepledge.org/
#'
#' @return A [`magpie`][magclass::magclass] object.
#' @author Gabriel Abrahao
#' @importFrom utils read.table
readGlobalMethanePledge <- function() {
dfgmp <- read.table("global_methane_pledge_members.csv", sep = ";", header = TRUE)
colnames(dfgmp) <- c("iso2", "country", "data")
mpgmp <- as.magpie(dfgmp[c("country", "data")], spatial = "country")
return(list(
x = mpgmp,
weight = NULL,
unit = "binary",
description = "Countries that commited to the Global Methane Pledge by 23.02.2025, 1 for commited, 0 for not"
))
}
10 changes: 6 additions & 4 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.219.1**
R package **mrremind**, version **0.220.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,15 +39,17 @@ 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, Koch J (2025). "mrremind: MadRat REMIND Input Data Package - Version 0.219.1."
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, Koch J (2025). "mrremind: MadRat REMIND Input Data Package." Version: 0.220.0, <https://github.com/pik-piam/mrremind>.

A BibTeX entry for LaTeX users is

```latex
@Misc{,
title = {mrremind: MadRat REMIND Input Data Package - Version 0.219.1},
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 and Johannes Koch},
date = {2025-02-21},
date = {2025-02-25},
year = {2025},
url = {https://github.com/pik-piam/mrremind},
note = {Version: 0.220.0},
}
```
20 changes: 20 additions & 0 deletions man/calcGMPReduction.Rd

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

17 changes: 17 additions & 0 deletions man/readGlobalMethanePledge.Rd

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

Loading