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/NAMESPACE b/NAMESPACE index f8d3c73..5777ece 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,6 +15,7 @@ export(calcHeatingCapacity) export(calcHeatingSystem) export(calcHouseholdSize) export(calcIEAPFU) +export(calcIEAfloorspace) export(calcLifetimeParams) export(calcMatchingReference) export(calcPFUDB) @@ -27,6 +28,7 @@ export(calcSharesBuildingDemand) export(calcSurface) export(calcUEdemand) export(calcUValue) +export(calcUvalues) export(convertCensusHub) export(convertDaioglou) export(convertDeetman2020) @@ -50,7 +52,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 new file mode 100644 index 0000000..82bf97a --- /dev/null +++ b/R/calcIEAfloorspace.R @@ -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." + ) + )) +} diff --git a/R/calcUvalues.R b/R/calcUvalues.R new file mode 100644 index 0000000..52bb2ca --- /dev/null +++ b/R/calcUvalues.R @@ -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 + ) + )) +} diff --git a/R/fullEDGEBUILDINGS.R b/R/fullEDGEBUILDINGS.R index 7701c44..e916c0f 100644 --- a/R/fullEDGEBUILDINGS.R +++ b/R/fullEDGEBUILDINGS.R @@ -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") + } 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..c5780bc --- /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 = 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) +} 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}, } ``` 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) +}