Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Energy Intensity on technology level #207

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '4346775'
ValidationKey: '4444060'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
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": "edgeTransport: Prepare EDGE Transport Data for the REMIND model",
"version": "0.22.5",
"version": "0.23.0",
"description": "<p>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 relies on the modified logit formulation. Most of the sources are not publicly available. PIK-internal users can find the sources in the distributed file system in the folder `/p/projects/rd3mod/inputdata/sources/EDGE-Transport-Standalone`.<\/p>",
"creators": [
{
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: 0.22.5
Version: 0.23.0
Authors@R: c(
person("Alois", "Dirnaichner", email = "[email protected]", role = c("aut", "cre")),
person("Marianna", "Rottoli", email = "[email protected]", role = "aut"))
Expand All @@ -13,7 +13,7 @@ Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.1
VignetteBuilder: knitr
Date: 2022-11-23
Date: 2022-11-26
Config/testthat/edition: 3
Imports:
rmndt,
Expand Down
75 changes: 53 additions & 22 deletions R/reportEDGET.R
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,9 @@ toolReportEDGET <- function(output_folder = ".",
`FE|Transport|non-LDV|Electricity` = c("FE|Transport|Pass|non-LDV|Electricity","FE|Transport|Freight|Road|Electricity","FE|Transport|Freight|Rail|Electricity"),
`FE|Transport|non-LDV|Hydrogen` = c("FE|Transport|Pass|non-LDV|Hydrogen","FE|Transport|Freight|Road|Hydrogen"))




names <- names(varsl)
totals <- sapply(names, reportTotals, datatable = toMIF, varlist = varsl, simplify = FALSE, USE.NAMES = TRUE)

Expand All @@ -560,19 +563,25 @@ toolReportEDGET <- function(output_folder = ".",

reportInt <- function(var, datatable){
#Energy Intensity MJ/pkm or MJ/tkm
repFE <- datatable[variable == paste0("FE|Transport|", var)]

repFE <- datatable[grepl(paste0("FE\\|Transport\\|", var), variable)]
repFE[, variable := NULL][, unit := NULL]
setnames(repFE, "value", "FE")
repES <- datatable[variable == paste0("ES|Transport|", var)]


repES <- datatable[grepl(paste0("ES\\|Transport\\|", var), variable)]
varname <- unique(repES$variable)
varname <- gsub("ES", "EInt", varname)
repES[, variable := NULL][, unit := NULL]

#check if variable is found
if (!(length(repFE)>0 && length(repES) > 0)){
if (!(nrow(repFE)>0 && nrow(repES) > 0)){
print(paste0("Variable not found to calculate (p/t)km Energy Intensity ", var))
}

repInt <- merge(repFE, repES, by = c("region", "period", "scenario", "model"))
repInt[, value := FE/value][, FE := NULL][, variable := paste0("EInt|Transport|", var)]
repInt[, value := FE/value][, FE := NULL][, variable := varname]

#FE in EJ to MJ + ES ib bn pkm to pkm 1e12/1e9
repInt[, value := value*1e3]
if (sub("\\|.*", "", var) == "Pass"){
Expand All @@ -581,16 +590,16 @@ toolReportEDGET <- function(output_folder = ".",
repInt[, unit := "MJ/tkm"]}

#Energy Intensity MJ/vkm
repVKM <- datatable[variable == paste0("ES|Transport|VKM|", var)]
repVKM <- datatable[grepl(paste0("ES\\|Transport\\|VKM\\|", var), variable)]
repVKM[, variable := NULL][, unit := NULL]

#check if variable is found
if (!(length(repFE)>0 && length(repVKM) > 0)){
if (!(nrow(repFE)>0 && nrow(repVKM) > 0)){
print(paste0("Variable not found to calculate VKM Energy Intensity ", var))
}

repIntVKM <- merge(repFE, repVKM, by = c("region", "period", "scenario", "model"))
repIntVKM[, value := FE/value][, FE := NULL][, variable := paste0("EInt|Transport|VKM|", var)]
repIntVKM[, value := FE/value][, FE := NULL][, variable := gsub("EInt", "EInt|VKM", varname)]
#FE in EJ to MJ + ES ib bn vkm to vkm 1e12/1e9
repIntVKM[, value := value*1e3][, unit := "MJ/vkm"]
return(rbind(repInt, repIntVKM))
Expand Down Expand Up @@ -801,20 +810,42 @@ toolReportEDGET <- function(output_folder = ".",
# UE[, value:= value*UE_efficiency][, variable := gsub("FE","UE", variable)]

# toMIF <- rbind(toMIF, UE)
varslist <- list("Pass|w/o bunkers",
"Pass|Aviation|International",
"Pass|Rail",
"Pass|Aviation|Domestic",
"Pass|Road",
"Pass|Road|LDV",
"Pass|Road|LDV|Two Wheelers",
"Pass|Road|LDV|Four Wheelers",
"Pass|Road|Bus",
"Freight|w/o bunkers",
"Freight|International Shipping",
"Freight|Navigation",
"Freight|Rail",
"Freight|Road")
varslist <- list("Freight\\|Rail$",
"Freight\\|Rail\\|(Electricity|Electric)$",
"Freight\\|Rail\\|Liquids$",
"Pass\\|w/o bunkers$",
"Pass\\|Aviation\\|International$",
"Pass\\|Rail$",
"Pass\\|Rail\\|HSR\\|(Electricity|Electric)$",
"Pass\\|Rail\\|non-HSR\\|(Electricity|Electric)$",
"Pass\\|Rail\\|non-HSR\\|Liquids$",
"Pass\\|Aviation\\|Domestic$",
"Pass\\|Aviation\\|Domestic\\|(Hydrogen|FCEV)$",
"Pass\\|Aviation\\|Domestic\\|Liquids$",
"Pass\\|Road$",
"Pass\\|Road\\|LDV$",
"Pass\\|Road\\|LDV\\|Two Wheelers$",
"Pass\\|Road\\|LDV\\|Two Wheelers\\|(Electricity|BEV)$",
"Pass\\|Road\\|LDV\\|Two Wheelers\\|Liquids$",
"Pass\\|Road\\|LDV\\|Four Wheelers$",
"Pass\\|Road\\|LDV\\|Four Wheelers\\|(Electricity|BEV)",
"Pass\\|Road\\|LDV\\|Four Wheelers\\|(Hydrogen|FCEV)",
"Pass\\|Road\\|LDV\\|Four Wheelers\\|Gases$",
"Pass\\|Road\\|LDV\\|Four Wheelers\\|Liquids$",
"Pass\\|Road\\|Bus$",
"Pass\\|Road\\|Bus\\|(Electricity|Electric)$",
"Pass\\|Road\\|Bus\\|(Hydrogen|FCEV)$",
"Pass\\|Road\\|Bus\\|Gases$",
"Pass\\|Road\\|Bus\\|Liquids$",
"Freight\\|w/o bunkers$",
"Freight\\|International Shipping$",
"Freight\\|Navigation$",
"Freight\\|Road$",
"Freight\\|Road\\|(Electricity|Electric)$",
"Freight\\|Road\\|(Hydrogen|FCEV)$",
"Freight\\|Road\\|Gases$",
"Freight\\|Road\\|Liquids$"
)

EInt <- sapply(varslist, reportInt, datatable = toMIF, simplify = FALSE, USE.NAMES = TRUE)
EInt <- rbindlist(EInt, use.names = TRUE)
Expand Down Expand Up @@ -973,7 +1004,7 @@ toolReportEDGET <- function(output_folder = ".",
)

## Make sure there are no duplicates!
idx <- anyDuplicated(toMIF, by = c("region", "variable", "period"))
idx <- toMIF[duplicated(toMIF[, c("region", "variable", "period")])]
if(idx){
warning(paste0("Duplicates found in EDGE-T reporting output:",
capture.output(toMIF[idx]), collapse="\n"))
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Prepare EDGE Transport Data for the REMIND model

R package **edgeTransport**, version **0.22.5**
R package **edgeTransport**, version **0.23.0**

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

Expand Down Expand Up @@ -46,7 +46,7 @@ In case of questions / problems please contact Alois Dirnaichner <dirnaichner@pi

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

Dirnaichner A, Rottoli M (2022). _edgeTransport: Prepare EDGE Transport Data for the REMIND model_. R package version 0.22.5.
Dirnaichner A, Rottoli M (2022). _edgeTransport: Prepare EDGE Transport Data for the REMIND model_. R package version 0.23.0.

A BibTeX entry for LaTeX users is

Expand All @@ -55,6 +55,6 @@ A BibTeX entry for LaTeX users is
title = {edgeTransport: Prepare EDGE Transport Data for the REMIND model},
author = {Alois Dirnaichner and Marianna Rottoli},
year = {2022},
note = {R package version 0.22.5},
note = {R package version 0.23.0},
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,57 @@ items <- c(
walk(items, showLinePlots, data = data, scales = "fixed")
```

## Passenger per pkm technology level
### Rail
```{r}
items <- c(
"EInt|Transport|Pass|Rail|HSR|Electric",
"EInt|Transport|Pass|Rail|non-HSR|Electric",
"EInt|Transport|Pass|Rail|non-HSR|Liquids")
walk(items, showLinePlots, data = data, scales = "fixed")
```

### Bus
```{r}
items <- c(
"EInt|Transport|Pass|Road|Bus|Electric",
"EInt|Transport|Pass|Road|Bus|Hydrogen",
"EInt|Transport|Pass|Road|Bus|Gases",
"EInt|Transport|Pass|Road|Bus|Liquids")

walk(items, showLinePlots, data = data, scales = "fixed")
```

### LDV 4-Wheeler
```{r}
items <- c(
"EInt|Transport|Pass|Road|LDV|Four Wheelers|BEV",
"EInt|Transport|Pass|Road|LDV|Four Wheelers|Hydrogen",
"EInt|Transport|Pass|Road|LDV|Four Wheelers|Hybrid Electric",
"EInt|Transport|Pass|Road|LDV|Four Wheelers|Liquids",
"EInt|Transport|Pass|Road|LDV|Four Wheelers|Gases")

walk(items, showLinePlots, data = data, scales = "fixed")
```

### LDV 2-Wheeler
```{r}
items <- c(
"EInt|Transport|Pass|Road|LDV|Two Wheelers|BEV",
"EInt|Transport|Pass|Road|LDV|Two Wheelers|Liquids")

walk(items, showLinePlots, data = data, scales = "fixed")
```

### Domestic Aviation
```{r}
items <- c(
"EInt|Transport|Pass|Aviation|Domestic|Hydrogen",
"EInt|Transport|Pass|Aviation|Domestic|Liquids")

walk(items, showLinePlots, data = data, scales = "fixed")
```

## Freight per tkm
```{r}
items <- c(
Expand All @@ -27,6 +78,27 @@ items <- c(
walk(items, showLinePlots, data = data, scales = "fixed")
```

## Freight per tkm technology level
#Rail
```{r}
items <- c(
"EInt|Transport|Freight|Rail|Electric",
"EInt|Transport|Freight|Rail|Liquids",
)
walk(items, showLinePlots, data = data, scales = "fixed")
```

#Trucks
```{r}
items <- c(
"EInt|Transport|Freight|Road|Truck|Electric",
"EInt|Transport|Freight|Road|Truck|FCEV",
"EInt|Transport|Freight|Road|Truck|Gases",
"EInt|Transport|Freight|Road|Truck|Liquids"
)
walk(items, showLinePlots, data = data, scales = "fixed")
```

## Passenger per vkm
```{r}
items <- c(
Expand Down