-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
171 additions
and
95 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,8 +1,8 @@ | ||
Type: Package | ||
Package: mredgebuildings | ||
Title: Prepare data to be used by the EDGE-Buildings model | ||
Version: 0.6.1 | ||
Date: 2024-04-25 | ||
Version: 0.7.0 | ||
Date: 2024-05-16 | ||
Authors@R: c( | ||
person("Robin", "Hasse", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0003-1818-3186")), | ||
|
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,83 @@ | ||
#' Convert WEO enduse shares w.r.t. to global final energy demand | ||
#' | ||
#' @param x readWEO object | ||
#' | ||
#' @author Hagen Tockhorn | ||
#' | ||
#' @importFrom madrat toolGetMapping | ||
#' @importFrom quitte aggregate_map | ||
|
||
convertWEO <- function(x) { | ||
|
||
# READ DATA------------------------------------------------------------------- | ||
|
||
data <- as.quitte(x) | ||
|
||
# region mapping | ||
regmapping <- toolGetMapping(name = "regionmappingWEO.csv", | ||
type = "regional", | ||
where = "mredgebuildings") | ||
|
||
# fe weights | ||
fe <- calcOutput("ShareETP", | ||
subtype = "enduse", | ||
aggregate = FALSE, | ||
feOnly = TRUE) %>% | ||
as.quitte() | ||
|
||
|
||
# CORRECTIONS----------------------------------------------------------------- | ||
|
||
data <- data %>% | ||
select("region", "period", "enduse", "value") %>% | ||
rename(variable = "enduse") %>% | ||
mutate(unit = NA) | ||
|
||
# Taken from EDGE-B by Antoine Levesque: | ||
# "OCD's appliances and lighting is too high compared to electricity consumption" | ||
|
||
dataCorr <- data %>% | ||
mutate(value = ifelse(.data[["region"]] == "Other OECD" & | ||
.data[["variable"]] %in% c("appliances", "lighting"), | ||
.data[["value"]] * 0.56, | ||
.data[["value"]])) %>% | ||
mutate(value = ifelse(.data[["region"]] == "Middle East" & | ||
.data[["variable"]] %in% c("appliances", "lighting", "space_cooling"), | ||
.data[["value"]] * 0.65, | ||
.data[["value"]])) %>% | ||
mutate(value = ifelse(.data[["region"]] == "Southeast Asia" & | ||
.data[["variable"]] %in% c("appliances", "lighting", "space_cooling"), | ||
.data[["value"]] * 0.66, | ||
.data[["value"]])) | ||
|
||
|
||
# PROCESS DATA---------------------------------------------------------------- | ||
|
||
fe <- fe %>% | ||
select("region", "period", "enduse", "value") %>% | ||
rename("variable" = "enduse") | ||
|
||
|
||
dataDisagg <- dataCorr %>% | ||
aggregate_map(mapping = regmapping, | ||
by = c(region = "RegionCode"), | ||
weights = fe %>% | ||
rename(weight_val_col = "value"), | ||
weight_item_col = "region", | ||
forceAggregation = TRUE) %>% | ||
rename(enduse = "variable") | ||
|
||
|
||
data <- dataDisagg %>% | ||
select("region", "period", "enduse", "value") | ||
|
||
|
||
# OUTPUT---------------------------------------------------------------------- | ||
|
||
data <- data %>% | ||
as.quitte() %>% | ||
as.magpie %>% | ||
toolCountryFill() | ||
|
||
return(data) | ||
} |
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,29 @@ | ||
#' Read WEO enduse shares w.r.t. to global final energy demand | ||
#' | ||
#' @param subtype variable to define data subset ("Buildings", "Transport", "Industry") | ||
#' | ||
#' @author Hagen Tockhorn | ||
|
||
readWEO <- function(subtype) { | ||
|
||
file <- "WEO_10.2.xlsx" | ||
|
||
# Read Data | ||
data <- read_xlsx(file, sheet = 2) | ||
|
||
# Process Data | ||
data <- data %>% | ||
filter(.data[["sector"]] == subtype) %>% | ||
gather("region", "value", 3:12) %>% | ||
mutate(period = 2014, | ||
region = gsub("\\.", " ", .data[["region"]]), | ||
enduse = tolower(.data[["enduse"]]), | ||
enduse = gsub(" ", "_", .data[["enduse"]])) %>% | ||
select("region", "period", "enduse", "value") | ||
|
||
data <- data %>% | ||
as.quitte() %>% | ||
as.magpie() | ||
|
||
return(data) | ||
} |
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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.