Skip to content

Commit

Permalink
Merge pull request #311 from fbenke-pik/refactor
Browse files Browse the repository at this point in the history
move reading in REMIND fuel costs to mrtransport
  • Loading branch information
fbenke-pik authored Dec 13, 2024
2 parents 15dd818 + 28d996e commit 8dca393
Show file tree
Hide file tree
Showing 7 changed files with 19 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: '42518720'
ValidationKey: '42568470'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
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: 'edgeTransport: Prepare EDGE Transport Data for the REMIND model'
version: 2.12.0
date-released: '2024-11-29'
version: 2.12.1
date-released: '2024-12-13'
abstract: EDGE-T is a fork of the GCAM transport module https://jgcri.github.io/gcam-doc/energy.html#transportation
with a high level of detail in its representation of technological and modal options.
It is a partial equilibrium model with a nested multinomial logit structure and
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: edgeTransport
Title: Prepare EDGE Transport Data for the REMIND model
Version: 2.12.0
Version: 2.12.1
Authors@R: c(
person("Johanna", "Hoppe", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0009-0004-6753-5090")),
Expand All @@ -19,7 +19,7 @@ Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.2
VignetteBuilder: knitr
Date: 2024-11-29
Date: 2024-12-13
Config/testthat/edition: 3
Imports:
rmndt,
Expand Down
3 changes: 0 additions & 3 deletions R/toolEdgeTransportSA.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ toolEdgeTransportSA <- function(SSPscen,
## Load input data
########################################################
if (is.null(outputFolder) & isStored) stop("Please provide an outputfolder to store your results")
if (is.null(gdxPath)) {gdxPath <- file.path(getConfig("sourcefolder"),
"REMINDinputForTransportStandalone", "v1.2", "fulldata.gdx")}
if (!file.exists(gdxPath)) stop("Please provide valid path to REMIND fulldata.gdx as input for fuel costs")

inputs <- toolLoadInputs(SSPscen, transportPolScen, demScen, gdxPath, hybridElecShare)

Expand Down
6 changes: 5 additions & 1 deletion R/toolLoadREMINDfuelCosts.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ toolLoadREMINDfuelCosts <- function(gdxPath, hybridElecShare, helpers){
decisionTree <- copy(helpers$decisionTree)

# load prices from REMIND gdx
fuelCosts <- readGDX(gdxPath, "pm_FEPrice", format = "first_found", restore_zeros = FALSE)[,, "trans.ES", pmatch = TRUE]
if (is.null(gdxPath)) {
fuelCosts <- readSource("REMINDinputForTransportStandalone", convert = FALSE)
} else {
fuelCosts <- readGDX(gdxPath, "pm_FEPrice", format = "first_found", restore_zeros = FALSE)[, , "trans.ES", pmatch = TRUE]
}

## smooth prices from REMIND gdx (over years) and convert to data.table
fuelCosts <- fuelCosts %>% lowpass() %>% magpie2dt()
Expand Down
10 changes: 5 additions & 5 deletions R/toolLoadmrremindData.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ toolLoadmrremindData <- function(helpers) {
yearOut = 2030
## attribute first (to the countries that have them) the same incentives value until the phase out year
subsidies[, value := ifelse(period >= 2020 & period <= yearOut, value[period == 2020], 0),
by = c("region", "technology")]
by = c("region", "technology")]

# map on decision tree, apply only on 4 wheelers
subsidies <- merge(unique(helpers$decisionTree[subsectorL3 == "trn_pass_road_LDV_4W",
c("region", "univocalName", "technology")]), subsidies,
c("region", "univocalName", "technology")]), subsidies,
by = c("region", "technology"), all.x = TRUE, allow.cartesian = TRUE)
monUnit <- gsub(".*?(\\d{4}).*", "US$\\1", mrdrivers::toolGetUnitDollar())
subsidies <- subsidies[!is.na(value)][, variable := "Capital costs subsidy"][, unit := paste0(monUnit, "/veh")]
#Q: How to include phase out of the incentives? Is that needed at all?

return(list(
subsidies = subsidies
))
return(list(
subsidies = subsidies
))
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Prepare EDGE Transport Data for the REMIND model

R package **edgeTransport**, version **2.12.0**
R package **edgeTransport**, version **2.12.1**

[![CRAN status](https://www.r-pkg.org/badges/version/edgeTransport)](https://cran.r-project.org/package=edgeTransport) [![R build status](https://github.com/pik-piam/edgeTransport/workflows/check/badge.svg)](https://github.com/pik-piam/edgeTransport/actions) [![codecov](https://codecov.io/gh/pik-piam/edgeTransport/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/edgeTransport) [![r-universe](https://pik-piam.r-universe.dev/badges/edgeTransport)](https://pik-piam.r-universe.dev/builds)
[![CRAN status](https://www.r-pkg.org/badges/version/edgeTransport)](https://cran.r-project.org/package=edgeTransport) [![R build status](https://github.com/pik-piam/edgeTransport/workflows/check/badge.svg)](https://github.com/pik-piam/edgeTransport/actions) [![codecov](https://codecov.io/gh/pik-piam/edgeTransport/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/edgeTransport) [![r-universe](https://pik-piam.r-universe.dev/badges/edgeTransport)](https://pik-piam.r-universe.dev/builds)

## Purpose and Functionality

Expand Down Expand Up @@ -46,7 +46,7 @@ In case of questions / problems please contact Johanna Hoppe <johanna.hoppe@pik-

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

Hoppe J, Dirnaichner A, Rottoli M, Muessel J (2024). _edgeTransport: Prepare EDGE Transport Data for the REMIND model_. R package version 2.12.0, <https://github.com/pik-piam/edgeTransport>.
Hoppe J, Dirnaichner A, Rottoli M, Muessel J (2024). _edgeTransport: Prepare EDGE Transport Data for the REMIND model_. R package version 2.12.1, <https://github.com/pik-piam/edgeTransport>.

A BibTeX entry for LaTeX users is

Expand All @@ -55,7 +55,7 @@ A BibTeX entry for LaTeX users is
title = {edgeTransport: Prepare EDGE Transport Data for the REMIND model},
author = {Johanna Hoppe and Alois Dirnaichner and Marianna Rottoli and Jarusch Muessel},
year = {2024},
note = {R package version 2.12.0},
note = {R package version 2.12.1},
url = {https://github.com/pik-piam/edgeTransport},
}
```

0 comments on commit 8dca393

Please sign in to comment.