From 8593f4a0fc2a5728b3250de955f18a64f8499386 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Thu, 4 Jan 2024 12:29:10 +0100 Subject: [PATCH] fix errors and warnings in reportEmi --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/reportEmi.R | 26 +++++++++++--------------- README.md | 8 ++++---- man/reportEmi.Rd | 2 +- man/reportFE.Rd | 2 +- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 1377ab4e..6feebe5e 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '222283680' +ValidationKey: '222529006' 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 6062cbe0..213d2767 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: 'remind2: The REMIND R package (2nd generation)' -version: 1.128.0 -date-released: '2023-12-15' +version: 1.128.1 +date-released: '2024-01-04' abstract: Contains the REMIND-specific routines for data and model output manipulation. authors: - family-names: Rodrigues diff --git a/DESCRIPTION b/DESCRIPTION index 1a608c01..e3a7f058 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: remind2 Title: The REMIND R package (2nd generation) -Version: 1.128.0 -Date: 2023-12-15 +Version: 1.128.1 +Date: 2024-01-04 Authors@R: c( person("Renato", "Rodrigues", , "renato.rodrigues@pik-potsdam.de", role = c("aut", "cre")), person("Lavinia", "Baumstark", role = "aut"), diff --git a/R/reportEmi.R b/R/reportEmi.R index aa4654b9..185a9ce6 100644 --- a/R/reportEmi.R +++ b/R/reportEmi.R @@ -11,7 +11,7 @@ #' @param t temporal resolution of the reporting, default: #' t=c(seq(2005,2060,5),seq(2070,2110,10),2130,2150) #' -#' @author Felix Schreyer... +#' @author Felix Schreyer, Simón Moreno Leiva #' @examples #' \dontrun{ #' reportEmi(gdx) @@ -27,7 +27,6 @@ reportEmi <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(seq(2005, 2060, 5), seq(2070, 2110, 10), 2130, 2150)) { - # emissions calculation requires information from other reporting functions if (is.null(output)) { message("reportEmi executes reportFE") @@ -308,8 +307,8 @@ reportEmi <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(seq(200 # get combinations of SE,FE,sector,emiMkt that exist in vm_demFeSector FE.map <- se2fe %>% - left_join(entyFe2Sector) %>% - left_join(sector2emiMkt) %>% + left_join(entyFe2Sector, by = "all_enty1", relationship = "many-to-many") %>% + left_join(sector2emiMkt, by = "emi_sectors", relationship = "many-to-many") %>% select( -all_te) %>% mutate( name = paste(all_enty,all_enty1,emi_sectors,all_emiMkt, sep = ".")) @@ -345,8 +344,8 @@ reportEmi <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(seq(200 # get combinations of SE,FE,sector,emiMkt that exist in vm_nonIncineratedPlastics FE.feed.map <- se2fe %>% - left_join(entyFe2Sector) %>% - left_join(sector2emiMkt) %>% + left_join(entyFe2Sector, by = "all_enty1", relationship = "many-to-many") %>% + left_join(sector2emiMkt, by = "emi_sectors", relationship = "many-to-many") %>% right_join(entyFe2sector2emiMkt_NonEn %>% rename(all_enty1 = all_enty)) %>% select( -all_te) %>% @@ -498,7 +497,7 @@ reportEmi <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(seq(200 - dimSums(plastic_CDR, dim=3) )*GtC_2_MtCO2, "Emi|CO2|Energy|+|Demand (Mt CO2/yr)") - + ) # CO2 emissions from the end-of-life of carbon-bearing products @@ -513,7 +512,7 @@ if (!is.null(vm_plasticsCarbon)) { setNames(out[, , "Emi|CO2|Energy|Waste|+|Feedstocks unknown fate (Mt CO2/yr)"] + out[, , "Emi|CO2|Energy|Waste|+|Plastics Incineration (Mt CO2/yr)"], "Emi|CO2|Energy|+|Waste (Mt CO2/yr)") - ) + ) } #### 2.1.2 Energy Supply ---- @@ -854,7 +853,7 @@ if (!is.null(vm_plasticsCarbon)) { x[['variable']]) }) %>% mbind()) - + # Baseline emission before CCS, corresponds to energy carbon content out <- mbind( # energy emissions @@ -2536,10 +2535,9 @@ if (!is.null(vm_plasticsCarbon)) { # 8. Ad-hoc fix for emissions w/o non-energy use and Aggregation to global and regional values ---- -if (is.null(vm_demFENonEnergySector) && (module2realisation["industry", 2] == "fixed_shares")) { - # (Note: The non-energy use variables are so far only available for REMIND-EU runs and industry fixed_shares) + + # (Note: The non-energy use variables are so far only available for REMIND-EU runs and industry fixed_shares) # TODO: add non-energy use variables for all regionmappings and sector realizations - #Note (SM): I'm not sure if I got these notes so I created the condition above to try to make sure that this will work anyways # Note: Non-energy use emissions should not be confused with process emissions. Non-energy use emissions are emissions/carbon flow of FE carriers which are used as feedstocks in industry. if ("FE|Non-energy Use|Industry (EJ/yr)" %in% getNames(output) && @@ -2659,12 +2657,10 @@ if (is.null(vm_demFENonEnergySector) && (module2realisation["industry", 2] == "f # insert "w/o Non-energy Use" label in variable names out.wNonEn <- setNames(out.wNonEn[, , emi.vars.wNonEn], names.wNonEn) - out <- mbind(out, out.wNonEn) - } -} + # add global values out <- mbind(out, dimSums(out, dim = 1)) # add other region aggregations diff --git a/README.md b/README.md index fade288e..fba9ce7c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # The REMIND R package (2nd generation) -R package **remind2**, version **1.128.0** +R package **remind2**, version **1.128.1** [![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, 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.128.1, . A BibTeX entry for LaTeX users is @@ -57,8 +57,8 @@ A BibTeX entry for LaTeX users is @Manual{, 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 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 = {2023}, - note = {R package version 1.128.0}, + year = {2024}, + note = {R package version 1.128.1}, url = {https://github.com/pik-piam/remind2}, } ``` diff --git a/man/reportEmi.Rd b/man/reportEmi.Rd index c6635095..ac4b8dff 100644 --- a/man/reportEmi.Rd +++ b/man/reportEmi.Rd @@ -34,5 +34,5 @@ reportEmi(gdx) } } \author{ -Felix Schreyer +Felix Schreyer, Simón Moreno Leiva } diff --git a/man/reportFE.Rd b/man/reportFE.Rd index 81edf9ba..e7bb0c84 100644 --- a/man/reportFE.Rd +++ b/man/reportFE.Rd @@ -31,5 +31,5 @@ convGDX2MIF.R for the reporting } \author{ -Renato Rodrigues, Christoph Bertram, Antoine Levesque +Renato Rodrigues, Felix Schreyer }