From 93784195c60d85b73003ae099805b3abb7c9a7d4 Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Fri, 11 Oct 2024 09:19:48 +0200 Subject: [PATCH 1/3] explicitly monitor GDPuc::convertGDP for madrat caching --- R/EDGE-Industry.R | 2 ++ R/UNIDO.R | 2 ++ R/calcBP.R | 2 ++ R/calcBiomassPrices.R | 1 + R/calcCO2Prices.R | 1 + R/calcCostsTradePeFinancial.R | 2 ++ R/calcCostsWeathering.R | 1 + R/calcDiffInvestCosts.R | 1 + R/calcEU_ReferenceScenario.R | 1 + R/calcEconometricEmiParameter.R | 1 + R/calcINNOPATHS.R | 1 + R/calcIndustry_EEK.R | 1 + R/calcJRC_IDEES.R | 1 + R/calcTaxConvergence.R | 1 + R/calcTaxLimits.R | 1 + R/calcTaxXport.R | 1 + R/convertDylanAusGasCost.R | 1 + R/convertGEA2012.R | 2 ++ R/convertIIASA_subs_taxes.R | 1 + R/convertTransportSubisidies.R | 2 ++ 20 files changed, 26 insertions(+) diff --git a/R/EDGE-Industry.R b/R/EDGE-Industry.R index bfb17cf7..e2b5a0a7 100644 --- a/R/EDGE-Industry.R +++ b/R/EDGE-Industry.R @@ -56,6 +56,8 @@ calcSteel_Projections <- function(subtype = 'production', save.plots = NULL, China_Production = NULL) { + "!# @monitor GDPuc::convertGDP" + if (!is.null(save.plots)) { if (!all(isTRUE(file.info(save.plots)$isdir), 448L == bitwAnd(file.info(save.plots)$mode, 448L))) { diff --git a/R/UNIDO.R b/R/UNIDO.R index f9e846bd..847d4e50 100644 --- a/R/UNIDO.R +++ b/R/UNIDO.R @@ -111,6 +111,8 @@ readUNIDO <- function(subtype = 'INDSTAT2') #' @export convertUNIDO <- function(x, subtype = 'INDSTAT2') { + "!# @monitor GDPuc::convertGDP" + # define convert functions for all subtypes ---- switchboard <- list( `INDSTAT2` = function(x) diff --git a/R/calcBP.R b/R/calcBP.R index ed35ea04..7d8c1bd7 100644 --- a/R/calcBP.R +++ b/R/calcBP.R @@ -7,6 +7,8 @@ #' @export #' calcBP <- function() { + "!# @monitor GDPuc::convertGDP" + # read in emissions, capacity, generation, price ---- emissions <- readSource("BP", subtype = "Emission") diff --git a/R/calcBiomassPrices.R b/R/calcBiomassPrices.R index 909d867a..ada32fed 100644 --- a/R/calcBiomassPrices.R +++ b/R/calcBiomassPrices.R @@ -2,6 +2,7 @@ #' @return Magpie object with two parameters determining linear biomass supply curve calcBiomassPrices <- function() { + "!# @monitor GDPuc::convertGDP" x <- readSource("MAgPIE", subtype = "supplyCurve_magpie_40") diff --git a/R/calcCO2Prices.R b/R/calcCO2Prices.R index ee6621c5..50ef26b3 100644 --- a/R/calcCO2Prices.R +++ b/R/calcCO2Prices.R @@ -1,4 +1,5 @@ calcCO2Prices <- function() { + "!# @monitor GDPuc::convertGDP" # read data x <- readSource("ExpertGuess", subtype = "co2prices") diff --git a/R/calcCostsTradePeFinancial.R b/R/calcCostsTradePeFinancial.R index f8fc67b8..97d36680 100644 --- a/R/calcCostsTradePeFinancial.R +++ b/R/calcCostsTradePeFinancial.R @@ -10,6 +10,8 @@ #' } #' calcCostsTradePeFinancial <- function() { + "!# @monitor GDPuc::convertGDP" + data <- readSource("ExpertGuess", subtype = "costsTradePeFinancial") data <- GDPuc::convertGDP( diff --git a/R/calcCostsWeathering.R b/R/calcCostsWeathering.R index bc1f308c..fcfe2d46 100644 --- a/R/calcCostsWeathering.R +++ b/R/calcCostsWeathering.R @@ -8,6 +8,7 @@ #' } #' calcCostsWeathering <- function() { + "!# @monitor GDPuc::convertGDP" costs <- readSource("Strefler", subtype = "weathering_costs") diff --git a/R/calcDiffInvestCosts.R b/R/calcDiffInvestCosts.R index 69d8fc31..9286e103 100644 --- a/R/calcDiffInvestCosts.R +++ b/R/calcDiffInvestCosts.R @@ -9,6 +9,7 @@ #' @author Aman Malik calcDiffInvestCosts <- function(subtype) { + "!# @monitor GDPuc::convertGDP" if (subtype == "Invest_Costs") { diff --git a/R/calcEU_ReferenceScenario.R b/R/calcEU_ReferenceScenario.R index 64d305ad..28d83f34 100644 --- a/R/calcEU_ReferenceScenario.R +++ b/R/calcEU_ReferenceScenario.R @@ -1,4 +1,5 @@ calcEU_ReferenceScenario <- function() { + "!# @monitor GDPuc::convertGDP" euRef2016 <- readSource("EU_ReferenceScenario", subtype = "2016") diff --git a/R/calcEconometricEmiParameter.R b/R/calcEconometricEmiParameter.R index 653c91f9..ba734097 100644 --- a/R/calcEconometricEmiParameter.R +++ b/R/calcEconometricEmiParameter.R @@ -14,6 +14,7 @@ #' } calcEconometricEmiParameter <- function() { + "!# @monitor GDPuc::convertGDP" # calculate parameter p3 edgar <- readSource("EDGAR", subtype = "co2") * 12 / 44 * 1e-6 diff --git a/R/calcINNOPATHS.R b/R/calcINNOPATHS.R index 5822488d..1b0006c5 100644 --- a/R/calcINNOPATHS.R +++ b/R/calcINNOPATHS.R @@ -1,4 +1,5 @@ calcINNOPATHS <- function() { + "!# @monitor GDPuc::convertGDP" x <- readSource("INNOPATHS") diff --git a/R/calcIndustry_EEK.R b/R/calcIndustry_EEK.R index 296c6f64..b48f3a36 100644 --- a/R/calcIndustry_EEK.R +++ b/R/calcIndustry_EEK.R @@ -15,6 +15,7 @@ #' @export calcIndustry_EEK <- function(kap) { + "!# @monitor GDPuc::convertGDP" # setup ---- i <- log(4) / 50 # assuming 50 year lifetime of EEK base_year <- 2015 diff --git a/R/calcJRC_IDEES.R b/R/calcJRC_IDEES.R index 4c8cd1dd..4b6c9c90 100644 --- a/R/calcJRC_IDEES.R +++ b/R/calcJRC_IDEES.R @@ -16,6 +16,7 @@ #' @importFrom stats aggregate calcJRC_IDEES <- function(subtype) { + "!# @monitor GDPuc::convertGDP" subtypes <- c("Industry", "Transport", "ResCom") if (!subtype %in% subtypes) { diff --git a/R/calcTaxConvergence.R b/R/calcTaxConvergence.R index 33de1a7a..ff60aab6 100644 --- a/R/calcTaxConvergence.R +++ b/R/calcTaxConvergence.R @@ -9,6 +9,7 @@ #' } #' calcTaxConvergence <- function() { + "!# @monitor GDPuc::convertGDP" # Read tax convergence levels at specific year and final energy type taxConvergence <- readSource("REMIND_11Regi", subtype = "taxConvergence") diff --git a/R/calcTaxLimits.R b/R/calcTaxLimits.R index ad210487..3f5cc5a2 100644 --- a/R/calcTaxLimits.R +++ b/R/calcTaxLimits.R @@ -17,6 +17,7 @@ #' } #' calcTaxLimits <- function(subtype) { + "!# @monitor GDPuc::convertGDP" if (!(subtype %in% c("maxFeSubsidy", "maxPeSubsidy", "propFeSubsidy"))) { stop("the argument subtype must be in c('maxFeSubsidy','maxPeSubsidy', 'propFeSubsidy')") diff --git a/R/calcTaxXport.R b/R/calcTaxXport.R index ee0639e5..71e80992 100644 --- a/R/calcTaxXport.R +++ b/R/calcTaxXport.R @@ -1,4 +1,5 @@ calcTaxXport <- function() { + "!# @monitor GDPuc::convertGDP" x <- readSource("REMIND_11Regi", subtype = "xpres_tax") diff --git a/R/convertDylanAusGasCost.R b/R/convertDylanAusGasCost.R index a902bea2..01cfb145 100644 --- a/R/convertDylanAusGasCost.R +++ b/R/convertDylanAusGasCost.R @@ -5,6 +5,7 @@ #' @seealso \code{\link{readSource}} convertDylanAusGasCost <- function(x) { + "!# @monitor GDPuc::convertGDP" x %>% # Converting from constant 2015 Australian dollars to constant 2017 US$MER diff --git a/R/convertGEA2012.R b/R/convertGEA2012.R index d6f1d32c..cfe5e770 100644 --- a/R/convertGEA2012.R +++ b/R/convertGEA2012.R @@ -11,6 +11,8 @@ #' } #' convertGEA2012 <- function(x, subtype) { + "!# @monitor GDPuc::convertGDP" + if (subtype == "coal") { # Load mapping file for GEA regions to country level diff --git a/R/convertIIASA_subs_taxes.R b/R/convertIIASA_subs_taxes.R index 10734a90..6ada4b82 100644 --- a/R/convertIIASA_subs_taxes.R +++ b/R/convertIIASA_subs_taxes.R @@ -18,6 +18,7 @@ #' } #' convertIIASA_subs_taxes <- function(x, subtype) { + "!# @monitor GDPuc::convertGDP" x <- toolCountryFill(x, verbosity = 2, fill = 0, diff --git a/R/convertTransportSubisidies.R b/R/convertTransportSubisidies.R index c2b9494a..9a0023aa 100644 --- a/R/convertTransportSubisidies.R +++ b/R/convertTransportSubisidies.R @@ -9,6 +9,8 @@ #' } #' convertTransportSubsidies <- function(x) { + "!# @monitor GDPuc::convertGDP" + x <- toolCountryFill(x, fill = 0, verbosity = 2) # fill countries with no data x[is.na(x)] <- 0 From 691d4d9cc735dfd9a07944fd6f74d8a1d92f1cee Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Fri, 11 Oct 2024 09:50:07 +0200 Subject: [PATCH 2/3] add monitoring from convert functions to read functions, as madrat does not seem to notice otherwise --- R/UNIDO.R | 2 ++ R/readDylanAusGasCost.R | 2 ++ R/readGEA2012.R | 2 ++ R/readIIASA_subs_taxes.R | 1 + R/readTransportSubsidies.R | 6 ++++-- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/R/UNIDO.R b/R/UNIDO.R index 847d4e50..d8ce9bd5 100644 --- a/R/UNIDO.R +++ b/R/UNIDO.R @@ -76,6 +76,8 @@ #' @export readUNIDO <- function(subtype = 'INDSTAT2') { + "!# @monitor GDPuc::convertGDP" + # define read functions for all subtypes ---- switchboard <- list( `INDSTAT2` = function() diff --git a/R/readDylanAusGasCost.R b/R/readDylanAusGasCost.R index 7c183ce6..2e12faa8 100644 --- a/R/readDylanAusGasCost.R +++ b/R/readDylanAusGasCost.R @@ -5,6 +5,8 @@ #' @seealso \code{\link{readSource}} #' readDylanAusGasCost <- function() { + "!# @monitor GDPuc::convertGDP" + # Dylan's gas extraction cost curve based on GSOO data on reserves and resources in 2015 # (only for Eastern gas reserves, not Western Australia!!) diff --git a/R/readGEA2012.R b/R/readGEA2012.R index 2df3bfe7..d8edc342 100644 --- a/R/readGEA2012.R +++ b/R/readGEA2012.R @@ -13,6 +13,8 @@ #' @importFrom dplyr relocate mutate readGEA2012 <- function(subtype) { + "!# @monitor GDPuc::convertGDP" + EJ_2_TWyr <- 1 / 31.536 ts1 <- 5 ts2 <- 10 diff --git a/R/readIIASA_subs_taxes.R b/R/readIIASA_subs_taxes.R index 4a66c4d0..b27a42f5 100644 --- a/R/readIIASA_subs_taxes.R +++ b/R/readIIASA_subs_taxes.R @@ -17,6 +17,7 @@ #' } #' readIIASA_subs_taxes <- function(subtype) { + "!# @monitor GDPuc::convertGDP" file <- "unlinked_countries_2017_03.xlsx" diff --git a/R/readTransportSubsidies.R b/R/readTransportSubsidies.R index d64f635f..f6cf43b1 100644 --- a/R/readTransportSubsidies.R +++ b/R/readTransportSubsidies.R @@ -1,7 +1,7 @@ #' Read transport subsidies data -#' +#' #' Read-in transport subsidies csv files as magclass object -#' +#' #' @return magpie object of the transport subsidies for BEV, FCEV and PHEV (euros/car) for private and legal entities #' @author Renato Rodrigues #' @seealso \code{\link{readSource}} @@ -9,6 +9,8 @@ #' \dontrun{ a <- readSource(type="TransportSubsidies") #' } readTransportSubsidies <- function() { + "!# @monitor GDPuc::convertGDP" + data <- read.csv("transportSubsidies.csv", sep = ";") as.magpie(data, datacol = 3) } From a912db135b8cf60fc1911b6559148443232bdf68 Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Fri, 11 Oct 2024 09:33:22 +0200 Subject: [PATCH 3/3] lucode hubbub --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- README.md | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 6efc9863..ca1ac5d9 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '38731616' +ValidationKey: '38753559' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/CITATION.cff b/CITATION.cff index 90b06dde..1fb8457c 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.193.6 -date-released: '2024-10-10' +version: 0.193.7 +date-released: '2024-10-11' abstract: The mrremind packages contains data preprocessing for the REMIND model. authors: - family-names: Baumstark diff --git a/DESCRIPTION b/DESCRIPTION index 90b5a484..15e521e1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrremind Title: MadRat REMIND Input Data Package -Version: 0.193.6 -Date: 2024-10-10 +Version: 0.193.7 +Date: 2024-10-11 Authors@R: c( person("Lavinia", "Baumstark", , "lavinia@pik-potsdam.de", role = c("aut", "cre")), person("Renato", "Rodrigues", role = "aut"), diff --git a/README.md b/README.md index 8d2adf18..24535646 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MadRat REMIND Input Data Package -R package **mrremind**, version **0.193.6** +R package **mrremind**, version **0.193.7** [![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.193.7, . 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.193.6}, + note = {R package version 0.193.7}, url = {https://github.com/pik-piam/mrremind}, } ```