-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from ahagen-pik/moveSubsidies
move preparation of subsidies data to mrtransport
- Loading branch information
Showing
7 changed files
with
71 additions
and
9 deletions.
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,6 +1,6 @@ | ||
Package: mrtransport | ||
Title: Input data generation for the EDGE-Transport model | ||
Version: 0.10.1 | ||
Version: 0.10.2 | ||
Authors@R: c( | ||
person("Johanna", "Hoppe", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0009-0004-6753-5090")), | ||
|
@@ -33,4 +33,4 @@ Imports: | |
tidyselect, | ||
utils, | ||
zoo | ||
Date: 2024-12-18 | ||
Date: 2024-12-19 |
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,40 @@ | ||
#' Prepare subsidies data | ||
#' @param helpers list containg several helpers used throughout the model. | ||
#' It includes dtTimeRes, a data.table containing the temporal | ||
#' resolution for different univocalNames | ||
#' @returns list of data.tables containing mrremind input data | ||
#' @importFrom rmndt magpie2dt | ||
#' @export | ||
|
||
toolPrepareTransportSubsidies <- function(helpers) { | ||
# bind variables locally to prevent NSE notes in R CMD CHECK | ||
period <- value <- subsectorL3 <- variable <- unit <- . <- NULL | ||
|
||
yrs <- unique(helpers$dtTimeRes$period) | ||
|
||
subsidies <- magpie2dt(readSource(type = "TransportSubsidies")) | ||
setnames(subsidies, "variable", "technology") | ||
# average between legal and private entities | ||
subsidies <- subsidies[, .(value = mean(value)), by = c("region", "period", "technology")] | ||
subsidies[, value := -value] # count subsidies negative | ||
completeSub <- unique(subsidies[, c("region", "technology")])[, temporal := "all"] | ||
temporal <- data.table(period = yrs)[, temporal := "all"] | ||
completeSub <- merge(completeSub, temporal, by = "temporal", allow.cartesian = TRUE)[, temporal := NULL] | ||
subsidies <- merge(subsidies, completeSub, all.y = TRUE, by = c("region", "technology", "period")) | ||
|
||
## year where complete phase-out incentives occurs | ||
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")] | ||
|
||
# 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, | ||
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(subsidies) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.