Skip to content

Commit

Permalink
Merge pull request #453 from fbenke-pik/years
Browse files Browse the repository at this point in the history
allow filtering for years when creating historical.mif
  • Loading branch information
fbenke-pik authored Dec 12, 2023
2 parents 60fe0ba + 7ab0105 commit bec3443
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '34274520'
ValidationKey: '34301182'
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.174.0
date-released: '2023-12-07'
version: 0.174.1
date-released: '2023-12-11'
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.174.0
Date: 2023-12-07
Version: 0.174.1
Date: 2023-12-11
Authors@R: c(
person("Lavinia", "Baumstark", , "[email protected]", role = c("aut", "cre")),
person("Renato", "Rodrigues", role = "aut"),
Expand Down
2 changes: 1 addition & 1 deletion R/filter_historical_mif.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' @export
filter_historical_mif <- function(path = NULL, filter_table = NULL) {
if (is.null(path))
path <- file.path(getConfig('outputfolder'), 'historical.mif')
path <- 'historical.mif'

if (is.null(filter_table))
filter_table <- read.csv(
Expand Down
4 changes: 1 addition & 3 deletions R/fullREMIND.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#'
#' Function that produces the complete regional data set required for the
#' REMIND model.
#'
#' @param rev data revision which should be used as input (positive numeric).
#' @importFrom madrat madratAttach
#' @importFrom magrittr %>%
#' @importFrom quitte cartesian madrat_mule
Expand All @@ -15,7 +13,7 @@
#' fullREMIND()
#' }
#'
fullREMIND <- function(rev = 0) {
fullREMIND <- function() {
rem_years <- seq(2005, 2150, 5)
rem_years_hist <- seq(1990, 2150, 5)

Expand Down
68 changes: 43 additions & 25 deletions R/fullVALIDATIONREMIND.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
#' Function that generates the historical regional dataset against which the
#' REMIND model results can be compared.
#'
#' @param rev data revision which should be used as input (positive numeric).
#' @author David Klein
#' @param years A vector of years that should be returned. If set to NULL all
#' available years are returned.
#' @author David Klein, Falk Benke
#' @seealso
#' \code{\link{fullREMIND}},\code{\link{readSource}},\code{\link{getCalculations}},\code{\link{calcOutput}}
#' @examples
#' \dontrun{
#' fullVALIDATIONREMIND()
#' }
#'
fullVALIDATIONREMIND <- function(rev = 0) {
fullVALIDATIONREMIND <- function(years = NULL) {
# get region mappings for aggregation ----
# Determines all regions data should be aggregated to by examining the columns
# of the `regionmapping` and `extramappings` currently configured.
Expand Down Expand Up @@ -45,29 +46,32 @@ fullVALIDATIONREMIND <- function(rev = 0) {

calcOutput("Historical",
round = 5, file = valfile, aggregate = columnsForAggregation,
append = FALSE, warnNA = FALSE, try = FALSE
append = FALSE, warnNA = FALSE, try = FALSE, years = years
)

# AGEB ----

calcOutput(
type = "AGEB", subtype = "balances", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "AGEB")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "AGEB")
)

calcOutput(
type = "AGEB", subtype = "electricity", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "AGEB")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "AGEB")
)

# BP ----

calcOutput(
type = "BP", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "BP")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "BP")
)

# EDGAR6 Emissions----
Expand All @@ -76,54 +80,60 @@ fullVALIDATIONREMIND <- function(rev = 0) {
calcOutput(
type = "Emissions", datasource = "EDGAR6", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "EDGAR6")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "EDGAR6")
)

# Ember electricity data ----

calcOutput(
type = "Ember", subtype = "all", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "Ember")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "Ember")
)

# European Eurostat data ----

calcOutput(
type = "EuropeanEnergyDatasheets", subtype = "EU27", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "Eurostat")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "Eurostat")
)

# EU Reference Scenario ----

calcOutput(
type = "EU_ReferenceScenario", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical")
try = FALSE, years = years,
writeArgs = list(scenario = "historical")
)

# Global Energy Monitor ----

calcOutput(
type = "GlobalEnergyMonitor", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical")
try = FALSE, years = years,
writeArgs = list(scenario = "historical")
)

# HRE Heat Roadmap Europe (Final Energy) ----

calcOutput(
type = "HRE", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical")
try = FALSE, years = years,
writeArgs = list(scenario = "historical")
)

# IEA ETP ----

calcOutput(
type = "IEA_ETP", aggregate = columnsForAggregation, file = valfile,
append = TRUE, warnNA = FALSE, try = FALSE, isValidation = TRUE,
append = TRUE, warnNA = FALSE, try = FALSE, years = years,
writeArgs = list(scenario = "historical")
)

Expand All @@ -132,22 +142,22 @@ fullVALIDATIONREMIND <- function(rev = 0) {
calcOutput(
type = "IEA_EVOutlook", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical")
try = FALSE, years = years, writeArgs = list(scenario = "historical")
)


# IEA WEO 2021 ----
weo <- calcOutput(
type = "IEA_WEO_2021", subtype = "global", aggregate = columnsForAggregation,
warnNA = FALSE, try = FALSE
warnNA = FALSE, try = FALSE, years = years,
)

weo <- weo["GLO", , ]
write.report(weo, file = valfile, append = TRUE, scenario = "historical")

weo <- calcOutput(
type = "IEA_WEO_2021", subtype = "region", aggregate = columnsForAggregation,
warnNA = FALSE, try = FALSE
warnNA = FALSE, try = FALSE, years = years,
)

weo <- weo["GLO", , invert = TRUE]
Expand All @@ -158,59 +168,67 @@ fullVALIDATIONREMIND <- function(rev = 0) {
calcOutput(
type = "INNOPATHS", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "INNOPATHS")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "INNOPATHS")
)

# JRC IDEES ----

calcOutput(
type = "JRC_IDEES", subtype = "Industry", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "JRC")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "JRC")
)

calcOutput(
type = "JRC_IDEES", subtype = "Transport", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "JRC")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "JRC")
)

calcOutput(
type = "JRC_IDEES", subtype = "ResCom", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "JRC")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "JRC")
)

# Mueller Steel Stock ----

calcOutput(
type = "SteelStock", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "Mueller")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "Mueller")
)

# UBA Emission data ----

calcOutput(
type = "UBA", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "UBA")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "UBA")
)

# UNFCCC ----

calcOutput(
type = "UNFCCC", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical")
try = FALSE, years = years,
writeArgs = list(scenario = "historical")
)

# UNIDO ----

calcOutput(
type = "UNIDO", subtype = "INDSTAT2", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, writeArgs = list(scenario = "historical", model = "INDSTAT2")
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "INDSTAT2")
)

# filter variables that are too imprecise on regional level ----
Expand Down
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.174.0**
R package **mrremind**, version **0.174.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://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.174.0, <URL: 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.174.1, <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.174.0},
note = {R package version 0.174.1},
url = {https://github.com/pik-piam/mrremind},
}
```
5 changes: 1 addition & 4 deletions man/fullREMIND.Rd

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

7 changes: 4 additions & 3 deletions man/fullVALIDATIONREMIND.Rd

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

0 comments on commit bec3443

Please sign in to comment.