diff --git a/.buildlibrary b/.buildlibrary index 2e6af706..b218bd4d 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '4346775' +ValidationKey: '4444060' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/.zenodo.json b/.zenodo.json index 48626e02..f9933036 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,6 +1,6 @@ { "title": "edgeTransport: Prepare EDGE Transport Data for the REMIND model", - "version": "0.22.5", + "version": "0.23.0", "description": "

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": [ { diff --git a/DESCRIPTION b/DESCRIPTION index 486efad7..abff813d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "dirnaichner@pik-potsdam.de", role = c("aut", "cre")), person("Marianna", "Rottoli", email = "rottoli@pik-potsdam.de", role = "aut")) @@ -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, diff --git a/R/reportEDGET.R b/R/reportEDGET.R index d4c556e9..cfbfcfdc 100644 --- a/R/reportEDGET.R +++ b/R/reportEDGET.R @@ -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) @@ -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"){ @@ -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)) @@ -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) @@ -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")) diff --git a/README.md b/README.md index 26ca0654..20ae2715 100644 --- a/README.md +++ b/README.md @@ -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) @@ -46,7 +46,7 @@ In case of questions / problems please contact Alois Dirnaichner