From 550de7315c82a0ffcc1862641a22263bae411fac Mon Sep 17 00:00:00 2001 From: Simon Moreno Date: Wed, 14 Feb 2024 10:37:49 +0100 Subject: [PATCH] fix backward compatibility for project reporting again and buildLibrary --- .buildlibrary | 2 +- .pre-commit-config.yaml | 2 +- CITATION.cff | 4 +- DESCRIPTION | 4 +- R/reportEmi.R | 105 +++++++++++++++++++++++++++++++++++++++- README.md | 6 +-- 6 files changed, 112 insertions(+), 11 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 73aed147..3dfb6988 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '224202816' +ValidationKey: '224256615' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2f134668..243f46a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: mixed-line-ending - repo: https://github.com/lorenzwalthert/precommit - rev: v0.3.2.9025 + rev: v0.4.0 hooks: - id: parsable-R - id: deps-in-desc diff --git a/CITATION.cff b/CITATION.cff index cd9c9a45..768bd1f4 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.134.4 -date-released: '2024-02-11' +version: 1.134.5 +date-released: '2024-02-14' abstract: Contains the REMIND-specific routines for data and model output manipulation. authors: - family-names: Rodrigues diff --git a/DESCRIPTION b/DESCRIPTION index 0f05abd3..8609944a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: remind2 Title: The REMIND R package (2nd generation) -Version: 1.134.4 -Date: 2024-02-11 +Version: 1.134.5 +Date: 2024-02-14 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 6070a4ea..14486a2f 100644 --- a/R/reportEmi.R +++ b/R/reportEmi.R @@ -1120,7 +1120,6 @@ if (!is.null(vm_plasticsCarbon)) { # deduce co2 captured by industrial processes which is not stored but used for CCU (synfuels) # -> gets accounted in industrial process emissions - vm_emiIndCCS[, , "co2cement_process"]*(1-p_share_CCS) - # fixme: missing/wrong emissions ) * GtC_2_MtCO2, "Emi|CO2|+|Energy (Mt CO2/yr)")) @@ -1882,7 +1881,7 @@ if (!is.null(vm_plasticsCarbon)) { ########################################### ## Gross emissions in Energy|Waste sector## ########################################### -# fixme: check that CDR addition makes sense + if (!is.null(vm_plasticsCarbon)){ # calculate gross emissions in energy waste sector out <- mbind(out, @@ -2431,6 +2430,11 @@ if (!is.null(vm_plasticsCarbon)){ "Emi|N2O|++|Outside ETS and ESR (kt N2O/yr)")) # market GHG emissions across sectors + + ################################### + ## When feedstocks are available ## + ################################### + if(!is.null(vm_plasticsCarbon)){ out <- mbind(out, # energy supply setNames( @@ -2533,6 +2537,103 @@ if (!is.null(vm_plasticsCarbon)){ "Emi|GHG|Outside ETS and ESR|+|F-Gases (Mt CO2eq/yr)") ) + }else{ + ####################################### + ## When feedstocks are not available ## + ####################################### +out <- mbind(out, + # energy supply + setNames( + out[, , "Emi|CO2|Energy|+|Supply (Mt CO2/yr)"] + + out[, , "Emi|GHG|CH4|+|Energy Supply (Mt CO2eq/yr)"] + + out[, , "Emi|GHG|N2O|+|Energy Supply (Mt CO2eq/yr)"], + "Emi|GHG|ETS|+|Energy Supply (Mt CO2eq/yr)"), + + # industry (energy and process emissions) + setNames( + # demand-side co2 emissions (before industry CCS) + (dimSums(mselect(EmiFeCarrier[, , "ETS"], emi_sectors = "indst"), dim = 3) + # industry CCS + # TODO: adapt to industry ETS/ESR split + - dimSums(vm_emiIndCCS[, , emiInd37_fuel]*p_share_CCS, dim=3) + # substract synthetic and biogenic carbon contained in non-incinerated plastics + - dimSums(plastic_CDR, dim=3) + # add captured CO2 from cement process which is not stored + # (EmiMACEq for co2cement_process contains cement process emissions - captured cement co2 process emissions) + + vm_emiIndCCS[, , "co2cement_process"]*(1-p_share_CCS)) * GtC_2_MtCO2 + + dimSums(mselect(EmiMACEq[, , "ETS"], sector = "indst"), dim = 3) + # add chemical process emissions to ETS + + dimSums(EmiProcess_Feedstocks, dim = 3) * GtC_2_MtCO2, + "Emi|GHG|ETS|+|Industry (Mt CO2eq/yr)"), + setNames( + # demand-side co2 emissions (before industry CCS) + dimSums(mselect(EmiFeCarrier[, , "ES"], emi_sectors = "indst"), dim = 3) * GtC_2_MtCO2, + "Emi|GHG|ESR|+|Industry (Mt CO2eq/yr)"), + + # Transport + setNames( + # demand-side co2 emissions (ETS) + (dimSums(mselect(EmiFeCarrier[, , "ETS"], emi_sectors = "trans"), dim = 3)) * GtC_2_MtCO2, + "Emi|GHG|ETS|+|Transport (Mt CO2eq/yr)"), + + setNames( + # demand-side co2 emissions (ESR) + dimSums(mselect(EmiFeCarrier[, , "ES"], emi_sectors = "trans"), dim = 3) * GtC_2_MtCO2 + + dimSums(mselect(EmiMACEq[, , "ES"], sector = "trans"), dim = 3), + "Emi|GHG|ESR|+|Transport (Mt CO2eq/yr)"), + + setNames( + # demand-side co2 emissions (bunkers) + dimSums(mselect(EmiFeCarrier[, , "other"], emi_sectors = "trans"), dim = 3) * GtC_2_MtCO2, + "Emi|GHG|Outside ETS and ESR|+|Transport (Mt CO2eq/yr)"), + + # Buildings + setNames( + # demand-side co2 emissions + dimSums(mselect(EmiFeCarrier[, , "ES"], emi_sectors = "build"), dim = 3) * GtC_2_MtCO2, + "Emi|GHG|ESR|+|Buildings (Mt CO2eq/yr)"), + + # CDR + setNames( + # demand-side co2 emissions (before industry CCS) + # CDR energy-related emissions + (dimSums(mselect(EmiFeCarrier[, , "ETS"], emi_sectors = "CDR"), dim = 3) + # Captured CO2 by non-BECCS capture technologies + + (vm_emiCdrTeDetail[, , "weathering"] + vm_emiCdrTeDetail[, , "dac"] * p_share_CCS)) * GtC_2_MtCO2, + "Emi|GHG|ETS|+|non-BECCS CDR (Mt CO2eq/yr)"), + + # Extraction + setNames( + out[, , "Emi|GHG|CH4|+|Extraction (Mt CO2eq/yr)"], + "Emi|GHG|ETS|+|Extraction (Mt CO2eq/yr)"), + + # Agriculture + setNames( + out[, , "Emi|GHG|CH4|+|Agriculture (Mt CO2eq/yr)"] + + out[, , "Emi|GHG|N2O|+|Agriculture (Mt CO2eq/yr)"], + "Emi|GHG|ESR|+|Agriculture (Mt CO2eq/yr)"), + + # Waste (from MAC curve) + setNames( + dimSums(mselect(EmiMACEq[, , "ETS"], sector = "Waste"), dim = 3) , + "Emi|GHG|ETS|+|Waste (Mt CO2eq/yr)"), + setNames( + dimSums(mselect(EmiMACEq[, , "ES"], sector = "Waste"), dim = 3), + "Emi|GHG|ESR|+|Waste (Mt CO2eq/yr)"), + + setNames( + out[, , "Emi|GHG|N2O|+|Land-Use Change (Mt CO2eq/yr)"] + + out[, , "Emi|GHG|CH4|+|Land-Use Change (Mt CO2eq/yr)"] + + out[, , "Emi|CO2|+|Land-Use Change (Mt CO2/yr)"], + "Emi|GHG|Outside ETS and ESR|+|Land-Use Change (Mt CO2eq/yr)"), + + # F-Gases + setNames( + out[, , "Emi|GHG|+|F-Gases (Mt CO2eq/yr)"], + "Emi|GHG|Outside ETS and ESR|+|F-Gases (Mt CO2eq/yr)") + + ) + } diff --git a/README.md b/README.md index e362e703..984e828d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # The REMIND R package (2nd generation) -R package **remind2**, version **1.134.4** +R package **remind2**, version **1.134.5** [![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.134.5, . 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.134.4}, + note = {R package version 1.134.5}, url = {https://github.com/pik-piam/remind2}, } ```