Skip to content

Commit

Permalink
introduce NAs for calculated UNFCCC variables
Browse files Browse the repository at this point in the history
  • Loading branch information
fbenke-pik committed Oct 27, 2023
1 parent 655a6c4 commit 074490d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '33483600'
ValidationKey: '33515185'
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.170.4
date-released: '2023-10-20'
version: 0.170.5
date-released: '2023-10-27'
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.170.4
Date: 2023-10-20
Version: 0.170.5
Date: 2023-10-27
Authors@R: c(
person("Lavinia", "Baumstark", , "[email protected]", role = c("aut", "cre")),
person("Renato", "Rodrigues", role = "aut"),
Expand Down
8 changes: 1 addition & 7 deletions R/calcHistorical.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,6 @@ calcHistorical <- function() {
UBA_emi <- calcOutput("UBA", aggregate = FALSE)
UBA_emi <- add_dimension(UBA_emi, dim = 3.1, add = "model", nm = "UBA")

# UNFCCC emission data
UNFCCC <- calcOutput("UNFCCC", aggregate = FALSE)
# remove years before 1990 due to incomplete data
UNFCCC <- UNFCCC[, seq(1986, 1989, 1), , invert = T]
UNFCCC <- add_dimension(UNFCCC, dim = 3.1, add = "model", nm = "UNFCCC")

# BP data
BP <- calcOutput("BP", aggregate = FALSE)
BP <- add_dimension(BP, dim = 3.1, add = "model", nm = "BP")
Expand Down Expand Up @@ -331,7 +325,7 @@ calcHistorical <- function() {
ARIADNE_ReferenceScenarioGdpCorona, ARIADNE_ReferenceScenarioPop,
EEA_GHGSectoral, EEA_GHGTotal, EEA_GHGProjections, Emi_Reference,
# EEA_GHGES,
INNOPATHS, JRC_Industry, JRC_Transport, JRC_ResCom, UBA_emi, UNFCCC, BP,
INNOPATHS, JRC_Industry, JRC_Transport, JRC_ResCom, UBA_emi, BP,
worldsteel, steelStock, USGS_cement
)

Expand Down
14 changes: 14 additions & 0 deletions R/calcUNFCCC.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ calcUNFCCC <- function() {
as.magpie() %>%
toolCountryFill(fill = NA, verbosity = 2)

mappedVariables <- getNames(x)

# aggregate pollutants ----

x <- add_columns(x, "Emi|CH4 (Mt CH4/yr)", dim = 3.1)
Expand Down Expand Up @@ -235,6 +237,18 @@ calcUNFCCC <- function() {
x[, , "Emi|GHG|Industrial Processes (Mt CO2eq/yr)"] +
x[, , "Emi|GHG|Energy|Demand|Industry (Mt CO2eq/yr)"]

# return results ----

# set 0 to NA in calculated variables
calculatedVariabes <- setdiff(getNames(x), mappedVariables)
tmp <- x[, , calculatedVariabes]
tmp[tmp == 0] <- NA
x[, , calculatedVariabes] <- tmp

# remove years before 1990 due to incomplete data
x <- x[, seq(1986, 1989, 1), , invert = TRUE]
x <- add_dimension(x, dim = 3.1, add = "model", nm = "UNFCCC")

return(list(
x = x, weight = NULL,
unit = c("Mt CO2", "Mt CH4", "kt N2O", "Mt CO2eq"),
Expand Down
10 changes: 10 additions & 0 deletions R/fullVALIDATIONREMIND.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ fullVALIDATIONREMIND <- function(rev = 0) {
)
}

## UNFCCC ----

x <- calcOutput(
type = "UNFCCC", aggregate = columnsForAggregation,
warnNA = FALSE, try = FALSE
)

write.report(x, file = valfile, append = TRUE, scenario = "historical")


# filter variables that are too imprecise on regional level ----
filter_historical_mif()
}
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.170.4**
R package **mrremind**, version **0.170.5**

[![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.170.4, <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.170.5, <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.170.4},
note = {R package version 0.170.5},
url = {https://github.com/pik-piam/mrremind},
}
```

0 comments on commit 074490d

Please sign in to comment.