Skip to content

Commit

Permalink
Bugfix transport FE prices with edge_esm
Browse files Browse the repository at this point in the history
  • Loading branch information
merfort committed Jun 14, 2021
1 parent 82ff869 commit a234896
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '6794762966'
ValidationKey: '6799847616'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "remind: The REMIND R Package",
"version": "36.184.7",
"version": "36.184.8",
"description": "<p>Contains the REMIND-specific routines for data and model output manipulation.<\/p>",
"creators": [
{
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: remind
Type: Package
Title: The REMIND R Package
Version: 36.184.7
Date: 2021-05-31
Version: 36.184.8
Date: 2021-06-14
Authors@R: c(
person("Anastasis", "Giannousakis", email="[email protected]", role=c("aut","cre")),
person("Michaja", "Pehl", role=c("aut")))
Expand Down
39 changes: 30 additions & 9 deletions R/reportPrices.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ reportPrices <- function(gdx,output=NULL,regionSubsetList=NULL) {
ppfen_build <- setdiff(ppfen_build, ue_dyn36)
ppfen_ind <- readGDX(gdx,c("ppfen_industry_dyn37","ppfen_industry_dyn28","ppfen_industry"),format="first_found", react = "silent")
ppfen_stat_build_ind <- c(ppfen_stat,ppfen_build,ppfen_ind)
edge_scen <- readGDX(gdx,"EDGE_scenario",format="first_found", react = "silent")

# Realisation of the different modules
if ( !is.null(realisation) & (!"CES_structure" %in% realisation[, 1] )){
Expand All @@ -135,6 +136,11 @@ reportPrices <- function(gdx,output=NULL,regionSubsetList=NULL) {
indu_mod = "fixed_shares"
buil_mod = "simple"
}
if ( !is.null(edge_scen)){ # In case the set realization did not exist, find out whether "edge_esm" or "complex" realization was chosen
tran_mod = "edge_esm"
} else {
tran_mod = "complex"
}
}

if (indu_mod %in% c('fixed_shares', 'subsectors')) {
Expand Down Expand Up @@ -290,18 +296,33 @@ reportPrices <- function(gdx,output=NULL,regionSubsetList=NULL) {
# energy services
tmp <- mbind(tmp,setNames(abs(esm2macro.m[,,name_trsp[2]]/(budget.m+1e-10)) * tdptwyr2dpgj , "Price|Energy Service|Transport nonLDV (US$2005/GJ)"))
tmp <- mbind(tmp,setNames(abs(esm2macro.m[,,name_trsp[1]]/(budget.m+1e-10)) * tdptwyr2dpgj , "Price|Energy Service|Transport LDV (US$2005/GJ)"))

tmp <- mbind(tmp,setNames(abs(febal.m[,,"feelt"]/(budget.m+1e-10)) * tdptwyr2dpgj, "Price|Final Energy|Electricity|Transport (US$2005/GJ)"))
if("fegat" %in% getNames(febal.m)){
tmp <- mbind(tmp,setNames(abs(febal.m[,,"fegat"]/(budget.m+1e-10)) * tdptwyr2dpgj, "Price|Final Energy|Gases|Transport (US$2005/GJ)"))

#Final energy prices
#Transport (Taxes already included)
if (tran_mod == "complex"){
#Translate the marginal utility of the constraint into the marginal income (price).
#For transport liquids use average between diesel and petrol.
tmp <- mbind(tmp,setNames(abs(febal.m[,,"feelt"]/(budget.m+1e-10)) * tdptwyr2dpgj, "Price|Final Energy|Electricity|Transport (US$2005/GJ)"))
if("fegat" %in% getNames(febal.m)){
tmp <- mbind(tmp,setNames(abs(febal.m[,,"fegat"]/(budget.m+1e-10)) * tdptwyr2dpgj, "Price|Final Energy|Gases|Transport (US$2005/GJ)"))
}
tmp <- mbind(tmp,setNames(abs(lowpass(febal.m[,,"feelt"]/(budget.m+1e-10), fix="both", altFilter=match(2010,time))) * tdptwyr2dpgj, "Price|Final Energy|Electricity|Transport|Moving Avg (US$2005/GJ)"))
tmp <- mbind(tmp,setNames(abs(febal.m[,,"feh2t"]/(budget.m+1e-10)) * tdptwyr2dpgj, "Price|Final Energy|Hydrogen|Transport (US$2005/GJ)"))
tmp <- mbind(tmp,setNames(abs((febal.m[,,"fedie"]+febal.m[,,"fepet"])/(2*budget.m+1e-10)) * tdptwyr2dpgj, "Price|Final Energy|Liquids|Transport (US$2005/GJ)"))
tmp <- mbind(tmp,setNames(abs(lowpass((febal.m[,,"fedie"]+febal.m[,,"fepet"])/(2*budget.m+1e-10), fix="both", altFilter=match(2010,time))) * tdptwyr2dpgj, "Price|Final Energy|Liquids|Transport|Moving Avg (US$2005/GJ)"))
} else if(tran_mod == "edge_esm"){
#Translate the marginal utility of the constraint into the marginal income (price)
#For transport liquids use average between diesel and petrol.
tmp <- mbind(tmp,setNames(abs(balfinen.m[,,"feelt"]/(budget.m+1e-10)) * tdptwyr2dpgj, "Price|Final Energy|Electricity|Transport (US$2005/GJ)"))
tmp <- mbind(tmp,setNames(abs(balfinen.m[,,"fegat"]/(budget.m+1e-10)) * tdptwyr2dpgj, "Price|Final Energy|Gases|Transport (US$2005/GJ)"))
tmp <- mbind(tmp,setNames(abs(lowpass(balfinen.m[,,"feelt"]/(budget.m+1e-10), fix="both", altFilter=match(2010,time))) * tdptwyr2dpgj, "Price|Final Energy|Electricity|Transport|Moving Avg (US$2005/GJ)"))
tmp <- mbind(tmp,setNames(abs(balfinen.m[,,"feh2t"]/(budget.m+1e-10)) * tdptwyr2dpgj, "Price|Final Energy|Hydrogen|Transport (US$2005/GJ)"))
tmp <- mbind(tmp,setNames(abs((balfinen.m[,,"fedie"]+balfinen.m[,,"fepet"])/(2*budget.m+1e-10)) * tdptwyr2dpgj, "Price|Final Energy|Liquids|Transport (US$2005/GJ)"))
tmp <- mbind(tmp,setNames(abs(lowpass((balfinen.m[,,"fedie"]+balfinen.m[,,"fepet"])/(2*budget.m+1e-10), fix="both", altFilter=match(2010,time))) * tdptwyr2dpgj, "Price|Final Energy|Liquids|Transport|Moving Avg (US$2005/GJ)"))
}
tmp <- mbind(tmp,setNames(abs(lowpass(febal.m[,,"feelt"]/(budget.m+1e-10), fix="both", altFilter=match(2010,time))) * tdptwyr2dpgj, "Price|Final Energy|Electricity|Transport|Moving Avg (US$2005/GJ)"))
tmp <- mbind(tmp,setNames(abs(febal.m[,,"feh2t"]/(budget.m+1e-10)) * tdptwyr2dpgj, "Price|Final Energy|Hydrogen|Transport (US$2005/GJ)"))
tmp <- mbind(tmp,setNames(abs(febal.m[,,"fedie"]/(budget.m+1e-10)) * tdptwyr2dpgj, "Price|Final Energy|Liquids|Transport (US$2005/GJ)"))
tmp <- mbind(tmp,setNames(abs(lowpass(febal.m[,,"fedie"]/(budget.m+1e-10), fix="both", altFilter=match(2010,time))) * tdptwyr2dpgj, "Price|Final Energy|Liquids|Transport|Moving Avg (US$2005/GJ)"))
tmp = compute_agg_price_fe(tmp,output,"Transport")

#Final energy prices
#Buildings and Industry (Taxes need to be added)
a = abs(mselect(balfinen.m[,y,][rbind(finenbal,fe2es)]))/abs((budget.m+1e-10)) # Translate the marginal utility of the constraint into the marginal income (price)
b = complete_magpie(a) # Due to a strange behaviour of magclass objects addition, we need to use complete_magpie to make the addition
prices_fe_bi = (b + mbind(fe_taxCES[,y,getColValues(finenbal,"all_in")],
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# The REMIND R Package

R package **remind**, version **36.184.7**
R package **remind**, version **36.184.8**

[![CRAN status](https://www.r-pkg.org/badges/version/remind)](https://cran.r-project.org/package=remind)


## Purpose and Functionality

Expand Down Expand Up @@ -46,8 +46,7 @@ In case of questions / problems please contact Anastasis Giannousakis <giannou@p

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

Giannousakis A, Pehl M (2021). _remind: The REMIND R Package_. R
package version 36.184.7.
Giannousakis A, Pehl M (2021). _remind: The REMIND R Package_. R package version 36.184.8.

A BibTeX entry for LaTeX users is

Expand All @@ -56,7 +55,7 @@ A BibTeX entry for LaTeX users is
title = {remind: The REMIND R Package},
author = {Anastasis Giannousakis and Michaja Pehl},
year = {2021},
note = {R package version 36.184.7},
note = {R package version 36.184.8},
}
```

0 comments on commit a234896

Please sign in to comment.