Skip to content

Commit

Permalink
Merge pull request #26 from fbenke-pik/uvalues
Browse files Browse the repository at this point in the history
read in Uvalues and floorspace
  • Loading branch information
fbenke-pik authored Sep 12, 2024
2 parents 61b80bd + 17fd860 commit 6388b02
Show file tree
Hide file tree
Showing 14 changed files with 187 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '1397480'
ValidationKey: '1418367'
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: 'mredgebuildings: Prepare data to be used by the EDGE-Buildings model'
version: 0.7.0
date-released: '2024-08-29'
version: 0.7.1
date-released: '2024-09-11'
abstract: Prepare data to be used by the EDGE-Buildings model.
authors:
- family-names: Hasse
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
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")),
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export(calcHeatingCapacity)
export(calcHeatingSystem)
export(calcHouseholdSize)
export(calcIEAPFU)
export(calcIEAfloorspace)
export(calcLifetimeParams)
export(calcMatchingReference)
export(calcPFUDB)
Expand All @@ -27,6 +28,7 @@ export(calcSharesBuildingDemand)
export(calcSurface)
export(calcUEdemand)
export(calcUValue)
export(calcUvalues)
export(convertCensusHub)
export(convertDaioglou)
export(convertDeetman2020)
Expand All @@ -50,7 +52,9 @@ export(readDeetman2020)
export(readECEMF)
export(readEEAfloorspace)
export(readEHI)
export(readETSAP)
export(readEUBuildingsDB)
export(readEUBuildingsObservatory)
export(readEnergiforsk2016)
export(readEurObservER)
export(readEuropeanCommissionRenovation)
Expand Down
17 changes: 17 additions & 0 deletions R/calcIEAfloorspace.R
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."
)
))
}
29 changes: 29 additions & 0 deletions R/calcUvalues.R
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
)
))
}
5 changes: 5 additions & 0 deletions R/fullEDGEBUILDINGS.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ fullEDGEBUILDINGS <- function(rev = 0) {
calcOutput("FloorspacePast", file = "f_floorspace.cs4r")
calcOutput("FEUE", file = "f_feue.cs4r")
calcOutput("FEUEefficiencies", file = "f_feue_efficiencies.cs4r")

calcOutput("IEAfloorspace", aggregate = FALSE, file = "f_iea_floorspace.cs4r")
calcOutput("Uvalues", subtype = "EUBuildingsObservatory", aggregate = FALSE, file = "f_uvalues_rescom.cs4r")
calcOutput("Uvalues", subtype = "ETSAP", aggregate = FALSE, file = "f_uvalues_etsap.cs4r")

}
45 changes: 45 additions & 0 deletions R/readETSAP.R
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)
}
30 changes: 30 additions & 0 deletions R/readEUBuildingsObservatory.R
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)
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Prepare data to be used by the EDGE-Buildings model

R package **mredgebuildings**, version **0.7.0**
R package **mredgebuildings**, version **0.7.1**

[![CRAN status](https://www.r-pkg.org/badges/version/mredgebuildings)](https://cran.r-project.org/package=mredgebuildings) [![R build status](https://github.com/pik-piam/mredgebuildings/workflows/check/badge.svg)](https://github.com/pik-piam/mredgebuildings/actions) [![codecov](https://codecov.io/gh/pik-piam/mredgebuildings/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mredgebuildings) [![r-universe](https://pik-piam.r-universe.dev/badges/mredgebuildings)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -38,7 +38,7 @@ In case of questions / problems please contact Robin Hasse <robin.hasse@pik-pots

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

Hasse R, Führlich P, Levesque A, Tockhorn H (2024). _mredgebuildings: Prepare data to be used by the EDGE-Buildings model_. R package version 0.7.0, <https://github.com/pik-piam/mredgebuildings>.
Hasse R, Führlich P, Levesque A, Tockhorn H (2024). _mredgebuildings: Prepare data to be used by the EDGE-Buildings model_. R package version 0.7.1, <https://github.com/pik-piam/mredgebuildings>.

A BibTeX entry for LaTeX users is

Expand All @@ -47,7 +47,7 @@ A BibTeX entry for LaTeX users is
title = {mredgebuildings: Prepare data to be used by the EDGE-Buildings model},
author = {Robin Hasse and Pascal Führlich and Antoine Levesque and Hagen Tockhorn},
year = {2024},
note = {R package version 0.7.0},
note = {R package version 0.7.1},
url = {https://github.com/pik-piam/mredgebuildings},
}
```
11 changes: 11 additions & 0 deletions man/calcIEAfloorspace.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions man/calcUvalues.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions man/readETSAP.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions man/readEUBuildingsObservatory.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6388b02

Please sign in to comment.