diff --git a/.buildlibrary b/.buildlibrary index 43d0152..9aa1d3a 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '1438488' +ValidationKey: '1459854' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 4583635..5cef930 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.2 -date-released: '2024-09-13' +version: 0.7.3 +date-released: '2024-10-02' abstract: Prepare data to be used by the EDGE-Buildings model. authors: - family-names: Hasse diff --git a/DESCRIPTION b/DESCRIPTION index b90c4bb..04d636d 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.2 -Date: 2024-09-13 +Version: 0.7.3 +Date: 2024-10-02 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 83edab0..8077aa6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -19,6 +19,7 @@ export(calcLifetimeParams) export(calcMatchingReference) export(calcPFUDB) export(calcPopulationBuildings) +export(calcRenDepth) export(calcRenovationCostModel) export(calcShareETP) export(calcShareOdyssee) diff --git a/R/calcRenDepth.R b/R/calcRenDepth.R new file mode 100644 index 0000000..ec00271 --- /dev/null +++ b/R/calcRenDepth.R @@ -0,0 +1,39 @@ +#' Calculate renovation depth +#' +#' The renovation depth is currently calculated based on the ratio of specific +#' useful energy demand after and before the renovation. This is valid under the +#' assumption that there is no change in behaviour (rebound effect) which we +#' currently make. Once adaptive behaviour is considered, we should use the +#' ratio of U-values. +#' +#' @author Robin Hasse +#' +#' @importFrom madrat toolGetMapping +#' @importFrom dplyr %>% .data left_join filter mutate select +#' @importFrom magclass as.magpie collapseDim +#' @export + +calcRenDepth <- function() { + + bsMap <- toolGetMapping("buildingShell.csv", "sectoral", "brick") + + renDepth <- expand.grid(bs = bsMap[["bs"]], + bsr = c(bsMap[["bs"]], "0")) %>% + left_join(bsMap, by = c("bs")) %>% + left_join(bsMap, by = c(bsr = "bs"), suffix = c("Before", "After")) %>% + filter(.data[["energyLadderBefore"]] >= .data[["energyLadderAfter"]] | + .data[["bsr"]] == 0) %>% + mutate(value = ifelse(.data[["bsr"]] == "0", + 0, + 1 - .data[["relDemAfter"]] / .data[["relDemBefore"]])) %>% + select("bs", "bsr", "value") %>% + as.magpie() %>% + collapseDim() + + return(list(x = renDepth, + isocountries = FALSE, + min = 0, + max = 1, + unit = "1", + description = "Renovation depth")) +} diff --git a/R/calcUEdemand.R b/R/calcUEdemand.R index 5e218cd..afb3c98 100644 --- a/R/calcUEdemand.R +++ b/R/calcUEdemand.R @@ -18,7 +18,8 @@ calcUEdemand <- function() { select("vin", "vinHotmaps") # map Hotmaps building types - typMap <- getBrickMapping("buildingType.csv") %>% + typMap <- toolGetMapping("buildingTypeMapping_Hotmaps.csv", "sectoral", + "mredgebuildings") %>% select("typ", "typHotmaps") # Useful energy demand for space heating (kWh/yr/m2) diff --git a/R/fullBRICK.R b/R/fullBRICK.R index 93c9a95..1838468 100644 --- a/R/fullBRICK.R +++ b/R/fullBRICK.R @@ -34,6 +34,8 @@ fullBRICK <- function(rev = 0) { calcOutput("UEdemand", file = "f_ueDemand.cs4r") calcOutput("HeatingSystem", subtype = "Efficiency", file = "f_heatingEfficiency.cs4r") + calcOutput("RenDepth", aggregate = FALSE, file = "f_renovationDepth.cs4r") + # Life time ------------------------------------------------------------------ diff --git a/README.md b/README.md index 161aa90..4814b4f 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.2** +R package **mredgebuildings**, version **0.7.3** [![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.3, . 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.2}, + note = {R package version 0.7.3}, url = {https://github.com/pik-piam/mredgebuildings}, } ``` diff --git a/inst/extdata/sectoral/buildingTypeMapping_Hotmaps.csv b/inst/extdata/sectoral/buildingTypeMapping_Hotmaps.csv new file mode 100644 index 0000000..d7f563e --- /dev/null +++ b/inst/extdata/sectoral/buildingTypeMapping_Hotmaps.csv @@ -0,0 +1,5 @@ +typ, typHotmaps +SFH,Residential sector|Single family- Terraced houses|Single family- Terraced houses +MFH,Residential sector|Appartment blocks|Appartment blocks +MFH,Residential sector|Multifamily houses|Multifamily houses +Com,Service sector|Total|Total diff --git a/man/calcRenDepth.Rd b/man/calcRenDepth.Rd new file mode 100644 index 0000000..28299dd --- /dev/null +++ b/man/calcRenDepth.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/calcRenDepth.R +\name{calcRenDepth} +\alias{calcRenDepth} +\title{Calculate renovation depth} +\usage{ +calcRenDepth() +} +\description{ +The renovation depth is currently calculated based on the ratio of specific +useful energy demand after and before the renovation. This is valid under the +assumption that there is no change in behaviour (rebound effect) which we +currently make. Once adaptive behaviour is considered, we should use the +ratio of U-values. +} +\author{ +Robin Hasse +}