Skip to content

Commit

Permalink
fix Price aggregation, one 2005->2017 was missing
Browse files Browse the repository at this point in the history
  • Loading branch information
orichters committed Sep 26, 2024
1 parent 57c1fa0 commit bb24d2b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '231092829'
ValidationKey: '231307440'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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.156.1
date-released: '2024-09-23'
version: 1.157.0
date-released: '2024-09-26'
abstract: Contains the REMIND-specific routines for data and model output manipulation.
authors:
- family-names: Rodrigues
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: remind2
Title: The REMIND R package (2nd generation)
Version: 1.156.1
Date: 2024-09-23
Version: 1.157.0
Date: 2024-09-26
Authors@R: c(
person("Renato", "Rodrigues", , "[email protected]", role = c("aut", "cre")),
person("Lavinia", "Baumstark", role = "aut"),
Expand Down
6 changes: 3 additions & 3 deletions R/reportLCOE.R
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ v33_emiEW <- add_columns(v33_emiEW, addnm = c("y2005", "y2010", "y2015", "y2020"
setNames(vm_demPe[, , pe2se$all_te], pe2se$all_enty), pe2se$all_te)

# 2.2 secondary fuel cost
Fuel.Price <- mbind(pm_PEPrice, pm_SEPrice)[, , ] * 1e12 # convert from trUSD2005/TWa to USD2005/TWa [note: this already includes the CO2 price]
Fuel.Price <- mbind(pm_PEPrice, pm_SEPrice)[, , ] * 1e12 # convert from trUSD/TWa to USD/TWa [note: this already includes the CO2 price]
Fuel.Price <- magclass::matchDim(Fuel.Price, vm_prodSe, dim = c(1), fill = 0)

pm_SecFuel <- pm_prodCouple[, , getNames(pm_prodCouple)[pm_prodCouple[reg1, , ] < 0]] # keep only second fuel consumption, not co-production
Expand All @@ -293,9 +293,9 @@ v33_emiEW <- add_columns(v33_emiEW, addnm = c("y2005", "y2010", "y2015", "y2020"
# calculation explanation:
# units: -1 (so pm_SecFuel turns positive because consuming energy)
# * electricity or heat demand (pm_SecFuel, TWa_input/TWa_mainOutput OR TWa/GtC)
# * electricity price (Fuel.Price, USD2005/TWa_inpu)
# * electricity price (Fuel.Price, USD2017/TWa_inpu)
# * main Output (for pe2se: vm_prodSe (TWa_mainOutput); for ccsinje: amount of CO2 captured (vm_co2CCS, GtC))
# = te_annual_secFuel_cost = [USD2005]
# = te_annual_secFuel_cost = [USD2017]

# 2.3 additional fuel demand of CDR module technologies
te_annual_otherFuel_cost <- new.magpie(getRegions(te_inv_annuity), ttot_from2005, getNames(te_inv_annuity), fill = 0)
Expand Down
18 changes: 9 additions & 9 deletions R/reportPrices.R
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,14 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL,
"tdh2t", "tdelt", "tdels", "tdhes", "tdbiosos", "tdbiogas", "tdh2s", "tdfoshos", "tdsyngat"
)

vm_costTeCapital <- readGDX(gdx, "vm_costTeCapital", field = "l", restore_zeros = F)[, YearsFrom2005, tech] # [tr USD2005/TWh]
vm_costTeCapital <- readGDX(gdx, "vm_costTeCapital", field = "l", restore_zeros = F)[, YearsFrom2005, tech] # [tr USD2017/TWh]
p_teAnnuity <- readGDX(gdx, c("p_teAnnuity","pm_teAnnuity"), restore_zeros = F)[, , tech]
vm_capFac <- readGDX(gdx, "vm_capFac", field = "l", restore_zeros = F)[, YearsFrom2005, tech] * 8760
pm_data_omf <- readGDX(gdx, "pm_data", restore_zeros = F)[, , "omf"][, , tech]

price.investment <- vm_costTeCapital * p_teAnnuity / vm_capFac
price.omf <- pm_data_omf * vm_costTeCapital / vm_capFac
price.td <- collapseDim(price.investment + price.omf) * 1e6 / 3.6 # [tr USD2005/TWh] -> [USD2005/GJ]
price.td <- collapseDim(price.investment + price.omf) * 1e6 / 3.6 # [tr USD2017/TWh] -> [USD2017/GJ]
price.td[price.td == Inf] <- 0

out <- mbind(
Expand Down Expand Up @@ -522,12 +522,12 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL,
pm_emifac <- readGDX(gdx, "pm_emifac", field = "l", restore_zeros = F)[, YearsFrom2005, "co2"][, , tech.fossil] # [GtC CO2/TWa]
pm_emifac <- pm_emifac * 1e9 / s_twa2mwh / 3.6 # [GtC CO2/TWa] -> [tC CO2/GJ]

p_priceCO2 <- readGDX(gdx,name=c("p_priceCO2","pm_priceCO2"),format="first_found", restore_zeros = F) # [USD2005/tC CO2]
p_priceCO2 <- readGDX(gdx,name=c("p_priceCO2","pm_priceCO2"),format="first_found", restore_zeros = F) # [USD2017/tC CO2]
if(length(p_priceCO2) > 0) {
p_priceCO2 <- add_columns(p_priceCO2, addnm = setdiff(YearsFrom2005, getYears(p_priceCO2)), dim = 2, fill = NA)
p_priceCO2 <- add_columns(p_priceCO2, addnm = setdiff(getRegions(pm_emifac), getRegions(p_priceCO2)), dim = 1, fill = NA)

price.carbon <- collapseDim(pm_emifac * p_priceCO2) # [USD2005/GJ]
price.carbon <- collapseDim(pm_emifac * p_priceCO2) # [USD2017/GJ]

out <- mbind(
out,
Expand All @@ -551,9 +551,9 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL,
"indst.fehos", "indst.fesos", "indst.feels", "indst.feh2s", "indst.fegas",
"build.fepet", "indst.fepet"
)
pm_tau_fe_tax <- readGDX(gdx, c("p21_tau_fe_tax","pm_tau_fe_tax"), format="first_found")[, YearsFrom2005, entyFe2Sector] # [tr USD2005/TWa]
pm_tau_fe_sub <- readGDX(gdx, c("p21_tau_fe_sub","pm_tau_fe_sub"), format="first_found")[, YearsFrom2005, entyFe2Sector] # [tr USD2005/TWa]
price.tax <- (pm_tau_fe_tax + pm_tau_fe_sub) / s_twa2mwh / 3.6 * 1e12 # [USD2005/GJ]
pm_tau_fe_tax <- readGDX(gdx, c("p21_tau_fe_tax","pm_tau_fe_tax"), format="first_found")[, YearsFrom2005, entyFe2Sector] # [tr USD2017/TWa]
pm_tau_fe_sub <- readGDX(gdx, c("p21_tau_fe_sub","pm_tau_fe_sub"), format="first_found")[, YearsFrom2005, entyFe2Sector] # [tr USD2017/TWa]
price.tax <- (pm_tau_fe_tax + pm_tau_fe_sub) / s_twa2mwh / 3.6 * 1e12 # [USD2017/GJ]

out <- mbind(
out,
Expand Down Expand Up @@ -595,7 +595,7 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL,
### Fuel Cost Component ----

se <- c("seliqfos", "segafos", "seliqbio", "segabio", "seliqsyn", "segasyn", "seh2", "seel", "sesofos", "sehe", "sesobio")
pm_SEPrice <- readGDX(gdx, "pm_SEPrice")[, YearsFrom2005, se] / s_twa2mwh / 3.6 * 1e12 # [tr USD2005/TWa] -> [USD2005/GJ]
pm_SEPrice <- readGDX(gdx, "pm_SEPrice")[, YearsFrom2005, se] / s_twa2mwh / 3.6 * 1e12 # [tr USD2017/TWa] -> [USD2017/GJ]
pm_eta_conv <- readGDX(gdx, "pm_eta_conv", restore_zeros = F)[, YearsFrom2005, tech]
price.fuel <- pm_SEPrice / pm_eta_conv

Expand Down Expand Up @@ -958,7 +958,7 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL,
if (length(pm_FEPrice_by_FE) > 0) {
margPriceVars <- grep("Price|Final Energy|", getItems(out,3), fixed = TRUE, value = TRUE)
margPriceVars <- setdiff(margPriceVars, names(int2ext))
vars <- gsub("US\\$2005/GJ", "EJ/yr", gsub("Price\\|Final Energy\\|","FE|",margPriceVars))
vars <- gsub("US\\$2017/GJ", "EJ/yr", gsub("Price\\|Final Energy\\|","FE|",margPriceVars))
names(vars) <- margPriceVars
vars <- gsub("Efuel","Hydrogen",vars) ###warning FE variable should be renamed and this line should be removed in the future
vars <- vars[vars %in% getItems(output,3)]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The REMIND R package (2nd generation)

R package **remind2**, version **1.156.1**
R package **remind2**, version **1.157.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)

Expand Down Expand Up @@ -49,7 +49,7 @@ In case of questions / problems please contact Renato Rodrigues <renato.rodrigue

To cite package **remind2** in publications use:

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, Rüter T (2024). _remind2: The REMIND R package (2nd generation)_. R package version 1.156.1, <https://github.com/pik-piam/remind2>.
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, Rüter T (2024). _remind2: The REMIND R package (2nd generation)_. R package version 1.157.0, <https://github.com/pik-piam/remind2>.

A BibTeX entry for LaTeX users is

Expand All @@ -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 and Tonn Rüter},
year = {2024},
note = {R package version 1.156.1},
note = {R package version 1.157.0},
url = {https://github.com/pik-piam/remind2},
}
```
8 changes: 4 additions & 4 deletions vignettes/remind_summary.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ swfigure(sw,print,p,fig.width=1)

Let's have a short look at the line plots. Line plots (234 ff). Here the plot code is already wrapped in a call to swfigure because we only want it in the PDF later.
```{r, eval=FALSE}
swfigure(sw,mipLineHistorical, data[,,"Price|Final Energy|Liquids|Transport (US$2005/GJ)"],x_hist=NULL,
ylab='Price|Final Energy|Liquids|Transport [US$2005/GJ]',color.dim="region",facet.dim="scenario",color.dim.name="Region",
swfigure(sw,mipLineHistorical, data[,,"Price|Final Energy|Liquids|Transport (US$2017/GJ)"],x_hist=NULL,
ylab='Price|Final Energy|Liquids|Transport [US$2017/GJ]',color.dim="region",facet.dim="scenario",color.dim.name="Region",
legend.ncol=8,plot.priority=c("x_hist","x","x_proj"),sw_option="height=10,width=9")
```

If we want to look at it directly, we just call mipLineHistorical()
```{r, eval=FALSE}
library(mip)
mipLineHistorical(data[,,"Price|Final Energy|Liquids|Transport (US$2005/GJ)"],x_hist=NULL,
ylab='Price|Final Energy|Liquids|Transport [US$2005/GJ]',color.dim="region",facet.dim="scenario",color.dim.name="Region",
mipLineHistorical(data[,,"Price|Final Energy|Liquids|Transport (US$2017/GJ)"],x_hist=NULL,
ylab='Price|Final Energy|Liquids|Transport [US$2017/GJ]',color.dim="region",facet.dim="scenario",color.dim.name="Region",
legend.ncol=8,plot.priority=c("x_hist","x","x_proj"))
```

Expand Down

0 comments on commit bb24d2b

Please sign in to comment.