From 9df2f8b64c08f8e1d78be2f501893cea03ce9125 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Fri, 6 Dec 2024 15:39:44 +0100 Subject: [PATCH] add expert guess 'taxConvergenceRollback' --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/calcTaxConvergence.R | 29 ++++++++++++++++++----------- R/convertExpertGuess.R | 3 +++ R/fullREMIND.R | 7 ++++++- R/readExpertGuess.R | 4 ++++ README.md | 6 +++--- man/calcTaxConvergence.Rd | 5 ++++- 9 files changed, 43 insertions(+), 21 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 3f6a8393..8e5ce5eb 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '40523220' +ValidationKey: '40547323' AcceptedWarnings: - Invalid URL: .* - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 0a19b91f..4e154f0c 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -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.202.0 -date-released: '2024-12-04' +version: 0.202.1 +date-released: '2024-12-06' abstract: The mrremind packages contains data preprocessing for the REMIND model. authors: - family-names: Baumstark diff --git a/DESCRIPTION b/DESCRIPTION index f10aadbc..05c0249a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrremind Title: MadRat REMIND Input Data Package -Version: 0.202.0 -Date: 2024-12-04 +Version: 0.202.1 +Date: 2024-12-06 Authors@R: c( person("Lavinia", "Baumstark", , "lavinia@pik-potsdam.de", role = c("aut", "cre")), person("Renato", "Rodrigues", role = "aut"), diff --git a/R/calcTaxConvergence.R b/R/calcTaxConvergence.R index 2523a77a..c2512864 100644 --- a/R/calcTaxConvergence.R +++ b/R/calcTaxConvergence.R @@ -2,29 +2,36 @@ #' @description tax convergence levels for specific regions #' #' @return magpie object of the tax convergence levels +#' @param subtype either taxConvergence or taxConvergenceRollback +#' #' @author Renato Rodrigues #' @examples #' \dontrun{ #' calcOutput("TaxConvergence") #' } #' -calcTaxConvergence <- function() { +calcTaxConvergence <- function(subtype) { + + if (subtype == "taxConvergence") { - # Read tax convergence levels at specific year and final energy type - taxConvergence <- readSource("REMIND_11Regi", subtype = "taxConvergence") + # Read tax convergence levels at specific year and final energy type + taxConvergence <- readSource("REMIND_11Regi", subtype = "taxConvergence") + + # convert data from $2005 to $2017 + taxConvergence <- GDPuc::toolConvertGDP( + gdp = taxConvergence, + unit_in = "constant 2005 US$MER", + unit_out = mrdrivers::toolGetUnitDollar(), + replace_NAs = "with_USA" + ) + } else { + taxConvergence <- readSource("ExpertGuess", subtype = "taxConvergenceRollback") + } # average weight w <- taxConvergence w[, , ] <- 1 - # convert data from $2005 to $2017 - taxConvergence <- GDPuc::toolConvertGDP( - gdp = taxConvergence, - unit_in = "constant 2005 US$MER", - unit_out = mrdrivers::toolGetUnitDollar(), - replace_NAs = "with_USA" - ) - return(list( x = taxConvergence, weight = w, diff --git a/R/convertExpertGuess.R b/R/convertExpertGuess.R index f497475e..8b9f5476 100644 --- a/R/convertExpertGuess.R +++ b/R/convertExpertGuess.R @@ -19,6 +19,9 @@ convertExpertGuess <- function(x, subtype) { ), weight = NULL ) + } else if (subtype == "taxConvergenceRollback") { + mapping <- toolGetMapping(type = "regional", name = "regionmappingH12.csv", where = "mappingfolder") + out <- toolAggregate(x, mapping, weight = NULL, from = "RegionCode", to = "CountryCode") } else { out <- x } diff --git a/R/fullREMIND.R b/R/fullREMIND.R index 5ff1e8d8..561ed6de 100644 --- a/R/fullREMIND.R +++ b/R/fullREMIND.R @@ -26,7 +26,12 @@ fullREMIND <- function() { calcOutput("MacroInvestments", round = 8, file = "p01_boundInvMacro.cs4r") calcOutput("FETaxes", subtype = "taxes", round = 2, file = "f21_tau_fe_tax.cs4r") calcOutput("FETaxes", subtype = "subsidies", round = 2, file = "f21_tau_fe_sub.cs4r") - calcOutput("TaxConvergence", round = 2, file = "f21_tax_convergence.cs4r") + + calcOutput("TaxConvergence", subtype = "taxConvergence", round = 2, + file = "f21_tax_convergence.cs4r") + calcOutput("TaxConvergence", subtype = "taxConvergenceRollback", round = 2, + file = "f21_tax_convergence_rollback.cs4r") + calcOutput("TaxLimits", subtype = "maxFeSubsidy", round = 2, file = "f21_max_fe_sub.cs4r") calcOutput("TaxLimits", subtype = "maxPeSubsidy", round = 2, file = "f21_max_pe_sub.cs4r") calcOutput("TaxLimits", subtype = "propFeSubsidy", round = 2, file = "f21_prop_fe_sub.cs4r") diff --git a/R/readExpertGuess.R b/R/readExpertGuess.R index c475097d..9d90e3ed 100644 --- a/R/readExpertGuess.R +++ b/R/readExpertGuess.R @@ -105,6 +105,10 @@ readExpertGuess <- function(subtype) { } else if (subtype == "tradeConstraints") { a <- read.csv("tradeConstraints.csv", sep = ";") out <- as.magpie(a) + } else if (subtype == "taxConvergenceRollback") { + out <- read.csv("tax_convergence_rollback.csv", sep = ",", + skip = 4, col.names = c("Year", "Region", "FE", "value"), + header = FALSE) %>% as.magpie(datacol = 4) } return(out) diff --git a/README.md b/README.md index b4b3079f..418b1d46 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MadRat REMIND Input Data Package -R package **mrremind**, version **0.202.0** +R package **mrremind**, version **0.202.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) @@ -39,7 +39,7 @@ In case of questions / problems please contact Lavinia Baumstark . +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 (2024). _mrremind: MadRat REMIND Input Data Package_. R package version 0.202.1, . A BibTeX entry for LaTeX users is @@ -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 and Johannes Koch}, year = {2024}, - note = {R package version 0.202.0}, + note = {R package version 0.202.1}, url = {https://github.com/pik-piam/mrremind}, } ``` diff --git a/man/calcTaxConvergence.Rd b/man/calcTaxConvergence.Rd index a7acccec..4d6d1e00 100644 --- a/man/calcTaxConvergence.Rd +++ b/man/calcTaxConvergence.Rd @@ -4,7 +4,10 @@ \alias{calcTaxConvergence} \title{calc Tax Convergence} \usage{ -calcTaxConvergence() +calcTaxConvergence(subtype) +} +\arguments{ +\item{subtype}{either taxConvergence or taxConvergenceRollback} } \value{ magpie object of the tax convergence levels