From aec2e756a06848e1f5f0799e1d557f8692b7f212 Mon Sep 17 00:00:00 2001 From: jmuessel Date: Fri, 21 Jul 2023 10:34:42 +0200 Subject: [PATCH 1/5] Delete call for non-existent bus data (GCAMBug) --- .buildlibrary | 2 +- .pre-commit-config.yaml | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- Makefile | 5 +++-- README.md | 6 +++--- inst/extdata/mapping_EDGECES.csv | 3 --- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 3a097eac..6e69a548 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '6043140' +ValidationKey: '1955900' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d9409d2b..9c3b0698 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: mixed-line-ending - repo: https://github.com/lorenzwalthert/precommit - rev: v0.3.2.9007 + rev: v0.3.2.9013 hooks: - id: parsable-R - id: deps-in-desc diff --git a/CITATION.cff b/CITATION.cff index dde684d9..4a683da1 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -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: 0.31.0 -date-released: '2023-05-17' +version: 1.0.0 +date-released: '2023-07-21' 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 diff --git a/DESCRIPTION b/DESCRIPTION index 823b61c8..7cfd22b2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: edgeTransport Title: Prepare EDGE Transport Data for the REMIND model -Version: 0.31.0 +Version: 1.0.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"), @@ -15,7 +15,7 @@ Encoding: UTF-8 LazyData: true RoxygenNote: 7.2.3 VignetteBuilder: knitr -Date: 2023-05-17 +Date: 2023-07-21 Config/testthat/edition: 3 Imports: rmndt, diff --git a/Makefile b/Makefile index c1e0c682..38e857f3 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,9 @@ HELP_PARSING = 'm <- readLines("Makefile");\ help: ## Show this help. @Rscript -e $(HELP_PARSING) -build: ## Build the package using lucode2::buildLibrary(). - Rscript -e 'lucode2::buildLibrary()' +build: ## Build the package using lucode2::buildLibrary(). You can pass the + ## updateType with 'make build u=3' + Rscript -e 'lucode2::buildLibrary(updateType = "$(u)")' check: ## Build documentation and vignettes, run testthat tests, ## and check if code etiquette is followed using lucode2::check(). diff --git a/README.md b/README.md index fd45ec07..91237dbc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Prepare EDGE Transport Data for the REMIND model -R package **edgeTransport**, version **0.31.0** +R package **edgeTransport**, version **1.0.0** [![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) @@ -46,7 +46,7 @@ In case of questions / problems please contact Alois Dirnaichner . +Dirnaichner A, Rottoli M, Hoppe J (2023). _edgeTransport: Prepare EDGE Transport Data for the REMIND model_. R package version 1.0.0, . A BibTeX entry for LaTeX users is @@ -55,7 +55,7 @@ A BibTeX entry for LaTeX users is title = {edgeTransport: Prepare EDGE Transport Data for the REMIND model}, author = {Alois Dirnaichner and Marianna Rottoli and Johanna Hoppe}, year = {2023}, - note = {R package version 0.31.0}, + note = {R package version 1.0.0}, url = {https://github.com/pik-piam/edgeTransport}, } ``` diff --git a/inst/extdata/mapping_EDGECES.csv b/inst/extdata/mapping_EDGECES.csv index 23739fcd..c272ac26 100644 --- a/inst/extdata/mapping_EDGECES.csv +++ b/inst/extdata/mapping_EDGECES.csv @@ -5,8 +5,6 @@ trn_pass,trn_pass_road_LDV,Hydrogen,feh2t_p_sm trn_pass,trn_pass_road_LDV,NG,fegat_p_sm trn_pass,Bus,Liquids,fedie_p_sm trn_pass,Bus,NG,fegat_p_sm -trn_pass,trn_pass_road_bus,Liquids,fedie_p_sm -trn_pass,trn_pass_road_bus,NG,fegat_p_sm trn_pass,Domestic Aviation_tmp_subsector_L2,Liquids,fedie_p_sm trn_pass,Domestic Aviation_tmp_subsector_L2,Hydrogen,feh2t_p_sm trn_pass,HSR_tmp_subsector_L2,Electricity,feelt_p_sm @@ -15,7 +13,6 @@ trn_pass,Passenger Rail_tmp_subsector_L2,Liquids,fedie_p_sm trn_freight,trn_freight_road_tmp_subsector_L2,Liquids,fedie_f_sm trn_freight,trn_freight_road_tmp_subsector_L2,NG,fegat_f_sm trn_freight,Domestic Ship_tmp_subsector_L2,Liquids,fedie_f_sm -trn_freight,Freight Rail_tmp_subsector_L2,Coal,fedie_f_sm trn_freight,Freight Rail_tmp_subsector_L2,Electricity,feelt_f_sm trn_freight,Freight Rail_tmp_subsector_L2,Liquids,fedie_f_sm trn_aviation_intl,International Aviation_tmp_subsector_L2,Liquids,fedie_p_lo From da0ed2dac341c52783855e9bfd941fef5fff9542 Mon Sep 17 00:00:00 2001 From: jmuessel Date: Thu, 1 Feb 2024 08:56:36 +0100 Subject: [PATCH 2/5] compscen until 2050 --- inst/Rmd/compareScenarios_Transport/csEDGET_main.Rmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inst/Rmd/compareScenarios_Transport/csEDGET_main.Rmd b/inst/Rmd/compareScenarios_Transport/csEDGET_main.Rmd index 43128e12..914f0744 100644 --- a/inst/Rmd/compareScenarios_Transport/csEDGET_main.Rmd +++ b/inst/Rmd/compareScenarios_Transport/csEDGET_main.Rmd @@ -20,9 +20,9 @@ params: mifScen: "" mifScenNames: !r c() mifHist: "" - yearsScen: !r c(seq(2005, 2060, 5), seq(2070, 2100, 10)) - yearsHist: !r c(seq(2010, 2020, 1), seq(2025, 2100, 5)) - yearsBarPlot: !r c(2010, 2030, 2050, 2100) + yearsScen: !r c(seq(2005, 2050, 5)) + yearsHist: !r c(seq(2010, 2020, 1), seq(2025, 2050, 5)) + yearsBarPlot: !r c(2010, 2030, 2050) reg: !r c("OAS","MEA","SSA","LAM","REF","CAZ","CHA","IND","JPN","USA","NEU","EUR","World") modelsHistExclude: !r c() sections: !r c("01_energy_demand","02_energy_services","03_energy_intensity", "04_stock_and_sales", "05_Emissions", "06_costs_and_shareweight_trends") From f3a3fd964cffe3b3a69f480caef0c7b818b0ecc6 Mon Sep 17 00:00:00 2001 From: jmuessel Date: Thu, 8 Aug 2024 16:35:43 +0200 Subject: [PATCH 3/5] Adjust Mix4 policy Mask (before 2030 and ICE ban) This is a quick correction of SSPEU Mix4 EUR 2020-2040 values. A thorough rework for all Mix scenarios and regions is still necessary. --- R/toolUpdateEndogenousCosts.R | 13 +++++++------ inst/extdata/scenParIncoCost.csv | 10 +++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/R/toolUpdateEndogenousCosts.R b/R/toolUpdateEndogenousCosts.R index f6f3eaa7..a1fc6c89 100644 --- a/R/toolUpdateEndogenousCosts.R +++ b/R/toolUpdateEndogenousCosts.R @@ -66,18 +66,19 @@ toolUpdateEndogenousCosts <- function(dataEndoCosts, applyICEban <- function(year, currentMask) { if (year < 2030){ floorCosts <- currentMask - } else if (year >= 2030 & year <= 2032){ - floorCosts <- strangeICEbanFunction(year, 2030, currentMask, 2032, 0.35) + } else if (year == 2030){ + floorCosts <- 0.05 + } else if (year > 2030 & year <= 2032){ + floorCosts <- strangeICEbanFunction(year, 2030, 0.1, 2032, 0.3) } else if(year > 2032 & year <= 2034){ - floorCosts <- strangeICEbanFunction(year, 2032, 0.35, 2034, 0.95) + floorCosts <- strangeICEbanFunction(year, 2032, 0.3, 2034, 0.5) } else if (year == 2035){ - floorCosts <- 0.95 - } else { + floorCosts <- 0.6 + } else if (year > 2035) { floorCosts <- 1 } return(floorCosts) } - policyMask <- copy(scenParIncoCost) # Expand regional and temporal resolution regions <- unique(dataEndoCosts$region) diff --git a/inst/extdata/scenParIncoCost.csv b/inst/extdata/scenParIncoCost.csv index caf3ceaf..d071345a 100644 --- a/inst/extdata/scenParIncoCost.csv +++ b/inst/extdata/scenParIncoCost.csv @@ -281,12 +281,12 @@ SSP2EU;Mix1;LDV|4W;Liquids;targetYear;2027 SSP2EU;Mix1;LDV|4W;Liquids;targetValue;0 SSP2EU;Mix1;LDV|4W;Hybrid electric;ratioPHEV;0.5 SSP2EU;Mix2;LDV|4W;BEV;startYear;2025 -SSP2EU;Mix2;LDV|4W;BEV;startValue;0.5 +SSP2EU;Mix2;LDV|4W;BEV;startValue;0.65 SSP2EU;Mix2;LDV|4W;BEV;targetYear;2035 SSP2EU;Mix2;LDV|4W;BEV;targetValue;0.15 -SSP2EU;Mix2;LDV|4W;Liquids;startYear;2020 +SSP2EU;Mix2;LDV|4W;Liquids;startYear;2023 SSP2EU;Mix2;LDV|4W;Liquids;targetYear;2027 -SSP2EU;Mix2;LDV|4W;Liquids;targetValue;0.05 +SSP2EU;Mix2;LDV|4W;Liquids;targetValue;0.01 SSP2EU;Mix2;LDV|4W;Hybrid electric;ratioPHEV;0.5 SSP2EU;Mix3;LDV|4W;BEV;startYear;2025 SSP2EU;Mix3;LDV|4W;BEV;startValue;0.5 @@ -297,12 +297,12 @@ SSP2EU;Mix3;LDV|4W;Liquids;targetYear;2045 SSP2EU;Mix3;LDV|4W;Liquids;targetValue;0.7 SSP2EU;Mix3;LDV|4W;Hybrid electric;ratioPHEV;0.5 SSP2EU;Mix4;LDV|4W;BEV;startYear;2025 -SSP2EU;Mix4;LDV|4W;BEV;startValue;0.5 +SSP2EU;Mix4;LDV|4W;BEV;startValue;1 SSP2EU;Mix4;LDV|4W;BEV;targetYear;2035 SSP2EU;Mix4;LDV|4W;BEV;targetValue;0 SSP2EU;Mix4;LDV|4W;Liquids;startYear;2023 SSP2EU;Mix4;LDV|4W;Liquids;targetYear;2055 -SSP2EU;Mix4;LDV|4W;Liquids;targetValue;1.5 +SSP2EU;Mix4;LDV|4W;Liquids;targetValue;0.1 SSP2EU;Mix4;LDV|4W;Hybrid electric;ratioPHEV;1.5 SSP2EU;NAV_act;LDV|4W;BEV;startYear;2025 SSP2EU;NAV_act;LDV|4W;BEV;startValue;0.5 From 00b30d4e278c757946b8e5fd53e2cf518ed5891f Mon Sep 17 00:00:00 2001 From: jmuessel Date: Thu, 8 Aug 2024 16:58:18 +0200 Subject: [PATCH 4/5] BuildLib --- .buildlibrary | 2 +- .pre-commit-config.yaml | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- README.md | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 5167a1f6..fd0dc3af 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '4005126' +ValidationKey: '4188030' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62f13da6..7ccf77e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: mixed-line-ending - repo: https://github.com/lorenzwalthert/precommit - rev: 7910e0323d7213f34275a7a562b9ef0fde8ce1b9 # frozen: v0.4.2 + rev: bae853d82da476eee0e0a57960ee6b741a3b3fb7 # frozen: v0.4.3 hooks: - id: parsable-R - id: deps-in-desc diff --git a/CITATION.cff b/CITATION.cff index 876871b2..d474819f 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -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.0.1 -date-released: '2024-07-22' +version: 2.1.0 +date-released: '2024-08-08' 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 diff --git a/DESCRIPTION b/DESCRIPTION index a2f3083e..c05b1f3f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: edgeTransport Title: Prepare EDGE Transport Data for the REMIND model -Version: 2.0.1 +Version: 2.1.0 Authors@R: c( person("Johanna", "Hoppe", , "johanna.hoppe@pik-potsdam.de", role = c("aut", "cre"), comment = c(ORCID = "0009-0004-6753-5090")), @@ -18,7 +18,7 @@ Encoding: UTF-8 LazyData: true RoxygenNote: 7.3.2 VignetteBuilder: knitr -Date: 2024-07-22 +Date: 2024-08-08 Config/testthat/edition: 3 Imports: rmndt, diff --git a/README.md b/README.md index b7069553..cece8440 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Prepare EDGE Transport Data for the REMIND model -R package **edgeTransport**, version **2.0.1** +R package **edgeTransport**, version **2.1.0** [![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) @@ -46,7 +46,7 @@ In case of questions / problems please contact Johanna Hoppe . +Hoppe J, Dirnaichner A, Rottoli M, Muessel J (2024). _edgeTransport: Prepare EDGE Transport Data for the REMIND model_. R package version 2.1.0, . A BibTeX entry for LaTeX users is @@ -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.0.1}, + note = {R package version 2.1.0}, url = {https://github.com/pik-piam/edgeTransport}, } ``` From 2e4fd0b1b9bf7ab6cabed55b2670201169f2e0b9 Mon Sep 17 00:00:00 2001 From: jmuessel Date: Thu, 8 Aug 2024 17:01:22 +0200 Subject: [PATCH 5/5] Delete csEDGET_main.Rmd --- .../csEDGET_main.Rmd | 329 ------------------ 1 file changed, 329 deletions(-) delete mode 100644 inst/Rmd/compareScenarios_Transport/csEDGET_main.Rmd diff --git a/inst/Rmd/compareScenarios_Transport/csEDGET_main.Rmd b/inst/Rmd/compareScenarios_Transport/csEDGET_main.Rmd deleted file mode 100644 index 914f0744..00000000 --- a/inst/Rmd/compareScenarios_Transport/csEDGET_main.Rmd +++ /dev/null @@ -1,329 +0,0 @@ ---- -title: "Edge Transport Compare Scenarios" -date: "`r format(Sys.Date())`" -output: - pdf_document: - toc: yes - number_sections: yes - toc_depth: 6 - keep_tex: false - template: cs2_latex_template.tex - includes: - in_header: cs_pdf_header_include.tex - html_document: - toc: yes - toc_float: yes - toc_depth: 6 - number_sections: yes -geometry: "a4paper,landscape,left = 0.5cm,right = 0.5cm,top = 0.5cm,bottom = 0.5cm,footnotesep=0.0cm,footskip = 0.1cm" -params: - mifScen: "" - mifScenNames: !r c() - mifHist: "" - yearsScen: !r c(seq(2005, 2050, 5)) - yearsHist: !r c(seq(2010, 2020, 1), seq(2025, 2050, 5)) - yearsBarPlot: !r c(2010, 2030, 2050) - reg: !r c("OAS","MEA","SSA","LAM","REF","CAZ","CHA","IND","JPN","USA","NEU","EUR","World") - modelsHistExclude: !r c() - sections: !r c("01_energy_demand","02_energy_services","03_energy_intensity", "04_stock_and_sales", "05_Emissions", "06_costs_and_shareweight_trends") - userSectionPath: null - mainReg: "World" - figWidth: 15 - figHeight: 10 - warning: no -subparagraph: yes ---- - -```{r setup, include=FALSE} -knitr::opts_chunk$set( - echo = FALSE, - error = TRUE, - message = FALSE, - warning = params$warning, - fig.width = params$figWidth, - fig.height = params$figHeight) -``` - - -```{r libraries, include=FALSE} -# kableExtra must not be loaded before the call of library(kableExtra) below, -# as its .onLoad() function must be called to tell knitr about add necessary -# LaTeX libraries needed for tables. -# If the following line is not included, successive calls to compareScenarios2() -# may cause "Undefined control sequence" errors in LaTeX. -try(unloadNamespace("kableExtra"), silent = TRUE) - -library(gridExtra) -options(tidyverse.quiet = TRUE) -library(tidyverse) -library(kableExtra) -library(devtools) -library(mip) -library(quitte) -library(edgeTransport) -library(data.table) -``` - -```{r read scenario mifs} -# Read *.mif-files as nested tibble. -tibble(path = unname(params$mifScen)) %>% - rowid_to_column("fileid") %>% - mutate(data = map( - path, - read.quitte, - factors = TRUE, - # read.quitte() default NA-strings and Inf, -Inf - na.strings = c("UNDF", "NA", "N/A", "n_a", "Inf", "-Inf"))) %>% - unnest(data) %>% - nest(data = -c(fileid, path, scenario)) -> - dataScenNested -# Add column character column "newScenarioName", -# either with contents of params$mifScenNames or copy names from column scenario. -if (is.null(params$mifScenNames)) { - dataScenNested %>% - mutate(newScenarioName = as.character(scenario)) -> - dataScenNested -} else { - dataScenNested %>% - left_join( - tibble( - fileid = seq_along(params$mifScen), - newScenarioName = params$mifScenNames), - by = "fileid") -> - dataScenNested -} -# Check for duplicated scenario names. -if (anyDuplicated(dataScenNested$newScenarioName)) { - warning("There are duplicated scenario names. They will be renamed.") - dataScenNested %>% - mutate(newScenarioName = make.unique(newScenarioName)) -> - dataScenNested -} -# Retrieve data for reference table to be shown at the beginning of the document. -dataScenNested %>% - select(fileid, path, scenario, newScenarioName) -> - fileReference -# Apply renaming of scenario, unnest, and select only relevant columns. -dataScenNested %>% - mutate(scenario = factor(newScenarioName, levels = newScenarioName)) %>% - unnest(data) %>% - select(model, scenario, region, variable, unit, period, value) -> - dataScen -``` - -```{r define scenario colors} -# Get colors of scenarios to be used, e.g., in the info sections. -# They will coincide with the colors of the scenarios in line plots. -scenarioColors <- plotstyle(fileReference$newScenarioName) -lightenColor <- function(clr, by) { - colRGB <- colorRamp(c(clr, "white"))(by) - rgb(colRGB[1], colRGB[2], colRGB[3], maxColorValue = 255) -} -bkgndColors <- sapply(scenarioColors, lightenColor, by = 0.5) -``` - - -```{r read historical mif} -params$mifHist %>% - read.quitte(factors = TRUE) -> - dataHist -``` - - -```{r preprocess} -# Filter years and NA. -dataScen %>% - filter(period %in% params$yearsScen) -> - dataScen -dataHist %>% - filter(period %in% params$yearsHist, !(model %in% params$modelsHistExclude), !is.na(value)) %>% - droplevels() -> - dataHist -# Combine into one data frame and remove old. -data <- bind_rows(dataScen, dataHist) -rm(dataScen, dataScenNested, dataHist) -# In the variable names, replace |+|, |++|, |+++|, ... by |. -data %>% - mutate( - varplus = as.character(variable), - variable = remind2::deletePlus(variable)) -> - data -# Filter regions. -if (!is.null(params$reg)) { - data %>% - filter(region %in% params$reg) -> - data -} -``` - - -```{r Corrections} -# TODO: Should not be done in compareScenarios. -# Change unit million US$2005/yr to billion US$2005/yr. -# Relevant for ARIADNE historical EUR GDP|PPP. -bind_rows( - data %>% filter(!unit %in% c("million US$2005/yr")), - data %>% - filter(unit == "million US$2005/yr") %>% - mutate( - unit = "billion US$2005/yr", - value = value / 1000)) -> - data -``` - - -```{r reference models for historical} -# Sometimes it is necessary to choose a single model for the historical data, -# e.g., calculating per capita variables. These reference models are defined here. -histRefModel <- c( - "Population" = "WDI", - "GDP|PPP pCap" = "James_IMF") -``` - - -```{r calcuate pCap variables} -# For all variables in following table, add a new variable to data with the name -# "OldName pCap". Calculate its value by -# OldValue * conversionFactor -# and set its unit to newUnit. -# The new variable "OldName pCap" will be available in the plot sections. -pCapVariables <- tribble( - ~variable, ~newUnit, ~conversionFactor, - "GDP|PPP", "kUS$2005", 1e6, - "ES|Transport|Pass|w/o bunkers", "pkm/yr", 1e9, - "ES|Transport|Pass|Aviation", "pkm/yr", 1e9, - "ES|Transport|Pass|Aviation|International", "pkm/yr", 1e9, - "ES|Transport|Pass|Aviation|Domestic", "pkm/yr", 1e9, - "ES|Transport|Pass|Road|Bus", "pkm/yr", 1e9, - "ES|Transport|Pass|Road|Non-Motorized|Walking", "pkm/yr", 1e9, - "ES|Transport|Pass|Road|Non-Motorized|Cycling", "pkm/yr", 1e9, - "ES|Transport|Pass|Rail|non-HSR", "pkm/yr", 1e9, - "ES|Transport|Pass|Rail|HSR", "pkm/yr", 1e9, - "ES|Transport|Freight|w/o bunkers", "tkm/yr", 1e9, - "ES|Transport|Freight|International Shipping", "tkm/yr", 1e9, - "ES|Transport|Freight|Road", "tkm/yr", 1e9, - "ES|Transport|Freight|Navigation", "tkm/yr", 1e9, - "ES|Transport|Freight|Rail", "tkm/yr", 1e9, - "ES|Transport|Pass|Road|LDV", "pkm/yr", 1e9, - "ES|Transport|Pass|Road|LDV|Four Wheelers", "pkm/yr", 1e9, - "ES|Transport|Pass|Road|LDV|Two Wheelers", "pkm/yr", 1e9, - "ES|Transport|Pass|non-LDV", "pkm/yr", 1e9, - "ES|Transport|Pass|Road|LDV|BEV", "pkm/yr", 1e9, - "ES|Transport|Pass|Road|LDV|FCEV", "pkm/yr", 1e9, - "ES|Transport|Pass|Road|LDV|Gases", "pkm/yr", 1e9, - "ES|Transport|Pass|Road|LDV|Hybrid Electric", "pkm/yr", 1e9, - "ES|Transport|Pass|Road|LDV|Liquids", "pkm/yr", 1e9, - "ES|Transport edge|Freight", "tkm/yr", 1e9, - "ES|Transport|Freight|Road|Electric", "pkm/yr", 1e9, - "ES|Transport|Freight|Road|FCEV", "pkm/yr", 1e9, - "ES|Transport|Freight|Road|Gases", "pkm/yr", 1e9, - "ES|Transport|Freight|Road|Liquids", "pkm/yr", 1e9) - -data %>% - filter(variable == "Population") %>% - filter(scenario != "historical" | model == histRefModel["Population"]) %>% - select(scenario, region, period, value) %>% - mutate( - population = value * 1e6, # unit originally is million, now is 1 - value = NULL) -> - dataPop - -data %>% - inner_join(pCapVariables, 'variable') %>% - left_join(dataPop, c('scenario', 'region', 'period')) %>% - mutate( - value = value / population * conversionFactor, - variable = paste0(variable, " pCap"), - unit = newUnit, - newUnit = NULL, conversionFactor = NULL, population = NULL) -> - dataPCap - -data %>% - bind_rows(dataPCap) -> - data -``` - - -```{r add gdp column} -# Create a new column gdp with the value of GDP|PPP pCap (kUS$2005). -data %>% - filter(variable == "GDP|PPP pCap") %>% - filter(scenario != "historical" | model == histRefModel["GDP|PPP pCap"]) %>% - select(scenario, region, period, value) %>% - rename(gdp = value) -> - dataGDP -data %>% - left_join(dataGDP, c('scenario', 'region', 'period')) -> - data -``` - - -```{r calcuate pGDP variables} -# For all variables in following table, add a new variable to data with the name -# "OldName pGDP". Calculate its value by -# OldValue / (GDP|PPP pCap) * conversionFactor -# and set its unit to newUnit. -# The new variable "OldName pGDP" will be available in the plot sections. -pGdpVariables <- tribble( - ~variable, ~newUnit, ~conversionFactor, - "FE", "MJ/US$2005", 1e3, - "FE|CDR", "MJ/US$2005", 1e3, - "FE|Transport", "MJ/US$2005", 1e3, - "FE|Buildings", "MJ/US$2005", 1e3, - "FE|Industry", "MJ/US$2005", 1e3) -data %>% - inner_join(pGdpVariables, 'variable') %>% - mutate( - value = value / gdp * conversionFactor, - variable = paste0(variable, " pGDP"), - unit = newUnit, - newUnit = NULL, conversionFactor = NULL) -> - dataPGdp -data %>% - bind_rows(dataPGdp) -> - data -``` - -```{r quitte} -data <- as.quitte(data) -``` - -```{r global variables} -# Set global variables for use in plotting. -options(mip.mainReg = params$mainReg) -options(mip.yearsBarPlot = params$yearsBarPlot) -options(mip.histRefModel = histRefModel) -``` - -```{r define plot functions} -source("cs2_plot_functions.R", local=TRUE) -``` - - -```{r sectionPaths, include=FALSE} -if (length(params$sections) == 1 && params$sections == "all") { - dir() %>% - str_subset("^csEDGET_[0-9]{2}.+//.Rmd$") %>% - sort() -> - sectionPaths -} else { - if (length(params$sections) > 0) { - sectionPaths <- paste0("csEDGET_", params$sections, ".Rmd") - } else { - sectionPaths <- character(0) - } -} -``` - - -```{r prepare mark} -# CLICK "RUN ALL CHUNKS ABOVE" HERE TO PREPARE THE ENVIRONMENT -``` - - -```{r include sections, child = sectionPaths} -``` - - -```{r include user section, child = params$userSectionPath} -```