-
Notifications
You must be signed in to change notification settings - Fork 4
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
Remove inconsistency regarding REMIND/EDGE-T communication of active modes energy service demand #24
Merged
johannah-pik
merged 8 commits into
pik-piam:master
from
johannah-pik:fixActiveModesReportingToRemind
Sep 10, 2024
Merged
Remove inconsistency regarding REMIND/EDGE-T communication of active modes energy service demand #24
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8ed4e5f
include active modes in to REMIND reporting
johannah-pik 38d1c79
Merge branch 'master' of github.com:pik-piam/reporttransport into fix…
johannah-pik 7dc8e78
include active modes in to REMIND reporting
johannah-pik 2e33ac7
change to shares + remove zeros
johannah-pik eeb1d8b
buildlib
johannah-pik 9c67cc1
Remove plotting script from package
johannah-pik f80e0b1
buildlib
johannah-pik 67195c0
Update README.md
johannah-pik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
Type: Package | ||
Package: reporttransport | ||
Title: Reporting package for edgeTransport | ||
Version: 0.1.0 | ||
Date: 2024-09-04 | ||
Version: 0.4.0 | ||
Date: 2024-09-10 | ||
Authors@R: | ||
person("Johanna", "Hoppe", , "[email protected]", role = c("aut", "cre")) | ||
Description: This package contains edgeTransport-specific routines to | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#'Report energy service demand to REMIND | ||
#' | ||
#'Note that this is a helpers function that accounts for structural differences in REMIND and EDGE-T. | ||
#'The REMIND CES tree cannot represent active modes, as they deliver valuable energy service demand without capital cost and final energy production. | ||
#'Just filtering out the active modes energy service demand allocated by EDGE-Transport would lead to inconsistencies between both models: | ||
#'E.g. REMIND would split the whole trn_pass energy service demand according to the FE shares and energy efficiencies reported by EDGE-T (without considering the active modes) | ||
#' and would calculate a different FE value compared to EDGE-T that reserves a part of the trn_pass energy service demand | ||
#'to the active modes. | ||
#' | ||
#'Solution: split and distribute the energy service demand of active modes across all technologies to calculate energy efficiency and capital cost per pkm. | ||
#'Consequence: This leads to the fact that in REMIND energy service demand, energy efficiencies, an capital costs on technology level are rather abstract values that are not technically correct. | ||
#'Hence, they should not be reported on technology level by REMIND (only by EDGE-T). The FE values on technology level are represented correctly as well as the energy service demand on CES node level. | ||
#'The decision of the technology share is anyway made by EDGE-T and not by REMIND. | ||
#' | ||
#' | ||
#' @param fleetESdemand energy service demand on fleet level | ||
#' @param hybridElecShare share of electric driving for hybrid electric vehicles | ||
#' @param timeResReporting time resolution reporting | ||
#' @param demScen demand scenario | ||
#' @param SSPscen SSP scenario | ||
#' @param transportPolScen transport policy scenario | ||
#' @param helpers list of helpers | ||
#' @returns Energy service demand per technology in [trillion pkm/trillion tkm] | ||
#' @export | ||
#' @author Johanna Hoppe | ||
#' @import data.table | ||
|
||
reportToREMINDesDemand <- function(fleetESdemand, hybridElecShare, timeResReporting, demScen, SSPscen, transportPolScen, helpers) { | ||
|
||
fleetESdemand <- copy(fleetESdemand) | ||
fleetESdemand <- fleetESdemand[period %in% timeResReporting] | ||
# convert billion pkm|tkm to trillion pkm|tkm | ||
fleetESdemand[, value := value * 1e-3] | ||
test <- fleetESdemand[, .(value = sum(value)), by = c("region", "period", "sector")] | ||
test <- test[sector == "trn_pass"][, sector := NULL] | ||
#split hybrid energy service demand | ||
fleetESdemandWoHybrid <- copy(fleetESdemand) | ||
hybrids <- fleetESdemandWoHybrid[technology == "Hybrid electric"] | ||
hybrids[, value := hybridElecShare * value][, technology := "BEV"] | ||
fleetESdemandWoHybrid[technology == "Hybrid electric", value := (1 - hybridElecShare) * value] | ||
fleetESdemandWoHybrid[technology == "Hybrid electric", technology := "Liquids"] | ||
fleetESdemandWoHybrid <- rbind(fleetESdemandWoHybrid, hybrids) | ||
byCols <- names(fleetESdemandWoHybrid) | ||
byCols <- byCols[!byCols %in% c("value")] | ||
fleetESdemand <- fleetESdemandWoHybrid[, .(value = sum(value)), by = eval(byCols)] | ||
|
||
# Split and distribute the active modes energy service demand to the technologies as | ||
# they are not represented in REMIND (see explanation in function header) | ||
demandMap <- unique(helpers$mapEdgeToREMIND[, c("all_teEs", "univocalName", "technology")]) | ||
demandMap <- demandMap[!is.na(all_teEs)] | ||
activeModes <- fleetESdemand[grepl(".*Cycle|Walk.*", subsectorL1)] | ||
REMINDesDemand <- fleetESdemand[!grepl(".*Cycle|Walk.*", subsectorL1)] | ||
activeModes <- activeModes[, .(activeESdemand = sum(value)), by = c("region", "period", "sector")] | ||
REMINDesDemand <- merge(REMINDesDemand, demandMap, by = c("univocalName", "technology"), all.x = TRUE) # nolint: object_name_linter | ||
REMINDesDemand <- REMINDesDemand[, .(value = sum(value)), by = c("region", "period", "sector", "all_teEs")] | ||
REMINDesDemand[, share := value / sum(value), by = c("region", "period", "sector")] | ||
REMINDesDemand <- merge(REMINDesDemand, activeModes[, c("region", "period", "sector", "activeESdemand")], by = c("region", "period", "sector"), all.x = TRUE) | ||
REMINDesDemand[sector == "trn_pass", value := value + share * activeESdemand][, c("activeESdemand", "sector", "share") := NULL] | ||
|
||
test2 <- REMINDesDemand[grepl(".*pass_sm", all_teEs), .(value = sum(value)), by = c("region", "period")] | ||
setkey(test, region, period) | ||
setkey(test2, region, period) | ||
if (!all.equal(test, test2)) stop("Something went wrong with the hybrids or active modes split in reportToREMINDesDemand()") | ||
checkForNAsAndDups(REMINDesDemand, "REMINDesDemand", "reportToREMINDesDemand()") | ||
REMINDesDemand <- prepareForREMIND(REMINDesDemand, demScen, SSPscen, transportPolScen) | ||
setnames(REMINDesDemand, c("period", "region"), c("tall", "all_regi")) | ||
|
||
return(REMINDesDemand) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robertpietzcker The differences in the energy efficiency values for freight are coming from a change in how the energy efficiency is caluclated. They appear solely, where the energy service/final energy demand is anyway zero.
Previously I used the reciprocal energy intensity and aggregated it to all_teEs level by using the final energy demand as weight (energy efficiency is reported in (p|t)km/MJ to REMIND).
Where the whole branch has zero final energy demand, a weight of 1 was used, so that the energy intensity value does not disappear (the CES tree cannot deal with an energy efficiency of zero). Now I used FE and ES on te_Es level including the active modes to calculate the energy efficiency. To get rid of the zeros I used another method: I removed them beforehand and interpolated the missing values afterwards. Filtering out the zero demand values in advance ensures that we do not also interpolate NAs, which would indicate errors in the model if they occur.
So in summary: The changes come from a different way of dealing with zero demand values and don't affect the model results.