-
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.
Merge pull request #26 from fbenke-pik/uvalues
read in Uvalues and floorspace
- Loading branch information
Showing
14 changed files
with
187 additions
and
8 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.7.0 | ||
Date: 2024-08-29 | ||
Version: 0.7.1 | ||
Date: 2024-09-11 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#' floor space by subsectors | ||
#' | ||
#' @export | ||
calcIEAfloorspace <- function() { | ||
|
||
x <- readSource("IEAfloorspace", convert = FALSE) | ||
|
||
return(list( | ||
x = x, | ||
isocountries = FALSE, | ||
unit = "billion m2", | ||
description = paste0( | ||
"Residential and commercial floor space for big world regions from the ", | ||
"IEA TCEP report 2014 in billion m2." | ||
) | ||
)) | ||
} |
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 @@ | ||
#' Calculate U-value | ||
#' | ||
#' @param subtype either 'EUBuildingsObservatory' or 'ETSAP' | ||
#' @export | ||
calcUvalues <- function(subtype) { | ||
|
||
if (!subtype %in% c("EUBuildingsObservatory", "ETSAP")) { | ||
stop("Invalid subtype. Must be either 'EUBuildingsObservatory' or 'ETSAP'") | ||
} | ||
|
||
if (subtype == "EUBuildingsObservatory") { | ||
x <- readSource("EUBuildingsObservatory", convert = FALSE) | ||
unit <- "W/m2C" | ||
} else { | ||
x <- readSource("ETSAP", convert = FALSE) | ||
unit <- "W/m2K" | ||
} | ||
|
||
return(list( | ||
x = x, | ||
isocountries = FALSE, | ||
unit = unit, | ||
description = paste0( | ||
"energy efficiency value of building shell in ", | ||
"residential and non-residential as reported by ", | ||
subtype | ||
) | ||
)) | ||
} |
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,45 @@ | ||
#' Read in energy efficiency values from ETSAP | ||
#' | ||
#' @export | ||
readETSAP <- function() { | ||
|
||
data <- read.csv2("IEA_ETSAP_Table2.csv", sep = ";", stringsAsFactors = FALSE) | ||
|
||
revalueVec <- c( | ||
"Roof.U.value..W.m2K." = "roof", | ||
"Wall.U.value..W.m2K." = "wall", | ||
"Window.U.value..W.m2K." = "window" | ||
) | ||
|
||
revalueRegion <- c( | ||
"Beijing" = "CHN", | ||
"EU" = "EUR", | ||
"Shanghai" = "CHN", | ||
"USA" = "USA" | ||
) | ||
|
||
regionSelection <- c("Shanghai", "Beijing", "USA", "EU") | ||
|
||
uvalue <- data %>% | ||
select("region" = "Region", names(revalueVec)) %>% | ||
gather("variable", "value", names(revalueVec)) %>% | ||
revalue.levels(variable = revalueVec) %>% | ||
separate(col = "value", into = c("value1", "value2"), sep = "-", fill = "right") %>% | ||
mutate(value2 = ifelse(is.na(.data$value2), .data$value1, .data$value2), | ||
value1 = as.double(.data$value1), | ||
value2 = as.double(.data$value2), | ||
value = 0.5 * (.data$value1 + .data$value2)) %>% | ||
select(-"value1", -"value2") %>% | ||
calc_addVariable("uvalue" = "window * 0.25 + roof * 0.375 + wall * 0.375", only.new = TRUE) %>% | ||
# !!! ETSAP estimates for DEU and SWE are approximately half as high as the data for European Regions only | ||
# !!! We therefore multiply the value by 2 to get comparable estimates | ||
mutate(value = .data$value * 2) %>% | ||
filter(.data$region %in% regionSelection) %>% | ||
revalue.levels(region = revalueRegion) %>% | ||
group_by(across(all_of("region"))) %>% | ||
reframe(uvalue = mean(.data$value)) | ||
|
||
x <- as.magpie(uvalue, spatial = 1, temporal = NA) | ||
|
||
return(x) | ||
} |
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,30 @@ | ||
#' Read in energy efficiency values of building shell in residential and | ||
#' non-residential buildings by the EU Buildings Observatory (2017) | ||
#' | ||
#' @export | ||
readEUBuildingsObservatory <- function() { | ||
|
||
res <- read.csv2(file.path("2017", "Uvalues_Res_export-eu-buildings-20170503115017.csv"), | ||
na.strings = "-", sep = ",", comment.char = "#", stringsAsFactors = FALSE) %>% | ||
mutate("variable" = "uvalue_res") | ||
|
||
com <- read.csv2(file.path("2017", "Uvalues_NonRes_export-eu-buildings-20170503115017.csv"), | ||
na.strings = "-", sep = ",", comment.char = "#", stringsAsFactors = FALSE) %>% | ||
mutate("variable" = "uvalue_com") | ||
|
||
data <- rbind(res, com) | ||
periodCols <- grep("X\\d{4}", colnames(data), value = TRUE) | ||
|
||
data <- data %>% | ||
select(-c("ISO.code", "Unit", "Source", "Long.source", "Link", "Data.quality", "Comment")) %>% | ||
gather("period", "value", all_of(periodCols)) %>% | ||
mutate( | ||
"period" = as.integer(gsub("X", "", .data$period)), | ||
"value" = suppressWarnings(as.numeric(.data$value)) | ||
) %>% | ||
na.omit() | ||
|
||
x <- as.magpie(data, spatial = 1, temporal = 3) | ||
|
||
return(x) | ||
} |
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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.