diff --git a/.buildlibrary b/.buildlibrary index 949b1913..feff1f87 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '2247142940' +ValidationKey: '2247162736' 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 28747bc9..c35bb3fc 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,7 +2,7 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'remind2: The REMIND R package (2nd generation)' -version: 1.135.15 +version: 1.135.16 date-released: '2024-03-14' abstract: Contains the REMIND-specific routines for data and model output manipulation. authors: diff --git a/DESCRIPTION b/DESCRIPTION index 4994f93e..b3f36387 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: remind2 Title: The REMIND R package (2nd generation) -Version: 1.135.15 +Version: 1.135.16 Date: 2024-03-14 Authors@R: c( person("Renato", "Rodrigues", , "renato.rodrigues@pik-potsdam.de", role = c("aut", "cre")), diff --git a/NAMESPACE b/NAMESPACE index 74bae3dc..791540a9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -81,7 +81,6 @@ export(showStatsTable) export(substituePlaceholder) export(switchValuesScenConf) export(toolRegionSubsets) -export(validationREMIND) export(variablesAsList) import(magclass) importFrom(abind,abind) @@ -163,18 +162,14 @@ importFrom(ggplot2,xlab) importFrom(gms,getLine) importFrom(gms,readDefaultConfig) importFrom(grDevices,colorRampPalette) -importFrom(iamc,iamCheck) importFrom(knitr,knit) importFrom(lucode2,getScenNames) importFrom(luplot,magpie2ggplot2) -importFrom(luplot,plotcountrymap) importFrom(luscale,speed_aggregate) -importFrom(lusweave,swR) importFrom(lusweave,swclose) importFrom(lusweave,swfigure) importFrom(lusweave,swlatex) importFrom(lusweave,swopen) -importFrom(lusweave,swtable) importFrom(madrat,calcOutput) importFrom(madrat,toolAggregate) importFrom(madrat,toolGetMapping) diff --git a/R/convGDX2MIF.R b/R/convGDX2MIF.R index ac86ddfa..4265b7eb 100644 --- a/R/convGDX2MIF.R +++ b/R/convGDX2MIF.R @@ -24,7 +24,7 @@ #' @importFrom gdx readGDX #' @importFrom magclass mbind write.report #' @importFrom piamInterfaces checkSummations -#' @importFrom utils write.csv +#' @importFrom utils write.csv capture.output convGDX2MIF <- function(gdx, gdx_ref = NULL, file = NULL, scenario = "default", t = c(seq(2005, 2060, 5), seq(2070, 2110, 10), 2130, 2150), diff --git a/R/reportEDGETransport.R b/R/reportEDGETransport.R index 314288fd..5b86dde4 100644 --- a/R/reportEDGETransport.R +++ b/R/reportEDGETransport.R @@ -20,6 +20,7 @@ #' @importFrom data.table fread fwrite rbindlist copy CJ setnames := data.table as.data.table #' @importFrom dplyr %>% #' @importFrom quitte as.quitte +#' @importFrom utils capture.output #' @export reportEDGETransport <- function(output_folder=".", diff --git a/R/validationREMIND.R b/R/validationREMIND.R deleted file mode 100644 index 756a2e7f..00000000 --- a/R/validationREMIND.R +++ /dev/null @@ -1,99 +0,0 @@ -#' @title validation -#' @description Create Validation pdf from REMIND output and corresponding historical.mif -#' -#' @export -#' -#' @param gdx GDX file -#' @param hist Validation data.All formats allowed which can be converted to quitte (including characters containing the path to a mif file) -#' @param file a file name the output pdf -#' @param reportfile file name to which a backup of the magpie reporting should be written (file ending should be ".mif"). No report written if set to NULL. -#' @param ... additional arguments supplied to the validationpdf function -#' @author Lavinia Baumstark -#' @examples -#' -#' \dontrun{ -#' validation(gdx="fulldata.gdx",hist="historical.mif") -#' } -#' -#' @importFrom lusweave swopen swlatex swclose swR swtable swfigure -#' @importFrom magclass getYears getRegions -#' @importFrom luplot plotcountrymap -#' @importFrom utils capture.output -#' @importFrom mip plotstyle -#' @importFrom iamc iamCheck - -validationREMIND <- function(gdx, hist, file="validation.pdf", reportfile=NULL, ...) { - - template <- c("\\documentclass[a4paper, portrait ]{article}", - "\\setlength{\\parindent}{0in}", - "\\usepackage{float}", - "\\usepackage[bookmarksopenlevel=section]{hyperref}", - "\\hypersetup{bookmarks=true,pdfauthor={PIK Landuse group}}", - "\\usepackage{graphicx}", - "\\usepackage{rotating}", - "\\usepackage[strings]{underscore}", - "\\usepackage[margin=2cm]{geometry}", - "\\usepackage{fancyhdr}", - "\\pagestyle{fancy}", - "\\begin{document}", - "<>=", - "options(width=90)", - "@") - - sw <- swopen(outfile = file, template = template) - swlatex(sw,c("\\title{REMIND run analysis}","\\maketitle","\\tableofcontents")) - on.exit(swclose(sw, clean_output=FALSE, engine="knitr")) - - - swlatex(sw,"\\part{Basics}") - - ######### Region map############## - swlatex(sw,"\\subsection{World regions}") - regi2iso <- readGDX(gdx,"regi2iso", react="silent") - if(!is.null(regi2iso)) { - map <- as.magpie(regi2iso[2:1],spatial=1) - col <- plotstyle(levels(as.factor(regi2iso[[1]]))) - tmpplot <- function(...) { - a <- capture.output(plotcountrymap(...)) - } - swfigure(sw,tmpplot,map,colourPalette=col,catMethod="categorical", mapTitle="", fig.orientation="landscape") - } else { - swlatex(sw,"Could not find mapping (regi2iso) between countries and regions in gdx file!") - } - - ######### Modelstat and objective function value############## - swlatex(sw,"\\subsection{Modelstat}") - #Modelstatus - repy <- readGDX(gdx,"p80_repy", react="silent") - if(!is.null(repy)) { - modstat <- repy[,,"modelstat"] - swtable(sw,modstat,table.placement="H",caption.placement="top",transpose=TRUE,caption="main",vert.lines=1,align="c") - } else { - swlatex(sw,"Could not find p80_repy (only in Nash available) in gdx file!") - } - #global/regional welfare - swlatex(sw,"\\subsection{Goal function value}") - welf <- readGDX(gdx,c("v02_welfare","v_welfare"), react="silent") - if(!is.null(welf)) { - welf <- welf[,,"l"] - swtable(sw,welf,table.placement="H",caption.placement="top",transpose=TRUE,caption="Welfare",vert.lines=1,align="c") - } else { - swlatex(sw,"Could not find welfare value (v02_welfare, v_welfare) in gdx file!") - } - - ################### Validation output ################################ - # if no reporting-mif-file is provided calculate reporting - if(is.null(reportfile)){ reportfile <- convGDX2MIF(gdx)} - # generate list of variables based on the existing reporting - rep <- read.report(reportfile,as.list=FALSE) - rep <- getNames(rep,dim=3) - rep <- as.data.frame(rep) - names(rep) <- "variable" - rep$unit <- rep$variable - rep$variable <- gsub(" \\(.+$","",rep$variable) - rep$unit <- gsub("^.+ \\(","",rep$unit) - rep$unit <- gsub(")","",rep$unit) - iamCheck(reportfile,pdf=sw, cfg=rep, refData=hist,pdfStyle = list("plot.priority"=c("x_hist","x","x_proj"),"years"=c(seq(2005,2060,5),seq(2070,2100,10)))) - - -} diff --git a/README.md b/README.md index 4b16b6de..e2fabb94 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # The REMIND R package (2nd generation) -R package **remind2**, version **1.135.15** +R package **remind2**, version **1.135.16** [![CRAN status](https://www.r-pkg.org/badges/version/remind2)](https://cran.r-project.org/package=remind2) [![R build status](https://github.com/pik-piam/remind2/workflows/check/badge.svg)](https://github.com/pik-piam/remind2/actions) [![codecov](https://codecov.io/gh/pik-piam/remind2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/remind2) [![r-universe](https://pik-piam.r-universe.dev/badges/remind2)](https://pik-piam.r-universe.dev/builds) @@ -49,7 +49,7 @@ In case of questions / problems please contact Renato Rodrigues . +Rodrigues R, Baumstark L, Benke F, Dietrich J, Dirnaichner A, Duerrwaechter J, Führlich P, Giannousakis A, Hasse R, Hilaire J, Klein D, Koch J, Kowalczyk K, Levesque A, Malik A, Merfort A, Merfort L, Morena-Leiva S, Pehl M, Pietzcker R, Rauner S, Richters O, Rottoli M, Schötz C, Schreyer F, Siala K, Sörgel B, Spahr M, Strefler J, Verpoort P, Weigmann P (2024). _remind2: The REMIND R package (2nd generation)_. R package version 1.135.16, . A BibTeX entry for LaTeX users is @@ -58,7 +58,7 @@ A BibTeX entry for LaTeX users is title = {remind2: The REMIND R package (2nd generation)}, author = {Renato Rodrigues and Lavinia Baumstark and Falk Benke and Jan Philipp Dietrich and Alois Dirnaichner and Jakob Duerrwaechter and Pascal Führlich and Anastasis Giannousakis and Robin Hasse and Jérome Hilaire and David Klein and Johannes Koch and Katarzyna Kowalczyk and Antoine Levesque and Aman Malik and Anne Merfort and Leon Merfort and Simón Morena-Leiva and Michaja Pehl and Robert Pietzcker and Sebastian Rauner and Oliver Richters and Marianna Rottoli and Christof Schötz and Felix Schreyer and Kais Siala and Björn Sörgel and Mike Spahr and Jessica Strefler and Philipp Verpoort and Pascal Weigmann}, year = {2024}, - note = {R package version 1.135.15}, + note = {R package version 1.135.16}, url = {https://github.com/pik-piam/remind2}, } ``` diff --git a/man/validationREMIND.Rd b/man/validationREMIND.Rd deleted file mode 100644 index 01413e41..00000000 --- a/man/validationREMIND.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/validationREMIND.R -\name{validationREMIND} -\alias{validationREMIND} -\title{validation} -\usage{ -validationREMIND(gdx, hist, file = "validation.pdf", reportfile = NULL, ...) -} -\arguments{ -\item{gdx}{GDX file} - -\item{hist}{Validation data.All formats allowed which can be converted to quitte (including characters containing the path to a mif file)} - -\item{file}{a file name the output pdf} - -\item{reportfile}{file name to which a backup of the magpie reporting should be written (file ending should be ".mif"). No report written if set to NULL.} - -\item{...}{additional arguments supplied to the validationpdf function} -} -\description{ -Create Validation pdf from REMIND output and corresponding historical.mif -} -\examples{ - - \dontrun{ - validation(gdx="fulldata.gdx",hist="historical.mif") - } - -} -\author{ -Lavinia Baumstark -}