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

Refactoring #264

Merged
merged 5 commits into from
Jul 15, 2024
Merged
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: '30135934'
ValidationKey: '30157366'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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: 1.5.13
date-released: '2024-07-14'
version: 1.5.14
date-released: '2024-07-15'
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
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: 1.5.13
Version: 1.5.14
Authors@R: c(
person("Johanna", "Hoppe", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0009-0004-6753-5090")),
Expand All @@ -17,7 +17,7 @@ Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.1
VignetteBuilder: knitr
Date: 2024-07-14
Date: 2024-07-15
Config/testthat/edition: 3
Imports:
rmndt,
Expand Down
3 changes: 1 addition & 2 deletions R/iterativeEDGETransport.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ iterativeEdgeTransport <- function() {
byCols <- names(REMINDfuelCostIterations)
byCols <- byCols[!byCols %in% c("value", "iteration")]
REMINDfuelCost <- copy(REMINDfuelCostIterations[iteration >= 20])
REMINDfuelCost[, .(value = mean(value)), by = ..byCols]
REMINDfuelCost <- REMINDfuelCost[, .(value = mean(value)), by = eval(byCols)]
}
}
} else {
Expand All @@ -114,7 +114,6 @@ iterativeEdgeTransport <- function() {
}
setcolorder(RDSinputs$CAPEXandNonFuelOPEX, names(REMINDfuelCost))
combinedCAPEXandOPEX <- rbind(RDSinputs$CAPEXandNonFuelOPEX, REMINDfuelCost)

# Data from previous EDGE-T iteration
fleetVehiclesPerTech <- NULL
pathTofleetVehiclesPerTech <- list.files(file.path(".", edgeTransportFolder), "fleetVehiclesPerTech.RDS", recursive = TRUE, full.names = TRUE)
Expand Down
11 changes: 7 additions & 4 deletions R/supportFunctionsIterative.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ toolLoadIterativeInputs <- function(edgeTransportFolder, inputFolder, inputFiles

## Transport policy scenario inconvenience cost factors
scenParIncoCost <- fread(system.file("extdata/scenParIncoCost.csv", package = "edgeTransport", mustWork = TRUE), header = TRUE)
scenParIncoCost <- scenParIncoCost[SSPscen == gsub("gdp_", "", SSPscenario) & transportPolScen == transportPolScenario][, c("SSPscen", "transportPolScen") := NULL]
scenParIncoCost <- scenParIncoCost[SSPscen == gsub("gdp_", "", SSPscenario) & transportPolScen == gsub("ICEban", "", transportPolScenario)][, c("SSPscen", "transportPolScen") := NULL]

annuityCalc <- fread(system.file("extdata/genParAnnuityCalc.csv", package = "edgeTransport", mustWork = TRUE), header = TRUE)
# Interest Rate and vehicle service life for annuity calculation
# NOTE: right now there is only "default". If we add scenario specific annuity parameters, we can shift annuityCalc to the scenPar's
if (transportPolScenario %in% annuityCalc$transportPolScen){
annuityCalc <- annuityCalc[transportPolScen == transportPolScenario][, transportPolScen := NULL]} else {
if (gsub("ICEban", "", transportPolScenario) %in% annuityCalc$transportPolScen){
annuityCalc <- annuityCalc[transportPolScen == gsub("ICEban", "", transportPolScenario)][, transportPolScen := NULL]} else {
annuityCalc <- annuityCalc[transportPolScen == "default"][, transportPolScen := NULL]
}

Expand All @@ -91,6 +91,8 @@ toolLoadIterativeInputs <- function(edgeTransportFolder, inputFolder, inputFiles
package = "edgeTransport"), skip = 1)
mitigationTechMap <- fread(system.file("extdata", "helpersMitigationTechmap.csv",
package = "edgeTransport"))
regionmappingISOto21to12 <- fread(system.file("extdata", "helpersRegionmappingISOto21to12.csv",
package = "edgeTransport"))

## Decision tree
# map on decisiontree for provided spatial resolution
Expand Down Expand Up @@ -121,7 +123,8 @@ toolLoadIterativeInputs <- function(edgeTransportFolder, inputFolder, inputFiles
mapEdgeToREMIND = mapEdgeToREMIND,
reportingNames = reportingNames,
reportingAggregation = reportingAggregation,
mitigationTechMap = mitigationTechMap)
mitigationTechMap = mitigationTechMap,
regionmappingISOto21to12 = regionmappingISOto21to12)

# general model parameters
genModelPar <- list(
Expand Down
2 changes: 1 addition & 1 deletion R/toolEdgeTransportSA.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ toolEdgeTransportSA <- function(SSPscen,
#------------------------------------------------------

fleetVehiclesPerTech <- NULL
iterations <- 1
iterations <- 3

if (isAnalyticsReported) {
endogenousCostsIterations <- list()
Expand Down
3 changes: 2 additions & 1 deletion R/toolUpdateEndogenousCosts.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ toolUpdateEndogenousCosts <- function(dataEndoCosts,
affectedRegions <- unique(helpers$regionmappingISOto21to12[regionCode12 == "EUR"]$regionCode21)
affectedRegions <- c(affectedRegions, "EUR")
#affectedRegions <- affectedRegions[!affectedRegions == "UKI"]
policyMask[technology %in% c("Liquids", "Gases", "Hybrid electric"), policyMask := applyICEban(period, policyMask), by = c("period")]
policyMask[technology %in% c("Liquids", "Gases", "Hybrid electric") & region %in% affectedRegions,
policyMask := applyICEban(period, policyMask), by = c("period")]
}

#check whether policy mask is calculated correctly for respective technologys
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 **1.5.13**
R package **edgeTransport**, version **1.5.14**

[![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)

Expand Down Expand Up @@ -46,7 +46,7 @@ In case of questions / problems please contact Johanna Hoppe <johanna.hoppe@pik-

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

Hoppe J, Dirnaichner A, Rottoli M, Muessel J (2024). _edgeTransport: Prepare EDGE Transport Data for the REMIND model_. R package version 1.5.13, <https://github.com/pik-piam/edgeTransport>.
Hoppe J, Dirnaichner A, Rottoli M, Muessel J (2024). _edgeTransport: Prepare EDGE Transport Data for the REMIND model_. R package version 1.5.14, <https://github.com/pik-piam/edgeTransport>.

A BibTeX entry for LaTeX users is

Expand All @@ -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 1.5.13},
note = {R package version 1.5.14},
url = {https://github.com/pik-piam/edgeTransport},
}
```
Loading