From 4fc18787e872b9691b70331acfbdfbbed44ae514 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Tue, 11 Jun 2024 16:19:54 +0200 Subject: [PATCH 1/3] read in Uvalues and floorspace --- R/calcIEAfloorspace.R | 17 +++++++++++++ R/calcUvalues.R | 28 +++++++++++++++++++++ R/fullEDGEBUILDINGS.R | 7 ++++-- R/readETSAP.R | 45 ++++++++++++++++++++++++++++++++++ R/readEUBuildingsObservatory.R | 30 +++++++++++++++++++++++ 5 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 R/calcIEAfloorspace.R create mode 100644 R/calcUvalues.R create mode 100644 R/readETSAP.R create mode 100644 R/readEUBuildingsObservatory.R diff --git a/R/calcIEAfloorspace.R b/R/calcIEAfloorspace.R new file mode 100644 index 0000000..be5da68 --- /dev/null +++ b/R/calcIEAfloorspace.R @@ -0,0 +1,17 @@ +#' floor space by subsectors +#' +#' @export +calcIEAfloorspace <- function() { + + x <- readSource("IEAfloorspace", convert = F) + + 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." + ) + )) +} diff --git a/R/calcUvalues.R b/R/calcUvalues.R new file mode 100644 index 0000000..0ceead4 --- /dev/null +++ b/R/calcUvalues.R @@ -0,0 +1,28 @@ +#' Calculate U-value +#' +#' @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 = F) + unit <- "W/m2C" + } else { + x <- readSource("ETSAP", convert = F) + 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 + ) + )) +} diff --git a/R/fullEDGEBUILDINGS.R b/R/fullEDGEBUILDINGS.R index ef69801..955c6f5 100644 --- a/R/fullEDGEBUILDINGS.R +++ b/R/fullEDGEBUILDINGS.R @@ -31,8 +31,11 @@ fullEDGEBUILDINGS <- function(rev = 0) { # move calcIO to mrcommons calcOutput("IOEdgeBuildings", subtype = "output_EDGE_buildings", aggregate = FALSE, file = "f_edge_buildings.cs4r") calcOutput("IOEdgeBuildings", subtype = "output_EDGE", aggregate = FALSE, file = "f_edge_stationary.cs4r") - calcOutput("IEAPFU", aggregate = FALSE, file = "f_iea_pfu.cs4r") - calcOutput("FloorspacePast", aggregate = FALSE, file = "f_floorspace.cs4r") + calcOutput("IEAPFU", aggregate = FALSE, file = "f_iea_pfu.cs4r") + calcOutput("FloorspacePast", aggregate = FALSE, file = "f_floorspace.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") # climate data --------------------------------------------------------------- for (tlim in 17:25) { diff --git a/R/readETSAP.R b/R/readETSAP.R new file mode 100644 index 0000000..13fb52f --- /dev/null +++ b/R/readETSAP.R @@ -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) +} diff --git a/R/readEUBuildingsObservatory.R b/R/readEUBuildingsObservatory.R new file mode 100644 index 0000000..0c953b2 --- /dev/null +++ b/R/readEUBuildingsObservatory.R @@ -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 = F) %>% + mutate("variable" = "uvalue_res") + + com <- read.csv2(file.path("2017", "Uvalues_NonRes_export-eu-buildings-20170503115017.csv"), + na.strings = "-", sep = ",", comment.char = "#", stringsAsFactors = F) %>% + 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) +} From da9f48da175b7393a64236979bcbc1474421e2a9 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Tue, 11 Jun 2024 16:31:46 +0200 Subject: [PATCH 2/3] increment version --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- NAMESPACE | 4 ++++ R/calcIEAfloorspace.R | 2 +- R/calcUvalues.R | 5 +++-- R/readEUBuildingsObservatory.R | 4 ++-- README.md | 6 +++--- man/calcIEAfloorspace.Rd | 11 +++++++++++ man/calcUvalues.Rd | 14 ++++++++++++++ man/readETSAP.Rd | 11 +++++++++++ man/readEUBuildingsObservatory.Rd | 13 +++++++++++++ 12 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 man/calcIEAfloorspace.Rd create mode 100644 man/calcUvalues.Rd create mode 100644 man/readETSAP.Rd create mode 100644 man/readEUBuildingsObservatory.Rd diff --git a/.buildlibrary b/.buildlibrary index ebd3fda..04e14ee 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '1210118' +ValidationKey: '1232870' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 036124d..f6153b6 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -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.6.1 -date-released: '2024-04-25' +version: 0.6.2 +date-released: '2024-06-11' abstract: Prepare data to be used by the EDGE-Buildings model. authors: - family-names: Hasse diff --git a/DESCRIPTION b/DESCRIPTION index 272df42..5ea6627 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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.6.2 +Date: 2024-06-11 Authors@R: c( person("Robin", "Hasse", , "robin.hasse@pik-potsdam.de", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1818-3186")), diff --git a/NAMESPACE b/NAMESPACE index c5976cd..d1121d3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,6 +11,7 @@ export(calcHeatingCapacity) export(calcHeatingSystem) export(calcHouseholdSize) export(calcIEAPFU) +export(calcIEAfloorspace) export(calcLifetimeParams) export(calcMatchingReference) export(calcPopulationBuildings) @@ -21,6 +22,7 @@ export(calcSharesBuildingDemand) export(calcSurface) export(calcUEdemand) export(calcUValue) +export(calcUvalues) export(convertCensusHub) export(convertDaioglou) export(convertDeetman2020) @@ -42,7 +44,9 @@ export(readDeetman2020) export(readECEMF) export(readEEAfloorspace) export(readEHI) +export(readETSAP) export(readEUBuildingsDB) +export(readEUBuildingsObservatory) export(readEnergiforsk2016) export(readEurObservER) export(readEuropeanCommissionRenovation) diff --git a/R/calcIEAfloorspace.R b/R/calcIEAfloorspace.R index be5da68..82bf97a 100644 --- a/R/calcIEAfloorspace.R +++ b/R/calcIEAfloorspace.R @@ -3,7 +3,7 @@ #' @export calcIEAfloorspace <- function() { - x <- readSource("IEAfloorspace", convert = F) + x <- readSource("IEAfloorspace", convert = FALSE) return(list( x = x, diff --git a/R/calcUvalues.R b/R/calcUvalues.R index 0ceead4..52bb2ca 100644 --- a/R/calcUvalues.R +++ b/R/calcUvalues.R @@ -1,5 +1,6 @@ #' Calculate U-value #' +#' @param subtype either 'EUBuildingsObservatory' or 'ETSAP' #' @export calcUvalues <- function(subtype) { @@ -8,10 +9,10 @@ calcUvalues <- function(subtype) { } if (subtype == "EUBuildingsObservatory") { - x <- readSource("EUBuildingsObservatory", convert = F) + x <- readSource("EUBuildingsObservatory", convert = FALSE) unit <- "W/m2C" } else { - x <- readSource("ETSAP", convert = F) + x <- readSource("ETSAP", convert = FALSE) unit <- "W/m2K" } diff --git a/R/readEUBuildingsObservatory.R b/R/readEUBuildingsObservatory.R index 0c953b2..c5780bc 100644 --- a/R/readEUBuildingsObservatory.R +++ b/R/readEUBuildingsObservatory.R @@ -5,11 +5,11 @@ readEUBuildingsObservatory <- function() { res <- read.csv2(file.path("2017", "Uvalues_Res_export-eu-buildings-20170503115017.csv"), - na.strings = "-", sep = ",", comment.char = "#", stringsAsFactors = F) %>% + 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 = F) %>% + na.strings = "-", sep = ",", comment.char = "#", stringsAsFactors = FALSE) %>% mutate("variable" = "uvalue_com") data <- rbind(res, com) diff --git a/README.md b/README.md index e84ccc9..cff18e7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Prepare data to be used by the EDGE-Buildings model -R package **mredgebuildings**, version **0.6.1** +R package **mredgebuildings**, version **0.6.2** [![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) @@ -38,7 +38,7 @@ In case of questions / problems please contact Robin Hasse . +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.6.2, . A BibTeX entry for LaTeX users is @@ -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.6.1}, + note = {R package version 0.6.2}, url = {https://github.com/pik-piam/mredgebuildings}, } ``` diff --git a/man/calcIEAfloorspace.Rd b/man/calcIEAfloorspace.Rd new file mode 100644 index 0000000..a831421 --- /dev/null +++ b/man/calcIEAfloorspace.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/calcIEAfloorspace.R +\name{calcIEAfloorspace} +\alias{calcIEAfloorspace} +\title{floor space by subsectors} +\usage{ +calcIEAfloorspace() +} +\description{ +floor space by subsectors +} diff --git a/man/calcUvalues.Rd b/man/calcUvalues.Rd new file mode 100644 index 0000000..16e5704 --- /dev/null +++ b/man/calcUvalues.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/calcUvalues.R +\name{calcUvalues} +\alias{calcUvalues} +\title{Calculate U-value} +\usage{ +calcUvalues(subtype) +} +\arguments{ +\item{subtype}{either 'EUBuildingsObservatory' or 'ETSAP'} +} +\description{ +Calculate U-value +} diff --git a/man/readETSAP.Rd b/man/readETSAP.Rd new file mode 100644 index 0000000..ac367d4 --- /dev/null +++ b/man/readETSAP.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/readETSAP.R +\name{readETSAP} +\alias{readETSAP} +\title{Read in energy efficiency values from ETSAP} +\usage{ +readETSAP() +} +\description{ +Read in energy efficiency values from ETSAP +} diff --git a/man/readEUBuildingsObservatory.Rd b/man/readEUBuildingsObservatory.Rd new file mode 100644 index 0000000..e9f823f --- /dev/null +++ b/man/readEUBuildingsObservatory.Rd @@ -0,0 +1,13 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/readEUBuildingsObservatory.R +\name{readEUBuildingsObservatory} +\alias{readEUBuildingsObservatory} +\title{Read in energy efficiency values of building shell in residential and +non-residential buildings by the EU Buildings Observatory (2017)} +\usage{ +readEUBuildingsObservatory() +} +\description{ +Read in energy efficiency values of building shell in residential and +non-residential buildings by the EU Buildings Observatory (2017) +} From 17fd86005c7528f9e821451d5c941fce63031917 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Wed, 11 Sep 2024 16:39:21 +0200 Subject: [PATCH 3/3] increment version --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/fullEDGEBUILDINGS.R | 6 +++--- README.md | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 4b6da5e..84840d1 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '1397480' +ValidationKey: '1418367' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index c85ff1c..32255f8 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -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 diff --git a/DESCRIPTION b/DESCRIPTION index f60b14b..5e8d623 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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", , "robin.hasse@pik-potsdam.de", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1818-3186")), diff --git a/R/fullEDGEBUILDINGS.R b/R/fullEDGEBUILDINGS.R index 84bc628..e916c0f 100644 --- a/R/fullEDGEBUILDINGS.R +++ b/R/fullEDGEBUILDINGS.R @@ -33,8 +33,8 @@ fullEDGEBUILDINGS <- function(rev = 0) { calcOutput("FEUE", file = "f_feue.cs4r") calcOutput("FEUEefficiencies", file = "f_feue_efficiencies.cs4r") - calcOutput("IEAfloorspace", file = "f_iea_floorspace.cs4r") - calcOutput("Uvalues", subtype = "EUBuildingsObservatory", file = "f_uvalues_rescom.cs4r") - calcOutput("Uvalues", subtype = "ETSAP", file = "f_uvalues_etsap.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") } diff --git a/README.md b/README.md index 34d7dd6..c6d12bf 100644 --- a/README.md +++ b/README.md @@ -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) @@ -38,7 +38,7 @@ In case of questions / problems please contact Robin Hasse . +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, . A BibTeX entry for LaTeX users is @@ -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}, } ```