Skip to content

Commit

Permalink
Merge pull request #191 from fbenke-pik/master
Browse files Browse the repository at this point in the history
remove gloabl IEA WEO 2021 data from historical.mif
  • Loading branch information
fbenke-pik authored Jan 14, 2022
2 parents f9fcd8c + 9074ac2 commit 640ec82
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
ValidationKey: '19385100'
ValidationKey: '19405126'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
- 'Warning: multiple methods tables found for ‘direction’'
- 'Warning: multiple methods tables found for ‘gridDistance’'
AcceptedNotes:
- unable to verify current time
- Imports includes .* non-default packages.
Expand Down
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "mrremind: MadRat REMIND Input Data Package",
"version": "0.102.0",
"version": "0.102.1",
"description": "<p>The mrremind packages contains data preprocessing for the REMIND model.<\/p>",
"creators": [
{
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: mrremind
Type: Package
Title: MadRat REMIND Input Data Package
Version: 0.102.0
Date: 2022-01-13
Version: 0.102.1
Date: 2022-01-14
Authors@R: c(person("Lavinia", "Baumstark", email = "[email protected]", role = c("aut","cre")),
person("Renato", "Rodrigues", role = "aut"),
person("Antoine", "Levesque", role = "aut"),
Expand Down
13 changes: 8 additions & 5 deletions R/calcHistorical.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,11 @@ calcHistorical <- function() {
BP_Price <- calcOutput("BP", subtype = "Price", aggregate = FALSE)
BP_Price <- add_dimension(BP_Price, dim = 3.1, add = "model", nm = "BP")

WEO_2021 <- calcOutput("IEA_WEO_2021", subtype = "GLO", aggregate = F)
WEO_2021_reg <- calcOutput("IEA_WEO_2021", subtype = "regional", aggregate = F)
# currently we don't include global data because regional disaggregation is too unprecise to
# compare the data on any other than global level
# WEO_2021 <- calcOutput("IEA_WEO_2021", subtype = "GLO", aggregate = F)

WEO_2021 <- calcOutput("IEA_WEO_2021", subtype = "regional", aggregate = F)

#====== start: blow up to union of years ===================
# find all existing years (y) and variable names (n)
Expand All @@ -251,16 +254,16 @@ calcHistorical <- function() {
EU_ReferenceScenario, emiEurostat, ARIADNE_ReferenceScenarioGdp, ARIADNE_ReferenceScenarioGdpCorona,
ARIADNE_ReferenceScenarioPop, EEA_GHGSectoral, EEA_GHGTotal, EEA_GHGProjections, Emi_Reference, #, EEA_GHGES
IEA_ETP, IEA_EVOutlook, INNOPATHS, JRC_Industry, JRC_Transport, JRC_ResCom, AGEB_FE, UBA_emi, UNFCCC,
BP_Emi, BP_Cap, BP_Gen, BP_Consump, BP_Trad, BP_Price, WEO_2021, WEO_2021_reg)
BP_Emi, BP_Cap, BP_Gen, BP_Consump, BP_Trad, BP_Price, WEO_2021)

y <- Reduce(union,lapply(varlist,getYears))
n <- Reduce(c,lapply(varlist,getNames))
y <- sort(y)

# create empty object with full temporal, regional and data dimensionality
data <- new.magpie(getRegions(fe_iea),y,n,fill=NA)
getSets(data)[3]<- "model"
getSets(data)[4]<- "variable"
getSets(data)[3] <- "model"
getSets(data)[4] <- "variable"

# transfer data of existing years
for (i in varlist) {
Expand Down
11 changes: 6 additions & 5 deletions R/convertIEA_WEO_2021.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ convertIEA_WEO_2021 <- function(x, subtype = "GLO") {
weight <- PE[, 2016, "PE (EJ/yr)"]
x.world <- toolAggregate(x.world, rel = mapping_world, weight = weight)
return(x.world)
}
else if (subtype == "regional") {
} else if (subtype == "regional") {
.removeNaRegions <- function(x) {
remove <- magpply(x, function(y) all(is.na(y)), MARGIN = 1)
return(x[!remove, , ])
Expand Down Expand Up @@ -70,7 +69,7 @@ convertIEA_WEO_2021 <- function(x, subtype = "GLO") {
return(x)
}

# exclude all regions we don't want to disaggregate due to reduncancies or lack of accuracy
# exclude all regions we don't want to disaggregate due to redundancies or lack of accuracy
x.reg <- x[c(
"Atlantic Basin", "East of Suez", "NonOPEC", "OPEC", "Japan and Korea",
"Southeast Asia", "Other", "European Union", "World"
Expand All @@ -80,6 +79,9 @@ convertIEA_WEO_2021 <- function(x, subtype = "GLO") {
remove <- magpply(x.reg, function(y) all(is.na(y)), MARGIN = 3)
x.reg <- x.reg[, , !remove]

# remove 2040 as year, as source has no regional data for this year
x.reg <- x.reg[, 2040, , invert = T]

regions <- c("Africa", "Asia Pacific", "Central and South America", "Europe", "Eurasia", "Middle East", "North America")

x.regional <- new.magpie(getISOlist(), getYears(x.reg), names = NULL)
Expand Down Expand Up @@ -118,8 +120,7 @@ convertIEA_WEO_2021 <- function(x, subtype = "GLO") {

x.regional <- x.regional[, , "dummy", invert = T]
return(x.regional)
}
else {
} else {
stop("Not a valid subtype!")
}
}
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.101.1**
R package **mrremind**, version **0.102.1**

[![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://codecov.io/gh/pik-piam/mrremind) [![r-universe](https://pik-piam.r-universe.dev/badges/mrremind)](https://pik-piam.r-universe.dev/ui#builds)

Expand Down Expand Up @@ -38,7 +38,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 (2022). _mrremind: MadRat REMIND Input Data Package_. R package version 0.101.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 (2022). _mrremind: MadRat REMIND Input Data Package_. R package version 0.102.1.

A BibTeX entry for LaTeX users is

Expand All @@ -47,6 +47,6 @@ 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},
year = {2022},
note = {R package version 0.101.1},
note = {R package version 0.102.1},
}
```

0 comments on commit 640ec82

Please sign in to comment.