From 7759a89ea47d8eaa8a63741582feb0f99b214674 Mon Sep 17 00:00:00 2001 From: orichters Date: Thu, 12 Oct 2023 13:40:33 +0200 Subject: [PATCH] calculate Price|Carbon from pm_taxCO2eqSum --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/readPVP.R | 7 +------ R/reportPrices.R | 20 ++++++++++---------- README.md | 6 +++--- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index d596ce65..1df4ffca 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '220254080' +ValidationKey: '220461780' 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 dc3b5aaf..9ffd19b3 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.121.0 -date-released: '2023-10-18' +version: 1.122.0 +date-released: '2023-10-19' abstract: Contains the REMIND-specific routines for data and model output manipulation. authors: - family-names: Rodrigues diff --git a/DESCRIPTION b/DESCRIPTION index 64dabde6..114f65cc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: remind2 Title: The REMIND R package (2nd generation) -Version: 1.121.0 -Date: 2023-10-18 +Version: 1.122.0 +Date: 2023-10-19 Authors@R: c( person("Renato", "Rodrigues", , "renato.rodrigues@pik-potsdam.de", role = c("aut", "cre")), person("Lavinia", "Baumstark", role = "aut"), diff --git a/R/readPVP.R b/R/readPVP.R index 7aa25b32..1448c454 100644 --- a/R/readPVP.R +++ b/R/readPVP.R @@ -28,12 +28,7 @@ readPVP <- function(gdx, level="glo", enty="good"){ tmp1[regi,,] <- tmp #getRegions(tmp1) <- sub("glob","GLO",getRegions(tmp1)) tmp <- tmp1 - if(level=="reg" & enty=="perm"){ - tmp <- readGDX(gdx, name = c("pm_pvpRegi","p80_pvpRegi"), format="first_found")[ , , enty] - } } - -# getNames(tmp) <- attr(tmp, "description") # this causes trouble due to ambiguous set definition - + # getNames(tmp) <- attr(tmp, "description") # this causes trouble due to ambiguous set definition return(tmp) } diff --git a/R/reportPrices.R b/R/reportPrices.R index 90623455..2d1e8cb6 100644 --- a/R/reportPrices.R +++ b/R/reportPrices.R @@ -84,8 +84,8 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL, if (is.null(bio_tax_factor)) bio_tax_factor <- readGDX(gdx,name="v21_tau_bio",field="l",format="first_found")[, t,] pm_pvp <- readGDX(gdx,name=c("pm_pvp","p80_pvp"),format="first_found")[, t, p80_subset] pm_dataemi <- readGDX(gdx,name=c("pm_emifac","pm_dataemi"),format="first_found",restore_zeros=FALSE)[,t, c("pegas.seel.ngt.co2","pecoal.seel.pc.co2")] - pm_pvpRegi <- readGDX(gdx,name='pm_pvpRegi',format="first_found")[, t, "perm"] pm_taxCO2eq <- readGDX(gdx,name=c("pm_taxCO2eq","pm_tau_CO2_tax"),format="first_found")[, t,] + pm_taxCO2eqSum <- readGDX(gdx,name="pm_taxCO2eqSum",format="first_found")[, t,] pm_taxCO2eqSCC <- readGDX(gdx,name='pm_taxCO2eqSCC',format="first_found")[, t,] p21_CO2TaxSectorMarkup <- readGDX(gdx,name=c('p21_CO2TaxSectorMarkup','p21_CO2_tax_sector_markup'),format="first_found",react="silent") if (dimExists("ttot", p21_CO2TaxSectorMarkup)) p21_CO2TaxSectorMarkup <- p21_CO2TaxSectorMarkup[, t,] @@ -751,7 +751,7 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL, # report GHG taxes, differentiated by sector # WARNING: the below sector markup code calculation does not consider regipol sector and emission market specific CO2eq prices. If you use both markups and the model 47 formulations, you will have wrongly reported CO2 sectoral and regional prices. if (all(p21_CO2TaxSectorMarkup == 0)) { # then all are identical - out <- mbind(out, setNames(abs(pm_pvpRegi / (pm_pvp[,,"good"] + 1e-10)) * 1000 * 12/44, "Price|Carbon (US$2005/t CO2)")) + out <- mbind(out, setNames(pm_taxCO2eqSum * 1000 * 12/44, "Price|Carbon (US$2005/t CO2)")) for (pcname in c("Price|Carbon|Demand|Buildings (US$2005/t CO2)", "Price|Carbon|Demand|Transport (US$2005/t CO2)", "Price|Carbon|Demand|Industry (US$2005/t CO2)", "Price|Carbon|Supply (US$2005/t CO2)", "Price|Carbon|AggregatedByGrossCO2 (US$2005/t CO2)")) { @@ -759,30 +759,30 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL, } } else { # currently p21_CO2TaxSectorMarkup is only implemented for build and trans in REMIND out <- mbind(out, - setNames((1 + p21_CO2TaxSectorMarkup[, , "build"]) * abs(pm_pvpRegi / (pm_pvp[,,"good"] + 1e-10)) * 1000 * 12/44, + setNames((1 + p21_CO2TaxSectorMarkup[, , "build"]) * pm_taxCO2eqSum * 1000 * 12/44, "Price|Carbon|Demand|Buildings (US$2005/t CO2)"), - setNames((1 + p21_CO2TaxSectorMarkup[, , "trans"]) * abs(pm_pvpRegi / (pm_pvp[,,"good"] + 1e-10)) * 1000 * 12/44, + setNames((1 + p21_CO2TaxSectorMarkup[, , "trans"]) * pm_taxCO2eqSum * 1000 * 12/44, "Price|Carbon|Demand|Transport (US$2005/t CO2)"), - setNames(abs(pm_pvpRegi / (pm_pvp[,,"good"] + 1e-10)) * 1000 * 12/44, + setNames(pm_taxCO2eqSum * 1000 * 12/44, "Price|Carbon|Demand|Industry (US$2005/t CO2)"), - setNames(abs(pm_pvpRegi / (pm_pvp[,,"good"] + 1e-10)) * 1000 * 12/44, + setNames(pm_taxCO2eqSum * 1000 * 12/44, "Price|Carbon|Supply (US$2005/t CO2)") ) - pm_pvpRegi_FE <- pm_pvpRegi * (1 + + pm_taxCO2eq_FE <- pm_taxCO2eqSum * (1 + ( p21_CO2TaxSectorMarkup[, , "build"] * output_wo_GLO[, , "FE|Buildings (EJ/yr)"] + p21_CO2TaxSectorMarkup[, , "trans"] * output_wo_GLO[, , "FE|Transport (EJ/yr)"] ) / output_wo_GLO[, , "FE (EJ/yr)"] ) - pm_pvpRegi_Emi <- pm_pvpRegi * (1 + + pm_taxCO2eq_Emi <- pm_taxCO2eqSum * (1 + ( p21_CO2TaxSectorMarkup[, , "build"] * output_wo_GLO[, , "Emi|GHG|Gross|Energy|Demand|Buildings (Mt CO2eq/yr)"] + p21_CO2TaxSectorMarkup[, , "trans"] * output_wo_GLO[, , "Emi|GHG|Gross|Energy|Demand|Transport (Mt CO2eq/yr)"] ) / output_wo_GLO[, , "Emi|GHG|Gross|Energy (Mt CO2eq/yr)"] ) - out <- mbind(out, setNames(abs(pm_pvpRegi_FE / (pm_pvp[,,"good"] + 1e-10)) * 1000 * 12/44, + out <- mbind(out, setNames(pm_taxCO2eq_FE * 1000 * 12/44, "Price|Carbon (US$2005/t CO2)")) # AggregatedbyFE - out <- mbind(out, setNames(abs(pm_pvpRegi_Emi / (pm_pvp[,,"good"] + 1e-10)) * 1000 * 12/44, + out <- mbind(out, setNames(pm_taxCO2eq_Emi * 1000 * 12/44, "Price|Carbon|AggregatedByGrossCO2 (US$2005/t CO2)")) # AggregatedByEmiGHGGross } diff --git a/README.md b/README.md index fdae14da..d3c455d3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # The REMIND R package (2nd generation) -R package **remind2**, version **1.121.0** +R package **remind2**, version **1.122.0** [![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 (2023). _remind2: The REMIND R package (2nd generation)_. R package version 1.122.0, . 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 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.121.0}, + note = {R package version 1.122.0}, url = {https://github.com/pik-piam/remind2}, } ```